2021与蓝度共同重构项目,服务端
fix
zhanzhiqin
2022-07-22 77edfb324184d304ae7763aae3ab609f2b495da4
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedPlayerEntityService.java
@@ -7,9 +7,11 @@
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.common.util.SpringContextHolder;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
import com.sandu.ximon.admin.utils.VnnoxAPIUtil;
import com.sandu.ximon.admin.vo.EquipmentInfomation;
import com.sandu.ximon.dao.domain.LedPlayerEntity;
import com.sandu.ximon.dao.enums.OrderByEnums;
import com.sandu.ximon.dao.mapper.LedPlayerEntityMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
@@ -38,8 +40,29 @@
        return getOne(Wrappers.lambdaQuery(LedPlayerEntity.class).eq(LedPlayerEntity::getPlayerId, playerId));
    }
    /**
     * 诺瓦设备新增
     *
     * @param ledPlayerEntity
     * @return
     */
    public boolean saveLed(LedPlayerEntity ledPlayerEntity) {
        return ledPlayerEntityMapper.saveLed(ledPlayerEntity);
        boolean b = ledPlayerEntityMapper.saveLed(ledPlayerEntity);
        /**
         * 诺瓦设备新增 日志记录开始
         */
        List<String> listCode = new ArrayList<>(1);
        listCode.add(ledPlayerEntity.getSn());
        String content = "{ 设备id:" + ledPlayerEntity.getId() + "设备code:" + ledPlayerEntity.getSn()
                + "诺瓦playId:" + ledPlayerEntity.getPlayerId()
                + "诺瓦设备名称:" + ledPlayerEntity.getName() +
                "}";
        StoreOperationRecordsUtils.storeOperationData(listCode, null, "诺瓦设备新增", content);
        /**
         * 诺瓦设备新增 日志记录结束
         */
        return b;
    }
@@ -66,7 +89,6 @@
    /**
     * 首页灯杆绑定信息
     */
    //TODO
    public EquipmentInfomation getBySnAndPlayerSnInfo(String sn) {
        EquipmentInfomation equipmentInfo = new EquipmentInfomation();
        equipmentInfo.setEquipmentType("诺瓦LED");
@@ -75,6 +97,9 @@
        }
        LedPlayerEntity one = getOne(Wrappers.lambdaQuery(LedPlayerEntity.class).eq(LedPlayerEntity::getSn, sn));
        if (one == null) {
            return equipmentInfo;
        }
        List<LedPlayerEntity> list = new ArrayList<>();
        list.add(one);
        List<LedPlayerEntity> ledPlayerEntities = vnnoxAPIUtil.syncCurrentInfo(list);
@@ -82,20 +107,60 @@
        if (one != null) {
            equipmentInfo.setEquipmentMac(one.getSn());
            equipmentInfo.setEquipmentName(one.getName());
           if (onlineStatus == 0) {
            if (onlineStatus == 0) {
                equipmentInfo.setEquipmentState("在线");
           }else {
               equipmentInfo.setEquipmentName("离线");
           }
            } else {
                equipmentInfo.setEquipmentState("离线");
            }
        }
        return equipmentInfo;
    }
    public List<LedPlayerEntity> ledPlayerEntityList(BaseConditionVO baseConditionVO, String keyword) {
    /**
     * 诺瓦列表
     *
     * @param baseConditionVO
     * @param keyword
     * @param order
     * @param seq
     * @return
     */
    public List<LedPlayerEntity> ledPlayerEntityList(BaseConditionVO baseConditionVO, String keyword, Integer order, Integer seq) {
        //排序字段
        String orderByResult = OrderByEnums.VNNOX_ID.getCode();
        //正序、倒叙
        String orderBySeq = OrderByEnums.ASC.getCode();
        if (order != null) {
            switch (order) {
                case 1:
                    orderByResult = OrderByEnums.VNNOX_POLE_NAME.getCode();
                    break;
                case 2:
                    orderByResult = OrderByEnums.VNNOX_CREATE_TIMESTAMP.getCode();
                    break;
                default:
            }
        }
        if (seq != null) {
            switch (seq) {
                case 1:
                    orderBySeq = OrderByEnums.ASC.getCode();
                    break;
                case 2:
                    orderBySeq = OrderByEnums.DESC.getCode();
                    break;
                default:
                    break;
            }
        }
        //排序方式
        String orderBy = orderByResult + " " + orderBySeq;
        if (baseConditionVO != null) {
            PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
            PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize(), orderBy);
        }
        List<LedPlayerEntity> list;
        //超管
@@ -107,14 +172,38 @@
        return SpringContextHolder.getBean(VnnoxService.class).setCacheInfo(vnnoxAPIUtil.syncCurrentInfo(list));
    }
//    public List<LedPlayerEntity> ledPlayerEntityList() {
//        List<LedPlayerEntity> list;
//        //超管
//        if (SecurityUtils.getClientId() == null) {
//            list = ledPlayerEntityMapper.ledPlayerEntityList(null, null);
//        } else {
//            list = ledPlayerEntityMapper.ledPlayerEntityList(null, SecurityUtils.getUserId());
//        }
//        return SpringContextHolder.getBean(VnnoxService.class).setCacheInfo(vnnoxAPIUtil.syncCurrentInfo(list));
//    }
    /**
     * 诺瓦列表(用于首页数据统计)
     *
     * @return
     */
    public List<LedPlayerEntity> ledPlayerEntityListOnHome() {
        List<LedPlayerEntity> list;
        //超管
        if (SecurityUtils.getClientId() == null) {
            list = ledPlayerEntityMapper.ledPlayerEntityList(null, null);
        } else {
            list = ledPlayerEntityMapper.ledPlayerEntityList(null, SecurityUtils.getUserId());
        }
        return list == null ? new ArrayList<>() : list;
    }
    /**
     * 诺瓦列表(用于绑定)
     *
     * @param keyword
     * @return
     */
    public List<LedPlayerEntity> ledPlayerEntityListOnBinding(String keyword) {
        List<LedPlayerEntity> list;
        //超管
        if (SecurityUtils.getClientId() == null) {
            list = ledPlayerEntityMapper.ledPlayerEntityListOnBinding(keyword, null);
        } else {
            list = ledPlayerEntityMapper.ledPlayerEntityListOnBinding(keyword, SecurityUtils.getUserId());
        }
        return SpringContextHolder.getBean(VnnoxService.class).setCacheInfo(vnnoxAPIUtil.syncCurrentInfo(list));
    }
}