From dbba9c3fc5187432c34329a2a18e07feca729de5 Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期二, 24 六月 2025 11:25:11 +0800
Subject: [PATCH] 2.5.1蓄电池对比分析同一时间同一品牌

---
 src/main/java/com/whyc/service/BattresdataInfService.java |   42 ++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/whyc/service/BattresdataInfService.java b/src/main/java/com/whyc/service/BattresdataInfService.java
index 0e089fe..f9fc71b 100644
--- a/src/main/java/com/whyc/service/BattresdataInfService.java
+++ b/src/main/java/com/whyc/service/BattresdataInfService.java
@@ -2,15 +2,17 @@
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.whyc.dto.Real.QuarterDto;
+import com.whyc.dto.Statistic.ComPareChart;
 import com.whyc.mapper.BattresdataInfMapper;
 import com.whyc.mapper.CommonMapper;
 import com.whyc.pojo.db_batt_testdata.BattresdataId;
 import com.whyc.pojo.db_batt_testdata.BattresdataInf;
+import com.whyc.pojo.db_station.BattInf;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.List;
+import java.util.*;
 
 @Service
 public class BattresdataInfService {
@@ -40,7 +42,6 @@
         wrapper.last(" ORDER BY test_record_count asc ");
         BattresdataInf rinf = mapper.selectOne(wrapper);
         if(rinf!=null){
-            String tableName ="db_batt_testdata.tb_battresdata_"+battgroupId;
             String existTableName = commonMapper.existTable("db_batt_testdata", "tb_battresdata_"+battgroupId);
             if(existTableName != null){
                 List<QuarterDto> list=subTablePageInfoService.getBattResInfData(battgroupId,rinf.getTestRecordCount());
@@ -49,4 +50,41 @@
         }
         return null;
     }
+
+    //钃勭數姹犲姣斿垎鏋愬彸渚ф渶楂樺崟浣撳唴闃绘暟鎹�(鏈�鏂颁竴娆″唴闃绘祴璇�)
+    public ComPareChart getMaxResData(BattInf binf) {
+        QueryWrapper wrapper = new QueryWrapper();
+        wrapper.eq("battgroup_id", binf.getBattgroupId());
+        wrapper.last(" limit 1");
+        wrapper.last(" ORDER BY test_starttime desc ");
+        BattresdataInf rinf = mapper.selectOne(wrapper);
+        ComPareChart chart=new ComPareChart();
+        chart.setBattgroupName(binf.getBattgroupName());
+        chart.setBattgroupId(binf.getBattgroupId());
+        chart.setValue(0f);
+        chart.setMonNum(1);
+        if(rinf!=null){
+            String existTableName = commonMapper.existTable("db_batt_testdata", "tb_battresdata_"+binf.getBattgroupId());
+            if(existTableName != null){
+                //鍙栧唴闃绘祴璇曠殑鏈�澶у唴闃诲拰鍗曚綋缂栧彿
+                List<QuarterDto> list=subTablePageInfoService.getMaxResInInfData(binf.getBattgroupId(),rinf.getTestRecordCount());
+                if(list!=null&&list.size()>0){
+                    Map<String, Object> map =list.stream()
+                            .max(Comparator.comparing(QuarterDto::getNumValue))
+                            .map(dto -> {
+                                Map<String, Object> result = new HashMap<>();
+                                result.put("maxNumValue", dto.getNumValue());
+                                result.put("monNum", dto.getMonNum());
+                                return result;
+                            })
+                            .orElse(Collections.emptyMap());
+                    chart.setBattgroupId(binf.getBattgroupId());
+                    chart.setBattgroupName(binf.getBattgroupName());
+                    chart.setValue(Float.parseFloat(map.get("maxNumValue").toString()));
+                    chart.setMonNum(Integer.parseInt(map.get("monNum").toString()));
+                }
+            }
+        }
+        return chart;
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1