| | |
| | | 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) { |
| | |
| | | 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电池组性能评估(根据电池组id查询所有的放电记录求出放电总次数,最高历史容量,最低历史容量,平均容量,最新测试容量) |
| | | 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.查询劣化(告警)和损坏(更换)的阈值 |
| | | 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();//劣化参数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); |
| | | } |
| | | |
| | | /*劣化:本年度未放电,内阻告警(预告警(重要),告警(紧急)) |
| | | *容量小于劣化阈值,大于损坏阈值,内阻告警(预告警,告警) |
| | | * 容量小于劣化阈值,内阻正常 |
| | | * 容量正常,内阻告警(预告警,告警) |
| | | */ |
| | | 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修改) |
| | | /*未放电:本年度未放电 |
| | | *优秀:本年度已放电,且容量健康,无内阻告警(预告警(重要),告警(紧急)) |
| | | *劣化:本年度未放电,内阻告警(预告警(重要),告警(紧急)) |
| | | * 容量小于劣化阈值,大于损坏阈值,内阻告警(预告警,告警) |
| | | * 容量小于劣化阈值,内阻正常 |
| | | * 容量正常,内阻告警(预告警,告警) |
| | | * 损坏:容量低,内阻告警 |
| | | * */ |
| | | 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.查询劣化(告警)和损坏(更换)的阈值 |
| | | 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();//劣化参数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); |
| | | } |
| | | /*劣化: |
| | | *容量小于劣化阈值,大于损坏阈值 |
| | | */ |
| | | 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; |
| | | } |
| | | |
| | | |
| | | } |