From f8479e6f138343b091b3ceeb7b232e75b3247946 Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq.com> Date: 星期四, 27 六月 2024 16:41:31 +0800 Subject: [PATCH] 蓄电池组后评估测试版 --- src/main/java/com/whyc/service/BattTestInfService.java | 255 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 254 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/whyc/service/BattTestInfService.java b/src/main/java/com/whyc/service/BattTestInfService.java index 05a4a89..290849e 100644 --- a/src/main/java/com/whyc/service/BattTestInfService.java +++ b/src/main/java/com/whyc/service/BattTestInfService.java @@ -4,18 +4,36 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.whyc.dto.BattCapFactory; +import com.whyc.dto.ReportBattDTO; import com.whyc.dto.Response; +import com.whyc.mapper.AlarmParamMapper; +import com.whyc.mapper.BattAlarmMapper; +import com.whyc.mapper.BattInfMapper; import com.whyc.mapper.BattTestInfMapper; +import com.whyc.pojo.AlarmParam; +import com.whyc.pojo.BattAlarm; +import com.whyc.pojo.BattInf; import com.whyc.pojo.BattTestInf; +import com.whyc.util.PageInfoUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.List; +import java.util.*; @Service public class BattTestInfService { @Autowired(required = false) private BattTestInfMapper mapper; + + @Autowired(required = false) + private BattInfMapper binfMapper; + + @Autowired(required = false) + private AlarmParamMapper alarmParamMapper; + + @Autowired(required = false) + private BattAlarmMapper alarmMapper; //鏌ヨ鍏呮斁鐢佃褰� public Response getTinfHis(int binfId, int pageNum, int pageSize) { @@ -26,4 +44,239 @@ PageInfo pageInfo=new PageInfo(list); return new Response().setII(1,list!=null,pageInfo,"鏌ヨ鍏呮斁鐢佃褰�"); } + + //1.4鐢垫睜鎬ц兘璇勪及 + public Response searchGroupAssess(int pageNum, int pageSize, ReportBattDTO tinf, int userId){ + //List<BattInf> battinfList = binfMapper.searchGroupAssess(tinf, userId); + List<BattInf> battinfList = binfMapper.searchGroupAssess(); + List<Map> result = new ArrayList<>(); + Integer assess = tinf.getAssess();//鎬ц兘绛涢�� + Integer wj = tinf.getWj();//寰�骞磋繕鏄湰骞� + Integer statictype= tinf.getStatictype();//缁熻鏂瑰紡 + if (assess == null) { + assess = -1; + } + if (wj == null) { + wj = -1; + } + if (battinfList != null && battinfList.size() > 0) { + for (BattInf binf : battinfList) { + Integer battGroupId = binf.getBinfId(); + Map<String, Object> map=new HashMap<>(); + Map<String, Object> batttestdataInfList = searchDischargeTest(battGroupId, binf.getMonCap(), binf.getMonVol(), tinf.getRecordStartTime(), tinf.getRecordEndTime(),wj); + if(statictype==0){ + //瀵规瘡涓數姹犵粍鐘舵�佽繘琛屽垽鏂紙瀹归噺+鍐呴樆锛� + map = getAssess2(binf, batttestdataInfList,assess); + }else{ + //瀵规瘡涓數姹犵粍鐘舵�佽繘琛屽垽鏂紙瀹归噺锛� + map = getAssess3(binf, batttestdataInfList,assess); + } + if (assess == -1) { + result.add(map); + } else { + if (map.get("flag") == assess) { + result.add(map); + } + } + } + } + PageInfo pageInfo = PageInfoUtils.list2PageInfo(result, pageNum, pageSize); + return new Response().set(1, pageInfo, "鏌ヨ鎴愬姛"); + } + + //1.4鐢垫睜缁勬�ц兘璇勪及(鏍规嵁鐢垫睜缁刬d鏌ヨ鎵�鏈夌殑鏀剧數璁板綍姹傚嚭鏀剧數鎬绘鏁帮紝鏈�楂樺巻鍙插閲�,鏈�浣庡巻鍙插閲忥紝骞冲潎瀹归噺锛屾渶鏂版祴璇曞閲�) + public Map<String, Object> searchDischargeTest(Integer battGroupId, float monCapStd, float monVolStd, Date recordStartTime, Date recordEndTime, int wj) { + List<BattTestInf> list = new ArrayList<>(); + Map<String, Object> map = new HashMap<>(); + if(wj==0){//鏈勾 + list=mapper.searchDischargeTest(battGroupId, recordStartTime, recordEndTime); + if( list.size()==0){ + map.put("wj", "N"); + }else{ + map.put("wj", "J"); + } + }else if(wj==1){//寰�骞� + list = mapper.searchDischargeTest_WJ(battGroupId, recordStartTime); + if( list.size()==0){ + map.put("wj", "N"); + }else{ + map.put("wj", "W"); + } + }else if(wj==-1){//鍏ㄩ儴 + list=mapper.searchDischargeTest(battGroupId, recordStartTime, recordEndTime); + if( list.size()==0){ + list = mapper.searchDischargeTest_WJ(battGroupId, recordStartTime); + if( list.size()==0){ + map.put("wj", "N"); + }else{ + map.put("wj", "W"); + } + }else{ + map.put("wj", "J"); + } + } + List<BattTestInf> testList = new LinkedList<>(); + int sum = 0;//鎬绘祴璇曟鏁� + float cap = 0f;//瀹為檯瀹归噺 + float allCap = 0f;//鎬诲閲� + float maxCap = 0f;//鏈�楂樺閲� + float minCap = 10000f;//鏈�浣庡閲� + float avgCap = 0f;//骞冲潎瀹归噺 + float lastCap = 0f;//鏈�杩戞祴璇曞閲� + for (int i = 0; i < list.size(); i++) { + BattTestInf binf = list.get(i); + int hourRate = BattCapFactory.GetHourRate(monCapStd, binf.getTestCurr()); + cap = (float) BattCapFactory.GetMonomerCap(monCapStd, hourRate, binf.getTestCap(), binf.getMaxMonvol(), binf.getMinMonvol(), monVolStd, BattCapFactory.CapType_Real); + binf.setRealCap(cap); + testList.add(binf); + if (sum == 0) { + lastCap = cap; + } + if (maxCap <= cap) { + maxCap = cap;//鏈�澶� + } + if (minCap >= cap) { + minCap = cap;//鏈�灏� + } + allCap += cap; + sum++; + } + if (sum != 0) { + avgCap = allCap / sum;//骞冲潎瀹归噺 + } else { + avgCap = 0; + minCap = 0; + } + map.put("battGroupid", battGroupId); + map.put("sum", sum); + map.put("maxCap", maxCap); + map.put("avgCap", avgCap); + map.put("minCap", minCap); + map.put("lastCap", lastCap); + map.put("testList", testList); + return map; + } + + //绛涢�夎搫鐢垫睜缁勫悗璇勬�ц兘(2024銆�4.15淇敼) + public Map<String, Object> getAssess2(BattInf binf, Map<String, Object> mapList,int assess) { + Map<String, Object> map = new HashMap(); + map.put("battinf", binf); + map.put("battTestDataInf", mapList); + map.put("wj",mapList.get("wj")); + //鐩存帴鍘婚泦鍚堢2涓暟锛堟斁鐢垫鏁帮級锛岀6涓暟锛堝疄闄呴浼板閲忥細鏈�杩戜竴娆℃牳瀹圭殑瀹為檯瀹归噺锛� + int battGroupId = (int) mapList.get("battGroupid"); + int disNum = (int) mapList.get("sum"); + float realCap = (Float) mapList.get("lastCap"); + float monCapStd = binf.getMonCap(); + //0.鏌ヨ鍔e寲(鍛婅)鍜屾崯鍧�(鏇存崲)鐨勯槇鍊� + QueryWrapper<AlarmParam> alarmWrapper = new QueryWrapper(); + alarmWrapper.and(wrapper -> { + return wrapper.eq("alm_name", "Batt_Alarm_Type_CapAlarm").or().eq("alm_name", "Batt_Alarm_Type_CapChange"); + }); + alarmWrapper.orderByAsc("alm_id"); + List<AlarmParam> paramList = alarmParamMapper.selectList(alarmWrapper); + float capAlarm = 0f; + float capChange = 0f; + if (paramList != null && paramList.size() > 0) { + capAlarm = paramList.get(0).getAlmLowCoe();//鍔e寲鍙傛暟0.8 + capChange = paramList.get(1).getAlmLowCoe();//鎹熷潖鍙傛暟0.6 + } else { + capAlarm = 0.8f; + capChange = 0.6f; + } + //鏌ヨ鐢垫睜鍛婅锛堝唴闃诲憡璀︼級 + List listALmRes = getAlm2(battGroupId); + map.put("noDisAlmSH",listALmRes); + //鏈斁鐢碉細鏈勾搴︽湭鏀剧數 + if( (disNum==0) ){ + map.put("flag",0); + } + //浼樼锛氭湰骞村害宸叉斁鐢碉紝涓斿閲忓仴搴凤紝鏃犲唴闃诲憡璀︼紙棰勫憡璀︼紙閲嶈锛夛紝鍛婅锛堢揣鎬ワ級锛� + if( (disNum>0)&&(realCap > capAlarm * monCapStd)&&(listALmRes.size()<=0)){ + map.put("flag",1); + } + + /*鍔e寲锛氭湰骞村害鏈斁鐢碉紝鍐呴樆鍛婅锛堥鍛婅锛堥噸瑕侊級锛屽憡璀︼紙绱ф�ワ級锛� + *瀹归噺灏忎簬鍔e寲闃堝�硷紝澶т簬鎹熷潖闃堝�硷紝鍐呴樆鍛婅(棰勫憡璀︼紝鍛婅) + * 瀹归噺灏忎簬鍔e寲闃堝�硷紝鍐呴樆姝e父 + * 瀹归噺姝e父锛屽唴闃诲憡璀�(棰勫憡璀︼紝鍛婅) + */ + if (((disNum==0)&&(listALmRes.size()>0)) + ||((disNum>0)&&(realCap <= capAlarm * monCapStd && realCap >= capChange * monCapStd)&&(listALmRes.size()>0)) + ||((disNum>0)&&(realCap <= capAlarm * monCapStd)&&(listALmRes.size()<=0)) + ||(disNum>0)&&(realCap > capAlarm * monCapStd)&&(listALmRes.size()>0)){ + if((assess==0)&&(disNum==0)){ + map.put("flag",0); + }else{ + map.put("flag",2); + } + } + //鎹熷潖锛氬閲忎綆锛屽唴闃诲憡璀� + if((disNum!=0)&&(realCap< capChange * monCapStd)&&(listALmRes.size()>0)){ + map.put("flag",3); + } + return map; + } + //鏌ヨ鐢垫睜鍛婅(2024銆�4.15淇敼) + /*鏈斁鐢碉細鏈勾搴︽湭鏀剧數 + *浼樼锛氭湰骞村害宸叉斁鐢碉紝涓斿閲忓仴搴凤紝鏃犲唴闃诲憡璀︼紙棰勫憡璀︼紙閲嶈锛夛紝鍛婅锛堢揣鎬ワ級锛� + *鍔e寲锛氭湰骞村害鏈斁鐢碉紝鍐呴樆鍛婅锛堥鍛婅锛堥噸瑕侊級锛屽憡璀︼紙绱ф�ワ級锛� + * 瀹归噺灏忎簬鍔e寲闃堝�硷紝澶т簬鎹熷潖闃堝�硷紝鍐呴樆鍛婅(棰勫憡璀︼紝鍛婅) + * 瀹归噺灏忎簬鍔e寲闃堝�硷紝鍐呴樆姝e父 + * 瀹归噺姝e父锛屽唴闃诲憡璀�(棰勫憡璀︼紝鍛婅) + * 鎹熷潖锛氬閲忎綆锛屽唴闃诲憡璀� + * */ + private List getAlm2(Integer battGroupId) { + List list = alarmMapper.getAlm2(battGroupId); + return list; + } + //绛涢�夎搫鐢垫睜缁勫悗璇勬�ц兘(2024銆�4.15淇敼) + public Map<String, Object> getAssess3(BattInf binf, Map<String, Object> mapList,int assess) { + Map<String, Object> map = new HashMap(); + map.put("battinf", binf); + map.put("battTestDataInf", mapList); + map.put("wj", mapList.get("wj")); + //鐩存帴鍘婚泦鍚堢2涓暟锛堟斁鐢垫鏁帮級锛岀6涓暟锛堝疄闄呴浼板閲忥細鏈�杩戜竴娆℃牳瀹圭殑瀹為檯瀹归噺锛� + int battGroupId = (int) mapList.get("battGroupid"); + int disNum = (int) mapList.get("sum"); + float realCap = (Float) mapList.get("lastCap"); + float monCapStd = binf.getMonCap(); + //0.鏌ヨ鍔e寲(鍛婅)鍜屾崯鍧�(鏇存崲)鐨勯槇鍊� + QueryWrapper<AlarmParam> alarmWrapper = new QueryWrapper(); + alarmWrapper.and(wrapper -> { + return wrapper.eq("alm_name", "Batt_Alarm_Type_CapAlarm").or().eq("alm_name", "Batt_Alarm_Type_CapChange"); + }); + alarmWrapper.orderByAsc("alm_id"); + List<AlarmParam> paramList = alarmParamMapper.selectList(alarmWrapper); + float capAlarm = 0f; + float capChange = 0f; + if (paramList != null && paramList.size() > 0) { + capAlarm = paramList.get(0).getAlmLowCoe();//鍔e寲鍙傛暟0.8 + capChange = paramList.get(1).getAlmLowCoe();//鎹熷潖鍙傛暟0.6 + } else { + capAlarm = 0.8f; + capChange = 0.6f; + } + //鏈斁鐢碉細鏈勾搴︽湭鏀剧數 + if ((disNum == 0)) { + map.put("flag", 0); + } + //浼樼锛氭湰骞村害宸叉斁鐢碉紝涓斿閲忓仴搴凤級 + if ((disNum > 0) && (realCap > capAlarm * monCapStd)) { + map.put("flag", 1); + } + /*鍔e寲锛� + *瀹归噺灏忎簬鍔e寲闃堝�硷紝澶т簬鎹熷潖闃堝�� + */ + if (((disNum > 0) && (realCap <= capAlarm * monCapStd && realCap >= capChange * monCapStd))) { + map.put("flag", 2); + } + //鎹熷潖锛氬閲忎綆 + if ((disNum > 0) && (realCap < capChange * monCapStd)) { + map.put("flag", 3); + } + return map; + } + + } \ No newline at end of file -- Gitblit v1.9.1