| | |
| | | import com.whyc.factory.ThreadPoolExecutorFactory; |
| | | import com.whyc.pojo.RtState; |
| | | import com.whyc.pojo.StationInf; |
| | | import com.whyc.service.BattAlarmService; |
| | | import com.whyc.service.BattInfService; |
| | | import com.whyc.service.RtDataService; |
| | | import com.whyc.service.RtStateService; |
| | |
| | | |
| | | private static RtDataService rtDataService; |
| | | |
| | | private static BattAlarmService battAlarmService; |
| | | |
| | | |
| | | @Autowired |
| | | public void setRtStateService(RtStateService rtStateService) { |
| | |
| | | public void setRtDataService(RtDataService rtDataService) { |
| | | BattSocket.rtDataService = rtDataService; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setBattAlarmService(BattAlarmService battAlarmService) { |
| | | BattSocket.battAlarmService = battAlarmService; |
| | | } |
| | | |
| | | @OnOpen |
| | | public void onOpen(Session session) { |
| | | this.session = session; |
| | |
| | | Map<String, Object> res = new HashMap<>(); |
| | | while (!currentThread().isInterrupted()) { |
| | | ThreadPoolExecutor poolExecutor = ThreadPoolExecutorFactory.getPoolExecutor(); |
| | | CountDownLatch latch = new CountDownLatch(2); |
| | | CountDownLatch latch = new CountDownLatch(3); |
| | | poolExecutor.execute(() -> { |
| | | Response resRtState = rtStateService.getResRtState(binfId); |
| | | res.put("resRtState", resRtState); |
| | |
| | | res.put("resRtData", resRtData); |
| | | latch.countDown(); |
| | | }); |
| | | poolExecutor.execute(() -> { |
| | | Response resBattAlm = battAlarmService.getResBattAlm(binfId); |
| | | res.put("resBattAlm", resBattAlm); |
| | | latch.countDown(); |
| | | }); |
| | | latch.await(10, TimeUnit.MINUTES); |
| | | session.getBasicRemote().sendObject(new Response().set(1, res)); |
| | | sleep(executeTime); |