| | |
| | | @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() { |
| | |
| | | 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(); |
| | |
| | | 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)); |