2021与蓝度共同重构项目,服务端
liuhaonan
2022-05-17 83be53d31f313a341238fc9422cc0e42bd3c12cc
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedPlayerEntityService.java
@@ -2,13 +2,14 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.object.BaseConditionVO;
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.VnnoxAPIUtil;
import com.sandu.ximon.admin.vo.EquipmentInfomation;
import com.sandu.ximon.dao.domain.LedPlayerEntity;
import com.sandu.ximon.dao.domain.PoleBinding;
import com.sandu.ximon.dao.mapper.LedPlayerEntityMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
@@ -48,7 +49,7 @@
    public LedPlayerEntity getBySnAndPlayerSn(String sn) {
        LedPlayerEntity one = getOne(Wrappers.lambdaQuery(LedPlayerEntity.class).eq(LedPlayerEntity::getSn, sn));
        if (one == null) {
            throw new RuntimeException("诺瓦设备不存在");
            throw new BusinessException("诺瓦设备不存在");
        }
        List list = new ArrayList();
        list.add(one);
@@ -62,9 +63,42 @@
        return one;
    }
    /**
     * 首页灯杆绑定信息
     */
    public EquipmentInfomation getBySnAndPlayerSnInfo(String sn) {
        EquipmentInfomation equipmentInfo = new EquipmentInfomation();
        equipmentInfo.setEquipmentType("诺瓦LED");
        if (sn == null || sn.trim().length() == 0) {
            return equipmentInfo;
        }
        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);
        Integer onlineStatus = ledPlayerEntities.get(0).getOnlineStatus();
        if (one != null) {
            equipmentInfo.setEquipmentMac(one.getSn());
            equipmentInfo.setEquipmentName(one.getName());
            if (onlineStatus == 0) {
                equipmentInfo.setEquipmentState("在线");
            } else {
                equipmentInfo.setEquipmentState("离线");
            }
        }
        return equipmentInfo;
    }
    public List<LedPlayerEntity> ledPlayerEntityList(BaseConditionVO baseConditionVO, String keyword) {
        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
        if (baseConditionVO != null) {
            PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
        }
        List<LedPlayerEntity> list;
        //超管
        if (SecurityUtils.getClientId() == null) {
@@ -75,4 +109,14 @@
        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));
//    }
}