whyclxw
2025-03-06 2b8f91e31b512c2868dc5cc26edf5d5d1167c557
Merge branch 'master' of http://118.89.139.230:10101/r/fg_v2.0
10个文件已修改
1个文件已添加
512 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/AlarmManualClearController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/BattInfMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/BattInfService.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/BattalarmDataService.java 165 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/Fbs9100StateService.java 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/webSocket/ScreenForSZSocket.java 264 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/BattInfMapper.xml 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/BattalarmDataMapper.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/DevAlarmDataVerifyMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/DevalarmDataMapper.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/PwrdevAlarmMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/AlarmManualClearController.java
@@ -25,6 +25,8 @@
    @PostMapping("submit")
    @ApiOperation("提交告警消除")
    public Response addClearSubmission(@RequestPart(value = "file",required = false) List<MultipartFile> file, @RequestParam String clearJson){
        //将clearJson字符串内的"monNum":"-"替换为"monNum":0
        clearJson = clearJson.replace("monNum\":\"-\"","monNum\":0");
        AlarmManualClear clear = ActionUtil.getGson().fromJson(clearJson, AlarmManualClear.class);
        return service.submit(file,clear);
    }
src/main/java/com/whyc/mapper/BattInfMapper.java
@@ -88,6 +88,8 @@
    int getBattGroupNum(int userId);
    int getBattGroupMonNum(int userId);
    //山西晋源特定接口
    int getBattGroupNumJY();
src/main/java/com/whyc/service/BattInfService.java
@@ -628,6 +628,10 @@
    /**
     * 获取电池,设备,电源,机房站点 计数/管理元首页:基础资源信息
     *
     * 设备的数量统计和设备状态的统计,逻辑是不同的,数据库筛选的时候条件逻辑必定是不同的: TODO
     *  通常情况下,设备数量统计,要排除掉一个设备两个id的一拖二情况;
     *  而设备状态统计,只需要区分一个设备的字段,一个设备有多条记录也是正常合理的,通过状态优先级覆盖来定义整个设备的状态
     *
     * @param userId
     * @return
     */
@@ -652,6 +656,30 @@
        }
    }
    public Response getDevCountMapForSZ(int userId) {
        try {
            Map<String, Object> map = new HashMap<>();
            int battGroupCount = battInfMapper.getBattGroupNum(userId);
            //电池单体总数
            int battGroupMonCount = battInfMapper.getBattGroupMonNum(userId);
            int devCount = battInfMapper.getDevNum(userId);
            int powerNum = powerInfService.getNum(userId);
            List<StationInf> stationInfList = stationInfService.getStationInfList(userId);
            int stationNum = stationInfService.getStation(userId);
            int hrDisNum = testInfService.getHrQuarterZC(userId);
            map.put("battGroupCount", battGroupCount);
            map.put("battGroupMonCount", battGroupMonCount);
            map.put("devCount", devCount);
            map.put("powerNum", powerNum);
            map.put("stationNum",stationNum);
            map.put("stationInfList",stationInfList);
            map.put("checkCapNum",hrDisNum);
            return new Response().setII(1,true, map,"");
        }catch (Exception e){
            return new Response<>().set(1,false,"发生异常:"+e.getCause());
        }
    }
    //山西晋源特定接口
    public Response getDevCountMapJY() {
        try {
src/main/java/com/whyc/service/BattalarmDataService.java
@@ -22,6 +22,7 @@
import com.whyc.util.ActionUtil;
import com.whyc.util.MessageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -43,6 +44,9 @@
    @Autowired
    private SubTablePageInfoService subService;
    @Autowired
    @Lazy
    private StationInfService stationInfService;
    //查询所有的告警
    public Response getAll() {
@@ -916,6 +920,167 @@
    }
    /**
     * 这里面的层级比getByLevel的层级要多一个层级,StationnName5,通过Map<String,levelMap>
     * @param userId
     * @return 返回的结构示例为:
     * {
     *     "1号线": {
     *         "level1":{
     *             battAlarmCount: 0,
     *             deviceAlarmCount: 0,
     *             powerAlarmCount: 0
     *         },
     *         "level2":{
     *             battAlarmCount: 0,
     *             deviceAlarmCount: 0,
     *             powerAlarmCount: 0
     *         },
     *         "level3":{
     *             battAlarmCount: 0,
     *             deviceAlarmCount: 0,
     *             powerAlarmCount: 0
     *         },
     *         "level4":{
     *             battAlarmCount: 0,
     *             deviceAlarmCount: 0,
     *             powerAlarmCount: 0
     *         }
     *     },
     *     "2号线": {
     *         "level1":{
     *             battAlarmCount: 0,
     *             deviceAlarmCount: 0,
     *             powerAlarmCount: 0
     *         },
     *         "level2":{
     *             battAlarmCount: 0,
     *             deviceAlarmCount: 0,
     *             powerAlarmCount: 0
     *         },
     *         "level3":{
     *             battAlarmCount: 0,
     *             deviceAlarmCount: 0,
     *             powerAlarmCount: 0
     *         },
     *         "level4":{
     *             battAlarmCount: 0,
     *             deviceAlarmCount: 0,
     *             powerAlarmCount: 0
     *         }
     *     }
     *
     * 步骤:
     * 1) 查询所有的区县
     * 2) 获取包含告警级别,区县的电池列表
     * 3) 根据区县分组
     *
     * }
     */
    public Response getByLevelAndStationName5(int userId) {
        //返回的结果结构初始化
        Map<String,Map<String,AlarmCountDTO>> subwayLineLevelMap = new LinkedHashMap<>();
        //查询所有的区县
        List<String> stationName5List = (List<String>) stationInfService.searchAllStationName5(userId,null,null).getData();
        List<BattalarmData> battAlarmListAll = getLevelListByUserId(userId);
        List<DevalarmData> deviceAlarmListAll = devalarmDataMapper.getLevelListByUserId(userId);
        List<PwrdevAlarm> powerAlarmListAll = pwrdevAlarmMapper.getLevelListByUserId(userId);
        for (String stationName5 : stationName5List) {
            Map<String,AlarmCountDTO> levelMap = new HashMap<>();
            AlarmCountDTO alarmCount1 = new AlarmCountDTO();
            AlarmCountDTO alarmCount2 = new AlarmCountDTO();
            AlarmCountDTO alarmCount3 = new AlarmCountDTO();
            AlarmCountDTO alarmCount4 = new AlarmCountDTO();
            //电池
            List<BattalarmData> battAlarmList = battAlarmListAll.stream().filter(battalarmData -> battalarmData.getStationName5().equals(stationName5)).collect(Collectors.toList());
            int battAlarmCountLevel1 = 0;
            int battAlarmCountLevel2 = 0;
            int battAlarmCountLevel3 = 0;
            int battAlarmCountLevel4 = 0;
            for (BattalarmData battalarmData : battAlarmList) {
                Integer almLevel = battalarmData.getAlmLevel();
                if(almLevel == 1){
                    battAlarmCountLevel1++;
                }
                else if(almLevel == 2){
                    battAlarmCountLevel2++;
                }
                else if(almLevel == 3){
                    battAlarmCountLevel3++;
                }
                else if(almLevel == 4){
                    battAlarmCountLevel4++;
                }
            }
            alarmCount1.setBattAlarmCount(battAlarmCountLevel1);
            alarmCount2.setBattAlarmCount(battAlarmCountLevel2);
            alarmCount3.setBattAlarmCount(battAlarmCountLevel3);
            alarmCount4.setBattAlarmCount(battAlarmCountLevel4);
            //设备
            List<DevalarmData> deviceAlarmList = deviceAlarmListAll.stream().filter(devalarmData -> devalarmData.getStationName5().equals(stationName5)).collect(Collectors.toList());
            int deviceAlarmCountLevel1 = 0;
            int deviceAlarmCountLevel2 = 0;
            int deviceAlarmCountLevel3 = 0;
            int deviceAlarmCountLevel4 = 0;
            for (DevalarmData deviceAlarmData : deviceAlarmList) {
                Integer almLevel = deviceAlarmData.getAlmLevel();
                if(almLevel == 1){
                    deviceAlarmCountLevel1++;
                }
                else if(almLevel == 2){
                    deviceAlarmCountLevel2++;
                }
                else if(almLevel == 3){
                    deviceAlarmCountLevel3++;
                }
                else if(almLevel == 4){
                    deviceAlarmCountLevel4++;
                }
            }
            alarmCount1.setDeviceAlarmCount(deviceAlarmCountLevel1);
            alarmCount2.setDeviceAlarmCount(deviceAlarmCountLevel2);
            alarmCount3.setDeviceAlarmCount(deviceAlarmCountLevel3);
            alarmCount4.setDeviceAlarmCount(deviceAlarmCountLevel4);
            //电源
            List<PwrdevAlarm> powerAlarmList = powerAlarmListAll.stream().filter(pwrdevAlarm -> pwrdevAlarm.getStationName5().equals(stationName5)).collect(Collectors.toList());
            int powerAlarmCountLevel1 = 0;
            int powerAlarmCountLevel2 = 0;
            int powerAlarmCountLevel3 = 0;
            int powerAlarmCountLevel4 = 0;
            for (PwrdevAlarm powerAlarmData : powerAlarmList) {
                Integer almLevel = powerAlarmData.getAlmLevel();
                if(almLevel == 1){
                    powerAlarmCountLevel1++;
                }
                else if(almLevel == 2){
                    powerAlarmCountLevel2++;
                }
                else if(almLevel == 3){
                    powerAlarmCountLevel3++;
                }
                else if(almLevel == 4){
                    powerAlarmCountLevel4++;
                }
            }
            alarmCount1.setPowerAlarmCount(powerAlarmCountLevel1);
            alarmCount2.setPowerAlarmCount(powerAlarmCountLevel2);
            alarmCount3.setPowerAlarmCount(powerAlarmCountLevel3);
            alarmCount4.setPowerAlarmCount(powerAlarmCountLevel4);
            levelMap.put("level1",alarmCount1);
            levelMap.put("level2",alarmCount2);
            levelMap.put("level3",alarmCount3);
            levelMap.put("level4",alarmCount4);
            subwayLineLevelMap.put(stationName5,levelMap);
        }
        return new Response().set(1,subwayLineLevelMap);
    }
    private List<BattalarmData> getLevelListByUserId(int userId) {
        return mapper.getLevelListByUserId(userId);
    }
src/main/java/com/whyc/service/Fbs9100StateService.java
@@ -224,6 +224,11 @@
     * 这个是按照设备ip来统计的.
     * 通讯故障>核容放电>充电>内阻>浮充,
     * 如果一拖二的设备,有两个不同状态,实现状态优先级覆盖
     *
     * 设备的数量统计和设备状态的统计,逻辑是不同的,数据库筛选的时候条件逻辑必定是不同的: TODO
     *  通常情况下,设备数量统计,要排除掉一个设备两个id的一拖二情况;
     *  而设备状态统计,只需要区分一个设备的字段,一个设备有多条记录也是正常合理的,通过状态优先级覆盖来定义整个设备的状态
     *
     * @param userId
     * @param type 1-太原排除蓄电池设备一拖二的第二组状态统计
     * @param type 2-统计所有设备ip的状态
@@ -234,20 +239,24 @@
        Response response = new Response();
        try {
            Map<String, Integer> resultMap = new HashMap<>();
            resultMap.put("直流充电数量", 0);
            resultMap.put("直连充电数量", 0);
            resultMap.put("预充电数量", 0);
            resultMap.put("核容测试数量", 0);
            resultMap.put("内阻测试数量", 0);
            resultMap.put("通讯故障数量", 0);
            List<Fbs9100State> fbs9100StateList = mapper.getListWithoutZJDYBTSE2(userId,type);
            //Map<String, List<Fbs9100State>> deviceMap = fbs9100StateList.stream().collect(Collectors.groupingBy(Fbs9100State::getDevIp));
            Map<String, List<Fbs9100State>> deviceMap = fbs9100StateList.stream().collect(Collectors.groupingBy(state ->
                    String.format("%s_%s",state.getDevIp(), state.getDevId())));
            //上面的分组字段 只要能区分 不同的设备就行了. 因为如果是一拖二的情况,也可通过后面的状态优先级来覆盖,设备不会重复
            //太供可以通过ip来确定是哪台设备
            Map<String, List<Fbs9100State>> deviceMap = fbs9100StateList.stream().collect(Collectors.groupingBy(Fbs9100State::getDevIp));
            //Map<String, List<Fbs9100State>> deviceMap = fbs9100StateList.stream().collect(Collectors.groupingBy(state ->
            //        String.format("%s_%s",state.getDevIp(), state.getDevId())));
            Set<String> deviceSet = deviceMap.keySet();
            Calendar instance = Calendar.getInstance();
            instance.add(Calendar.MINUTE, -1);
            Date time = instance.getTime();
            //这个遍历里面,是按照groupingBy(字段)来进行分组的,可以存在一个设备多个记录,即出现一拖二的情况. 这个时候按照优先级进行覆盖来定义整个设备的状态
            //上面的分组字段 只要能区分 不同的设备就行了. 因为如果是一拖二的情况,也可通过状态优先级来覆盖
            for (String deviceIp : deviceSet) {
                List<Fbs9100State> fbs9100States = deviceMap.get(deviceIp);
                List<Integer> workStateList = fbs9100States.stream().map(Fbs9100State::getDevWorkstate).collect(Collectors.toList());
@@ -274,7 +283,7 @@
                        resultMap.put("内阻测试数量", resultMap.get("内阻测试数量") + 1);
                    }
                    else if(workStateSet.contains(DeviceConstant.DEV_ONLINE_CHARGE)) {
                        resultMap.put("直流充电数量", resultMap.get("直流充电数量") + 1);
                        resultMap.put("直连充电数量", resultMap.get("直连充电数量") + 1);
                    }
                }
@@ -317,7 +326,7 @@
        Response response = new Response();
        try {
            Map<String, Integer> resultMap = new HashMap<>();
            resultMap.put("直流充电数量", 0);
            resultMap.put("直连充电数量", 0);
            resultMap.put("预充电数量", 0);
            resultMap.put("核容测试数量", 0);
            resultMap.put("内阻测试数量", 0);
@@ -326,6 +335,7 @@
            List<Fbs9100State> fbs9100StateList = mapper.getListWithoutZJDYBTSE2JY(type);
            //Map<String, List<Fbs9100State>> deviceMap = fbs9100StateList.stream().collect(Collectors.groupingBy(Fbs9100State::getDevIp));
            //JY的设备,ip都一样,所以区分不同的设备,需要通过ip+id
            Map<String, List<Fbs9100State>> deviceMap = fbs9100StateList.stream().collect(Collectors.groupingBy(state ->String.format("%s_%s",state.getDevIp(), state.getDevId())));
            Set<String> deviceSet = deviceMap.keySet();
            Calendar instance = Calendar.getInstance();
@@ -357,7 +367,7 @@
                        resultMap.put("内阻测试数量", resultMap.get("内阻测试数量") + 1);
                    }
                    else if(workStateSet.contains(DeviceConstant.DEV_ONLINE_CHARGE)) {
                        resultMap.put("直流充电数量", resultMap.get("直流充电数量") + 1);
                        resultMap.put("直连充电数量", resultMap.get("直连充电数量") + 1);
                    }
                }
src/main/java/com/whyc/webSocket/ScreenForSZSocket.java
New file
@@ -0,0 +1,264 @@
package com.whyc.webSocket;
import com.whyc.config.WebSocketConfig;
import com.whyc.dto.Response;
import com.whyc.factory.ThreadPoolExecutorFactory;
import com.whyc.pojo.Battinf;
import com.whyc.pojo.UserInf;
import com.whyc.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpSession;
import javax.websocket.*;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
 * 苏州地铁
 * 首页大屏展示 Socket
 */
@Component
@ServerEndpoint(value = "/screen_sz",encoders = WebSocketEncoder.class,configurator = WebSocketConfig.class)
public class ScreenForSZSocket {
    private Session session;
    private Thread thread;
    private static PwrdevAlarmService powerAlarmService;
    private static BattalarmDataService battAlarmDataService;
    private static Fbs9100StateService fbs9100StateService;
    private static DevalarmDataService devAlarmDataService;
    private static BattInfService battInfService;
    private static BattEnduranceService battEnduranceService;
    private static StationInfService stationService;
    private static PowerInfService powerInfService;
    //private static BatttestdataInfService testInfService;
    private static BatttestdataInfService batttestdataInfService;
    private static BattRtstateService battRtStateService;
    @Autowired
    public void setPowerAlarmService(PwrdevAlarmService powerAlarmService) {
        ScreenForSZSocket.powerAlarmService = powerAlarmService;
    }
    @Autowired
    public void setBattAlarmDataService(BattalarmDataService battAlarmDataService) {
        ScreenForSZSocket.battAlarmDataService = battAlarmDataService;
    }
    @Autowired
    public void setFbs9100StateService(Fbs9100StateService fbs9100StateService) {
        ScreenForSZSocket.fbs9100StateService = fbs9100StateService;
    }
    @Autowired
    public void setDevAlarmDataService(DevalarmDataService devAlarmDataService) {
        ScreenForSZSocket.devAlarmDataService = devAlarmDataService;
    }
    @Autowired
    public void setBattInfService(BattInfService battInfService) {
        ScreenForSZSocket.battInfService = battInfService;
    }
    @Autowired
    public void setBattEnduranceService(BattEnduranceService battEnduranceService) {
        ScreenForSZSocket.battEnduranceService = battEnduranceService;
    }
    @Autowired
    public void setStationService(StationInfService stationService) {
        ScreenForSZSocket.stationService = stationService;
    }
    @Autowired
    public void setPowerInfService(PowerInfService powerInfService) {
        ScreenForSZSocket.powerInfService = powerInfService;
    }
    @Autowired
    public void setBatttestdataInfService(BatttestdataInfService batttestdataInfService) {
        ScreenForSZSocket.batttestdataInfService = batttestdataInfService;
    }
    @Autowired
    public void setBattRtStateService(BattRtstateService battRtStateService) {
        ScreenForSZSocket.battRtStateService = battRtStateService;
    }
    @OnOpen
    public void onOpen(Session session, EndpointConfig config){
        this.session = session;
        HttpSession httpSession = (HttpSession) config.getUserProperties().get("httpSession");
        UserInf user = (UserInf) httpSession.getAttribute("user");
        final int userId = user.getUId().intValue();
        //final int userId = 1001;
        Thread thread = new Thread() {
            @Override
            public void run() {
                try {
                    Map<String, Object> res = new HashMap<>();
                    while (!currentThread().isInterrupted()) {
                        ThreadPoolExecutor poolExecutor = ThreadPoolExecutorFactory.getPoolExecutor();
                        CountDownLatch latch = new CountDownLatch(5);
                        /*poolExecutor.execute(()->{
                            //1.统计:电池统计 分为品牌和标称电压
                            Response res_battGroupInfo = new Response();
                            try {
                                List<Battinf> battinfList = battInfService.getBattGroupList(userId);
                                Map<String, List<Battinf>> battProducerMap = battinfList.stream().collect(Collectors.groupingBy(Battinf::getBattProducer));
                                Map<Float, List<Battinf>> battMonVolStdMap = battinfList.stream().collect(Collectors.groupingBy(Battinf::getMonVolStd));
                                Map<String, Object> battGroupProducerMap = new HashMap<>();
                                Map<String, Object> battGroupMonVolMap = new HashMap<>();
                                Map<String, Object> battGroupInfoMap = new HashMap<>();
                                int battSize = battinfList.size();
                                for (String producer : battProducerMap.keySet()) {
                                    battGroupProducerMap.put(producer, battProducerMap.get(producer).size());
                                }
                                for (Float monVolStd : battMonVolStdMap.keySet()) {
                                    battGroupMonVolMap.put(Float.toString(monVolStd), battMonVolStdMap.get(monVolStd).size());
                                }
                                battGroupInfoMap.put("producer",battGroupProducerMap);
                                battGroupInfoMap.put("monVol",battGroupMonVolMap);
                                battGroupInfoMap.put("totalNum",battSize);
                                res_battGroupInfo.setII(1,true,battGroupInfoMap,null);
                            }catch (Exception e){
                                res_battGroupInfo.set(1,false,"发生异常:"+e.getCause());
                            }
                            res.put("battGroupInfo", res_battGroupInfo);
                            latch.countDown();
                        });*/
                        poolExecutor.execute(()->{
                            //2.统计:设备状态
                            Response<Map> res_devStates = fbs9100StateService.getBTSEquipStatus2(userId,2);
                            res.put("devStates", res_devStates);
                            latch.countDown();
                        });
                        poolExecutor.execute(()->{
                            //3.统计:组端容量
                            //Response res_monCapacityLowAnalysis = battAlarmDataService.getMonCapacityLowAnalysis(userId);
                            Response res_groupCap = battEnduranceService.getGroupCapList(userId);
                            res.put("groupCap", res_groupCap);
                            latch.countDown();
                        });
                        poolExecutor.execute(()->{
                            //4.统计:各种设备类型总数 电池 设备 电源 站点 新增电池单体数
                            Response<Map> res_devCountMap = battInfService.getDevCountMapForSZ(userId);
                            res.put("devCountMap", res_devCountMap);
                            latch.countDown();
                        });
                        /*//5.统计:每个省的机房数统计
                        poolExecutor.execute(()->{
                            Response res_stationCount = stationService.getProvinceCountMap(userId);
                            res.put("stationCount", res_stationCount);
                            latch.countDown();
                        });*/
                        /*poolExecutor.execute(()->{
                            //6.统计:实时放电信息 正在放电的电池信息展示
                            Response dischargingList = battRtStateService.getDischargingList(userId);
                            res.put("dischargingBattery", dischargingList);
                            latch.countDown();
                        });*/
                        /*poolExecutor.execute(()->{
                            //7.统计:电源统计
                            Response res_powerProducer = new Response();
                            try {
                                Response producersCount = powerInfService.getProducerCount(userId);
                                res_powerProducer.setII(1,true,producersCount,null);
                            }catch (Exception e){
                                res_powerProducer.set(1,false,"发生异常:"+e.getCause());
                            }
                            res.put("powerProducerCount", res_powerProducer);
                            latch.countDown();
                        });*/
                        /*poolExecutor.execute(()->{
                            //9.统计:告警统计 电源,设备,电池
                            Response res_devAlarmNum = new Response();
                            Map<String, Integer> devAlarmNumMap = new HashMap<>();
                            try {
                                int battAlarmNum = battAlarmDataService.getRealTimeWithLevel1(userId).getCode();
                                int devAlarmNum = devAlarmDataService.getRealTimeWithLevel1(userId);
                                int powerAlarmNum = powerAlarmService.getRealTimeWithLevel1(userId);
                                devAlarmNumMap.put("battAlarmNum",battAlarmNum);
                                devAlarmNumMap.put("devAlarmNum",devAlarmNum);
                                devAlarmNumMap.put("powerAlarmNum",powerAlarmNum);
                                res_devAlarmNum.setII(1,true,devAlarmNumMap,null);
                            }catch (Exception e){
                                res_devAlarmNum.set(1,false,"发生异常:"+e.getCause());
                            }
                            res.put("devAlarmNum", res_devAlarmNum);
                            latch.countDown();
                        });*/
                        poolExecutor.execute(()->{
                            //9-1.统计:区县(StationName5)的 告警统计 级别及类型统计
                            //查询出所有的区县,并按照区县来进行告警的分类统计
                            Response res_alarmLevel = new Response();
                            try {
                                Response alarmsCountByLevel = battAlarmDataService.getByLevelAndStationName5(userId);
                                res_alarmLevel.setII(1,true,alarmsCountByLevel,null);
                            }catch (Exception e){
                                res_alarmLevel.set(1,false,"发生异常:"+e.getCause());
                            }
                            res.put("alarmsLevelWithStationName5", res_alarmLevel);
                            latch.countDown();
                        });
                        poolExecutor.execute(()->{
                            //9-2.统计:告警统计 级别及类型统计
                            Response res_alarmLevel = new Response();
                            Map<String, Integer> devAlarmNumMap = new HashMap<>();
                            try {
                                Response alarmsCountByLevel = battAlarmDataService.getByLevel(userId);
                                res_alarmLevel.setII(1,true,alarmsCountByLevel,null);
                            }catch (Exception e){
                                res_alarmLevel.set(1,false,"发生异常:"+e.getCause());
                            }
                            res.put("alarmsLevel", res_alarmLevel);
                            latch.countDown();
                        });
                        latch.await(10, TimeUnit.MINUTES);
                        session.getBasicRemote().sendObject(new Response().set(1, res));
                        sleep(4000);
                    }
                } catch (Exception e) {
                    this.interrupt();
                }
            }
        };
        thread.start();
        this.thread = thread;
    }
    @OnClose
    public void onClose(CloseReason closeReason) throws IOException {
        //System.err.println("closeReason = " + closeReason);
        if(session.isOpen()){
            session.close();
        }
    }
    @OnError
    public void onError(Throwable error) throws IOException {
        //error.printStackTrace();
        thread.isInterrupted();
        if(session.isOpen()){
            session.close();
        }
    }
}
src/main/resources/mapper/BattInfMapper.xml
@@ -547,6 +547,14 @@
        and db_user.tb_user_inf.uid=#{userId})
    </select>
    <select id="getBattGroupMonNum" resultType="java.lang.Integer">
        select sum(MonCount) from db_battinf.tb_battinf where StationId in(select distinct db_battinf.tb_battinf.StationId
        from db_battinf.tb_battinf,db_user.tb_user_battgroup_baojigroup_battgroup,db_user.tb_user_battgroup_baojigroup_usr,db_user.tb_user_inf
        where db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId=db_battinf.tb_battinf.BattGroupId
        and db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id
        and db_user.tb_user_inf.uid=db_user.tb_user_battgroup_baojigroup_usr.uid
        and db_user.tb_user_inf.uid=#{userId})
    </select>
    <select id="getBattGroupNumJY" resultType="java.lang.Integer">
        select count(*) from db_battinf.tb_battinf
    </select>
src/main/resources/mapper/BattalarmDataMapper.xml
@@ -592,10 +592,11 @@
    </select>
    <select id="getLevelListByUserId" resultType="com.whyc.pojo.BattalarmData">
        SELECT alm_level
        from db_alarm.tb_battalarm_data
        SELECT alm_level,StationName5 as stationName5
        from db_alarm.tb_battalarm_data,db_battinf.tb_battinf
        where
        BattGroupId
        db_alarm.tb_battalarm_data.battgroupid=db_battinf.tb_battinf.battgroupid
        and db_alarm.tb_battalarm_data.BattGroupId
        in (select distinct db_battinf.tb_battinf.battgroupid
        from db_battinf.tb_battinf,db_user.tb_user_battgroup_baojigroup_battgroup,db_user.tb_user_battgroup_baojigroup_usr,db_user.tb_user_inf
        where db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId=db_battinf.tb_battinf.BattGroupId
src/main/resources/mapper/DevAlarmDataVerifyMapper.xml
@@ -42,8 +42,8 @@
            and stationname1=#{stationName1}
        </if>
        <if test="stationName!=''">
            and stationname=#{stationName}
        <if test="stationId!=''">
            and stationId=#{stationId}
        </if>
        <if test="almLevel!=0 and almLevel!=null">
            and alm_level=#{almLevel}
src/main/resources/mapper/DevalarmDataMapper.xml
@@ -383,9 +383,9 @@
        ORDER by GroupIndexInFBSDevice limit 1
    </select>
    <select id="getLevelListByUserId" resultType="com.whyc.pojo.DevalarmData">
        select alm_level
        from db_alarm.tb_devalarm_data
        where dev_id in (select distinct db_battinf.tb_battinf.FbsDeviceId
        select alm_level,StationName5 as stationName5
        from db_alarm.tb_devalarm_data,db_battinf.tb_battinf where db_alarm.tb_devalarm_data.dev_id=db_battinf.tb_battinf.FbsDeviceId
        and db_alarm.tb_devalarm_data.dev_id in (select distinct db_battinf.tb_battinf.FbsDeviceId
        from db_battinf.tb_battinf,db_user.tb_user_battgroup_baojigroup_battgroup,db_user.tb_user_battgroup_baojigroup_usr,db_user.tb_user_inf
        where db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId=db_battinf.tb_battinf.BattGroupId
        and db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id
src/main/resources/mapper/PwrdevAlarmMapper.xml
@@ -413,7 +413,7 @@
        </foreach>
    </select>
    <select id="getLevelListByUserId" resultType="com.whyc.pojo.PwrdevAlarm">
        select alm_level from db_pwrdev_alarm.tb_pwrdev_alarm alarm,db_pwrdev_inf.tb_pwrdev_inf inf
        select alm_level,StationName5 as stationName5 from db_pwrdev_alarm.tb_pwrdev_alarm alarm,db_pwrdev_inf.tb_pwrdev_inf inf
        where alarm.PowerDeviceId = inf.PowerDeviceId
        and inf.StationId in ( select distinct inf.StationId from
        (select StationId from db_battinf.tb_battinf union select StationId from db_pwrdev_inf.tb_pwrdev_inf ) inf,