| | |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.constant.Capperformance; |
| | | import com.whyc.constant.StopReasonEnum; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.Statistic.*; |
| | | import com.whyc.factory.BattCapFactory; |
| | |
| | | BatttestdataInf tinf = mapper.selectOne(wrapper); |
| | | return tinf; |
| | | } |
| | | |
| | | //获取电池组在给定时间段的放电记录(指定时间段的标准核容放电) |
| | | private BatttestdataInf getLastStandardTestDataByTime(Integer battgroupId, Date testStartTime, Date testEndTime) { |
| | | QueryWrapper wrapper = new QueryWrapper(); |
| | | wrapper.eq("battgroup_id", battgroupId); |
| | | wrapper.eq("test_type", 3); |
| | | wrapper.eq("test_starttype", 3); |
| | | if(testStartTime!=null){ |
| | | wrapper.gt("test_starttime",testStartTime); |
| | | } |
| | | if(testEndTime!=null){ |
| | | wrapper.lt("test_starttime",testEndTime); |
| | | } |
| | | wrapper.last(" and test_timelong >= 7200 ORDER BY test_starttime DESC "); |
| | | wrapper.last("limit 1"); |
| | | BatttestdataInf tinf = mapper.selectOne(wrapper); |
| | | return tinf; |
| | | } |
| | | /*单节数量统计 |
| | | 1筛选满足条件的电池组,找最近一次标准核容放电记录的最后一笔数据 |
| | | 2再按照公式计算单体实际容量, |
| | | 3然后找到判断优秀,劣化,损坏的参数,得到结果。 |
| | | 4浮充电压图,需要显示单体+实时数据的单体电压,单体内阻 |
| | | */ |
| | | public Response getMonStatistic(MonStic stic) { |
| | | public Map getMonStatistic(MonStic stic) { |
| | | Map<String,Object> map=new HashMap<>(); |
| | | List<SticMonRes> goodlist=new ArrayList(); |
| | | List<SticMonRes> badlist=new ArrayList(); |
| | |
| | | List<BattInf> binfList=battInfService.getMonStatistic(stic); |
| | | Float realCap=0f; |
| | | if(binfList==null){ |
| | | return new Response().set(1,false,"当前用户未管理满足条件的电池组"); |
| | | return map; |
| | | } |
| | | for (BattInf binf:binfList) { |
| | | BatttestdataInf tinf =getLastStandardTestData(binf.getBattgroupId()); |
| | |
| | | SticMonRes res=new SticMonRes(); |
| | | res.setBattgroupId(binf.getBattgroupId()); |
| | | res.setBattgroupName(binf.getBattgroupName()); |
| | | res.setStationName(binf.getStationName()); |
| | | res.setDevName(binf.getDevName()); |
| | | res.setMonNum(data.getMonNum()); |
| | | //获取单体的实时数据 |
| | | BattRtdata rtdata=rtdataService.getRtdataByNum(binf.getBattgroupId(),data.getMonNum()); |
| | |
| | | map.put("goodlistNum",goodlist.size()); |
| | | map.put("badlistNum",badlist.size()); |
| | | map.put("damagelistNum",damagelist.size()); |
| | | return new Response().setII(1,true,map,"单节数量统计"); |
| | | return map; |
| | | |
| | | } |
| | | //将不满足条件的电池组的所有单体放入damage中 |
| | | private void setDamage(List damagelist, BattInf binf) { |
| | |
| | | SticMonRes res=new SticMonRes(); |
| | | res.setBattgroupId(binf.getBattgroupId()); |
| | | res.setBattgroupName(binf.getBattgroupName()); |
| | | res.setStationName(binf.getStationName()); |
| | | res.setDevName(binf.getDevName()); |
| | | res.setMonNum(i+1); |
| | | res.setMonVol(0f); |
| | | res.setMonRes(0f); |
| | |
| | | SticMonRes res=new SticMonRes(); |
| | | res.setBattgroupId(binf.getBattgroupId()); |
| | | res.setBattgroupName(binf.getBattgroupName()); |
| | | res.setStationName(binf.getStationName()); |
| | | res.setDevName(binf.getDevName()); |
| | | res.setMonNum(rtdata.getMonNum()); |
| | | res.setMonVol(rtdata.getMonVol()); |
| | | res.setMonRes(rtdata.getMonRes()); |
| | |
| | | res.setCountry(binf.getCountry()); |
| | | res.setStationName(binf.getStationName()); |
| | | res.setBattgroupName(binf.getBattgroupName()); |
| | | res.setDevName(binf.getDevName()); |
| | | res.setProduct(binf.getProduct()); |
| | | res.setInuseTime(binf.getInuseTime()); |
| | | res.setMonvolstd(binf.getMonvolstd()); |
| | | res.setStationId(binf.getStationId()); |
| | | res.setPowerId(binf.getPowerId()); |
| | | res.setDevId(binf.getDevId()); |
| | | res.setBattgroupId(binf.getBattgroupId()); |
| | | //2.获取电池组在给定时间段的放电记录(指定时间段的标准核容放电) |
| | | BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime()); |
| | | if(tinf==null){ |
| | |
| | | } |
| | | } |
| | | res.setMonNums(monNums); |
| | | if(stic.getPerformance()==0){ |
| | | if(stic.getPerformance()==null){ |
| | | reslist.add(res); |
| | | }else{ |
| | | if(res.getCapperformance().equals(Capperformance.getValue(stic.getPerformance()))){ |
| | |
| | | PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize()); |
| | | return new Response().setII(1,reslist.size()>0,pageInfo,"蓄电池组对比分析界面(同一品牌同一时间)"); |
| | | } |
| | | //获取电池组在给定时间段的放电记录(指定时间段的标准核容放电) |
| | | private BatttestdataInf getLastStandardTestDataByTime(Integer battgroupId, Date testStartTime, Date testEndTime) { |
| | | QueryWrapper wrapper = new QueryWrapper(); |
| | | wrapper.eq("battgroup_id", battgroupId); |
| | | wrapper.eq("test_type", 3); |
| | | wrapper.eq("test_starttype", 3); |
| | | wrapper.gt("test_starttime",testStartTime); |
| | | wrapper.lt("test_starttime",testEndTime); |
| | | wrapper.last(" and test_timelong >= 7200 ORDER BY test_starttime DESC "); |
| | | wrapper.last("limit 1"); |
| | | BatttestdataInf tinf = mapper.selectOne(wrapper); |
| | | return tinf; |
| | | |
| | | //蓄电池组对比分析界面(不同品牌同一时间)(1.2.16) |
| | | public Response getBattCompare16Statistic(BattCompareStic stic) { |
| | | //获取核容优劣,损坏参数 |
| | | 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(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | //1查询符合条件的电池组 |
| | | List<BattInf> binfList=battInfService.getBattCompare16Statistic(stic); |
| | | if(binfList==null||binfList.size()==0){ |
| | | return new Response().set(1,false,"当前用户未管理满足条件的电池组"); |
| | | } |
| | | List<SticCompare16Res> reslist=new ArrayList<>(); |
| | | for (BattInf binf:binfList) { |
| | | SticCompare16Res res=new SticCompare16Res(); |
| | | res.setProvice(binf.getProvice()); |
| | | res.setCity(binf.getCity()); |
| | | res.setCountry(binf.getCountry()); |
| | | res.setStationName(binf.getStationName()); |
| | | res.setBattgroupName(binf.getBattgroupName()); |
| | | res.setDevName(binf.getDevName()); |
| | | res.setProduct(binf.getProduct()); |
| | | res.setInuseTime(binf.getInuseTime()); |
| | | res.setMonvolstd(binf.getMonvolstd()); |
| | | res.setMoncapstd(binf.getMoncapstd()); |
| | | res.setStationId(binf.getStationId()); |
| | | res.setPowerId(binf.getPowerId()); |
| | | res.setDevId(binf.getDevId()); |
| | | res.setBattgroupId(binf.getBattgroupId()); |
| | | //2.获取电池组在给定时间段的放电记录(指定时间段的标准核容放电) |
| | | BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime()); |
| | | if(tinf==null){ |
| | | res.setRealCap(0f); |
| | | res.setPrecentCap("0"); |
| | | res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_3.getStateId())); |
| | | res.setStopReason("--"); |
| | | continue; |
| | | } |
| | | res.setStopReason(StopReasonEnum.getValue(tinf.getTestStoptype())); |
| | | Float moncapStd=binf.getMoncapstd(); |
| | | int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr()); |
| | | Float grouprealCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real); |
| | | //Float restCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Rest); |
| | | res.setRealCap(grouprealCap); |
| | | if(grouprealCap>=moncapStd*badValue){ |
| | | res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_1.getStateId())); |
| | | } |
| | | if(grouprealCap<=moncapStd*damageValue){ |
| | | res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_3.getStateId())); |
| | | } |
| | | if((grouprealCap>moncapStd*damageValue)&&(grouprealCap<moncapStd*badValue)){ |
| | | res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_2.getStateId())); |
| | | } |
| | | //保留5位小数 |
| | | String precentCap = String.format("%.5f",(grouprealCap/binf.getMoncapstd()*100)); |
| | | //评分的逻辑 |
| | | res.setScore(0f); |
| | | res.setPrecentCap(precentCap); |
| | | if(stic.getPerformance()==null){ |
| | | reslist.add(res); |
| | | }else{ |
| | | if(res.getCapperformance().equals(Capperformance.getValue(stic.getPerformance()))){ |
| | | reslist.add(res); |
| | | } |
| | | } |
| | | |
| | | } |
| | | PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize()); |
| | | return new Response().setII(1,reslist.size()>0,pageInfo,"蓄电池组对比分析界面(不同品牌同一时间)"); |
| | | } |
| | | //蓄电池组对比分析界面(同一品牌不同时间)(1.2.17) |
| | | public Response getBattCompare17Statistic(BattCompareStic stic) { |
| | | //获取核容优劣,损坏参数 |
| | | 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(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | //1查询符合条件的电池组 |
| | | List<BattInf> binfList=battInfService.getBattCompare15Statistic(stic); |
| | | if(binfList==null||binfList.size()==0){ |
| | | return new Response().set(1,false,"当前用户未管理满足条件的电池组"); |
| | | } |
| | | List<SticCompare17Res> reslist=new ArrayList<>(); |
| | | for (BattInf binf:binfList) { |
| | | //2.获取电池组在给定时间段的放电记录(指定时间段的标准核容放电) |
| | | BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime()); |
| | | if(tinf==null){ |
| | | //不存在放电记录则默认为实际预估容量全为0 |
| | | setSticCompare17Res(binf,reslist,stic.getPerformance()); |
| | | continue; |
| | | } |
| | | //找这次放电的最后一笔数据 |
| | | List<BatttestdataId> idDataList=battTestdataIdService.getLastDataByBattgroupId(tinf.getBattgroupId(),tinf.getTestRecordCount(),tinf.getRecordNum()); |
| | | if(idDataList==null||idDataList.size()==0){ |
| | | //不存在放电记录则默认为实际预估容量全为0 |
| | | setSticCompare17Res(binf,reslist,stic.getPerformance()); |
| | | continue; |
| | | } |
| | | Float moncapStd=binf.getMoncapstd(); |
| | | int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr()); |
| | | for (BatttestdataId data:idDataList) {//求单体的 实际容量,最小值就是单体的单体电压 |
| | | SticCompare17Res res=new SticCompare17Res(); |
| | | res.setProvice(binf.getProvice()); |
| | | res.setCity(binf.getCity()); |
| | | res.setCountry(binf.getCountry()); |
| | | res.setStationName(binf.getStationName()); |
| | | res.setDevName(binf.getDevName()); |
| | | res.setBattgroupName(binf.getBattgroupName()); |
| | | res.setProduct(binf.getProduct()); |
| | | res.setInuseTime(binf.getInuseTime()); |
| | | res.setMonvolstd(binf.getMonvolstd()); |
| | | res.setMonNum(data.getMonNum()); |
| | | res.setStationId(binf.getStationId()); |
| | | res.setPowerId(binf.getPowerId()); |
| | | res.setDevId(binf.getDevId()); |
| | | res.setBattgroupId(binf.getBattgroupId()); |
| | | Float monrealCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), data.getMonVol(), tinf.getGroupVol(), BattCapFactory.CapType_Real); |
| | | res.setMonrealCap(monrealCap); |
| | | //保留5位小数 |
| | | String monprecentCap = String.format("%.5f",(monrealCap/binf.getMoncapstd()*100)); |
| | | res.setMonprecentCap(monprecentCap); |
| | | if(monrealCap>=moncapStd*badValue){ |
| | | res.setMoncapperformance(Capperformance.getValue(Capperformance.BATTSTATE_1.getStateId())); |
| | | } |
| | | if (monrealCap <= moncapStd * damageValue) {//损坏的 |
| | | res.setMoncapperformance(Capperformance.getValue(Capperformance.BATTSTATE_3.getStateId())); |
| | | } |
| | | if((monrealCap>moncapStd*damageValue)&&(monrealCap<moncapStd*badValue)){ |
| | | res.setMoncapperformance(Capperformance.getValue(Capperformance.BATTSTATE_2.getStateId())); |
| | | } |
| | | if(stic.getPerformance()==null){ |
| | | reslist.add(res); |
| | | }else{ |
| | | if(res.getMoncapperformance().equals(Capperformance.getValue(stic.getPerformance()))){ |
| | | reslist.add(res); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize()); |
| | | return new Response().setII(1,reslist.size()>0,pageInfo,"蓄电池组对比分析界面(同一品牌同一时间)"); |
| | | } |
| | | //不存在放电记录则默认为实际预估容量全为0 |
| | | private void setSticCompare17Res( BattInf binf, List<SticCompare17Res> reslist,Integer performance) { |
| | | for (int i=0;i<binf.getMoncount();i++){ |
| | | SticCompare17Res res=new SticCompare17Res(); |
| | | res.setProvice(binf.getProvice()); |
| | | res.setCity(binf.getCity()); |
| | | res.setCountry(binf.getCountry()); |
| | | res.setStationName(binf.getStationName()); |
| | | res.setDevName(binf.getDevName()); |
| | | res.setBattgroupName(binf.getBattgroupName()); |
| | | res.setProduct(binf.getProduct()); |
| | | res.setInuseTime(binf.getInuseTime()); |
| | | res.setMonvolstd(binf.getMonvolstd()); |
| | | res.setStationId(binf.getStationId()); |
| | | res.setPowerId(binf.getPowerId()); |
| | | res.setDevId(binf.getDevId()); |
| | | res.setBattgroupId(binf.getBattgroupId()); |
| | | res.setMonNum(i+1); |
| | | res.setMonrealCap(0f); |
| | | res.setMonprecentCap("0"); |
| | | res.setMoncapperformance(Capperformance.getValue(Capperformance.BATTSTATE_3.getStateId())); |
| | | if(performance==null){ |
| | | reslist.add(res); |
| | | }else{ |
| | | if(res.getMoncapperformance().equals(Capperformance.getValue(performance))){ |
| | | reslist.add(res); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |