whycxzp
2024-03-09 813b1e0a24b1d7ba70b3929d4e7f90d99c2241a2
src/main/java/com/whyc/webSocket/ScreenForNWKMSocket.java
@@ -94,10 +94,10 @@
    @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;
        //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() {
@@ -105,7 +105,7 @@
                    Map<String, Object> res = new HashMap<>();
                    while (!currentThread().isInterrupted()) {
                        ThreadPoolExecutor poolExecutor = ThreadPoolExecutorFactory.getPoolExecutor();
                        CountDownLatch latch = new CountDownLatch(9);
                        CountDownLatch latch = new CountDownLatch(10);
                        poolExecutor.execute(()->{
                            //1.统计:电池统计 分为品牌和标称电压
                            Response res_battGroupInfo = new Response();
@@ -222,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);
                        session.getBasicRemote().sendObject(new Response().set(1, res));