From 4288e68cced096a216bebfcd797e78791e192c67 Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq.com> Date: 星期三, 04 六月 2025 10:49:34 +0800 Subject: [PATCH] 添加电池组使用时间,常量参数处理,单体统计修改,下拉条件增加 --- src/main/java/com/whyc/service/BatttestdataInfService.java | 125 +++++++++++++++++++++++++++++++++++++---- 1 files changed, 112 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/whyc/service/BatttestdataInfService.java b/src/main/java/com/whyc/service/BatttestdataInfService.java index 88735ab..aec61ec 100644 --- a/src/main/java/com/whyc/service/BatttestdataInfService.java +++ b/src/main/java/com/whyc/service/BatttestdataInfService.java @@ -7,17 +7,23 @@ import com.whyc.dto.Statistic.BattTinfStic; import com.whyc.dto.Statistic.MonStic; import com.whyc.dto.Statistic.StationStic; +import com.whyc.dto.Statistic.SticMonRes; import com.whyc.factory.BattCapFactory; import com.whyc.mapper.BattInfMapper; import com.whyc.mapper.BatttestdataInfMapper; import com.whyc.pojo.db_batt_testdata.BatttestdataId; import com.whyc.pojo.db_batt_testdata.BatttestdataInf; +import com.whyc.pojo.db_param.AppParam; +import com.whyc.pojo.db_ram_db.BattRtdata; import com.whyc.pojo.db_ram_db.BattRtstate; import com.whyc.pojo.db_station.BattInf; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Service public class BatttestdataInfService { @@ -28,10 +34,17 @@ private BattRtstateService rtstateService; @Autowired(required = false) + private BattRtdataService rtdataService; + + @Autowired(required = false) private BattInfService battInfService; @Autowired(required = false) private BatttestdataIdService battTestdataIdService; + + @Autowired(required = false) + private AppParamService appParamService; + @@ -86,11 +99,10 @@ public BatttestdataInf getLastStandardTestData(Integer battgroupId) { QueryWrapper wrapper = new QueryWrapper(); wrapper.eq("battgroup_id", battgroupId); - wrapper.eq("data_available", 1); wrapper.eq("test_type", 3); wrapper.eq("test_starttype", 3); - wrapper.last("limit 1"); wrapper.last(" and test_timelong >= 7200 ORDER BY test_starttime DESC "); + wrapper.last("limit 1"); BatttestdataInf tinf = mapper.selectOne(wrapper); return tinf; } @@ -101,20 +113,107 @@ 4娴厖鐢靛帇鍥撅紝闇�瑕佹樉绀哄崟浣�+瀹炴椂鏁版嵁鐨勫崟浣撶數鍘嬶紝鍗曚綋鍐呴樆 */ public Response getMonStatistic(MonStic stic) { + Map<String,Object> map=new HashMap<>(); + List<SticMonRes> goodlist=new ArrayList(); + List<SticMonRes> badlist=new ArrayList(); + List<SticMonRes> damagelist=new ArrayList(); + map.put("goodlist",goodlist); + map.put("badlist",badlist); + map.put("damagelist",damagelist); + map.put("goodlistNum",0); + map.put("badlistNum",0); + map.put("damagelistNum",0); + //鑾峰彇鏍稿浼樺姡锛屾崯鍧忓弬鏁� + List<AppParam> paramList=appParamService.getHrParam(); + Float badValue=0f; + Float damageValue=0f; + if(paramList!=null){ + for (AppParam param:paramList) { + if(param.getParamNamePsx().equals("batt_mon_deteriorate_val")){ + badValue=param.getParamValue(); + } + if(param.getParamNamePsx().equals("batt_mon_damage_val")){ + damageValue=param.getParamValue(); + } + + } + } List<BattInf> binfList=battInfService.getMonStatistic(stic); - if(binfList!=null&&binfList.size()>0){ - for (BattInf binf:binfList) { - BatttestdataInf tinf =getLastStandardTestData(binf.getBattgroupId()); - if(tinf!=null){ - //鎵捐繖娆℃斁鐢电殑鏈�鍚庝竴绗旀暟鎹� - List<BatttestdataId> idDataList=battTestdataIdService.getLastDataByBattgroupId(tinf.getBattgroupId(),tinf.getTestRecordCount(),tinf.getRecordNum()); - for (BatttestdataId data:idDataList) { - int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr()); - Float realCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real); - } + Float realCap=0f; + if(binfList==null){ + return new Response().set(1,false,"褰撳墠鐢ㄦ埛鏈鐞嗘弧瓒虫潯浠剁殑鐢垫睜缁�"); + } + for (BattInf binf:binfList) { + BatttestdataInf tinf =getLastStandardTestData(binf.getBattgroupId()); + if(tinf==null){ + //灏嗕笉婊¤冻鏉′欢鐨勭數姹犵粍鐨勬墍鏈夊崟浣撴斁鍏amage涓� + setDamage(damagelist,binf); + continue; + } + //鎵捐繖娆℃斁鐢电殑鏈�鍚庝竴绗旀暟鎹� + List<BatttestdataId> idDataList=battTestdataIdService.getLastDataByBattgroupId(tinf.getBattgroupId(),tinf.getTestRecordCount(),tinf.getRecordNum()); + if(idDataList==null||idDataList.size()==0){ + //灏嗕笉婊¤冻鏉′欢鐨勭數姹犵粍鐨勬墍鏈夊崟浣撴斁鍏amage涓� + setDamage(damagelist,binf); + continue; + } + int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr()); + Float moncapStd=binf.getMoncapstd(); + for (BatttestdataId data:idDataList) {//姹傚崟浣撶殑 瀹為檯瀹归噺锛屾渶灏忓�煎氨鏄崟浣撶殑鍗曚綋鐢靛帇 + realCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(),data.getMonVol() , tinf.getGroupVol(), BattCapFactory.CapType_Real); + SticMonRes res=new SticMonRes(); + res.setBattgroupId(binf.getBattgroupId()); + res.setMonNum(data.getMonNum()); + //鑾峰彇鍗曚綋鐨勫疄鏃舵暟鎹� + BattRtdata rtdata=rtdataService.getRtdataByNum(binf.getBattgroupId(),data.getMonNum()); + if(rtdata==null){ + res.setMonVol(0f); + res.setMonRes(0f); + }else{ + res.setMonVol(rtdata.getMonVol()); + res.setMonRes(rtdata.getMonRes()); + } + if(realCap>=moncapStd*badValue){ + goodlist.add(res); + } + if(realCap<=moncapStd*damageValue){ + damagelist.add(res); + } + if((realCap>moncapStd*damageValue)&&(realCap<moncapStd*badValue)){ + badlist.add(res); } } } - return new Response().set(1,false,""); + map.put("goodlist",goodlist); + map.put("badlist",badlist); + map.put("damagelist",damagelist); + map.put("goodlistNum",goodlist.size()); + map.put("badlistNum",badlist.size()); + map.put("damagelistNum",damagelist.size()); + return new Response().setII(1,true,map,"鍗曡妭鏁伴噺缁熻"); + } + //灏嗕笉婊¤冻鏉′欢鐨勭數姹犵粍鐨勬墍鏈夊崟浣撴斁鍏amage涓� + private void setDamage(List damagelist, BattInf binf) { + //鑾峰彇鐢垫睜缁勭殑瀹炴椂鏁版嵁 + List<BattRtdata> rtdataList=rtdataService.getRtdataRealInfo(binf.getBattgroupId()); + if(rtdataList==null||rtdataList.size()==0){ + for (int i=0;i<binf.getMoncount();i++){ + SticMonRes res=new SticMonRes(); + res.setBattgroupId(binf.getBattgroupId()); + res.setMonNum(i+1); + res.setMonVol(0f); + res.setMonRes(0f); + damagelist.add(res); + } + }else { + for (BattRtdata rtdata:rtdataList) { + SticMonRes res=new SticMonRes(); + res.setBattgroupId(binf.getBattgroupId()); + res.setMonNum(rtdata.getMonNum()); + res.setMonVol(rtdata.getMonVol()); + res.setMonRes(rtdata.getMonRes()); + damagelist.add(res); + } + } } } \ No newline at end of file -- Gitblit v1.9.1