whyclxw
2025-05-28 e16302f9d475c7cc4dd18c5abf1a23cb5502e362
src/main/java/com/whyc/webSocket/ScreenForNWKMSocket.java
@@ -44,7 +44,15 @@
    private static BattEnduranceService battEnduranceService;
    private static BaoJiGroupService baoJiGroupService;
    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) {
@@ -71,9 +79,25 @@
    public void setBattEnduranceService(BattEnduranceService battEnduranceService) {
        ScreenForNWKMSocket.battEnduranceService = battEnduranceService;
    }
    @Autowired
    public void setBaoJiGroupService(BaoJiGroupService baoJiGroupService) {
        ScreenForNWKMSocket.baoJiGroupService = baoJiGroupService;
    public void setStationService(StationInfService stationService) {
        ScreenForNWKMSocket.stationService = stationService;
    }
    @Autowired
    public void setPowerInfService(PowerInfService powerInfService) {
        ScreenForNWKMSocket.powerInfService = powerInfService;
    }
    @Autowired
    public void setBatttestdataInfService(BatttestdataInfService batttestdataInfService) {
        ScreenForNWKMSocket.batttestdataInfService = batttestdataInfService;
    }
    @Autowired
    public void setBattRtStateService(BattRtstateService battRtStateService) {
        ScreenForNWKMSocket.battRtStateService = battRtStateService;
    }
    @OnOpen
@@ -90,7 +114,7 @@
                    Map<String, Object> res = new HashMap<>();
                    while (!currentThread().isInterrupted()) {
                        ThreadPoolExecutor poolExecutor = ThreadPoolExecutorFactory.getPoolExecutor();
                        CountDownLatch latch = new CountDownLatch(9);
                        CountDownLatch latch = new CountDownLatch(8);
                        poolExecutor.execute(()->{
                            //1.统计:电池统计 分为品牌和标称电压
                            Response res_battGroupInfo = new Response();
@@ -120,7 +144,7 @@
                        });
                        poolExecutor.execute(()->{
                            //2.统计:设备状态
                            Response<Map> res_devStates = fbs9100StateService.getBTSEquipStatus2(userId);
                            Response<Map> res_devStates = fbs9100StateService.getBTSEquipStatus2(userId,2);
                            res.put("devStates", res_devStates);
                            latch.countDown();
                        });
@@ -138,54 +162,50 @@
                            latch.countDown();
                        });
                        //5.统计:TODO 每个省的机房数统计
                        /*//5.统计:每个省的机房数统计
                        poolExecutor.execute(()->{
                            Response res_stationCount = null;
                            Response res_stationCount = stationService.getProvinceCountMap(userId);
                            res.put("stationCount", res_stationCount);
                            latch.countDown();
                        });
                        });*/
                        poolExecutor.execute(()->{
                            //6.统计:TODO 实时告警
                            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);
                            //6.统计:实时放电信息 正在放电的电池信息展示
                            Response dischargingList = battRtStateService.getDischargingList(userId);
                            res.put("dischargingBattery", dischargingList);
                            latch.countDown();
                        });
                        poolExecutor.execute(()->{
                            //7.统计:TODO 资产统计
                            Response res_asset = new Response();
                            //7.统计:电源统计
                            Response res_powerProducer = new Response();
                            try {
                                Response producersCount = powerInfService.getProducerCount(userId);
                                res_powerProducer.setII(1,true,producersCount,null);
                            }catch (Exception e){
                                res_asset.set(1,false,"发生异常:"+e.getCause());
                                res_powerProducer.set(1,false,"发生异常:"+e.getCause());
                            }
                            res.put("asset", res_asset);
                            res.put("powerProducerCount", res_powerProducer);
                            latch.countDown();
                        });
                        poolExecutor.execute(()->{
                            //8.统计:能效统计
                            /*//8.统计:能效统计,默认取五年的能效
                            Response resNX = new Response();
                            Map<String, Integer> devAlarmNumMap = new HashMap<>();
                            try {
                                resNX=testInfService.getEnergyStatistics_nj(5,userId);
                            }catch (Exception e){
                                resNX.set(1,false,"发生异常:"+e.getCause());
                            }
                            res.put("nx", resNX);
                            res.put("nx", resNX);*/
                            //测试信息
                            Response resTestdataInfAnalysis = new Response();
                            try {
                                resTestdataInfAnalysis = batttestdataInfService.getTestdataInfAnalysis(userId);
                            }catch (Exception e){
                                resTestdataInfAnalysis.set(1,false,"发生异常:"+e.getCause());
                            }
                            res.put("resTestdataInfAnalysis", resTestdataInfAnalysis);
                            latch.countDown();
                        });
                        poolExecutor.execute(()->{
                        /*poolExecutor.execute(()->{
                            //9.统计:告警统计 电源,设备,电池
                            Response res_devAlarmNum = new Response();
                            Map<String, Integer> devAlarmNumMap = new HashMap<>();
@@ -202,6 +222,19 @@
                            }
                            res.put("devAlarmNum", res_devAlarmNum);
                            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);