From 7a8d50965cb69ecc348a6b11d902409628012cd0 Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期三, 25 六月 2025 17:15:10 +0800
Subject: [PATCH] 蓄电池对比分析导出

---
 src/main/java/com/whyc/service/BatttestdataInfService.java |  766 +++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 639 insertions(+), 127 deletions(-)

diff --git a/src/main/java/com/whyc/service/BatttestdataInfService.java b/src/main/java/com/whyc/service/BatttestdataInfService.java
index ed4de41..2d40379 100644
--- a/src/main/java/com/whyc/service/BatttestdataInfService.java
+++ b/src/main/java/com/whyc/service/BatttestdataInfService.java
@@ -3,15 +3,16 @@
 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.ResSocreHehavior;
 import com.whyc.dto.Response;
+import com.whyc.dto.SocreHehaviorDto;
 import com.whyc.dto.Statistic.*;
 import com.whyc.factory.BattCapFactory;
 import com.whyc.mapper.BatttestdataInfMapper;
-import com.whyc.pojo.db_alarm.BattalarmData;
 import com.whyc.pojo.db_batt_testdata.BatttestdataId;
 import com.whyc.pojo.db_batt_testdata.BatttestdataInf;
 import com.whyc.pojo.db_param.AppParam;
@@ -21,12 +22,14 @@
 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.*;
+import java.util.stream.Collectors;
 
 @Service
 public class BatttestdataInfService {
@@ -57,11 +60,14 @@
     @Autowired(required = false)
     private PwrdevHistorydataIdService pwrHisdataIdService;
 
+    @Autowired(required = false)
+    private BattresdataInfService battResdataInfService;
+
 
 
 
     //鑾峰彇鏈�鍚庝竴娆℃祴璇曟暟鎹苟璁$畻鍓╀綑瀹归噺
-    public Float getLastTestDataRestCap(Integer battgroupId) {
+    public Float getLastTestDataRestCap(Float moncapstd,Integer battgroupId) {
         //鑾峰彇鏀剧數璁板綍
         QueryWrapper wrapper=new QueryWrapper();
         wrapper.eq("battgroup_id",battgroupId);
@@ -70,7 +76,7 @@
         BatttestdataInf tinf=mapper.selectOne(wrapper);
         if(tinf!=null){
             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 restcap = (float) BattCapFactory.GetMonomerCap(moncapstd, hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Rest);
             return restcap;
         }else{
             return 0f;
@@ -82,17 +88,18 @@
         List<BatttestdataInf> list=mapper.getBattTinfStatistic(stic);
         if(list!=null&&list.size()>0){
             for (BatttestdataInf tinf:list) {
+                //鑾峰彇鐢垫睜缁勪俊鎭�
+                BattInf binf=battInfService.getBinfByBattgroupId(tinf.getBattgroupId());
                 //鍓╀綑瀹归噺鍜屽墿浣欐椂闂磋绠�
                 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);
+                Float restCap = (float) BattCapFactory.GetMonomerCap(binf.getMoncapstd(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Rest);
+                Float realCap = (float) BattCapFactory.GetMonomerCap(binf.getMoncapstd(), 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());
@@ -113,7 +120,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()));
@@ -132,8 +140,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;
     }
@@ -191,7 +200,7 @@
             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);
+                realCap = (float) BattCapFactory.GetMonomerCap(binf.getMoncapstd(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(),data.getMonVol() , tinf.getGroupVol(), BattCapFactory.CapType_Real);
                 SticMonRes res=new SticMonRes();
                 res.setBattgroupId(binf.getBattgroupId());
                 res.setBattgroupName(binf.getBattgroupName());
@@ -258,8 +267,8 @@
         }
     }
     /*钃勭數姹犵粍瀵规瘮鍒嗘瀽鐣岄潰锛堝悓涓�鍝佺墝鍚屼竴鏃堕棿锛�
-     *1.鏌ヨ鍑虹鍚堟潯浠剁殑鐢垫睜缁勪俊鎭�
-     * 2.璁$畻鐢垫睜缁勭殑棰勪及鍓╀綑瀹归噺
+     *1.鏌ヨ鍑虹鍚堟潯浠剁殑鐢垫睜缁勪俊鎭紙鍚屼竴鍝佺墝鍚屼竴鎶曡繍鏃堕棿锛�
+     * 2.璁$畻鐢垫睜缁勭殑鏈�杩戜竴娆℃爣鍑嗘牳瀹规斁鐢电殑棰勪及瀹归噺
      *3.鍒ゆ柇鎬ц兘鍜岀櫨鍒嗘瘮
      * 4.鍒嗛〉
      */
@@ -276,15 +285,27 @@
                 if(param.getParamNamePsx().equals("batt_mon_damage_val")){
                     damageValue=param.getParamValue();
                 }
-
             }
         }
+        Map<String,Object> map=new HashMap<>();//鍙充晶鍥捐〃
+        map.put("avgCap",0f);
+        map.put("standCapDiff",0f);
+        Float sumCap=0f;
+        Float maxCap=0f;
+        Float minCap=0f;
+        Float standCapDiff=0f;
+        List<ComPareChart> capList=new ArrayList<>();
+        List<ComPareChart> resList=new ArrayList<>();
+        List<ComPareChart> flotVolList=new ArrayList<>();
+        map.put("capList",capList);
+        map.put("resList",resList);
+        map.put("flotVolList",flotVolList);
         //1鏌ヨ绗﹀悎鏉′欢鐨勭數姹犵粍
         List<BattInf> binfList=battInfService.getBattCompare15Statistic(stic);
         if(binfList==null||binfList.size()==0){
             return new Response().set(1,false,"褰撳墠鐢ㄦ埛鏈鐞嗘弧瓒虫潯浠剁殑鐢垫睜缁�");
         }
-        List<SticCompare15Res> reslist=new ArrayList<>();
+        List<SticCompare15Res> comparelist=new ArrayList<>();
         for (BattInf binf:binfList) {
             SticCompare15Res res=new SticCompare15Res();
             res.setProvice(binf.getProvice());
@@ -295,65 +316,173 @@
             res.setDevName(binf.getDevName());
             res.setProduct(binf.getProduct());
             res.setInuseTime(binf.getInuseTime());
+            res.setInuseTimeStr(ActionUtil.sdfwithday.format(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());
+            res.setFullName(binf.getFullName());
             //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_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(Capperformance.getValue(Capperformance.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(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.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);
+                res.setPrecentCap("0.00000");
+                res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_4.getStateId()));
+                res.setStopReason("--");
+                res.setFloatGroupVol(0f);
             }else{
-                if(res.getCapperformance().equals(Capperformance.getValue(stic.getPerformance()))){
-                    reslist.add(res);
+                res.setStopReason(StopReasonEnum.getValue(tinf.getTestStoptype()));
+                res.setFloatGroupVol(tinf.getFloatGroupVol());
+                //鎵捐繖娆℃斁鐢电殑鏈�鍚庝竴绗旀暟鎹�
+                List<BatttestdataId> idDataList=battTestdataIdService.getLastDataByBattgroupId(tinf.getBattgroupId(),tinf.getTestRecordCount(),tinf.getRecordNum());
+                if(idDataList==null||idDataList.size()==0){
+                    res.setRealCap(0f);
+                    res.setPrecentCap("0.00000");
+                    res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_4.getStateId()));
+                    res.setFloatGroupVol(0f);
+                }else{
+                    Float moncapStd=binf.getMoncapstd();
+                    int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr());
+                    Float grouprealCap = (float) BattCapFactory.GetMonomerCap(binf.getMoncapstd(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real);
+                    //Float restCap = (float) BattCapFactory.GetMonomerCap(binf.getMoncapstd(), 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);
+                    sumCap+=grouprealCap;
+                    if(grouprealCap>=maxCap){
+                        maxCap=grouprealCap;
+                    }
+                    if(grouprealCap<=minCap){
+                        minCap=grouprealCap;
+                    }
                 }
             }
-
+            if(stic.getPerformance()==null){
+                comparelist.add(res);
+            }else{
+                if(res.getCapperformance().equals(BattCapperformanceEnum.getValue(stic.getPerformance()))){
+                    comparelist.add(res);
+                }
+            }
+            ComPareChart capChart=new ComPareChart();
+            capChart.setBattgroupId(binf.getBattgroupId());
+            capChart.setBattgroupName(binf.getBattgroupName());
+            capChart.setValue(res.getRealCap());
+            capList.add(capChart);
+            ComPareChart floatVolChart=new ComPareChart();
+            floatVolChart.setBattgroupId(binf.getBattgroupId());
+            floatVolChart.setBattgroupName(binf.getBattgroupName());
+            floatVolChart.setValue(res.getFloatGroupVol());
+            flotVolList.add(floatVolChart);
+            //缁熻鍐呴樆娴嬭瘯
+            ComPareChart resChart=battResdataInfService.getMaxResData(binf);
+            resList.add(resChart);
         }
-        PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize());
-        return new Response().setII(1,reslist.size()>0,pageInfo,"钃勭數姹犵粍瀵规瘮鍒嗘瀽鐣岄潰锛堝悓涓�鍝佺墝鍚屼竴鏃堕棿锛�");
+        map.put("avgCap",sumCap/binfList.size());
+        map.put("standCapDiff",maxCap-minCap);
+        PageInfo pageInfo=PageInfoUtils.list2PageInfo(comparelist, stic.getPageNum(), stic.getPageSize());
+        return new Response().setIII(1,comparelist.size()>0,pageInfo,map,"钃勭數姹犵粍瀵规瘮鍒嗘瀽鐣岄潰锛堝悓涓�鍝佺墝鍚屼竴鏃堕棿锛�");
     }
-
+    /*钃勭數姹犵粍瀵规瘮鍒嗘瀽瀵煎嚭浣跨敤
+     */
+    public List<SticCompare15Res> exportBattCompare(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);
+        List<SticCompare15Res> comparelist=new ArrayList<>();
+        if(binfList!=null&&binfList.size()>=0){
+            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.setInuseTimeStr(ActionUtil.sdfwithday.format(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());
+                res.setFullName(binf.getFullName());
+                //2.鑾峰彇鐢垫睜缁勫湪缁欏畾鏃堕棿娈电殑鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數)
+                BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime());
+                if(tinf==null){
+                    res.setRealCap(0f);
+                    res.setPrecentCap("0.00000");
+                    res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_4.getStateId()));
+                    res.setStopReason("--");
+                    res.setFloatGroupVol(0f);
+                }else{
+                    res.setStopReason(StopReasonEnum.getValue(tinf.getTestStoptype()));
+                    res.setFloatGroupVol(tinf.getFloatGroupVol());
+                    //鎵捐繖娆℃斁鐢电殑鏈�鍚庝竴绗旀暟鎹�
+                    List<BatttestdataId> idDataList=battTestdataIdService.getLastDataByBattgroupId(tinf.getBattgroupId(),tinf.getTestRecordCount(),tinf.getRecordNum());
+                    if(idDataList==null||idDataList.size()==0){
+                        res.setRealCap(0f);
+                        res.setPrecentCap("0.00000");
+                        res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_4.getStateId()));
+                        res.setFloatGroupVol(0f);
+                    }else{
+                        Float moncapStd=binf.getMoncapstd();
+                        int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr());
+                        Float grouprealCap = (float) BattCapFactory.GetMonomerCap(binf.getMoncapstd(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real);
+                        //Float restCap = (float) BattCapFactory.GetMonomerCap(binf.getMoncapstd(), 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);
+                    }
+                }
+                if(stic.getPerformance()==null){
+                    comparelist.add(res);
+                }else{
+                    if(res.getCapperformance().equals(BattCapperformanceEnum.getValue(stic.getPerformance()))){
+                        comparelist.add(res);
+                    }
+                }
+            }
+        }
+        return comparelist;
+    }
     //钃勭數姹犵粍瀵规瘮鍒嗘瀽鐣岄潰锛堜笉鍚屽搧鐗屽悓涓�鏃堕棿锛�(1.2.16)
     public Response getBattCompare16Statistic(BattCompareStic stic) {
         //鑾峰彇鏍稿浼樺姡锛屾崯鍧忓弬鏁�
@@ -398,24 +527,24 @@
             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;
             }
             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);
+            Float grouprealCap = (float) BattCapFactory.GetMonomerCap(binf.getMoncapstd(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real);
+            //Float restCap = (float) BattCapFactory.GetMonomerCap(binf.getMoncapstd(), 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));
@@ -425,7 +554,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);
                 }
             }
@@ -490,24 +619,24 @@
                 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);
+                Float monrealCap = (float) BattCapFactory.GetMonomerCap(binf.getMoncapstd(), 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()));
+                    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);
                     }
                 }
@@ -536,11 +665,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);
                 }
             }
@@ -571,23 +700,22 @@
             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());
+            int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr());
+            Float realCap = (float) BattCapFactory.GetMonomerCap(binf.getMoncapstd(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real);
+            dto.setRealCap(realCap);
+            //瀹炴椂鑾峰彇鐢垫睜缁勪俊鎭�
+            BattRtstate battRtstate = rtstateService.getBattRealInfo(tinf.getBattgroupId());
+            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);
@@ -693,23 +821,23 @@
             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);
+            Float grouprealCap = (float) BattCapFactory.GetMonomerCap(binf.getMoncapstd(), 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);
         }
@@ -760,14 +888,15 @@
             res.setBattgroupId(binf.getBattgroupId());
             res.setDevId(binf.getDevId());
             //鑾峰彇鐢垫睜缁勬湭鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數)
-            getNoDischargeData(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime(),stic.getTypeList(),res);
-            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();
@@ -780,11 +909,11 @@
     }
     //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);
+            //res.setStopReasonType(1);
             for (int i=0;i<tinfList.size();i++) {
                 BatttestdataInf tinf=tinfList.get(i);
                 if(i==0){
@@ -807,7 +936,7 @@
         }else {
             res.setErrorNum(0);
             res.setStopList(new ArrayList<>());
-            res.setStopReasonType(0);
+            //res.setStopReasonType(0);
         }
     }
     //鑾峰彇鏍稿鍋滄鍘熷洜绫诲瀷(涓嬫媺)
@@ -858,30 +987,30 @@
             BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime());
             if(tinf==null){
                 res.setRealCap(0f);
-                res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_4.getStateId()));
+                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(Capperformance.getValue(Capperformance.BATTSTATE_4.getStateId()));
+                    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);
+                    Float grouprealCap = (float) BattCapFactory.GetMonomerCap(binf.getMoncapstd(), 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()));
+                        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()));
                     }
                 }
             }
-            if(res.getCapperformance().equals(Capperformance.getValue(stic.getPerformance()))){
+            if(res.getCapperformance().equals(BattCapperformanceEnum.getValue(stic.getPerformance()))){
                 reslist.add(res);
             }
         }
@@ -930,7 +1059,7 @@
             //鏌ヨ褰撳墠鐢垫睜缁勫綋鍓嶅崟浣撶數鍘嬫垨鑰呭崟浣撳唴闃讳綆浜庡叾鍗曚綋鐢靛帇鐨勪笅涓嬮檺鎴栭珮浜庝笂涓婇檺鍒ゅ畾褰撳墠鐢垫睜缁勫姡鍖�
             int flag = rtdataService.getVolAndRes(binf.getBattgroupId());
             if(flag==1){
-                res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_2.getStateId()));
+                res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_2.getStateId()));
                 reslist.add(res);
             }
         }
@@ -938,36 +1067,51 @@
         return new Response().setII(1,reslist.size()>0,pageInfo,"鐢垫睜缁勭數姹犳�ц兘缁熻锛堟湭鏀剧數锛屼紭绉�锛屽姡鍖栵紝鎹熷潖锛夌粺璁�(1.2.8/9/10)");
     }
    //浼樿壇鐢垫簮鏁伴噺缁熻(1.2.7)
-    public Response getPwr7Statistic(Pwr7Stic stic) {
+    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,"褰撳墠鐢ㄦ埛鏈鐞嗘弧瓒虫潯浠剁殑鐢垫睜缁�");
+            return new Response().set(1,false,"褰撳墠鐢ㄦ埛鏈鐞嗘弧瓒虫潯浠剁殑鐢垫簮");
         }
         List<SticPwr7Res> reslist=new ArrayList<>();
         for (PowerInf pinf:pinfList) {
-            SticPwr7Res res=new SticPwr7Res();
-            //鏌ヨ鐢垫睜缁勬墍鍦ㄧ殑鐝粍
+            SticPwr7Res res = new SticPwr7Res();
+            //鏌ヨ鐢垫簮鎵�鍦ㄧ殑鐝粍
             String groupName = bjService.getGroupName(pinf.getPowerId());
-            if(groupName.equals("none")){
-                continue;
-            }else{
-                if(stic.getGroupName()==null||res.getGroupName()==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());
-                    Map<String,Integer> map=pwrHisdataIdService.getPwrQuarter7(pinf.getPowerId(),null);
+            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)");
     }
@@ -980,4 +1124,372 @@
     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);
+    }
+    //鐐瑰嚮鍙充晶鎶樼嚎鍥剧敾鍑虹數姹犵粍鎵�鏈夊畬鏁村懆鏈熺殑瀹為檯瀹归噺鍙樺寲鍥�(1.2.15/16/17)
+    public Response getRealCapChangeByBattgroupId(Integer battgroupId) {
+        QueryWrapper wrapper = new QueryWrapper();
+        wrapper.eq("battgroup_id", battgroupId);
+        wrapper.eq("test_type", 3);
+        wrapper.eq("test_starttype", 3);
+        wrapper.eq("data_available", 1);//涓�娆℃湁鏁堢殑璁板綍
+        wrapper.last("  ORDER BY test_starttime DESC ");
+        List<BatttestdataInf> list = mapper.selectList(wrapper);
+        //鑾峰彇鐢垫睜缁勭殑鏍囩О瀹归噺
+        BattInf binf=battInfService.getBattgroupIdInf(battgroupId);
+        List<ComPareChangeCurve> curvelist=new ArrayList<>();
+        for (BatttestdataInf tinf:list) {
+            int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr());
+            Float realCap = (float) BattCapFactory.GetMonomerCap(binf.getMoncapstd(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real);
+            ComPareChangeCurve curve=new ComPareChangeCurve();
+            curve.setBattgroupId(battgroupId);
+            curve.setStartTime(tinf.getTestStarttime());
+            curve.setCurveValue(realCap);
+            curvelist.add(curve);
+        }
+        return new Response().setII(1,list.size()>0,curvelist,"鐐瑰嚮鍙充晶鎶樼嚎鍥剧敾鍑虹數姹犵粍鎵�鏈夊畬鏁村懆鏈熺殑瀹為檯瀹归噺鍙樺寲鍥�(1.2.15/16/17)");
+    }
+    //鐐瑰嚮鍙充晶鎶樼嚎鍥剧敾鍑虹數姹犵粍鎵�鏈夊畬鏁村懆鏈熺殑娴厖鐢靛帇鍙樺寲鍥�(1.2.15/16/17)
+    public Response getFloatGroupVolChangeByBattgroupId(Integer battgroupId) {
+        QueryWrapper wrapper = new QueryWrapper();
+        wrapper.eq("battgroup_id", battgroupId);
+        wrapper.eq("test_type", 3);
+        wrapper.eq("test_starttype", 3);
+        wrapper.eq("data_available", 1);//涓�娆℃湁鏁堢殑璁板綍
+        wrapper.last("  ORDER BY test_starttime asc ");
+        List<BatttestdataInf> list = mapper.selectList(wrapper);
+        List<ComPareChangeCurve> curvelist=new ArrayList<>();
+        for (BatttestdataInf tinf:list) {
+            ComPareChangeCurve curve=new ComPareChangeCurve();
+            curve.setBattgroupId(battgroupId);
+            curve.setStartTime(tinf.getTestStarttime());
+            curve.setCurveValue(tinf.getFloatGroupVol());
+            curvelist.add(curve);
+        }
+        return new Response().setII(1,list.size()>0,curvelist,"鐐瑰嚮鍙充晶鎶樼嚎鍥剧敾鍑虹數姹犵粍鎵�鏈夊畬鏁村懆鏈熺殑娴厖鐢靛帇鍙樺寲鍥�(1.2.15/16/17)");
+    }
+    //寮圭獥鏍规嵁璁剧疆鐨勬潈閲嶈〃鏍艰瘎鍒�
+    public Response getScoreByHehavior(SocreHehaviorDto dto) {
+        List<ResSocreHehavior> reslist=new ArrayList<>();
+        //璇㈢鍚堟潯浠剁殑鐢垫睜缁勬潈閲嶈〃鏍艰瘎鍒�
+        List<BattInf> binfList=battInfService.getScoreByHehavior(dto);
+        if(binfList==null||binfList.size()==0){
+            return new Response().set(1,false,"褰撳墠鐢ㄦ埛鏈鐞嗘弧瓒虫潯浠剁殑鐢垫睜缁�");
+        }else{
+            Map<String, List<BattInf>> map=new HashMap<>();
+            if(dto.getSelectType()==1){//閫夊搧鐗岋紝閫夋椂闂�
+                map=binfList.stream().collect(Collectors.groupingBy(item -> item.getProduct() + '-' + item.getInuseYear()));
+                groupby1(dto,reslist,map);
+            }
+            if(dto.getSelectType()==2){//閫夊搧鐗岋紝涓嶉�夋椂闂�
+                map=binfList.stream().collect(Collectors.groupingBy(item -> item.getProduct()));
+                groupby2(dto,reslist,map);
+            }
+            if(dto.getSelectType()==3){//涓嶉�夊搧鐗岋紝閫夋椂闂�
+                map=binfList.stream().collect(Collectors.groupingBy(item -> ""+item.getInuseYear()));
+                groupby3(dto,reslist,map);
+            }
+            if(dto.getSelectType()==4){//涓嶉�夊搧鐗屼笉閫夋椂闂�
+                map=binfList.stream().collect(Collectors.groupingBy(item -> item.getMonvolstd().toString() + '-' + item.getMoncapstd()));
+                groupby4(dto,reslist,map);
+            }
+        }
+        return new Response().setII(1,reslist.size()>0,reslist,"寮圭獥鏍规嵁璁剧疆鐨勬潈閲嶈〃鏍艰瘎鍒�");
+    }
+    //涓嶉�夊搧鐗屼笉閫夋椂闂�
+    private void groupby4(SocreHehaviorDto dto,List<ResSocreHehavior> reslist, Map<String, List<BattInf>> map) {
+        //鑾峰彇鏍稿浼樺姡锛屾崯鍧忓弬鏁�
+        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();
+                }
+            }
+        }
+        for (String groupType : map.keySet()) {
+            List<BattInf> list=map.get(groupType);
+            Map<String,List<BattInf>> groupMap=list.stream().collect(Collectors.groupingBy(item -> item.getProduct()+"-"+item.getBattYear()));
+            for (String group : groupMap.keySet()) {
+                List<BattInf> grouplist=groupMap.get(group);
+                ResSocreHehavior res=new ResSocreHehavior();
+                Integer goodBatt=0;
+                Integer badBatt=0;
+                Integer damageBatt=0;
+                Integer nodisBatt=0;
+                Integer sumBatt=grouplist.size();
+                res.setSumBatt(sumBatt);
+                String[] productYearparts = group.split("-"); // 浣跨敤split鏂规硶鍒嗗壊瀛楃涓�
+                res.setProduct(productYearparts[0]);
+                res.setInuseYear(productYearparts[1]+"骞村唴");
+                res.setMonvolstd(dto.getMonvolstd());
+                res.setMoncapstd(dto.getMoncapstd());
+                for (BattInf binf:grouplist) {
+                    Float moncapStd=binf.getMoncapstd();
+                    //2.鑾峰彇鐢垫睜缁勫湪缁欏畾鏃堕棿娈电殑鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數)
+                    BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),null,null);
+                    if(tinf==null){
+                        nodisBatt++;
+                    }else{
+
+                        int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr());
+                        Float grouprealCap = (float) BattCapFactory.GetMonomerCap(moncapStd, hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real);
+                        if(grouprealCap>=moncapStd*badValue){
+                            goodBatt++;
+                        }
+                        if(grouprealCap<=moncapStd*damageValue){
+                            damageBatt++;
+                        }
+                        if((grouprealCap>moncapStd*damageValue)&&(grouprealCap<moncapStd*badValue)){
+                            badBatt++;
+                        }
+                    }
+                }
+                //淇濈暀5浣嶅皬鏁�
+                String goodPercent = String.format("%.5f",(goodBatt/sumBatt*100.0));
+                res.setGoodBatt(goodBatt);
+                res.setGoodPercent(goodPercent);
+                String badPercent = String.format("%.5f",(badBatt/sumBatt*100.0));
+                res.setBadBatt(badBatt);
+                res.setBadPercent(badPercent);
+                String damagePercent = String.format("%.5f",(damageBatt/sumBatt*100.0));
+                res.setDamagebatt(damageBatt);
+                res.setDamagePercent(damagePercent);
+                String nodisPercent = String.format("%.5f",(nodisBatt/sumBatt*100.0));
+                res.setNodisbatt(nodisBatt);
+                res.setNodisPercent(nodisPercent);
+                res.setScore(0f);
+                reslist.add(res);
+            }
+        }
+    }
+
+    //涓嶉�夊搧鐗岋紝閫夋椂闂�
+    private void groupby3(SocreHehaviorDto dto,List<ResSocreHehavior> reslist, Map<String, List<BattInf>> map) {
+        //鑾峰彇鏍稿浼樺姡锛屾崯鍧忓弬鏁�
+        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();
+                }
+            }
+        }
+        for (String groupType : map.keySet()) {
+            List<BattInf> list=map.get(groupType);
+            Map<String,List<BattInf>> productMap=list.stream().collect(Collectors.groupingBy(item -> item.getProduct()));
+            for (String product : productMap.keySet()) {
+                List<BattInf> productList=productMap.get(product);
+                ResSocreHehavior res=new ResSocreHehavior();
+                res.setInuseYear(dto.getInuseYear()+"骞村唴");
+                res.setProduct(product);
+                Integer goodBatt=0;
+                Integer badBatt=0;
+                Integer damageBatt=0;
+                Integer nodisBatt=0;
+                Integer sumBatt=productList.size();
+                res.setSumBatt(sumBatt);
+                res.setMonvolstd(dto.getMonvolstd());
+                res.setMoncapstd(dto.getMoncapstd());
+                for (BattInf binf:productList) {
+                    Float moncapStd=binf.getMoncapstd();
+                    //2.鑾峰彇鐢垫睜缁勫湪缁欏畾鏃堕棿娈电殑鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數)
+                    BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),null,null);
+                    if(tinf==null){
+                        nodisBatt++;
+                    }else{
+
+                        int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr());
+                        Float grouprealCap = (float) BattCapFactory.GetMonomerCap(moncapStd, hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real);
+                        if(grouprealCap>=moncapStd*badValue){
+                            goodBatt++;
+                        }
+                        if(grouprealCap<=moncapStd*damageValue){
+                            damageBatt++;
+                        }
+                        if((grouprealCap>moncapStd*damageValue)&&(grouprealCap<moncapStd*badValue)){
+                            badBatt++;
+                        }
+                    }
+                }
+                //淇濈暀5浣嶅皬鏁�
+                String goodPercent = String.format("%.5f",(goodBatt/sumBatt*100.0));
+                res.setGoodBatt(goodBatt);
+                res.setGoodPercent(goodPercent);
+                String badPercent = String.format("%.5f",(badBatt/sumBatt*100.0));
+                res.setBadBatt(badBatt);
+                res.setBadPercent(badPercent);
+                String damagePercent = String.format("%.5f",(damageBatt/sumBatt*100.0));
+                res.setDamagebatt(damageBatt);
+                res.setDamagePercent(damagePercent);
+                String nodisPercent = String.format("%.5f",(nodisBatt/sumBatt*100.0));
+                res.setNodisbatt(nodisBatt);
+                res.setNodisPercent(nodisPercent);
+                res.setScore(0f);
+                reslist.add(res);
+            }
+        }
+    }
+
+    //閫夊搧鐗岋紝涓嶉�夋椂闂�
+    private void groupby2(SocreHehaviorDto dto,List<ResSocreHehavior> reslist, Map<String, List<BattInf>> map) {
+        //鑾峰彇鏍稿浼樺姡锛屾崯鍧忓弬鏁�
+        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();
+                }
+            }
+        }
+        for (String groupType : map.keySet()) {
+            List<BattInf> list=map.get(groupType);
+            Map<String,List<BattInf>> timeMap=list.stream().collect(Collectors.groupingBy(item -> item.getBattYear().toString()));
+            for (String time : timeMap.keySet()) {
+                List<BattInf> timeList=timeMap.get(time);
+                ResSocreHehavior res=new ResSocreHehavior();
+                res.setProduct(dto.getProduct());
+                res.setInuseYear(time+"骞村唴");
+                Integer goodBatt=0;
+                Integer badBatt=0;
+                Integer damageBatt=0;
+                Integer nodisBatt=0;
+                Integer sumBatt=timeList.size();
+                res.setSumBatt(sumBatt);
+                res.setMonvolstd(dto.getMonvolstd());
+                res.setMoncapstd(dto.getMoncapstd());
+                for (BattInf binf:timeList) {
+                    Float moncapStd=binf.getMoncapstd();
+                    //2.鑾峰彇鐢垫睜缁勫湪缁欏畾鏃堕棿娈电殑鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數)
+                    BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),null,null);
+                    if(tinf==null){
+                        nodisBatt++;
+                    }else{
+                        int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr());
+                        Float grouprealCap = (float) BattCapFactory.GetMonomerCap(moncapStd, hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real);
+                        if(grouprealCap>=moncapStd*badValue){
+                            goodBatt++;
+                        }
+                        if(grouprealCap<=moncapStd*damageValue){
+                            damageBatt++;
+                        }
+                        if((grouprealCap>moncapStd*damageValue)&&(grouprealCap<moncapStd*badValue)){
+                            badBatt++;
+                        }
+                    }
+                }
+                //淇濈暀5浣嶅皬鏁�
+                String goodPercent = String.format("%.5f",(goodBatt/sumBatt*100.0));
+                res.setGoodBatt(goodBatt);
+                res.setGoodPercent(goodPercent);
+                String badPercent = String.format("%.5f",(badBatt/sumBatt*100.0));
+                res.setBadBatt(badBatt);
+                res.setBadPercent(badPercent);
+                String damagePercent = String.format("%.5f",(damageBatt/sumBatt*100.0));
+                res.setDamagebatt(damageBatt);
+                res.setDamagePercent(damagePercent);
+                String nodisPercent = String.format("%.5f",(nodisBatt/sumBatt*100.0));
+                res.setNodisbatt(nodisBatt);
+                res.setNodisPercent(nodisPercent);
+                res.setScore(0f);
+                reslist.add(res);
+            }
+        }
+    }
+
+    //閫夊搧鐗岋紝閫夋椂闂�
+    private void groupby1(SocreHehaviorDto dto,List<ResSocreHehavior> reslist, Map<String, List<BattInf>> map) {
+        //鑾峰彇鏍稿浼樺姡锛屾崯鍧忓弬鏁�
+        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();
+                }
+            }
+        }
+        for (String groupType : map.keySet()) {
+            List<BattInf> list=map.get(groupType);
+            ResSocreHehavior res=new ResSocreHehavior();
+            res.setProduct(dto.getProduct());
+            res.setInuseYear(dto.getInuseYear()+"骞村唴");
+            Integer goodBatt=0;
+            Integer badBatt=0;
+            Integer damageBatt=0;
+            Integer nodisBatt=0;
+            Integer sumBatt=list.size();
+            res.setSumBatt(sumBatt);
+            res.setMonvolstd(dto.getMonvolstd());
+            res.setMoncapstd(dto.getMoncapstd());
+            for (BattInf binf:list) {
+                Float moncapStd=binf.getMoncapstd();
+                //2.鑾峰彇鐢垫睜缁勫湪缁欏畾鏃堕棿娈电殑鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數)
+                BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),null,null);
+                if(tinf==null){
+                    nodisBatt++;
+                }else{
+                    int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr());
+                    Float grouprealCap = (float) BattCapFactory.GetMonomerCap(moncapStd, hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real);
+                    if(grouprealCap>=moncapStd*badValue){
+                        goodBatt++;
+                    }
+                    if(grouprealCap<=moncapStd*damageValue){
+                        damageBatt++;
+                    }
+                    if((grouprealCap>moncapStd*damageValue)&&(grouprealCap<moncapStd*badValue)){
+                        badBatt++;
+                    }
+                }
+            }
+            //淇濈暀5浣嶅皬鏁�
+            String goodPercent = String.format("%.5f",(goodBatt/sumBatt*100.0));
+            res.setGoodBatt(goodBatt);
+            res.setGoodPercent(goodPercent);
+            String badPercent = String.format("%.5f",(badBatt/sumBatt*100.0));
+            res.setBadBatt(badBatt);
+            res.setBadPercent(badPercent);
+            String damagePercent = String.format("%.5f",(damageBatt/sumBatt*100.0));
+            res.setDamagebatt(damageBatt);
+            res.setDamagePercent(damagePercent);
+            String nodisPercent = String.format("%.5f",(nodisBatt/sumBatt*100.0));
+            res.setNodisbatt(nodisBatt);
+            res.setNodisPercent(nodisPercent);
+            res.setScore(0f);
+            reslist.add(res);
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1