whyclxw
2025-05-28 e16302f9d475c7cc4dd18c5abf1a23cb5502e362
src/main/java/com/whyc/webSocket/ScreenSocket.java
@@ -22,6 +22,7 @@
import java.util.stream.Collectors;
/**
 * 山西太原
 * 大屏展示 Socket
 */
@Component
@@ -40,6 +41,10 @@
    private static DevalarmDataService devAlarmDataService;
    private static BattInfService battInfService;
    private static BattEnduranceService battEnduranceService;
    private static BaoJiGroupService baoJiGroupService;
    @Autowired
    public void setPowerAlarmService(PwrdevAlarmService powerAlarmService) {
@@ -62,6 +67,15 @@
        ScreenSocket.battInfService = battInfService;
    }
    @Autowired
    public void setBattEnduranceService(BattEnduranceService battEnduranceService) {
        ScreenSocket.battEnduranceService = battEnduranceService;
    }
    @Autowired
    public void setBaoJiGroupService(BaoJiGroupService baoJiGroupService) {
        ScreenSocket.baoJiGroupService = baoJiGroupService;
    }
    @OnOpen
    public void onOpen(Session session, EndpointConfig config){
        this.session = session;
@@ -76,7 +90,7 @@
                    Map<String, Object> res = new HashMap<>();
                    while (!currentThread().isInterrupted()) {
                        ThreadPoolExecutor poolExecutor = ThreadPoolExecutorFactory.getPoolExecutor();
                        CountDownLatch latch = new CountDownLatch(8);
                        CountDownLatch latch = new CountDownLatch(9);
                        poolExecutor.execute(()->{
                            //一体   告警:交流ABC
                            Response res_acABC = powerAlarmService.getAcABCAnalysis(userId);
@@ -84,9 +98,10 @@
                            latch.countDown();
                        });
                        poolExecutor.execute(()->{
                            //一体   告警:单体容量
                            Response res_monCapacityLowAnalysis = battAlarmDataService.getMonCapacityLowAnalysis(userId);
                            res.put("monCapacityLowAnalysis", res_monCapacityLowAnalysis);
                            //一体   组端容量
                            //Response res_monCapacityLowAnalysis = battAlarmDataService.getMonCapacityLowAnalysis(userId);
                            Response res_groupCap = battEnduranceService.getGroupCapList(userId);
                            res.put("groupCap", res_groupCap);
                            latch.countDown();
                        });
                        poolExecutor.execute(()->{
@@ -100,9 +115,9 @@
                            Response res_devAlarmNum = new Response();
                            Map<String, Integer> devAlarmNumMap = new HashMap<>();
                            try {
                                int battAlarmNum = battAlarmDataService.serchRealTime(userId).getCode();
                                int devAlarmNum = devAlarmDataService.getAlarmNum(userId);
                                int powerAlarmNum = (int) powerAlarmService.getAlarmNum().getData();
                                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);
@@ -142,7 +157,7 @@
                        });
                        poolExecutor.execute(()->{
                            //一体   统计:设备状态
                            Response<Map> res_devStates = fbs9100StateService.getBTSEquipStatus(userId);
                            Response<Map> res_devStates = fbs9100StateService.getBTSEquipStatus2(userId,1);
                            res.put("devStates", res_devStates);
                            latch.countDown();
                        });
@@ -153,15 +168,13 @@
                            latch.countDown();
                        });
                        poolExecutor.execute(()->{
                            //续航检测:按照电池组为单位进行检测,告警判定:实际容量/标称容量<=某个百分比 TODO 续航表中读取需要询问李军确认
                            Response res_capAlarmNum = new Response();
                            try {
                                int capAlarmNum = battInfService.getCapAlarmNum(userId);
                                res_capAlarmNum.setII(1,true,capAlarmNum,null);
                            }catch (Exception e){
                                res_capAlarmNum.set(1,false,"发生异常:"+e.getCause());
                            }
                            res.put("capAlarmNum", res_capAlarmNum);
                            Response res_endurance = battEnduranceService.getEnduranceTimeLong(userId,4);
                            res.put("enduranceLow", res_endurance);
                            latch.countDown();
                        });
                        poolExecutor.execute(()->{
                            Response res_groupInfo = baoJiGroupService.getGroupWithStationAndAlarmForScreen(userId);
                            res.put("res_groupInfo", res_groupInfo);
                            latch.countDown();
                        });