From 2a0d63149431539aae2abf67b1302c9041220796 Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期二, 10 六月 2025 14:53:38 +0800
Subject: [PATCH] 实时推送修改

---
 src/main/java/com/whyc/service/BatttestdataInfService.java |   50 +++++++-----------------
 src/main/java/com/whyc/webSocket/RealTimeSocket.java       |   14 ++++++
 src/main/resources/mapper/BatttestdataInfMapper.xml        |   19 +++++++++
 src/main/java/com/whyc/mapper/BatttestdataInfMapper.java   |    4 ++
 4 files changed, 51 insertions(+), 36 deletions(-)

diff --git a/src/main/java/com/whyc/mapper/BatttestdataInfMapper.java b/src/main/java/com/whyc/mapper/BatttestdataInfMapper.java
index 8652828..bff2b84 100644
--- a/src/main/java/com/whyc/mapper/BatttestdataInfMapper.java
+++ b/src/main/java/com/whyc/mapper/BatttestdataInfMapper.java
@@ -4,9 +4,13 @@
 import com.whyc.pojo.db_batt_testdata.BatttestdataInf;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
 import java.util.List;
 
 public interface BatttestdataInfMapper extends CustomMapper<BatttestdataInf>{
     //钃勭數姹犳牳瀹逛俊鎭粺璁�
     List<BatttestdataInf> getBattTinfStatistic(@Param("stic") BattTinfStic stic);
+    //鑾峰彇鐢垫睜缁勬湭鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數)
+    List<BatttestdataInf> getNoDischargeData(@Param("battgroupId") Integer battgroupId,@Param("testStartTime") Date testStartTime
+            , @Param("testEndTime") Date testEndTime, @Param("typeList") List<Integer> typeList);
 }
\ No newline at end of file
diff --git a/src/main/java/com/whyc/service/BatttestdataInfService.java b/src/main/java/com/whyc/service/BatttestdataInfService.java
index b8f010d..7dbf755 100644
--- a/src/main/java/com/whyc/service/BatttestdataInfService.java
+++ b/src/main/java/com/whyc/service/BatttestdataInfService.java
@@ -722,7 +722,7 @@
             return new Response().set(1,false,"褰撳墠鐢ㄦ埛鏈鐞嗘弧瓒虫潯浠剁殑鐢垫睜缁�");
         }
         List<SticDischarge6Res> reslist=new ArrayList<>();
-        /*for (BattInf binf:binfList) {
+        for (BattInf binf:binfList) {
             //鏌ヨ鐢垫睜缁勬墍鍦ㄧ殑鐝粍
             String  groupName=bjService.getGroupName(binf.getPowerId());
             SticDischarge6Res res=new SticDischarge6Res();
@@ -731,16 +731,11 @@
             res.setCountry(binf.getCountry());
             res.setStationName(binf.getStationName());
             res.setBattgroupName(binf.getBattgroupName());
-            //2.鑾峰彇鐢垫睜缁勬湭鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數)
+            //鑾峰彇鐢垫睜缁勬湭鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數)
+            getNoDischargeData(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime(),stic.getTypeList(),res);
+            //2.鑾峰彇鐢垫睜缁勫湪缁欏畾鏃堕棿娈电殑鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數)
             BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime());
             if(tinf==null){
-                res.setRealCap(0f);
-                res.setTestStartTime(ThreadLocalUtil.parse("1972-01-01 00:00:00",1));
-                res.setTestTimelong(0);
-                res.setTestCap(0f);
-                res.setStopReason("");
-                res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_4.getStateId()));
-                res.setDisChargeType(2);
                 if(!groupName.equals("none")){
                     BanZu bz= (BanZu) map.get(groupName);
                     int nochargeNum=bz.getNochargeNum();
@@ -755,33 +750,18 @@
                 bz.setDischargeNum(dischargeNum+1);
                 map.put(groupName,bz);
             }
-            res.setTestStartTime(tinf.getTestStarttime());
-            res.setTestTimelong(tinf.getTestTimelong());
-            res.setTestCap(tinf.getTestCap());
-            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);
-            res.setRealCap(grouprealCap);
-            res.setDisChargeType(1);
-            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()));
-            }
-            if(stic.getDisChargeType()==null){
-                reslist.add(res);
-            }else{
-                if(res.getDisChargeType()==stic.getDisChargeType()){
-                    reslist.add(res);
-                }
-            }
-        }*/
+        }
         PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize());
         return new Response().setII(1,reslist.size()>0,pageInfo,"鏈勾搴︽湭鏀剧數鏁伴噺缁熻");
     }
+    //2.鑾峰彇鐢垫睜缁勬湭鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數)
+    private void getNoDischargeData(Integer battgroupId, Date testStartTime, Date testEndTime, List<Integer> typeList, SticDischarge6Res res) {
+        List<BatttestdataInf> tinfList=mapper.getNoDischargeData(battgroupId,testStartTime,testEndTime,typeList);
+        if(tinfList!=null&&tinfList.size()>0){
+            res.setErrorNum(tinfList.size());
+        }else {
+            res.setErrorNum(0);
+            res.setStopList(new ArrayList<>());
+        }
+    }
 }
\ No newline at end of file
diff --git a/src/main/java/com/whyc/webSocket/RealTimeSocket.java b/src/main/java/com/whyc/webSocket/RealTimeSocket.java
index bad7677..16d5062 100644
--- a/src/main/java/com/whyc/webSocket/RealTimeSocket.java
+++ b/src/main/java/com/whyc/webSocket/RealTimeSocket.java
@@ -498,7 +498,19 @@
         List<Integer> maxResNumList = new ArrayList<>();
         List<Integer> minResNumList = new ArrayList<>();
           //璁$畻闆嗗悎涓崟浣撶數鍘嬶紝鍐呴樆锛屾俯搴︼紝瀹归噺鐨勬渶澶ф渶灏忓��
-        for (BattRtdata rtdata:battRtdataList) {
+        for (int i=0;i<battRtdataList.size();i++) {
+            BattRtdata rtdata=battRtdataList.get(i);
+            if(i==0){
+                //璧嬪�煎垵濮嬪��
+                maxVol = rtdata.getMonVol();
+                minVol = rtdata.getMonVol();
+                maxTmp = rtdata.getMonTmp();
+                minTmp = rtdata.getMonTmp();
+                maxRes = rtdata.getMonRes();
+                minRes = rtdata.getMonRes();
+                maxCap = rtdata.getMonCap();
+                minCap = rtdata.getMonCap();
+            }
             if(rtdata.getMonVol()>=maxVol){
                 maxVol = rtdata.getMonVol();
             }
diff --git a/src/main/resources/mapper/BatttestdataInfMapper.xml b/src/main/resources/mapper/BatttestdataInfMapper.xml
index 756b648..2ca8ffb 100644
--- a/src/main/resources/mapper/BatttestdataInfMapper.xml
+++ b/src/main/resources/mapper/BatttestdataInfMapper.xml
@@ -41,4 +41,23 @@
         </where>
         order by tb_batttestdata_inf.battgroup_id asc, tb_batttestdata_inf.test_record_count asc
     </select>
+    <select id="getNoDischargeData" resultType="com.whyc.pojo.db_batt_testdata.BatttestdataInf">
+        select * from db_batt_testdata.tb_batttestdata_inf
+        <where>
+            battgroup_id=#{battgroupId} and test_type=3
+            and (test_starttype!=3 or test_timelong &lt;7200)
+            <if test="stic.testStartTime!=null">
+                and tb_batttestdata_inf.test_starttime>=#{stic.testStartTime}
+            </if>
+            <if test="stic.testEndTime!=null">
+                and tb_batttestdata_inf.test_starttime&lt;=#{stic.testEndTime}
+            </if>
+            <if test="typeList!=null">
+                and test_stoptype in
+                <foreach item="item" index="index" collection="typeList" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.1