From 82d3504d93db29e2b04ed1137e541a19e0cba0f1 Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期一, 23 六月 2025 09:08:14 +0800
Subject: [PATCH] 预警分析管理

---
 src/main/java/com/whyc/service/PwrdevHistorydataIdService.java |   46 +++++++++++++++++++++++++++++++++-------------
 1 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/src/main/java/com/whyc/service/PwrdevHistorydataIdService.java b/src/main/java/com/whyc/service/PwrdevHistorydataIdService.java
index ca1b960..8e69404 100644
--- a/src/main/java/com/whyc/service/PwrdevHistorydataIdService.java
+++ b/src/main/java/com/whyc/service/PwrdevHistorydataIdService.java
@@ -106,11 +106,9 @@
         latch.await(10, TimeUnit.MINUTES);
         List dataListSorted = dataList.stream().sorted(Comparator.comparing(PwrHisRealAcInDto::getRecordDatetime)).collect(Collectors.toList());
         return new Response().setII(1,dataList.size()>0,dataListSorted,"鑾峰彇鍗婂皬鏃跺唴浜ゆ祦杈撳叆缁熻");
-
     }
     //绯荤粺姒傝鑾峰彇鍓峃绗旂洿娴佽緭鍑虹粺璁�
-    public Response getHalfHourPwrHisDcoutData(Integer powerId) {
-        String dateTime = ActionUtil.sdfwithOutday.format(new Date());
+    public Response getHalfHourPwrHisDcoutData(Integer powerId) throws InterruptedException, ParseException {
         //鑾峰彇鍓嶇瑪鏁�*鏃堕棿闂撮殧
         PowerheartParam heartParam=heartService.getHeartParamByPowerId(powerId);
         Integer interverCount=100*5;//榛樿鍊�
@@ -119,26 +117,48 @@
             interverCount=heartParam.getAcinInterverCfg()*heartParam.getAcinCountCfg();
             granularity=heartParam.getAcinInterverCfg();
         }
-        //鑾峰彇鍓嶅崐涓皬鏃舵暟鎹�
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         LocalDateTime now = LocalDateTime.now();
-        // 璁$畻鍗婂皬鏃跺墠鐨勬椂闂寸偣
+        String dateTime = now.format(formatter);
+        Date endTime=ActionUtil.sdf.parse(dateTime);
+        // 璁$畻绗旀暟*鏃堕棿闂撮殧鐨勬椂闂寸偣
         LocalDateTime halfHourAgo = now.minusMinutes(interverCount);
         // 鏍煎紡鍖栬緭鍑�
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         String halfHourAgoTime=halfHourAgo.format(formatter);
-
-        String tableName ="db_data_history.tb_pwrdev_historydata_"+powerId+"_"+dateTime;
-        String existTableName = commonMapper.existTable("db_data_history", "tb_pwrdev_historydata_"+powerId+"_"+dateTime);
-        if(existTableName == null){
-            return new Response().set(1,false,"褰撳墠鐢垫簮涓嶅瓨鍦ㄥ墠闈㈠皬鏃舵暟鎹�");
+        Date startTime=ActionUtil.sdf.parse(halfHourAgoTime);
+        //鑾峰彇涓や釜鏃堕棿鍒嗗壊澶氬皯寮犺〃
+        List<List<Date>> monthTimeList = DateUtil.getMonthTime(startTime,endTime);
+        List<PwrHisRealDcoutInDto> dataList = new LinkedList<>();
+        ThreadPoolExecutor pool = ThreadPoolExecutorFactory.getPoolExecutor();
+        CountDownLatch latch = new CountDownLatch(monthTimeList.size());
+        for (int i = 0; i < monthTimeList.size(); i++) {
+            int finalI = i;
+            Integer finalGranularity = granularity;
+            pool.execute(() -> {
+                int finalII = finalI;
+                Date recordDatetime=monthTimeList.get(finalII).get(0);
+                Date recordDatetime1=monthTimeList.get(finalII).get(1);
+                String table = powerId + "_" + ThreadLocalUtil.format(recordDatetime,2);
+                String tableName="db_data_history.tb_pwrdev_historydata_"+table;
+                //鍒ゆ柇琛ㄦ槸鍚﹀瓨鍦�
+                int tableNum = subTablePageInfoService.judgeTable_pwrhis(table);
+                List<PwrHisRealDcoutInDto> list = new ArrayList();
+                if (tableNum > 0) {
+                    list=subTablePageInfoService.getHalfHourPwrHisDcoutData(tableName, finalGranularity,recordDatetime,recordDatetime1);
+                }
+                dataList.addAll(list);
+                latch.countDown();
+            });
+            sleep(200);
         }
-        List<PwrHisRealDcoutInDto> datalist=subTablePageInfoService.getHalfHourPwrHisDcoutData(tableName,granularity,halfHourAgoTime);
+        latch.await(10, TimeUnit.MINUTES);
+        List dataListSorted = dataList.stream().sorted(Comparator.comparing(PwrHisRealDcoutInDto::getRecordDatetime)).collect(Collectors.toList());
         Long modelCfg=0l;
         PowerInf pinf=powerInfService.getPowerInfById(powerId);
         if(pinf!=null){
             modelCfg=pinf.getModelCfg();
         }
-        return new Response().setIII(1,datalist.size()>0,datalist,modelCfg,"鑾峰彇鍗婂皬鏃跺唴鐩存祦杈撳嚭缁熻");
+        return new Response().setIII(1,dataList.size()>0,dataListSorted,modelCfg,"鑾峰彇鍗婂皬鏃跺唴鐩存祦杈撳嚭缁熻");
     }
     //1.2.7浼樿壇鐢垫簮缁熻涓婁竴瀛e害鐨勭數婧愭煇涓�灞炴�у拰鍙傛暟闃堝�艰秴杩囩殑娆℃暟
     public Integer getPwrQuarter7(Integer powerId,Integer powerType) throws NoSuchFieldException, IllegalAccessException {

--
Gitblit v1.9.1