From 64f046ed41c2ae607dc065c82b6d454f64e90584 Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq.com> Date: 星期四, 19 六月 2025 21:52:33 +0800 Subject: [PATCH] 预警分析管理-电源告警 --- src/main/java/com/whyc/service/BatttestdataInfService.java | 949 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 945 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/whyc/service/BatttestdataInfService.java b/src/main/java/com/whyc/service/BatttestdataInfService.java index 6ece9a4..1a81da5 100644 --- a/src/main/java/com/whyc/service/BatttestdataInfService.java +++ b/src/main/java/com/whyc/service/BatttestdataInfService.java @@ -3,22 +3,61 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +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; -import com.whyc.dto.Statistic.BattTinfStic; +import com.whyc.dto.Statistic.*; 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 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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.List; +import java.time.LocalDateTime; +import java.util.*; @Service public class BatttestdataInfService { @Autowired(required = false) private BatttestdataInfMapper mapper; + + @Autowired(required = false) + 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; + + @Autowired(required = false) + private BaojigroupService bjService; + + @Autowired(required = false) + private PowerInfService powerInfService; + + @Autowired(required = false) + private PwrdevHistorydataIdService pwrHisdataIdService; + + //鑾峰彇鏈�鍚庝竴娆℃祴璇曟暟鎹苟璁$畻鍓╀綑瀹归噺 @@ -41,6 +80,30 @@ public Response getBattTinfStatistic(BattTinfStic stic) { PageHelper.startPage(stic.getPageNum(), stic.getPageSize()); List<BatttestdataInf> list=mapper.getBattTinfStatistic(stic); + if(list!=null&&list.size()>0){ + for (BatttestdataInf tinf:list) { + //鍓╀綑瀹归噺鍜屽墿浣欐椂闂磋绠� + int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr()); + Float restCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Rest); + Float realCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real); + tinf.setRestCap(restCap); + tinf.setRealCap(realCap); + tinf.setRestTime(0f); + //鑾峰彇鐢垫睜缁勫疄鏃舵暟鎹� + BattRtstate battRtstate=rtstateService.getBattRealInfo(tinf.getBattgroupId()); + //鑾峰彇鐢垫睜缁勪俊鎭� + BattInf binf=battInfService.getBinfByBattgroupId(tinf.getBattgroupId()); + //瀹炴椂缁勭鐢垫祦锛屽墿浣欏閲忥紝鏍囩О瀹归噺 + if(battRtstate!=null){ + Float restTime= BattCapFactory.getTheoryTime(battRtstate.getLoadCurr(), restCap, binf.getMoncapstd()); + tinf.setRestTime(restTime); + } + //淇濈暀5浣嶅皬鏁� + String precentCap = String.format("%.5f",(restCap/binf.getMoncapstd()*100)); + tinf.setPrecentCap(precentCap); + } + } + PageInfo pageInfo=new PageInfo(list); return new Response().setII(1,list.size()>0,pageInfo,"钃勭數姹犳牳瀹逛俊鎭粺璁�"); } @@ -48,11 +111,889 @@ 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(" and test_timelong >= 7200 ORDER BY test_starttime DESC "); + wrapper.last("limit 1"); + BatttestdataInf tinf = mapper.selectOne(wrapper); + tinf.setTestStoptypeReason(StopReasonEnum.getValue(tinf.getTestStoptype())); + return tinf; + } + + //鑾峰彇鐢垫睜缁勫湪缁欏畾鏃堕棿娈电殑鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數) + protected 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 Map 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); + Float realCap=0f; + if(binfList==null){ + return map; + } + 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.setBattgroupName(binf.getBattgroupName()); + res.setStationName(binf.getStationName()); + res.setDevName(binf.getDevName()); + 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); + } + } + } + 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 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.setBattgroupName(binf.getBattgroupName()); + res.setStationName(binf.getStationName()); + res.setDevName(binf.getDevName()); + 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.setBattgroupName(binf.getBattgroupName()); + res.setStationName(binf.getStationName()); + res.setDevName(binf.getDevName()); + res.setMonNum(rtdata.getMonNum()); + res.setMonVol(rtdata.getMonVol()); + res.setMonRes(rtdata.getMonRes()); + damagelist.add(res); + } + } + } + /*钃勭數姹犵粍瀵规瘮鍒嗘瀽鐣岄潰锛堝悓涓�鍝佺墝鍚屼竴鏃堕棿锛� + *1.鏌ヨ鍑虹鍚堟潯浠剁殑鐢垫睜缁勪俊鎭� + * 2.璁$畻鐢垫睜缁勭殑棰勪及鍓╀綑瀹归噺 + *3.鍒ゆ柇鎬ц兘鍜岀櫨鍒嗘瘮 + * 4.鍒嗛〉 + */ + public Response getBattCompare15Statistic(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<SticCompare15Res> reslist=new ArrayList<>(); + for (BattInf binf:binfList) { + SticCompare15Res res=new SticCompare15Res(); + 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.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(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_4.getStateId())); + continue; + } + //鎵捐繖娆℃斁鐢电殑鏈�鍚庝竴绗旀暟鎹� + List<BatttestdataId> idDataList=battTestdataIdService.getLastDataByBattgroupId(tinf.getBattgroupId(),tinf.getTestRecordCount(),tinf.getRecordNum()); + if(idDataList==null||idDataList.size()==0){ + res.setRealCap(0f); + res.setPrecentCap("0"); + res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_4.getStateId())); + continue; + } + 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(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())); + } + //淇濈暀5浣嶅皬鏁� + String precentCap = String.format("%.5f",(grouprealCap/binf.getMoncapstd()*100)); + res.setPrecentCap(precentCap); + List<Integer> monNums=new ArrayList<>(); + for (BatttestdataId data:idDataList) {//姹傚崟浣撶殑 瀹為檯瀹归噺锛屾渶灏忓�煎氨鏄崟浣撶殑鍗曚綋鐢靛帇 + Float monrealCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), data.getMonVol(), tinf.getGroupVol(), BattCapFactory.CapType_Real); + if (monrealCap <= moncapStd * damageValue) {//鎹熷潖鐨� + monNums.add(data.getMonNum()); + } + } + res.setMonNums(monNums); + if(stic.getPerformance()==null){ + reslist.add(res); + }else{ + 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.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(BattCapperformanceEnum.getValue(BattCapperformanceEnum.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(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())); + } + //淇濈暀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(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.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.getBattCompare17Statistic(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(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_1.getStateId())); + } + if (monrealCap <= moncapStd * damageValue) {//鎹熷潖鐨� + res.setMoncapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_3.getStateId())); + } + if((monrealCap>moncapStd*damageValue)&&(monrealCap<moncapStd*badValue)){ + res.setMoncapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_2.getStateId())); + } + if(stic.getPerformance()==null){ + reslist.add(res); + }else{ + if(res.getMoncapperformance().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,"钃勭數姹犵粍瀵规瘮鍒嗘瀽鐣岄潰锛堝悓涓�鍝佺墝鍚屼竴鏃堕棿锛�"); + } + //涓嶅瓨鍦ㄦ斁鐢佃褰曞垯榛樿涓哄疄闄呴浼板閲忓叏涓�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(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_4.getStateId())); + if(performance==null){ + reslist.add(res); + }else{ + if(res.getMoncapperformance().equals(BattCapperformanceEnum.getValue(performance))){ + reslist.add(res); + } + } + } + } + //鍘嗗彶娴嬭瘯璁板綍 + public Response getBattTinf(Integer battgroupId) { + Map<String, Object> map=new HashMap<>(); + List<TestDataDto> List1=new ArrayList<>(); + List<TestDataDto> List2=new ArrayList<>(); + List<TestDataDto> List3=new ArrayList<>(); + List<TestDataDto> List4=new ArrayList<>(); + List<TestDataDto> List5=new ArrayList<>(); + 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"); + List<BatttestdataInf> list=mapper.selectList(wrapper); + for (BatttestdataInf tinf:list) { + TestDataDto dto=new TestDataDto(); + dto.setTestStarttime(tinf.getTestStarttime()); + dto.setBattgroupId(tinf.getBattgroupId()); + dto.setTestRecordCount(tinf.getTestRecordCount()); + dto.setRecordNum(tinf.getRecordNum()); + dto.setTestCap(tinf.getTestCap()); + dto.setTestTimeLong(tinf.getTestTimelong()); + 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); + dto.setRealCap(realCap); + //瀹炴椂鑾峰彇鐢垫睜缁勪俊鎭� + BattRtstate battRtstate = rtstateService.getBattRealInfo(tinf.getBattgroupId()); + //鑾峰彇鐢垫睜缁勪俊鎭� + BattInf binf = battInfService.getBinfByBattgroupId(tinf.getBattgroupId()); + dto.setMoncapstd(binf.getMoncapstd()); + dto.setMonCount(binf.getMoncount()); + dto.setMonvolstd(binf.getMonvolstd()); + 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){ + BatttestdataId idData=idDataList.get(0); + dto.setOnlineVol(idData.getOnlineVol()); + dto.setGroupCurr(idData.getTestCurr()); + }else { + dto.setOnlineVol(0f); + dto.setGroupCurr(0f); + } + if (tinf.getTestType() == 3) { + // 娴嬭瘯绫诲瀷涓烘斁鐢� + if (tinf.getTestStarttype() == 3) { + List1.add(dto); + } else if(tinf.getTestStarttype() == 4){ + List5.add(dto); + }else { + List3.add(dto); + } + } else if (tinf.getTestType() == 2) { + // 娴嬭瘯绫诲瀷涓哄厖鐢� + if (tinf.getTestStarttype() == 3) { + List2.add(dto); + } else { + List4.add(dto); + } + } + } + return new Response().setII(1,true,map,"鍘嗗彶娴嬭瘯璁板綍"); + } + //鏈勾搴﹀凡鏀剧數鏁伴噺缁熻(1.2.5)<鍙煡鐪嬪凡鏀剧數鏁版嵁> + public Response getDischr5Statistic(DisChargeStic stic) { + //鐝粍 + Map<String, Object> bzmap=new HashMap<>(); + //鎬ц兘 + Map<String, Integer> xnmap=new HashMap<>(); + xnmap.put("浼樼",0); + xnmap.put("鍔e寲",0); + xnmap.put("鎹熷潖",0); + xnmap.put("鏈斁鐢�",0); + //鏌ヨ鍑烘墍鏈夌殑鐝粍骞惰祴浜堝垵濮嬪�� + setBanZuDefault(bzmap); + //鑾峰彇鏍稿浼樺姡锛屾崯鍧忓弬鏁� + 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.getDischr5Statistic(stic); + if(binfList==null||binfList.size()==0){ + return new Response().set(1,false,"褰撳墠鐢ㄦ埛鏈鐞嗘弧瓒虫潯浠剁殑鐢垫睜缁�"); + } + List<SticDischarge5Res> reslist=new ArrayList<>(); + for (BattInf binf:binfList) { + //鏌ヨ鐢垫睜缁勬墍鍦ㄧ殑鐝粍 + String groupName=bjService.getGroupName(binf.getPowerId()); + SticDischarge5Res res=new SticDischarge5Res(); + res.setProvice(binf.getProvice()); + res.setCity(binf.getCity()); + 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){ + continue; + } + if(!groupName.equals("none")){ + BanZu bz= (BanZu) bzmap.get(groupName); + int dischargeNum=bz.getDischargeNum(); + bz.setDischargeNum(dischargeNum+1); + bzmap.put(groupName,bz); + } + res.setTestStartTime(tinf.getTestStarttime()); + 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(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(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(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); + } + PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize()); + return new Response().setIIII(1,reslist.size()>0,pageInfo,bzmap,xnmap,"鏈勾搴﹀凡鏀剧數鏁伴噺缁熻"); + } + + //鏌ヨ鍑烘墍鏈夌殑鐝粍骞惰祴浜堝垵濮嬪�� + private void setBanZuDefault(Map<String, Object> map) { + List<Baojigroup> banZuList=bjService.getGroupList(); + for (Baojigroup bj:banZuList) { + BanZu bz=new BanZu(); + bz.setBaojiGroupId(bj.getBaojiGroupId()); + bz.setBaojiGroupName(bj.getBaojiGroupName()); + bz.setDischargeNum(0); + bz.setNochargeNum(0); + map.put(bj.getBaojiGroupName(),bz); + } + } + + //鏈勾搴︽湭鏀剧數鏁伴噺缁熻(1.2.6) + public Response getDischr6Statistic(DisChargeStic stic) { + //鐝粍 + Map<String, Object> bzmap=new HashMap<>(); + //鏌ヨ鍑烘墍鏈夌殑鐝粍骞惰祴浜堝垵濮嬪�� + setBanZuDefault(bzmap); + //1鏌ヨ绗﹀悎鏉′欢鐨勭數姹犵粍 + List<BattInf> binfList=battInfService.getDischr6Statistic(stic); + if(binfList==null||binfList.size()==0){ + return new Response().set(1,false,"褰撳墠鐢ㄦ埛鏈鐞嗘弧瓒虫潯浠剁殑鐢垫睜缁�"); + } + List<SticDischarge6Res> reslist=new ArrayList<>(); + for (BattInf binf:binfList) { + //鏌ヨ鐢垫睜缁勬墍鍦ㄧ殑鐝粍 + String groupName=bjService.getGroupName(binf.getPowerId()); + SticDischarge6Res res=new SticDischarge6Res(); + res.setProvice(binf.getProvice()); + res.setCity(binf.getCity()); + res.setCountry(binf.getCountry()); + res.setStationName(binf.getStationName()); + res.setBattgroupName(binf.getBattgroupName()); + res.setMoncapstd(binf.getMoncapstd()); + 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(),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); + } + } + 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,null); + List<String> stopList=new ArrayList<>(); + if(tinfList!=null&&tinfList.size()>0){ + res.setErrorNum(tinfList.size()); + //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); + } + res.setStopList(stopList); + }else { + res.setErrorNum(0); + res.setStopList(new ArrayList<>()); + //res.setStopReasonType(0); + } + } + //鑾峰彇鏍稿鍋滄鍘熷洜绫诲瀷(涓嬫媺) + public Response getStopReasonType() { + Map<String,Map<Integer,String>> map= StopReasonEnum.getOpInfo(); + return new Response().setII(1,true,map,"鑾峰彇鏍稿鍋滄鍘熷洜绫诲瀷(涓嬫媺)"); + } + //鐢垫睜缁勭數姹犳�ц兘缁熻锛堟湭鏀剧數锛屼紭绉�锛屽姡鍖栵紝鎹熷潖锛夌粺璁�(1.2.8/9/10) + public Response getPerformanceStatistic(PerformanceStic 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.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(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())); + } + } + } + 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); + }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); + } + } + //鏌ヨ褰撳墠鐢垫睜缁勫綋鍓嶅崟浣撶數鍘嬫垨鑰呭崟浣撳唴闃讳綆浜庡叾鍗曚綋鐢靛帇鐨勪笅涓嬮檺鎴栭珮浜庝笂涓婇檺鍒ゅ畾褰撳墠鐢垫睜缁勫姡鍖� + 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) 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<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); + } } \ No newline at end of file -- Gitblit v1.9.1