From f998f917f90d86499bf8a24c8912e270655e4d43 Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq.com> Date: 星期二, 24 六月 2025 17:27:57 +0800 Subject: [PATCH] 预警分析修改 --- src/main/java/com/whyc/service/BattresdataInfService.java | 63 ++++++++++++++++++++++++++++++- 1 files changed, 61 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..de45b7c 100644 --- a/src/main/java/com/whyc/service/BattresdataInfService.java +++ b/src/main/java/com/whyc/service/BattresdataInfService.java @@ -2,15 +2,19 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.whyc.dto.Real.QuarterDto; +import com.whyc.dto.Response; +import com.whyc.dto.Statistic.ComPareChangeCurve; +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 +44,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 +52,60 @@ } 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; + } + //鐐瑰嚮鍙充晶鎶樼嚎鍥剧敾鍑虹數姹犵粍鍗曚綋鐨勬墍鏈夊唴闃绘祴璇曞崟浣撳唴闃诲彉鍖栧浘(1.2.15/16/17) + public Response getMonResChangeByBattgroupId(Integer battgroupId, Integer monNum) { + QueryWrapper wrapper = new QueryWrapper(); + wrapper.eq("battgroup_id", battgroupId); + wrapper.last(" ORDER BY test_starttime asc "); + List<BattresdataInf> list = mapper.selectList(wrapper); + List<ComPareChangeCurve> curvelist=new ArrayList<>(); + for (BattresdataInf rinf:list) { + String existTableName = commonMapper.existTable("db_batt_testdata", "tb_battresdata_"+battgroupId); + if(existTableName != null){ + //鍙栧唴闃绘祴璇曟寚瀹氬崟浣撶殑鍗曚綋鐢靛帇 + ComPareChangeCurve curve=subTablePageInfoService.getMonResChangeByBattgroupId(battgroupId,rinf.getTestRecordCount(),monNum); + if(curve!=null){ + curvelist.add(curve); + } + } + } + return new Response().setII(1,list.size()>0,curvelist,"鐐瑰嚮鍙充晶鎶樼嚎鍥剧敾鍑虹數姹犵粍鍗曚綋鐨勬墍鏈夊唴闃绘祴璇曞崟浣撳唴闃诲彉鍖栧浘(1.2.15/16/17)"); + } } \ No newline at end of file -- Gitblit v1.9.1