| | |
| | | import com.whyc.service.BattInfService; |
| | | import com.whyc.service.BatttestdataInfService; |
| | | import com.whyc.service.PowerInfService; |
| | | import com.whyc.util.ActionUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.websocket.*; |
| | | import javax.websocket.server.ServerEndpoint; |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | while (!currentThread().isInterrupted()) { |
| | | ThreadPoolExecutor poolExecutor = ThreadPoolExecutorFactory.getPoolExecutor(); |
| | | CountDownLatch latch = new CountDownLatch(7); |
| | | Date date = new Date(); |
| | | poolExecutor.execute(() -> { |
| | | //蓄电池优劣分析 |
| | | Response resQualityAnalysis = badBattMonService.getQualityAnalysis(userId); |
| | | res.put("resQualityAnalysis", resQualityAnalysis); |
| | | latch.countDown(); |
| | | System.out.println(ActionUtil.sdf.format(date) + " :t1: " + latch.getCount()); |
| | | }); |
| | | poolExecutor.execute(() -> { |
| | | //基础资源信息 |
| | | Response resBattInfoAnalysis = battInfService.getBattInfoAnalysis(userId); |
| | | res.put("resBattInfoAnalysis", resBattInfoAnalysis); |
| | | latch.countDown(); |
| | | System.out.println(ActionUtil.sdf.format(date) + " :t2: " + latch.getCount()); |
| | | }); |
| | | poolExecutor.execute(() -> { |
| | | //站点信息 |
| | |
| | | } |
| | | res.put("resStationAnalysis", resStationAnalysis); |
| | | latch.countDown(); |
| | | System.out.println(ActionUtil.sdf.format(date) + " :t3: " + latch.getCount()); |
| | | }); |
| | | poolExecutor.execute(() -> { |
| | | //不同品牌同一时间品质和同品牌同时间品质 |
| | | Response resProductQuaAnalysis = badBattMonService.getProductQuaAnalysis(userId); |
| | | res.put("resProductQuaAnalysis", resProductQuaAnalysis); |
| | | latch.countDown(); |
| | | System.out.println(ActionUtil.sdf.format(date) + " :t4: " + latch.getCount()); |
| | | }); |
| | | poolExecutor.execute(() -> { |
| | | //电池信息 |
| | |
| | | } |
| | | res.put("battGroupInfo", res_battGroupInfo); |
| | | latch.countDown(); |
| | | System.out.println(ActionUtil.sdf.format(date) + " :t5: " + latch.getCount()); |
| | | }); |
| | | poolExecutor.execute(() -> { |
| | | //电源信息 |
| | |
| | | } |
| | | res.put("resPwrdevInfAnalysis", resPwrdevInfAnalysis); |
| | | latch.countDown(); |
| | | System.out.println(ActionUtil.sdf.format(date) + " :t6: " + latch.getCount()); |
| | | }); |
| | | poolExecutor.execute(() -> { |
| | | //测试信息 |
| | | Response resTestdataInfAnalysis = batttestdataInfService.getTestdataInfAnalysis(userId); |
| | | res.put("resTestdataInfAnalysis", resTestdataInfAnalysis); |
| | | latch.countDown(); |
| | | System.out.println(ActionUtil.sdf.format(date) + " :t7: " + latch.getCount()); |
| | | }); |
| | | latch.await(10, TimeUnit.MINUTES); |
| | | System.out.println(ActionUtil.sdf.format(date) + " :all: " + latch.getCount()); |
| | | latch.await(10, TimeUnit.SECONDS); |
| | | session.getBasicRemote().sendObject(new Response().set(1, res)); |
| | | sleep(4000); |
| | | } |