From 84403b5ebe123b200f4bfba5848dd8307d99e8d2 Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期二, 10 六月 2025 17:20:58 +0800
Subject: [PATCH] 实时推送添加状态对应关系

---
 src/main/java/com/whyc/service/BatttestdataInfService.java |   92 +++++++++++++++++++++++
 src/main/java/com/whyc/dto/Statistic/PerformanceStic.java  |   22 +++++
 src/main/java/com/whyc/webSocket/RealTimeSocket.java       |    5 +
 src/main/java/com/whyc/mapper/BattAlmparamMapper.java      |    6 +
 src/main/resources/mapper/BattAlmparamMapper.xml           |   33 ++++++++
 src/main/java/com/whyc/controller/StatisticController.java |    8 ++
 src/main/java/com/whyc/service/BattAlmparamService.java    |   11 ++
 src/main/java/com/whyc/dto/Real/TopDto.java                |    8 ++
 8 files changed, 184 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/whyc/controller/StatisticController.java b/src/main/java/com/whyc/controller/StatisticController.java
index 77c5df3..a42096d 100644
--- a/src/main/java/com/whyc/controller/StatisticController.java
+++ b/src/main/java/com/whyc/controller/StatisticController.java
@@ -83,6 +83,14 @@
         return battTinfService.getDischr6Statistic(stic);
     }
 
+    @ApiOperation(value = "鐢垫睜缁勭數姹犳�ц兘缁熻锛堟湭鏀剧數锛屼紭绉�锛屽姡鍖栵紝鎹熷潖锛夌粺璁�(1.2.8/9/10)")
+    @PostMapping("getPerformanceStatistic")
+    public Response getPerformanceStatistic(@RequestBody PerformanceStic stic){
+        User uinf= ActionUtil.getUser();
+        stic.setUid(uinf.getId());
+        return battTinfService.getPerformanceStatistic(stic);
+    }
+
 
     @ApiOperation(value = "绔欑偣淇℃伅缁熻(1.2.11)")
     @PostMapping("getStationStatistic")
diff --git a/src/main/java/com/whyc/dto/Real/TopDto.java b/src/main/java/com/whyc/dto/Real/TopDto.java
index 558f932..5ac8f55 100644
--- a/src/main/java/com/whyc/dto/Real/TopDto.java
+++ b/src/main/java/com/whyc/dto/Real/TopDto.java
@@ -5,9 +5,13 @@
 @Data
 public class TopDto {
     private Integer systemState;  //绯荤粺鐘舵��
+    private String systemStateName;
     private Integer devState;    //璁惧鐘舵��
+    private String devStateName;
     private Integer battState;   //鐢垫睜鐘舵��
+    private String battStateName;
     private Integer pwrState;    //鐢垫簮鐘舵��
+    private String pwrStateName;
     private Float vbusVol;      //姣嶇嚎鐢靛帇
     private Float onlineVol;   //鍦ㄧ嚎鐢靛帇
     private Integer battALmNum;//鐢垫睜缁勫疄鏃跺憡璀︽暟
@@ -34,9 +38,13 @@
 
     public TopDto() {
         this.systemState = 0;
+        this.systemStateName = "";
         this.devState = 0;
+        this.devStateName = "";
         this.battState = 0;
+        this.battStateName = "";
         this.pwrState = 0;
+        this.pwrStateName="";
         this.vbusVol = 0.0f;
         this.onlineVol = 0.0f;
         this.battALmNum = 0;
diff --git a/src/main/java/com/whyc/dto/Statistic/PerformanceStic.java b/src/main/java/com/whyc/dto/Statistic/PerformanceStic.java
new file mode 100644
index 0000000..f2908db
--- /dev/null
+++ b/src/main/java/com/whyc/dto/Statistic/PerformanceStic.java
@@ -0,0 +1,22 @@
+package com.whyc.dto.Statistic;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class PerformanceStic {
+    private String provice;
+    private String city;
+    private String country;
+    private String stationName;
+    private Integer performance;//鐢垫睜鎬ц兘锛�1浼樼锛�2鍔e寲锛�3鎹熷潖 4鏈斁鐢� 涓嶄紶鍏ㄩ儴
+    private Integer uid;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date testStartTime;//寮�濮嬫椂闂�
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date testEndTime;//缁撴潫鏃堕棿
+    private Integer pageNum;
+    private Integer pageSize;
+}
\ No newline at end of file
diff --git a/src/main/java/com/whyc/mapper/BattAlmparamMapper.java b/src/main/java/com/whyc/mapper/BattAlmparamMapper.java
index d6dd6ab..ebfc057 100644
--- a/src/main/java/com/whyc/mapper/BattAlmparamMapper.java
+++ b/src/main/java/com/whyc/mapper/BattAlmparamMapper.java
@@ -1,6 +1,12 @@
 package com.whyc.mapper;
 
+import com.whyc.dto.Real.AlmDto;
 import com.whyc.pojo.db_param.BattAlmparam;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface BattAlmparamMapper extends CustomMapper<BattAlmparam>{
+    //鑾峰彇鐢垫睜鍛婅鍙傛暟
+    List<BattAlmparam> getBattAlmParam(@Param("almDto") AlmDto almDto);
 }
\ No newline at end of file
diff --git a/src/main/java/com/whyc/service/BattAlmparamService.java b/src/main/java/com/whyc/service/BattAlmparamService.java
index 02914df..1376246 100644
--- a/src/main/java/com/whyc/service/BattAlmparamService.java
+++ b/src/main/java/com/whyc/service/BattAlmparamService.java
@@ -1,10 +1,16 @@
 package com.whyc.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import com.whyc.dto.Real.AlmDto;
 import com.whyc.dto.Response;
 import com.whyc.mapper.BattAlmparamMapper;
+import com.whyc.pojo.db_param.BattAlmparam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.util.List;
 
 @Service
 public class BattAlmparamService {
@@ -12,6 +18,9 @@
     private BattAlmparamMapper mapper;
     //鑾峰彇鐢垫睜鍛婅鍙傛暟
     public Response getBattAlmParam(AlmDto almDto) {
-        return null;
+        PageHelper.startPage(almDto.getPageNum(),almDto.getPageSize());
+        List<BattAlmparam> list = mapper.getBattAlmParam(almDto);
+        PageInfo  pageInfo=new PageInfo(list);
+        return new Response().setII(1,list!=null,pageInfo,"鑾峰彇鐢垫睜鍛婅鍙傛暟");
     }
 }
\ 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 74520d7..9f9835b 100644
--- a/src/main/java/com/whyc/service/BatttestdataInfService.java
+++ b/src/main/java/com/whyc/service/BatttestdataInfService.java
@@ -791,4 +791,96 @@
         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.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(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);
+            }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,"钃勭數姹犵粍瀵规瘮鍒嗘瀽鐣岄潰锛堝悓涓�鍝佺墝鍚屼竴鏃堕棿锛�");*/
+        return null;
+    }
 }
\ 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 040de90..e7307e4 100644
--- a/src/main/java/com/whyc/webSocket/RealTimeSocket.java
+++ b/src/main/java/com/whyc/webSocket/RealTimeSocket.java
@@ -1,6 +1,7 @@
 package com.whyc.webSocket;
 
 import com.whyc.config.WebSocketConfig;
+import com.whyc.constant.BattStateEnum;
 import com.whyc.constant.DevStateEnum;
 import com.whyc.constant.FailReasonEnum;
 import com.whyc.constant.StopReasonEnum;
@@ -204,6 +205,7 @@
             BattRtstate battRtstate = battRtstateService.getBattRealInfo(realDto.getBattgroupId());
             if (battRtstate != null) {
                 topDto.setBattState(battRtstate.getBattState());
+                topDto.setBattStateName(BattStateEnum.getValue(battRtstate.getBattState()));
                 topDto.setVbusVol(battRtstate.getVbusVol());
                 topDto.setOnlineVol(battRtstate.getOnlineVol());
                 topDto.setRecordtime(ThreadLocalUtil.format(battRtstate.getRecDatetime(),1));
@@ -232,6 +234,7 @@
             DeviceState deviceState = deviceStateService.getDevRealInfo(realDto.getDevId());
             if (deviceState != null) {
                 topDto.setDevState(deviceState.getDevWorkstate());
+                topDto.setDevStateName(DevStateEnum.getValue(deviceState.getDevWorkstate()));
                 if (deviceState.getDevWorkstate() == DevStateEnum.DEVSTATE_2.getStateId()) {//鏍稿鏀剧數
                     topDto.setCaptestGroupvol(deviceState.getDevCaptestGroupvol());
                     topDto.setCaptestCurr(deviceState.getDevCaptestCurr());
@@ -260,10 +263,12 @@
                 //瀹炴椂鑾峰彇鐢垫簮淇℃伅(鏄惁瀛樺湪鐢垫簮鍛婅淇℃伅)
                 //PwrdevAcdcdata pwrdevAcdcdata = pwrdevAcdcdataService.getPwrRealInfo(realDto.getPowerId());
                 topDto.setPwrState((pwrALmNum > 0 ? 1 : 0));
+                topDto.setPwrStateName((pwrALmNum > 0 ? "鐢垫簮寮傚父" : "鐢垫簮姝e父"));
 
                 Integer allALmNum = battALmNum + devALmNum + pwrALmNum;
                 topDto.setAllALmNum(allALmNum);
                 topDto.setSystemState((allALmNum > 0 ? 1 : 0));
+                topDto.setSystemStateName((allALmNum > 0 ? "绯荤粺寮傚父" : "绯荤粺姝e父"));
             }
             return new Response().setII(1, true, topDto, "瀹炴椂椤甸潰澶撮儴鏁版嵁鎺ㄩ��");
         } catch (Exception e) {
diff --git a/src/main/resources/mapper/BattAlmparamMapper.xml b/src/main/resources/mapper/BattAlmparamMapper.xml
new file mode 100644
index 0000000..2be7e7c
--- /dev/null
+++ b/src/main/resources/mapper/BattAlmparamMapper.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.whyc.mapper.BattAlmparamMapper">
+
+    <select id="getBattAlmParam" resultType="com.whyc.pojo.db_param.BattAlmparam">
+        select distinct tb_batt_inf.*
+        ,tb_station_inf.station_type,tb_station_inf.station_name,tb_station_inf.provice,tb_station_inf.city,tb_station_inf.country,tb_station_inf.full_name
+        from db_station.tb_batt_inf,db_station.tb_station_inf
+        <where>
+            tb_batt_inf.station_id=tb_station_inf.station_id
+            <if test="stic.provice!=null">
+                and tb_station_inf.provice=#{stic.provice}
+            </if>
+            <if test="stic.city!=null">
+                and tb_station_inf.city=#{stic.city}
+            </if>
+            <if test="stic.country!=null">
+                and tb_station_inf.country=#{stic.country}
+            </if>
+            <if test="stic.stationName!=null">
+                and tb_station_inf.station_name=#{stic.stationName}
+            </if>
+            <if test="stic.uid>100">
+                and tb_batt_inf.station_id in(
+                select distinct station_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
+                where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
+                and tb_baojigroup_usr.uid=#{stic.uid}
+                )
+            </if>
+            order by tb_batt_inf.dev_id asc,battgroup_id asc
+        </where>
+    </select>
+</mapper>
\ No newline at end of file

--
Gitblit v1.9.1