From a4e25fc0cd113518980305af3c061892b1b24b14 Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq.com> Date: 星期一, 23 六月 2025 17:07:05 +0800 Subject: [PATCH] 预警分析管理 --- src/main/java/com/whyc/service/BatttestdataInfService.java | 349 +++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 238 insertions(+), 111 deletions(-) diff --git a/src/main/java/com/whyc/service/BatttestdataInfService.java b/src/main/java/com/whyc/service/BatttestdataInfService.java index c6dbf82..b462679 100644 --- a/src/main/java/com/whyc/service/BatttestdataInfService.java +++ b/src/main/java/com/whyc/service/BatttestdataInfService.java @@ -3,8 +3,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; -import com.whyc.constant.Capperformance; -import com.whyc.constant.PowerAlarmEnum; +import com.whyc.constant.BattCapperformanceEnum; +import com.whyc.constant.PwrCapperformanceEnum; import com.whyc.constant.StopReasonEnum; import com.whyc.dto.Real.TestDataDto; import com.whyc.dto.Response; @@ -17,13 +17,15 @@ import com.whyc.pojo.db_ram_db.BattRtdata; import com.whyc.pojo.db_ram_db.BattRtstate; import com.whyc.pojo.db_station.BattInf; +import com.whyc.pojo.db_station.PowerInf; import com.whyc.pojo.db_user.Baojigroup; import com.whyc.util.ActionUtil; +import com.whyc.util.DateUtil; import com.whyc.util.PageInfoUtils; -import com.whyc.util.ThreadLocalUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; import java.util.*; @Service @@ -49,6 +51,11 @@ @Autowired(required = false) private BaojigroupService bjService; + @Autowired(required = false) + private PowerInfService powerInfService; + + @Autowired(required = false) + private PwrdevHistorydataIdService pwrHisdataIdService; @@ -106,7 +113,8 @@ wrapper.eq("battgroup_id", battgroupId); wrapper.eq("test_type", 3); wrapper.eq("test_starttype", 3); - wrapper.last(" and test_timelong >= 7200 ORDER BY test_starttime DESC "); + wrapper.eq("data_available", 1);//涓�娆℃湁鏁堢殑璁板綍 + wrapper.last(" ORDER BY test_starttime DESC "); wrapper.last("limit 1"); BatttestdataInf tinf = mapper.selectOne(wrapper); tinf.setTestStoptypeReason(StopReasonEnum.getValue(tinf.getTestStoptype())); @@ -114,7 +122,7 @@ } //鑾峰彇鐢垫睜缁勫湪缁欏畾鏃堕棿娈电殑鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數) - private BatttestdataInf getLastStandardTestDataByTime(Integer battgroupId, Date testStartTime, Date testEndTime) { + protected BatttestdataInf getLastStandardTestDataByTime(Integer battgroupId, Date testStartTime, Date testEndTime) { QueryWrapper wrapper = new QueryWrapper(); wrapper.eq("battgroup_id", battgroupId); wrapper.eq("test_type", 3); @@ -125,8 +133,9 @@ if(testEndTime!=null){ wrapper.lt("test_starttime",testEndTime); } - wrapper.last(" and test_timelong >= 7200 ORDER BY test_starttime DESC "); - wrapper.last("limit 1"); + wrapper.eq("data_available", 1);//涓�娆℃湁鏁堢殑璁板綍 + wrapper.last(" ORDER BY test_starttime DESC "); + wrapper.last(" limit 1 "); BatttestdataInf tinf = mapper.selectOne(wrapper); return tinf; } @@ -269,7 +278,6 @@ if(param.getParamNamePsx().equals("batt_mon_damage_val")){ damageValue=param.getParamValue(); } - } } //1鏌ヨ绗﹀悎鏉′欢鐨勭數姹犵粍 @@ -298,7 +306,7 @@ if(tinf==null){ res.setRealCap(0f); res.setPrecentCap("0"); - res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_4.getStateId())); + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_4.getStateId())); continue; } //鎵捐繖娆℃斁鐢电殑鏈�鍚庝竴绗旀暟鎹� @@ -306,7 +314,7 @@ if(idDataList==null||idDataList.size()==0){ res.setRealCap(0f); res.setPrecentCap("0"); - res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_4.getStateId())); + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_4.getStateId())); continue; } Float moncapStd=binf.getMoncapstd(); @@ -315,13 +323,13 @@ //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())); + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_1.getStateId())); } if(grouprealCap<=moncapStd*damageValue){ - res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_3.getStateId())); + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_3.getStateId())); } if((grouprealCap>moncapStd*damageValue)&&(grouprealCap<moncapStd*badValue)){ - res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_2.getStateId())); + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_2.getStateId())); } //淇濈暀5浣嶅皬鏁� String precentCap = String.format("%.5f",(grouprealCap/binf.getMoncapstd()*100)); @@ -337,7 +345,7 @@ if(stic.getPerformance()==null){ reslist.add(res); }else{ - if(res.getCapperformance().equals(Capperformance.getValue(stic.getPerformance()))){ + if(res.getCapperformance().equals(BattCapperformanceEnum.getValue(stic.getPerformance()))){ reslist.add(res); } } @@ -391,7 +399,7 @@ if(tinf==null){ res.setRealCap(0f); res.setPrecentCap("0"); - res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_3.getStateId())); + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_3.getStateId())); res.setStopReason("--"); continue; } @@ -402,13 +410,13 @@ //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())); + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_1.getStateId())); } if(grouprealCap<=moncapStd*damageValue){ - res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_3.getStateId())); + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_3.getStateId())); } if((grouprealCap>moncapStd*damageValue)&&(grouprealCap<moncapStd*badValue)){ - res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_2.getStateId())); + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_2.getStateId())); } //淇濈暀5浣嶅皬鏁� String precentCap = String.format("%.5f",(grouprealCap/binf.getMoncapstd()*100)); @@ -418,7 +426,7 @@ if(stic.getPerformance()==null){ reslist.add(res); }else{ - if(res.getCapperformance().equals(Capperformance.getValue(stic.getPerformance()))){ + if(res.getCapperformance().equals(BattCapperformanceEnum.getValue(stic.getPerformance()))){ reslist.add(res); } } @@ -489,18 +497,18 @@ String monprecentCap = String.format("%.5f",(monrealCap/binf.getMoncapstd()*100)); res.setMonprecentCap(monprecentCap); if(monrealCap>=moncapStd*badValue){ - res.setMoncapperformance(Capperformance.getValue(Capperformance.BATTSTATE_1.getStateId())); + res.setMoncapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_1.getStateId())); } if (monrealCap <= moncapStd * damageValue) {//鎹熷潖鐨� - res.setMoncapperformance(Capperformance.getValue(Capperformance.BATTSTATE_3.getStateId())); + res.setMoncapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_3.getStateId())); } if((monrealCap>moncapStd*damageValue)&&(monrealCap<moncapStd*badValue)){ - res.setMoncapperformance(Capperformance.getValue(Capperformance.BATTSTATE_2.getStateId())); + res.setMoncapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_2.getStateId())); } if(stic.getPerformance()==null){ reslist.add(res); }else{ - if(res.getMoncapperformance().equals(Capperformance.getValue(stic.getPerformance()))){ + if(res.getMoncapperformance().equals(BattCapperformanceEnum.getValue(stic.getPerformance()))){ reslist.add(res); } } @@ -529,11 +537,11 @@ res.setMonNum(i+1); res.setMonrealCap(0f); res.setMonprecentCap("0"); - res.setMoncapperformance(Capperformance.getValue(Capperformance.BATTSTATE_4.getStateId())); + res.setMoncapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_4.getStateId())); if(performance==null){ reslist.add(res); }else{ - if(res.getMoncapperformance().equals(Capperformance.getValue(performance))){ + if(res.getMoncapperformance().equals(BattCapperformanceEnum.getValue(performance))){ reslist.add(res); } } @@ -547,11 +555,11 @@ List<TestDataDto> List3=new ArrayList<>(); List<TestDataDto> List4=new ArrayList<>(); List<TestDataDto> List5=new ArrayList<>(); - map.put("1",List1); //鏍稿鏀剧數 - map.put("2",List2); //鏍稿鍏呯數 - map.put("3",List3); //鐩戞祴鏀剧數 - map.put("4",List4); //鐩戞祴鍏呯數 - map.put("5",List5); //鍋滅數鏀剧數 + map.put("鏍稿鏀剧數",List1); //鏍稿鏀剧數 + map.put("鏍稿鍏呯數",List2); //鏍稿鍏呯數 + map.put("鐩戞祴鏀剧數",List3); //鐩戞祴鏀剧數 + map.put("鐩戞祴鍏呯數",List4); //鐩戞祴鍏呯數 + map.put("鍋滅數鏀剧數",List5); //鍋滅數鏀剧數 QueryWrapper wrapper=new QueryWrapper(); wrapper.eq("battgroup_id",battgroupId); wrapper.orderByDesc("test_starttime"); @@ -574,17 +582,16 @@ dto.setMoncapstd(binf.getMoncapstd()); dto.setMonCount(binf.getMoncount()); dto.setMonvolstd(binf.getMonvolstd()); + dto.setFloatchartVol(tinf.getFloatGroupVol()); if(battRtstate!=null){ Float restTime= BattCapFactory.getTheoryTime(battRtstate.getLoadCurr(), realCap, binf.getMoncapstd()); dto.setRestTime(restTime); - dto.setFloatchartVol(battRtstate.getGroupVol()); }else{ dto.setRestTime(0f); - dto.setFloatchartVol(0f); } //鎵捐繖娆℃斁鐢电殑鎸囧畾涓�绗旀暟鎹� List<BatttestdataId> idDataList=battTestdataIdService.getLastDataByBattgroupId(tinf.getBattgroupId(),tinf.getTestRecordCount(),1); - if(idDataList!=null&&idDataList.size()>=0){ + if(idDataList!=null&&idDataList.size()>0){ BatttestdataId idData=idDataList.get(0); dto.setOnlineVol(idData.getOnlineVol()); dto.setGroupCurr(idData.getTestCurr()); @@ -654,16 +661,13 @@ res.setCountry(binf.getCountry()); res.setStationName(binf.getStationName()); res.setBattgroupName(binf.getBattgroupName()); + res.setStationId(binf.getStationId()); + res.setPowerId(binf.getPowerId()); + res.setBattgroupId(binf.getBattgroupId()); + res.setDevId(binf.getDevId()); //2.鑾峰彇鐢垫睜缁勫湪缁欏畾鏃堕棿娈电殑鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數) BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime()); if(tinf==null){ - /* res.setRealCap(0f); - res.setTestStartTime(ThreadLocalUtil.parse("1972-01-01 00:00:00",1)); - res.setTestTimelong(0); - res.setTestCap(0f); - res.setStopReason(""); - res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_4.getStateId())); - res.setDisChargeType(2);*/ continue; } if(!groupName.equals("none")){ @@ -676,25 +680,36 @@ res.setTestTimelong(tinf.getTestTimelong()); res.setTestCap(tinf.getTestCap()); res.setStopReason(StopReasonEnum.getValue(tinf.getTestStoptype())); + if (tinf.getTestType() == 3) { + // 娴嬭瘯绫诲瀷涓烘斁鐢� + if (tinf.getTestStarttype() == 3) { + res.setDischargeName("鏍稿鏀剧數"); + } else if(tinf.getTestStarttype() == 4){ + res.setDischargeName("鍋滅數鏀剧數"); + }else { + res.setDischargeName("鐩戞祴鏀剧數"); + } + } + res.setTestRecordCount(tinf.getTestRecordCount()); 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); res.setRealCap(grouprealCap); //res.setDisChargeType(1); if(grouprealCap>=moncapStd*badValue){ - res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_1.getStateId())); - int value=xnmap.get(Capperformance.getValue(Capperformance.BATTSTATE_1.getStateId())); - xnmap.put(Capperformance.getValue(Capperformance.BATTSTATE_1.getStateId()),value+1); + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_1.getStateId())); + int value=xnmap.get(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_1.getStateId())); + xnmap.put(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_1.getStateId()),value+1); } if(grouprealCap<=moncapStd*damageValue){ - res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_3.getStateId())); - int value=xnmap.get(Capperformance.getValue(Capperformance.BATTSTATE_3.getStateId())); - xnmap.put(Capperformance.getValue(Capperformance.BATTSTATE_3.getStateId()),value+1); + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_3.getStateId())); + int value=xnmap.get(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_3.getStateId())); + xnmap.put(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_3.getStateId()),value+1); } if((grouprealCap>moncapStd*damageValue)&&(grouprealCap<moncapStd*badValue)){ - res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_2.getStateId())); - int value=xnmap.get(Capperformance.getValue(Capperformance.BATTSTATE_2.getStateId())); - xnmap.put(Capperformance.getValue(Capperformance.BATTSTATE_2.getStateId()),value+1); + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_2.getStateId())); + int value=xnmap.get(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_2.getStateId())); + xnmap.put(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_2.getStateId()),value+1); } reslist.add(res); } @@ -740,40 +755,52 @@ res.setMonvolstd(binf.getMonvolstd()); res.setMoncount(binf.getMoncount()); res.setProduct(binf.getProduct()); + res.setStationId(binf.getStationId()); + res.setPowerId(binf.getPowerId()); + res.setBattgroupId(binf.getBattgroupId()); + res.setDevId(binf.getDevId()); //鑾峰彇鐢垫睜缁勬湭鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數) - getNoDischargeData(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime(),stic.getTypeList(),res); - //2.鑾峰彇鐢垫睜缁勫湪缁欏畾鏃堕棿娈电殑鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數) - BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime()); - res.setTinf(tinf); - if(stic.getStopReasonType()==0){ + getNoDischargeData(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime(),null,res); + /*if(stic.getStopReasonType()==0){ reslist.add(res); }else { if(res.getStopReasonType()==stic.getStopReasonType()){ reslist.add(res); } + }*/ + reslist.add(res); + if(!groupName.equals("none")){ + BanZu bz= (BanZu) bzmap.get(groupName); + int nochargeNum=bz.getNochargeNum(); + bz.setNochargeNum(nochargeNum+1); + bzmap.put(groupName,bz); } - if(tinf==null){ - if(!groupName.equals("none")){ - BanZu bz= (BanZu) bzmap.get(groupName); - int nochargeNum=bz.getNochargeNum(); - bz.setNochargeNum(nochargeNum+1); - bzmap.put(groupName,bz); - } - continue; - } - } PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize()); return new Response().setIII(1,reslist.size()>0,pageInfo,bzmap,"鏈勾搴︽湭鏀剧數鏁伴噺缁熻"); } //2.鑾峰彇鐢垫睜缁勬湭鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數) private void getNoDischargeData(Integer battgroupId, Date testStartTime, Date testEndTime, List<Integer> typeList, SticDischarge6Res res) { - List<BatttestdataInf> tinfList=mapper.getNoDischargeData(battgroupId,testStartTime,testEndTime,typeList); + List<BatttestdataInf> tinfList=mapper.getNoDischargeData(battgroupId,testStartTime,testEndTime,null); List<String> stopList=new ArrayList<>(); if(tinfList!=null&&tinfList.size()>0){ res.setErrorNum(tinfList.size()); - res.setStopReasonType(1); - for (BatttestdataInf tinf:tinfList) { + //res.setStopReasonType(1); + for (int i=0;i<tinfList.size();i++) { + BatttestdataInf tinf=tinfList.get(i); + if(i==0){ + res.setTestRecordCount(tinf.getTestRecordCount()); + if (tinf.getTestType() == 3) { + // 娴嬭瘯绫诲瀷涓烘斁鐢� + if (tinf.getTestStarttype() == 3) { + res.setDischargeName("鏍稿鏀剧數"); + } else if(tinf.getTestStarttype() == 4){ + res.setDischargeName("鍋滅數鏀剧數"); + }else { + res.setDischargeName("鐩戞祴鏀剧數"); + } + } + } String stopReason=StopReasonEnum.getValue(tinf.getTestStoptype()); stopList.add(stopReason); } @@ -781,7 +808,7 @@ }else { res.setErrorNum(0); res.setStopList(new ArrayList<>()); - res.setStopReasonType(0); + //res.setStopReasonType(0); } } //鑾峰彇鏍稿鍋滄鍘熷洜绫诲瀷(涓嬫媺) @@ -820,69 +847,169 @@ res.setStationName(binf.getStationName()); res.setBattgroupName(binf.getBattgroupName()); res.setProduct(binf.getProduct()); - res.setInuseYear(ActionUtil.getDateYear(new Date())-ActionUtil.getDateYear(binf.getInuseTime())); + res.setInuseYear(ActionUtil.getDateYear(new Date())-ActionUtil.getDateYear(binf.getInuseTime())+1); res.setMonvolstd(binf.getMonvolstd()); res.setMoncapstd(binf.getMoncapstd()); res.setMoncount(binf.getMoncount()); + res.setStationId(binf.getStationId()); + res.setPowerId(binf.getPowerId()); + res.setBattgroupId(binf.getBattgroupId()); + res.setDevId(binf.getDevId()); //2.鑾峰彇鐢垫睜缁勫湪缁欏畾鏃堕棿娈电殑鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數) BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime()); - if(stic.getPerformance()==null){ - reslist.add(res); - }else{ - if(res.getCapperformance().equals(Capperformance.getValue(stic.getPerformance()))){ - reslist.add(res); - } - } if(tinf==null){ res.setRealCap(0f); - res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_4.getStateId())); - continue; + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_4.getStateId())); + }else{ + //鎵捐繖娆℃斁鐢电殑鏈�鍚庝竴绗旀暟鎹� + List<BatttestdataId> idDataList=battTestdataIdService.getLastDataByBattgroupId(tinf.getBattgroupId(),tinf.getTestRecordCount(),tinf.getRecordNum()); + if(idDataList==null||idDataList.size()==0){ + res.setRealCap(0f); + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_4.getStateId())); + }else{ + 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); + res.setRealCap(grouprealCap); + if(grouprealCap>=moncapStd*badValue){ + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_1.getStateId())); + } + if(grouprealCap<=moncapStd*damageValue){ + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_3.getStateId())); + } + if((grouprealCap>moncapStd*damageValue)&&(grouprealCap<moncapStd*badValue)){ + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_2.getStateId())); + } + } } - //鎵捐繖娆℃斁鐢电殑鏈�鍚庝竴绗旀暟鎹� - List<BatttestdataId> idDataList=battTestdataIdService.getLastDataByBattgroupId(tinf.getBattgroupId(),tinf.getTestRecordCount(),tinf.getRecordNum()); - if(idDataList==null||idDataList.size()==0){ + if(res.getCapperformance().equals(BattCapperformanceEnum.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.8/9/10)"); + } + //鐢垫睜缁勭數姹犳�ц兘缁熻锛堝姡鍖�<鎸夌収鍗曚綋鐢靛帇+鍐呴樆缁熻>锛夌粺璁�(1.2.9) + public Response getPerVolAndRes9Statistic(PerformanceStic stic) { + //1鏌ヨ绗﹀悎鏉′欢鐨勭數姹犵粍 + List<BattInf> binfList=battInfService.getPerformanceStatistic(stic); + if(binfList==null||binfList.size()==0){ + return new Response().set(1,false,"褰撳墠鐢ㄦ埛鏈鐞嗘弧瓒虫潯浠剁殑鐢垫睜缁�"); + } + List<PerformanceRes> reslist=new ArrayList<>(); + for (BattInf binf:binfList) { + PerformanceRes res=new PerformanceRes(); + res.setProvice(binf.getProvice()); + res.setCity(binf.getCity()); + res.setCountry(binf.getCountry()); + res.setStationName(binf.getStationName()); + res.setBattgroupName(binf.getBattgroupName()); + res.setProduct(binf.getProduct()); + res.setInuseYear(ActionUtil.getDateYear(new Date())-ActionUtil.getDateYear(binf.getInuseTime())+1); + res.setMonvolstd(binf.getMonvolstd()); + res.setMoncapstd(binf.getMoncapstd()); + res.setMoncount(binf.getMoncount()); + res.setStationId(binf.getStationId()); + res.setPowerId(binf.getPowerId()); + res.setBattgroupId(binf.getBattgroupId()); + res.setDevId(binf.getDevId()); + //2.鑾峰彇鐢垫睜缁勫湪缁欏畾鏃堕棿娈电殑鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數) + BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime()); + if(tinf==null){ res.setRealCap(0f); - res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_4.getStateId())); - continue; + }else{ + //鎵捐繖娆℃斁鐢电殑鏈�鍚庝竴绗旀暟鎹� + List<BatttestdataId> idDataList=battTestdataIdService.getLastDataByBattgroupId(tinf.getBattgroupId(),tinf.getTestRecordCount(),tinf.getRecordNum()); + if(idDataList==null||idDataList.size()==0){ + res.setRealCap(0f); + }else{ + 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); + res.setRealCap(grouprealCap); + } } - 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); - 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())); + //鏌ヨ褰撳墠鐢垫睜缁勫綋鍓嶅崟浣撶數鍘嬫垨鑰呭崟浣撳唴闃讳綆浜庡叾鍗曚綋鐢靛帇鐨勪笅涓嬮檺鎴栭珮浜庝笂涓婇檺鍒ゅ畾褰撳墠鐢垫睜缁勫姡鍖� + int flag = rtdataService.getVolAndRes(binf.getBattgroupId()); + if(flag==1){ + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_2.getStateId())); + reslist.add(res); } } PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize()); return new Response().setII(1,reslist.size()>0,pageInfo,"鐢垫睜缁勭數姹犳�ц兘缁熻锛堟湭鏀剧數锛屼紭绉�锛屽姡鍖栵紝鎹熷潖锛夌粺璁�(1.2.8/9/10)"); } //浼樿壇鐢垫簮鏁伴噺缁熻(1.2.7) - public Response getPwr7Statistic(Pwr7Stic 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(); - } - + public Response getPwr7Statistic(Pwr7Stic stic) throws NoSuchFieldException, IllegalAccessException { + Date inuseTimeStart =new Date(); + if(stic.getInuseYear()!=null){ + if(stic.getInuseYear()==1){ + //鎶曞叆浣跨敤鏃堕棿鏉′欢绛涢�� + LocalDateTime startTime = LocalDateTime.now().minusYears(5); + inuseTimeStart = DateUtil.convertToDate(startTime); + }else{ + //鎶曞叆浣跨敤鏃堕棿鏉′欢绛涢�� + LocalDateTime startTime = LocalDateTime.now().minusYears(stic.getInuseYear()); + inuseTimeStart = DateUtil.convertToDate(startTime); } + stic.setPwrInUseTime(inuseTimeStart); } //1鏌ヨ绗﹀悎鏉′欢鐨勭數姹犵粍 - List<BattInf> binfList=battInfService.getPwr7Statistic(stic); - List<PerformanceRes> reslist=new ArrayList<>(); + List<PowerInf> pinfList=powerInfService.getPwr7Statistic(stic); + if(pinfList==null||pinfList.size()==0){ + return new Response().set(1,false,"褰撳墠鐢ㄦ埛鏈鐞嗘弧瓒虫潯浠剁殑鐢垫簮"); + } + List<SticPwr7Res> reslist=new ArrayList<>(); + for (PowerInf pinf:pinfList) { + SticPwr7Res res = new SticPwr7Res(); + //鏌ヨ鐢垫簮鎵�鍦ㄧ殑鐝粍 + String groupName = bjService.getGroupName(pinf.getPowerId()); + if (stic.getGroupName() == null || groupName == stic.getGroupName()) { + res.setProvice(pinf.getProvice()); + res.setCity(pinf.getCity()); + res.setCountry(pinf.getCountry()); + res.setStationName(pinf.getStationName()); + res.setPowerName(pinf.getPowerName()); + res.setCompany(pinf.getCompany()); + res.setStationType(pinf.getStationType()); + res.setGroupName(groupName); + res.setInuseTime(pinf.getPowerInuseTime()); + Integer performance= pwrHisdataIdService.getPwrQuarter7(pinf.getPowerId(),pinf.getPowerType()); + res.setPerformanceName(PwrCapperformanceEnum.getValue(performance)); + if(stic.getPerformance()==null){ + reslist.add(res); + }else{ + if(performance==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.7)"); } + + + public List<BatttestdataInf> getListByUserId(Integer userId) { + return mapper.getListByUserId(userId); + } + + public int getHrDisCount(Integer userId, Date startTime, Date endTime) { + return mapper.getHrDisCount(userId, startTime, endTime); + } + //鑾峰彇杩欎竴娆$殑鏀剧數淇℃伅 + public BatttestdataInf getTinfByTestRecordCount(Integer battgroupId, Integer testRecordCount) { + QueryWrapper wrapper=new QueryWrapper(); + wrapper.eq("battgroup_id",battgroupId); + wrapper.eq("test_record_count",testRecordCount); + wrapper.last(" limit 1"); + return mapper.selectOne(wrapper); + } + //鍘嗗彶娴嬭瘯鏁版嵁瀵煎嚭 + public BatttestdataInf exportTinfDataByTestRecordCount(Integer battgroupId, Integer testRecordCount) { + QueryWrapper wrapper =new QueryWrapper(); + wrapper.eq("battgroup_id",battgroupId); + wrapper.eq("test_record_count",testRecordCount); + wrapper.last(" limit 1"); + return mapper.selectOne(wrapper); + } } \ No newline at end of file -- Gitblit v1.9.1