2021与蓝度共同重构项目,服务端
liuhaonan
2022-05-17 83be53d31f313a341238fc9422cc0e42bd3c12cc
日志
已修改4个文件
143 ■■■■ 文件已修改
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/VnnoxController.java 76 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedPlayerEntityService.java 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/VnnoxController.java
@@ -1,8 +1,8 @@
package com.sandu.ximon.admin.controller;
import cn.hutool.core.collection.CollectionUtil;
import com.sandu.common.domain.ResponseVO;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.security.annotation.AnonymousAccess;
import com.sandu.common.util.ResponseUtil;
import com.sandu.ximon.admin.param.VnnoxParam;
import com.sandu.ximon.admin.security.PermissionConfig;
@@ -75,17 +75,7 @@
        if (!permissionConfig.check(MenuEnum.VNNOX_RESTART.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        List<List<String>> split = CollectionUtil.split(vnnoxWebRequest, 100);
        VnnoxResult vnnoxResult=null;
        for (List<String> splist : split) {
            VnnoxResult  vnnox = vnnoxService.reboot(splist);
            if(vnnoxResult!=null){
                vnnoxResult.getSuccess().addAll(vnnox.getSuccess());
                vnnoxResult.getFail().addAll(vnnox.getFail());
            }
        }
        VnnoxResult vnnoxResult = vnnoxService.reboot(vnnoxWebRequest);
        return ResponseUtil.success(vnnoxResult);
    }
@@ -99,16 +89,7 @@
        }
        List playIdlist = (List) map.get("playIdlist");
        Integer option = (Integer) map.get("option");
        List<List<String>> split = CollectionUtil.split(playIdlist, 100);
        VnnoxResult vnnoxResult=null;
        for (List<String> splist : split) {
            VnnoxResult  vnnox = vnnoxService.syncPlay(splist, option);
            if(vnnoxResult!=null){
                vnnoxResult.getSuccess().addAll(vnnox.getSuccess());
                vnnoxResult.getFail().addAll(vnnox.getFail());
            }
        }
        VnnoxResult vnnoxResult = vnnoxService.syncPlay(playIdlist, option);
        return ResponseUtil.success(vnnoxResult);
    }
@@ -122,17 +103,7 @@
        }
        boolean enable = (boolean) map.get("enable");
        List playIdlist = (List) map.get("playIdlist");
        List<List<String>> split = CollectionUtil.split(playIdlist, 100);
        VnnoxResult vnnoxResult=null;
        for (List<String> splist : split) {
            VnnoxResult  vnnox = vnnoxService.ntpSync(splist, enable);
            if(vnnoxResult!=null){
                vnnoxResult.getSuccess().addAll(vnnox.getSuccess());
                vnnoxResult.getFail().addAll(vnnox.getFail());
            }
        }
        VnnoxResult vnnoxResult = vnnoxService.ntpSync(playIdlist, enable);
        return ResponseUtil.success(vnnoxResult);
    }
@@ -145,17 +116,7 @@
        if (!permissionConfig.check(MenuEnum.VNNOX_ON_OFF.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        List<List<LedPlayerEntity>> split = CollectionUtil.split(vnnoxWebRequest.getPlayerList(), 100);
        VnnoxResult vnnoxResult=null;
        for (List<LedPlayerEntity> splist : split) {
            VnnoxResult  vnnox = vnnoxService.screenStatusChange(splist, vnnoxWebRequest.getScreenStatus());
            if(vnnoxResult!=null){
                vnnoxResult.getSuccess().addAll(vnnox.getSuccess());
                vnnoxResult.getFail().addAll(vnnox.getFail());
            }
        }
        VnnoxResult vnnoxResult = vnnoxService.screenStatusChange(vnnoxWebRequest.getPlayerList(), vnnoxWebRequest.getScreenStatus());
        return ResponseUtil.success(vnnoxResult);
    }
@@ -170,17 +131,7 @@
        if (!permissionConfig.check(MenuEnum.VNNOX_VOL_CHANGE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        List<List<LedPlayerEntity>> split = CollectionUtil.split(vnnoxWebRequest.getPlayerList(), 100);
        VnnoxResult vnnoxResult=null;
        for (List<LedPlayerEntity> splist : split) {
            VnnoxResult  vnnox = vnnoxService.volChange(splist, vnnoxWebRequest.getVol());
            if(vnnoxResult!=null){
                vnnoxResult.getSuccess().addAll(vnnox.getSuccess());
                vnnoxResult.getFail().addAll(vnnox.getFail());
            }
        }
        VnnoxResult vnnoxResult = vnnoxService.volChange(vnnoxWebRequest.getPlayerList(), vnnoxWebRequest.getVol());
        return ResponseUtil.success(vnnoxResult);
    }
@@ -195,17 +146,7 @@
        if (!permissionConfig.check(MenuEnum.VNNOX_BRIGHTNESS_CHANGE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        List<List<LedPlayerEntity>> split = CollectionUtil.split(vnnoxWebRequest.getPlayerList(), 100);
        VnnoxResult vnnoxResult=null;
        for (List<LedPlayerEntity> splist : split) {
            VnnoxResult  vnnox = vnnoxService.brightnessChange(splist, vnnoxWebRequest.getBrightness());
            if(vnnoxResult!=null){
                vnnoxResult.getSuccess().addAll(vnnox.getSuccess());
                vnnoxResult.getFail().addAll(vnnox.getFail());
            }
        }
        VnnoxResult vnnoxResult = vnnoxService.brightnessChange(vnnoxWebRequest.getPlayerList(), vnnoxWebRequest.getBrightness());
        return ResponseUtil.success(vnnoxResult);
    }
@@ -252,8 +193,9 @@
            return ResponseUtil.fail("缺少对应用户权限");
        }
        List<LedPlayerEntity> list = ledPlayerEntityService.ledPlayerEntityList(baseConditionVO, keyword);
        List<LedPlayerEntity> entities = vnnoxService.setCacheInfo(vnnoxAPIUtil.syncCurrentInfo(list));
        List<LedPlayerEntity> online = new ArrayList<>();
        for (LedPlayerEntity ledPlayer : list) {
        for (LedPlayerEntity ledPlayer : entities) {
            if (ledPlayer.getOnlineStatus() == 1) {
                online.add(ledPlayer);
            }
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedPlayerEntityService.java
@@ -1,6 +1,5 @@
package com.sandu.ximon.admin.service;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.sandu.common.execption.BusinessException;
@@ -107,16 +106,17 @@
        } else {
            list = ledPlayerEntityMapper.ledPlayerEntityList(keyword, SecurityUtils.getUserId());
        }
        List<List<LedPlayerEntity>> split = CollectionUtil.split(list, 100);
        List<LedPlayerEntity> ledPlayerEntities=null;
        for (List<LedPlayerEntity> splist : split) {
            List<LedPlayerEntity> ledPlayerEntitie = SpringContextHolder.getBean(VnnoxService.class).setCacheInfo(vnnoxAPIUtil.syncCurrentInfo(splist));
            if (ledPlayerEntitie != null) {
                ledPlayerEntities.addAll(ledPlayerEntitie);
            }
        }
        return ledPlayerEntities;
        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));
//    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java
@@ -3,7 +3,6 @@
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.HexUtil;
import cn.hutool.core.util.StrUtil;
import com.aliyuncs.iot.model.v20180120.BatchGetDeviceStateResponse;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.sandu.common.domain.CommonPage;
@@ -100,37 +99,12 @@
    public List<LightBo> listLight(int pageNo, int pageSize, String keyword) {
        Long clientId = SecurityUtils.getClientId();
      //  PageHelper.startPage(pageNo, pageSize);
        PageHelper.startPage(pageNo, pageSize);
        List<LightBo> listLight = baseMapper.listLight(clientId, keyword);
        // 获取最近的上报时间
        List<String> deviceCodeList = listLight.stream().map(Light::getDeviceCode).collect(Collectors.toList());
        //拆分list
        List<List<String>> split = CollectionUtil.split(deviceCodeList, 100);
        List<BatchGetDeviceStateResponse.DeviceStatus> deviceStatuses=null;
        for (List<String> splist : split) {
            deviceStatuses=MainBoardInvokeSyncService.getInstance().batchGetDeviceState(splist);
            if (deviceStatuses != null) {
                for (LightBo lightBo : listLight) {
                    for (BatchGetDeviceStateResponse.DeviceStatus deviceStatus : deviceStatuses) {
                        if (lightBo.getDeviceCode() != null && lightBo.getDeviceCode().equals(deviceStatus.getDeviceName())) {
                            if("ONLINE".equals(deviceStatus.getStatus()) ){
                                lightBo.setOnlineStatus(0);
                            }else if("OFFLINE".equals(deviceStatus.getStatus())){
                                lightBo.setOnlineStatus(1);
                            }else {
                                lightBo.setOnlineStatus(2);
                            }
                        }
                    }
                }
            }
        }
        if (CollectionUtil.isNotEmpty(deviceCodeList)) {
            List<LightReportData> reportDataList = lightReportDataService.getNewestReportByDeviceCode(deviceCodeList);
            for (LightBo lightBo : listLight) {
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
@@ -339,6 +339,8 @@
        List<Pole> online = new ArrayList<>();//在线
        List<Pole> offline = new ArrayList<>();//离线
        list.forEach(onLinePole -> {
            System.out.println("online---------------------------------------------------" + ("ONLINE").equals(onLinePole.getOnLineState()));
            System.out.println("online---------------------------------------------------" + (onLinePole.getOnLineState()));
            if (("ONLINE").equals(onLinePole.getOnLineState())) {
                online.add(onLinePole);
            } else if (("OFFLINE").equals(onLinePole.getOnLineState())) {
@@ -438,29 +440,20 @@
                MacCodes.add(post.getDeviceCode());
            }
        }
        List<BatchGetDeviceStateResponse.DeviceStatus> deviceStatuses=null;
        //拆分list
        List<List<String>> split = CollectionUtil.split(MacCodes, 50);
        for (List<String> splist : split) {
            deviceStatuses=MainBoardInvokeSyncService.getInstance().batchGetDeviceState(splist);
//
        List<BatchGetDeviceStateResponse.DeviceStatus> deviceStatuses = MainBoardInvokeSyncService.getInstance().batchGetDeviceState(MacCodes);
            if (deviceStatuses != null) {
                for (Pole post : list) {
                    for (BatchGetDeviceStateResponse.DeviceStatus deviceStatus : deviceStatuses) {
                        if (post.getDeviceCode() != null && post.getDeviceCode().equals(deviceStatus.getDeviceName())) {
                            post.setOnLineState(deviceStatus.getStatus());
                        }
                    }
                }
            }
        }
//        List<BatchGetDeviceStateResponse.DeviceStatus> deviceStatuses = MainBoardInvokeSyncService.getInstance().batchGetDeviceState(MacCodes);
        return list;
    }