lxw
2023-03-11 87ab97e38d72baa46536509095bb5588e044ea7b
src/main/java/com/whyc/webSocket/HomeAdminSocket.java
@@ -9,12 +9,14 @@
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;
@@ -77,17 +79,20 @@
                    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(() -> {
                            //站点信息
@@ -115,12 +120,14 @@
                            }
                            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(() -> {
                            //电池信息
@@ -148,6 +155,7 @@
                            }
                            res.put("battGroupInfo", res_battGroupInfo);
                            latch.countDown();
                            System.out.println(ActionUtil.sdf.format(date) + " :t5: " + latch.getCount());
                        });
                        poolExecutor.execute(() -> {
                            //电源信息
@@ -165,14 +173,17 @@
                            }
                            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);
                    }