From 494a59976459b88ac0f0a13c5893b906e10bdfa0 Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期五, 30 五月 2025 16:17:56 +0800
Subject: [PATCH] 单体统计修改

---
 src/main/java/com/whyc/mapper/DevAlmparamMapper.java        |    6 +
 src/main/java/com/whyc/controller/StatisticController.java  |    8 ++
 src/main/resources/mapper/BattInfMapper.xml                 |   27 ++++++
 src/main/java/com/whyc/dto/Statistic/MonStic.java           |   18 ++++
 src/main/java/com/whyc/service/BattInfService.java          |    5 +
 src/main/java/com/whyc/service/BatttestdataInfService.java  |   30 +++++++
 src/main/java/com/whyc/service/DevAlmparamService.java      |   11 ++
 src/main/java/com/whyc/mapper/BattAlmparamMapper.java       |    6 +
 src/main/java/com/whyc/service/SubTablePageInfoService.java |   29 +++++++
 src/main/java/com/whyc/controller/AlmParamController.java   |   34 ++++++++
 src/main/java/com/whyc/service/BatttestdataIdService.java   |   12 +++
 src/main/java/com/whyc/service/BattAlmparamService.java     |   17 ++++
 src/main/java/com/whyc/mapper/BattInfMapper.java            |    3 
 13 files changed, 206 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/whyc/controller/AlmParamController.java b/src/main/java/com/whyc/controller/AlmParamController.java
new file mode 100644
index 0000000..3ff7097
--- /dev/null
+++ b/src/main/java/com/whyc/controller/AlmParamController.java
@@ -0,0 +1,34 @@
+package com.whyc.controller;
+
+import com.whyc.dto.Real.AlmDto;
+import com.whyc.dto.Response;
+import com.whyc.service.BattAlmparamService;
+import com.whyc.service.DevAlmparamService;
+import com.whyc.util.ActionUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@Api(tags = "鍛婅绠$悊")
+@RequestMapping("almParam")
+public class AlmParamController {
+    @Autowired
+    private BattAlmparamService battAlmparamService;
+
+    @Autowired
+    private DevAlmparamService devAlmparamService;
+
+
+    @PostMapping("getBattAlmParam")
+    @ApiOperation("鑾峰彇鐢垫睜鍛婅鍙傛暟")
+    public Response getBattAlmParam(@RequestBody AlmDto almDto){
+        almDto.setUid(ActionUtil.getUser().getId());
+        return battAlmparamService.getBattAlmParam(almDto);
+    }
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/whyc/controller/StatisticController.java b/src/main/java/com/whyc/controller/StatisticController.java
index 562dae7..a0e4991 100644
--- a/src/main/java/com/whyc/controller/StatisticController.java
+++ b/src/main/java/com/whyc/controller/StatisticController.java
@@ -3,6 +3,7 @@
 import com.whyc.dto.Response;
 import com.whyc.dto.Statistic.BattTinfStic;
 import com.whyc.dto.Statistic.DeviceStateStic;
+import com.whyc.dto.Statistic.MonStic;
 import com.whyc.dto.Statistic.StationStic;
 import com.whyc.pojo.db_user.User;
 import com.whyc.service.*;
@@ -57,6 +58,13 @@
         return battService.getBattStatistic(stic);
     }
 
+    @ApiOperation(value = "鍗曡妭鏁伴噺缁熻")
+    @PostMapping("getMonStatistic")
+    public Response getMonStatistic(@RequestBody MonStic stic){
+        User uinf= ActionUtil.getUser();
+        stic.setUid(uinf.getId());
+        return battTinfService.getMonStatistic(stic);
+    }
 
 
     @ApiOperation(value = "绔欑偣淇℃伅缁熻")
diff --git a/src/main/java/com/whyc/dto/Statistic/MonStic.java b/src/main/java/com/whyc/dto/Statistic/MonStic.java
new file mode 100644
index 0000000..716e7b6
--- /dev/null
+++ b/src/main/java/com/whyc/dto/Statistic/MonStic.java
@@ -0,0 +1,18 @@
+package com.whyc.dto.Statistic;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class MonStic {
+    private String product;
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai")
+    private Date   startTime;
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai")
+    private Date   endTime;
+    private Float moncapstd;
+    private Float monvolstd;
+    private Integer uid;
+}
\ 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
new file mode 100644
index 0000000..d6dd6ab
--- /dev/null
+++ b/src/main/java/com/whyc/mapper/BattAlmparamMapper.java
@@ -0,0 +1,6 @@
+package com.whyc.mapper;
+
+import com.whyc.pojo.db_param.BattAlmparam;
+
+public interface BattAlmparamMapper extends CustomMapper<BattAlmparam>{
+}
\ No newline at end of file
diff --git a/src/main/java/com/whyc/mapper/BattInfMapper.java b/src/main/java/com/whyc/mapper/BattInfMapper.java
index abee1d2..539672d 100644
--- a/src/main/java/com/whyc/mapper/BattInfMapper.java
+++ b/src/main/java/com/whyc/mapper/BattInfMapper.java
@@ -2,6 +2,7 @@
 
 import com.whyc.dto.BattDto;
 import com.whyc.dto.InfoDto;
+import com.whyc.dto.Statistic.MonStic;
 import com.whyc.dto.Statistic.StationStic;
 import com.whyc.pojo.db_station.BattInf;
 import org.apache.ibatis.annotations.Param;
@@ -37,4 +38,6 @@
     Integer getBattCountBydevId(Integer devId);
     //钃勭數姹犵粍淇℃伅缁熻
     List<BattInf> getBattStatistic(@Param("stic") StationStic stic);
+    //鍗曚綋缁熻鏌ヨ绗﹀悎鏉′欢鐨勭數姹犵粍
+    List<BattInf> getMonStatistic(@Param("stic") MonStic stic);
 }
\ No newline at end of file
diff --git a/src/main/java/com/whyc/mapper/DevAlmparamMapper.java b/src/main/java/com/whyc/mapper/DevAlmparamMapper.java
new file mode 100644
index 0000000..2190c88
--- /dev/null
+++ b/src/main/java/com/whyc/mapper/DevAlmparamMapper.java
@@ -0,0 +1,6 @@
+package com.whyc.mapper;
+
+import com.whyc.pojo.db_param.DevAlmparam;
+
+public interface DevAlmparamMapper extends CustomMapper<DevAlmparam>{
+}
\ 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
new file mode 100644
index 0000000..02914df
--- /dev/null
+++ b/src/main/java/com/whyc/service/BattAlmparamService.java
@@ -0,0 +1,17 @@
+package com.whyc.service;
+
+import com.whyc.dto.Real.AlmDto;
+import com.whyc.dto.Response;
+import com.whyc.mapper.BattAlmparamMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class BattAlmparamService {
+    @Autowired(required = false)
+    private BattAlmparamMapper mapper;
+    //鑾峰彇鐢垫睜鍛婅鍙傛暟
+    public Response getBattAlmParam(AlmDto almDto) {
+        return null;
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/com/whyc/service/BattInfService.java b/src/main/java/com/whyc/service/BattInfService.java
index f9890c4..9ce4310 100644
--- a/src/main/java/com/whyc/service/BattInfService.java
+++ b/src/main/java/com/whyc/service/BattInfService.java
@@ -8,6 +8,7 @@
 import com.whyc.dto.InfoDto;
 import com.whyc.dto.Real.QuarterDto;
 import com.whyc.dto.Response;
+import com.whyc.dto.Statistic.MonStic;
 import com.whyc.dto.Statistic.StationStic;
 import com.whyc.factory.InfoFactory;
 import com.whyc.mapper.BattInfMapper;
@@ -424,4 +425,8 @@
         PageInfo<BattInf> pageInfo=new PageInfo<>(list);
         return new Response().setII(1,list.size()>0,pageInfo,"钃勭數姹犵粍淇℃伅缁熻");
     }
+    //鍗曚綋缁熻鏌ヨ绗﹀悎鏉′欢鐨勭數姹犵粍
+    public List<BattInf> getMonStatistic(MonStic stic) {
+        return mapper.getMonStatistic(stic);
+    }
 }
\ No newline at end of file
diff --git a/src/main/java/com/whyc/service/BatttestdataIdService.java b/src/main/java/com/whyc/service/BatttestdataIdService.java
index 93f1162..dac9615 100644
--- a/src/main/java/com/whyc/service/BatttestdataIdService.java
+++ b/src/main/java/com/whyc/service/BatttestdataIdService.java
@@ -1,7 +1,19 @@
 package com.whyc.service;
 
+import com.whyc.pojo.db_batt_testdata.BatttestdataId;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.util.List;
 
 @Service
 public class BatttestdataIdService {
+    @Autowired
+    private SubTablePageInfoService subTablePageInfoService;
+
+    //鎵捐繖娆℃斁鐢电殑鏈�鍚庝竴绗旀暟鎹�
+    public List<BatttestdataId> getLastDataByBattgroupId(Integer battgroupId, Integer testRecordCount, Integer recordNum) {
+        List<BatttestdataId> list=subTablePageInfoService.getLastDataByBattgroupId(battgroupId,  testRecordCount, recordNum);
+        return list;
+    }
 }
\ 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 84e0ab1..88735ab 100644
--- a/src/main/java/com/whyc/service/BatttestdataInfService.java
+++ b/src/main/java/com/whyc/service/BatttestdataInfService.java
@@ -5,10 +5,12 @@
 import com.github.pagehelper.PageInfo;
 import com.whyc.dto.Response;
 import com.whyc.dto.Statistic.BattTinfStic;
+import com.whyc.dto.Statistic.MonStic;
 import com.whyc.dto.Statistic.StationStic;
 import com.whyc.factory.BattCapFactory;
 import com.whyc.mapper.BattInfMapper;
 import com.whyc.mapper.BatttestdataInfMapper;
+import com.whyc.pojo.db_batt_testdata.BatttestdataId;
 import com.whyc.pojo.db_batt_testdata.BatttestdataInf;
 import com.whyc.pojo.db_ram_db.BattRtstate;
 import com.whyc.pojo.db_station.BattInf;
@@ -27,6 +29,10 @@
 
     @Autowired(required = false)
     private BattInfService battInfService;
+
+    @Autowired(required = false)
+    private BatttestdataIdService battTestdataIdService;
+
 
 
     //鑾峰彇鏈�鍚庝竴娆℃祴璇曟暟鎹苟璁$畻鍓╀綑瀹归噺
@@ -56,6 +62,7 @@
                 Float restCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Rest);
                 Float realCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real);
                 tinf.setRestCap(restCap);
+                tinf.setRealCap(realCap);
                 tinf.setRestTime(0f);
                 //鑾峰彇鐢垫睜缁勫疄鏃舵暟鎹�
                 BattRtstate battRtstate=rtstateService.getBattRealInfo(tinf.getBattgroupId());
@@ -87,4 +94,27 @@
         BatttestdataInf tinf = mapper.selectOne(wrapper);
         return tinf;
     }
+    /*鍗曡妭鏁伴噺缁熻
+      1绛涢�夋弧瓒虫潯浠剁殑鐢垫睜缁勶紝鎵炬渶杩戜竴娆℃爣鍑嗘牳瀹规斁鐢佃褰曠殑鏈�鍚庝竴绗旀暟鎹�
+      2鍐嶆寜鐓у叕寮忚绠楀崟浣撳疄闄呭閲忥紝
+      3鐒跺悗鎵惧埌鍒ゆ柇浼樼锛屽姡鍖栵紝鎹熷潖鐨勫弬鏁帮紝寰楀埌缁撴灉銆�
+      4娴厖鐢靛帇鍥撅紝闇�瑕佹樉绀哄崟浣�+瀹炴椂鏁版嵁鐨勫崟浣撶數鍘嬶紝鍗曚綋鍐呴樆
+    */
+    public Response getMonStatistic(MonStic stic) {
+        List<BattInf> binfList=battInfService.getMonStatistic(stic);
+        if(binfList!=null&&binfList.size()>0){
+            for (BattInf binf:binfList) {
+                BatttestdataInf tinf =getLastStandardTestData(binf.getBattgroupId());
+                if(tinf!=null){
+                    //鎵捐繖娆℃斁鐢电殑鏈�鍚庝竴绗旀暟鎹�
+                    List<BatttestdataId> idDataList=battTestdataIdService.getLastDataByBattgroupId(tinf.getBattgroupId(),tinf.getTestRecordCount(),tinf.getRecordNum());
+                    for (BatttestdataId data:idDataList) {
+                        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);
+                    }
+                }
+            }
+        }
+        return new Response().set(1,false,"");
+    }
 }
\ No newline at end of file
diff --git a/src/main/java/com/whyc/service/DevAlmparamService.java b/src/main/java/com/whyc/service/DevAlmparamService.java
new file mode 100644
index 0000000..cb92fcd
--- /dev/null
+++ b/src/main/java/com/whyc/service/DevAlmparamService.java
@@ -0,0 +1,11 @@
+package com.whyc.service;
+
+import com.whyc.mapper.DevAlmparamMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class DevAlmparamService {
+    @Autowired(required = false)
+    private DevAlmparamMapper mapper;
+}
\ No newline at end of file
diff --git a/src/main/java/com/whyc/service/SubTablePageInfoService.java b/src/main/java/com/whyc/service/SubTablePageInfoService.java
index e93f3e9..f0391a7 100644
--- a/src/main/java/com/whyc/service/SubTablePageInfoService.java
+++ b/src/main/java/com/whyc/service/SubTablePageInfoService.java
@@ -8,6 +8,7 @@
 import com.whyc.mapper.CallBack;
 import com.whyc.pojo.db_alarm.BattalarmDataHistory;
 import com.whyc.pojo.db_alarm.DevalarmDataHistory;
+import com.whyc.pojo.db_batt_testdata.BatttestdataId;
 import com.whyc.pojo.db_pwrdev_alarm.PwrdevAlarmHistory;
 import com.whyc.util.ThreadLocalUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -528,4 +529,32 @@
         });
        return list;
     }
+    //鎵捐繖娆℃斁鐢电殑鏈�鍚庝竴绗旀暟鎹�
+    public List<BatttestdataId> getLastDataByBattgroupId(Integer battgroupId, Integer testRecordCount, Integer recordNum) {
+        String sql="select   distinct * from db_batt_testdata.tb_batttestdata_"+battgroupId
+                +" where test_record_count="+testRecordCount+" and record_num="+recordNum+ " order by mon_num asc";
+        List<BatttestdataId> list = sqlExecuteService.executeQuery_call(sql, new CallBack() {
+            @Override
+            public List getResults(ResultSet rs) throws SQLException {
+                List<BatttestdataId> list=new ArrayList<>();
+                while (rs.next()){
+                    BatttestdataId data=new BatttestdataId();
+                    data.setBattgroupId(rs.getInt("battgroup_id"));
+                    data.setTestRecordCount(rs.getInt("test_record_count"));
+                    data.setTestStarttime(rs.getTimestamp("test_starttime"));
+                    data.setOnlineVol(rs.getFloat("online_vol"));
+                    data.setGroupVol(rs.getFloat("group_vol"));
+                    data.setTestCurr(rs.getFloat("test_curr"));
+                    data.setTestCap(rs.getFloat("test_cap"));
+                    data.setMonNum(rs.getInt("mon_num"));
+                    data.setMonVol(rs.getFloat("mon_vol"));
+                    data.setMonRes(rs.getFloat("mon_res"));
+                    data.setMonTmp(rs.getFloat("mon_tmp"));
+                    list.add(data);
+                }
+                return list;
+            }
+        });
+        return list;
+    }
 }
diff --git a/src/main/resources/mapper/BattInfMapper.xml b/src/main/resources/mapper/BattInfMapper.xml
index b44af18..97c223a 100644
--- a/src/main/resources/mapper/BattInfMapper.xml
+++ b/src/main/resources/mapper/BattInfMapper.xml
@@ -173,5 +173,32 @@
             order by tb_batt_inf.dev_id asc,battgroup_id asc
         </where>
     </select>
+    <select id="getMonStatistic" resultType="com.whyc.pojo.db_station.BattInf">
+        select distinct tb_batt_inf.* from db_station.tb_batt_inf
+        <where>
+            <if test="stic.product!=null">
+                and tb_batt_inf.product=#{stic.product}
+            </if>
+            <if test="stic.moncapstd!=null">
+                and tb_batt_inf.moncapstd=#{stic.moncapstd}
+            </if>
+            <if test="stic.monvolstd!=null">
+                and tb_batt_inf.monvolstd=#{stic.monvolstd}
+            </if>
+            <if test="stic.startTime!=null">
+                and tb_batt_inf.create_time>=#{stic.startTime}
+            </if>
+            <if test="stic.endTime!=null">
+                and tb_batt_inf.create_time&lt;=#{stic.endTime}
+            </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>
+        </where>
+    </select>
 
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.1