2021与蓝度共同重构项目,服务端
liuhaonan
2022-05-17 fb842a99734726e628bd0981ccdf80a253534eaa
日志
已修改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,7 +75,17 @@
        if (!permissionConfig.check(MenuEnum.VNNOX_RESTART.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        VnnoxResult vnnoxResult = vnnoxService.reboot(vnnoxWebRequest);
        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());
            }
        }
        return ResponseUtil.success(vnnoxResult);
    }
@@ -89,7 +99,16 @@
        }
        List playIdlist = (List) map.get("playIdlist");
        Integer option = (Integer) map.get("option");
        VnnoxResult vnnoxResult = vnnoxService.syncPlay(playIdlist, 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());
            }
        }
        return ResponseUtil.success(vnnoxResult);
    }
@@ -103,7 +122,17 @@
        }
        boolean enable = (boolean) map.get("enable");
        List playIdlist = (List) map.get("playIdlist");
        VnnoxResult vnnoxResult = vnnoxService.ntpSync(playIdlist, enable);
        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());
            }
        }
        return ResponseUtil.success(vnnoxResult);
    }
@@ -116,7 +145,17 @@
        if (!permissionConfig.check(MenuEnum.VNNOX_ON_OFF.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        VnnoxResult vnnoxResult = vnnoxService.screenStatusChange(vnnoxWebRequest.getPlayerList(), vnnoxWebRequest.getScreenStatus());
        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());
            }
        }
        return ResponseUtil.success(vnnoxResult);
    }
@@ -131,7 +170,17 @@
        if (!permissionConfig.check(MenuEnum.VNNOX_VOL_CHANGE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        VnnoxResult vnnoxResult = vnnoxService.volChange(vnnoxWebRequest.getPlayerList(), vnnoxWebRequest.getVol());
        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());
            }
        }
        return ResponseUtil.success(vnnoxResult);
    }
@@ -146,7 +195,17 @@
        if (!permissionConfig.check(MenuEnum.VNNOX_BRIGHTNESS_CHANGE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        VnnoxResult vnnoxResult = vnnoxService.brightnessChange(vnnoxWebRequest.getPlayerList(), vnnoxWebRequest.getBrightness());
        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());
            }
        }
        return ResponseUtil.success(vnnoxResult);
    }
@@ -193,9 +252,8 @@
            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 : entities) {
        for (LedPlayerEntity ledPlayer : list) {
            if (ledPlayer.getOnlineStatus() == 1) {
                online.add(ledPlayer);
            }
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedPlayerEntityService.java
@@ -1,5 +1,6 @@
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;
@@ -106,17 +107,16 @@
        } else {
            list = ledPlayerEntityMapper.ledPlayerEntityList(keyword, SecurityUtils.getUserId());
        }
        return SpringContextHolder.getBean(VnnoxService.class).setCacheInfo(vnnoxAPIUtil.syncCurrentInfo(list));
        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;
    }
//    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,6 +3,7 @@
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;
@@ -99,12 +100,37 @@
    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,8 +339,6 @@
        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())) {
@@ -440,20 +438,29 @@
                MacCodes.add(post.getDeviceCode());
            }
        }
//
        List<BatchGetDeviceStateResponse.DeviceStatus> deviceStatuses = MainBoardInvokeSyncService.getInstance().batchGetDeviceState(MacCodes);
        List<BatchGetDeviceStateResponse.DeviceStatus> deviceStatuses=null;
        //拆分list
        List<List<String>> split = CollectionUtil.split(MacCodes, 50);
        for (List<String> splist : split) {
            deviceStatuses=MainBoardInvokeSyncService.getInstance().batchGetDeviceState(splist);
        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;
    }