From 2753ad7aee272a5a5a8a0124b1feea5a1e4cc83e Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期五, 20 六月 2025 22:40:52 +0800
Subject: [PATCH] 电源告警参数返回

---
 src/main/java/com/whyc/service/BattRealdataIdService.java |   58 +++++++++++++++-------------------------------------------
 1 files changed, 15 insertions(+), 43 deletions(-)

diff --git a/src/main/java/com/whyc/service/BattRealdataIdService.java b/src/main/java/com/whyc/service/BattRealdataIdService.java
index 8a1faed..cfa95d3 100644
--- a/src/main/java/com/whyc/service/BattRealdataIdService.java
+++ b/src/main/java/com/whyc/service/BattRealdataIdService.java
@@ -11,6 +11,8 @@
 import com.whyc.pojo.db_data_history.BattRealdataId;
 import com.whyc.pojo.db_param.AlmAnalysisParam;
 import com.whyc.pojo.db_param.AppParam;
+import com.whyc.pojo.db_ram_db.BattRtstate;
+import com.whyc.pojo.db_station.BattInf;
 import com.whyc.util.ActionUtil;
 import com.whyc.util.DateUtil;
 import com.whyc.util.ThreadLocalUtil;
@@ -43,11 +45,9 @@
     @Autowired
     private BattInfService binfService;
 
-    @Autowired
-    private AlmAnalysisParamService almAnalysisParamService;
+    @Autowired(required = false)
+    private BattRtstateService rtstateService;
 
-    @Autowired
-    private AppParamService appParamService;
 
 
     //鑾峰彇鐢垫睜缁勬渶杩戜竴瀛e害鐨勫崟浣撴暟鎹�
@@ -190,6 +190,16 @@
     }
     //鍘嗗彶瀹炴椂鏁版嵁
     public Response getBattRealDataHis(Integer battgroupId, Integer granularity,String startTime,String endTime) throws ParseException, InterruptedException {
+        Map<String,Object> map=new HashMap<>();
+        //瀹炴椂鑾峰彇鐢垫睜缁勪俊鎭�
+        BattRtstate battRtstate = rtstateService.getBattRealInfo(battgroupId);
+        //鑾峰彇鐢垫睜缁勪俊鎭�
+        BattInf binf = binfService.getBinfByBattgroupId(battgroupId);
+        map.put("鏍囩О瀹归噺",binf.getMoncapstd());
+        map.put("钃勭數姹犳暟閲�",binf.getMoncount());
+        map.put("鏍囩О鐢靛帇",binf.getMonvolstd());
+        map.put("娴厖鐢靛帇",battRtstate.getGroupVol());
+
         List<RealDateDTO> dataList = new LinkedList<>();
         List<List<Date>> monthTimeList = DateUtil.getMonthTime(ThreadLocalUtil.parse(startTime,1), ThreadLocalUtil.parse(endTime,1));
         ThreadPoolExecutor pool = ThreadPoolExecutorFactory.getPoolExecutor();
@@ -224,44 +234,6 @@
         }
         latch.await(10, TimeUnit.MINUTES);
         List dataListSorted = dataList.stream().sorted(Comparator.comparing(RealDateDTO::getRecordTime)).collect(Collectors.toList());
-        return new Response().set(1, dataListSorted);
-    }
-    //鐢垫睜鍛婅鐐瑰嚮鍏蜂綋鍛婅淇℃伅鏌ョ湅浠庡憡璀﹀紑濮嬫椂闂村埌鐜板湪鐨勫巻鍙插疄鏃舵暟鎹�
-    public Response getBattHisRealInAlm(Integer battgroupId, String startTime, Integer almId) throws ParseException, InterruptedException {
-        //鑾峰彇鍛婅almId瀵瑰簲鐨勫垎鏋愰厤缃睘鎬у��
-        AlmAnalysisParam almAnalysisParam= almAnalysisParamService.getAnalysisParam(almId);
-        List<RealDateDTO> dataList = new LinkedList<>();
-        //鑾峰彇棰勮鍒嗘瀽鍛ㄦ湡闃堝��
-        AppParam appParam = appParamService.getAlarmAnalysisCycle();
-        Integer cycleTime=appParam.getParamValue().intValue();
-        Date cyscleDate=ActionUtil.getDateAdd(ThreadLocalUtil.parse(startTime,1),cycleTime*(-1));
-        //鑾峰彇cyscleDate鍒扮幇鍦ㄦ墍鏈夌殑鍘嗗彶瀹炴椂鏁版嵁
-        List<List<Date>> monthTimeList = DateUtil.getMonthTime(cyscleDate,new Date());
-        ThreadPoolExecutor pool = ThreadPoolExecutorFactory.getPoolExecutor();
-        CountDownLatch latch = new CountDownLatch(monthTimeList.size());
-        for (int i = 0; i < monthTimeList.size(); i++) {
-            int finalI = i;
-            pool.execute(() -> {
-                int finalII = finalI;
-                BattRealdataId realdata = new BattRealdataId();
-                realdata.setRecordTime(monthTimeList.get(finalII).get(0));
-                realdata.setRecordTime1(monthTimeList.get(finalII).get(1));
-                String table = battgroupId + "_" + ThreadLocalUtil.format(realdata.getRecordTime(),2);
-                realdata.setTableName(table);//琛ㄥ悕鏃堕棿鏍煎紡閮ㄥ垎
-                //鍒ゆ柇琛ㄦ槸鍚﹀瓨鍦�
-                int tableNum = subTablePageInfoService.judgeTable_realdata(table);
-                List<RealDateDTO> list = new ArrayList();
-                if (tableNum > 0) {
-                    list = subTablePageInfoService.getBattHisRealInAlm(realdata);
-                }
-                dataList.addAll(list);
-                latch.countDown();
-            });
-            sleep(200);
-        }
-        latch.await(10, TimeUnit.MINUTES);
-        List dataListSorted = dataList.stream().sorted(Comparator.comparing(RealDateDTO::getRecordTime)).collect(Collectors.toList());
-        return new Response().setIII(1,true, dataListSorted,almAnalysisParam,"鐢垫睜鍛婅鐐瑰嚮鍏蜂綋鍛婅淇℃伅鏌ョ湅浠庡憡璀﹀紑濮嬫椂闂村埌鐜板湪鐨勫巻鍙插疄鏃舵暟鎹�");
-
+        return new Response().setIII(1, dataListSorted!=null,dataListSorted,map,"鍘嗗彶瀹炴椂鏌ヨ");
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1