From c3f2b09d8dc64bc7e8100c01a15cb3c933b5d70e Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期四, 05 六月 2025 09:14:22 +0800
Subject: [PATCH] 修改提交

---
 src/main/java/com/whyc/service/BatttestdataInfService.java |  188 ++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 176 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/whyc/service/BatttestdataInfService.java b/src/main/java/com/whyc/service/BatttestdataInfService.java
index d23e2bd..10b27d3 100644
--- a/src/main/java/com/whyc/service/BatttestdataInfService.java
+++ b/src/main/java/com/whyc/service/BatttestdataInfService.java
@@ -4,6 +4,7 @@
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.whyc.constant.Capperformance;
+import com.whyc.constant.StopReasonEnum;
 import com.whyc.dto.Response;
 import com.whyc.dto.Statistic.*;
 import com.whyc.factory.BattCapFactory;
@@ -96,6 +97,20 @@
         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.last("limit 1");
+        BatttestdataInf tinf = mapper.selectOne(wrapper);
+        return tinf;
+    }
+
+    //鑾峰彇鐢垫睜缁勫湪缁欏畾鏃堕棿娈电殑鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數)
+    private BatttestdataInf getLastStandardTestDataByTime(Integer battgroupId, Date testStartTime, Date testEndTime) {
+        QueryWrapper wrapper = new QueryWrapper();
+        wrapper.eq("battgroup_id", battgroupId);
+        wrapper.eq("test_type", 3);
+        wrapper.eq("test_starttype", 3);
+        wrapper.gt("test_starttime",testStartTime);
+        wrapper.lt("test_starttime",testEndTime);
         wrapper.last("  and test_timelong >= 7200 ORDER BY test_starttime DESC ");
         wrapper.last("limit 1");
         BatttestdataInf tinf = mapper.selectOne(wrapper);
@@ -305,17 +320,166 @@
         PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize());
         return new Response().setII(1,reslist.size()>0,pageInfo,"钃勭數姹犵粍瀵规瘮鍒嗘瀽鐣岄潰锛堝悓涓�鍝佺墝鍚屼竴鏃堕棿锛�");
     }
-    //鑾峰彇鐢垫睜缁勫湪缁欏畾鏃堕棿娈电殑鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數)
-    private BatttestdataInf getLastStandardTestDataByTime(Integer battgroupId, Date testStartTime, Date testEndTime) {
-        QueryWrapper wrapper = new QueryWrapper();
-        wrapper.eq("battgroup_id", battgroupId);
-        wrapper.eq("test_type", 3);
-        wrapper.eq("test_starttype", 3);
-        wrapper.gt("test_starttime",testStartTime);
-        wrapper.lt("test_starttime",testEndTime);
-        wrapper.last("  and test_timelong >= 7200 ORDER BY test_starttime DESC ");
-        wrapper.last("limit 1");
-        BatttestdataInf tinf = mapper.selectOne(wrapper);
-        return tinf;
+
+    //钃勭數姹犵粍瀵规瘮鍒嗘瀽鐣岄潰锛堜笉鍚屽搧鐗屽悓涓�鏃堕棿锛�(1.2.16)
+    public Response getBattCompare16Statistic(BattCompareStic stic) {
+        //鑾峰彇鏍稿浼樺姡锛屾崯鍧忓弬鏁�
+        List<AppParam> paramList=appParamService.getHrParam();
+        Float badValue=0f;
+        Float damageValue=0f;
+        if(paramList!=null){
+            for (AppParam param:paramList) {
+                if(param.getParamNamePsx().equals("batt_mon_deteriorate_val")){
+                    badValue=param.getParamValue();
+                }
+                if(param.getParamNamePsx().equals("batt_mon_damage_val")){
+                    damageValue=param.getParamValue();
+                }
+
+            }
+        }
+        //1鏌ヨ绗﹀悎鏉′欢鐨勭數姹犵粍
+        List<BattInf> binfList=battInfService.getBattCompare16Statistic(stic);
+        if(binfList==null||binfList.size()==0){
+            return new Response().set(1,false,"褰撳墠鐢ㄦ埛鏈鐞嗘弧瓒虫潯浠剁殑鐢垫睜缁�");
+        }
+        List<SticCompare16Res> reslist=new ArrayList<>();
+        for (BattInf binf:binfList) {
+            SticCompare16Res res=new SticCompare16Res();
+            res.setProvice(binf.getProvice());
+            res.setCity(binf.getCity());
+            res.setCountry(binf.getCountry());
+            res.setStationName(binf.getStationName());
+            res.setBattgroupName(binf.getBattgroupName());
+            res.setProduct(binf.getProduct());
+            res.setInuseTime(binf.getInuseTime());
+            res.setMonvolstd(binf.getMonvolstd());
+            res.setMoncapstd(binf.getMoncapstd());
+            //2.鑾峰彇鐢垫睜缁勫湪缁欏畾鏃堕棿娈电殑鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數)
+            BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime());
+            if(tinf==null){
+                res.setRealCap(0f);
+                res.setPrecentCap("0");
+                res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_3.getStateId()));
+                res.setStopReason("--");
+                continue;
+            }
+            res.setStopReason(StopReasonEnum.getValue(tinf.getTestStoptype()));
+            Float moncapStd=binf.getMoncapstd();
+            int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr());
+            Float grouprealCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real);
+            //Float restCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Rest);
+            res.setRealCap(grouprealCap);
+            if(grouprealCap>=moncapStd*badValue){
+                res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_1.getStateId()));
+            }
+            if(grouprealCap<=moncapStd*damageValue){
+                res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_3.getStateId()));
+            }
+            if((grouprealCap>moncapStd*damageValue)&&(grouprealCap<moncapStd*badValue)){
+                res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_2.getStateId()));
+            }
+            //淇濈暀5浣嶅皬鏁�
+            String precentCap = String.format("%.5f",(grouprealCap/binf.getMoncapstd()*100));
+            //璇勫垎鐨勯�昏緫
+            res.setScore(0f);
+            res.setPrecentCap(precentCap);
+            if(stic.getPerformance()==null){
+                reslist.add(res);
+            }else{
+                if(res.getCapperformance().equals(Capperformance.getValue(stic.getPerformance()))){
+                    reslist.add(res);
+                }
+            }
+
+        }
+        PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize());
+        return new Response().setII(1,reslist.size()>0,pageInfo,"钃勭數姹犵粍瀵规瘮鍒嗘瀽鐣岄潰锛堜笉鍚屽搧鐗屽悓涓�鏃堕棿锛�");
+    }
+    //钃勭數姹犵粍瀵规瘮鍒嗘瀽鐣岄潰锛堝悓涓�鍝佺墝涓嶅悓鏃堕棿锛�(1.2.17)
+    public Response getBattCompare17Statistic(BattCompareStic stic) {
+        //鑾峰彇鏍稿浼樺姡锛屾崯鍧忓弬鏁�
+        List<AppParam> paramList=appParamService.getHrParam();
+        Float badValue=0f;
+        Float damageValue=0f;
+        if(paramList!=null){
+            for (AppParam param:paramList) {
+                if(param.getParamNamePsx().equals("batt_mon_deteriorate_val")){
+                    badValue=param.getParamValue();
+                }
+                if(param.getParamNamePsx().equals("batt_mon_damage_val")){
+                    damageValue=param.getParamValue();
+                }
+
+            }
+        }
+        //1鏌ヨ绗﹀悎鏉′欢鐨勭數姹犵粍
+        List<BattInf> binfList=battInfService.getBattCompare15Statistic(stic);
+        if(binfList==null||binfList.size()==0){
+            return new Response().set(1,false,"褰撳墠鐢ㄦ埛鏈鐞嗘弧瓒虫潯浠剁殑鐢垫睜缁�");
+        }
+        List<SticCompare17Res> reslist=new ArrayList<>();
+        for (BattInf binf:binfList) {
+            SticCompare17Res res=new SticCompare17Res();
+            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.setInuseTime(binf.getInuseTime());
+            res.setMonvolstd(binf.getMonvolstd());
+            //2.鑾峰彇鐢垫睜缁勫湪缁欏畾鏃堕棿娈电殑鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數)
+            BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime());
+            /*if(tinf==null){
+                res.setMonrealCap(0f);
+                res.setMonprecentCap("0");
+                res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_3.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_3.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()==0){
+                reslist.add(res);
+            }else{
+                if(res.getCapperformance().equals(Capperformance.getValue(stic.getPerformance()))){
+                    reslist.add(res);
+                }
+            }
+*/
+        }
+        PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize());
+        return new Response().setII(1,reslist.size()>0,pageInfo,"钃勭數姹犵粍瀵规瘮鍒嗘瀽鐣岄潰锛堝悓涓�鍝佺墝鍚屼竴鏃堕棿锛�");
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1