From 9e00ddb22f97d49567aaea7a228a39f89cef71de Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期五, 20 六月 2025 14:59:21 +0800
Subject: [PATCH] 历史测试数据详情

---
 src/main/java/com/whyc/service/BatttestdataInfService.java       |    8 ++++++++
 src/main/java/com/whyc/service/BatttestdataIdService.java        |   22 ++++++++++++++++++++++
 src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataId.java |    8 ++++++++
 3 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataId.java b/src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataId.java
index d37a080..efec285 100644
--- a/src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataId.java
+++ b/src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataId.java
@@ -1,6 +1,7 @@
 package com.whyc.pojo.db_batt_testdata;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -82,5 +83,12 @@
     @ApiModelProperty(value = "鍗曚綋鍐呴樆")
     private Float monRes;
 
+    @TableField(exist = false)
+    private Float realCap;
 
+    @TableField(exist = false)
+    private Float restCap;
+
+    @TableField(exist = false)
+    private String percentCap;
 }
diff --git a/src/main/java/com/whyc/service/BatttestdataIdService.java b/src/main/java/com/whyc/service/BatttestdataIdService.java
index bdc2852..e3949e4 100644
--- a/src/main/java/com/whyc/service/BatttestdataIdService.java
+++ b/src/main/java/com/whyc/service/BatttestdataIdService.java
@@ -1,8 +1,13 @@
 package com.whyc.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.whyc.dto.Response;
+import com.whyc.factory.BattCapFactory;
+import com.whyc.mapper.BatttestdataInfMapper;
 import com.whyc.mapper.CommonMapper;
 import com.whyc.pojo.db_batt_testdata.BatttestdataId;
+import com.whyc.pojo.db_batt_testdata.BatttestdataInf;
+import com.whyc.pojo.db_station.BattInf;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -16,6 +21,11 @@
     @Resource
     private CommonMapper commonMapper;
 
+    @Autowired
+    private BatttestdataInfService tinfService;
+
+    @Autowired
+    private BattInfService binfService;
     //鎵捐繖娆℃斁鐢电殑鎸囧畾鐨勪竴绗旀暟鎹�
     public List<BatttestdataId> getLastDataByBattgroupId(Integer battgroupId, Integer testRecordCount, Integer recordNum) {
         List<BatttestdataId> list=subTablePageInfoService.getLastDataByBattgroupId(battgroupId,  testRecordCount, recordNum);
@@ -29,6 +39,18 @@
             return new Response().set(1,false,battgroupId+"鐢垫睜缁勬壘涓嶅埌绗�"+testRecordCount+"娆℃斁鐢佃褰�");
         }
         List<BatttestdataId> list=subTablePageInfoService.getTinfDataWithTestRecordCount(tableName,testRecordCount,recordNum,granularity);
+        //鑾峰彇鐢垫睜缁勪俊鎭�
+        BattInf binf = binfService.getBinfByBattgroupId(battgroupId);
+        //鑾峰彇杩欎竴娆$殑鏀剧數淇℃伅
+        BatttestdataInf tinf=tinfService.getTinfByTestRecordCount(battgroupId,testRecordCount);
+        int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr());
+        for (BatttestdataId data:list) {
+            Float realCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(),data.getMonVol() , tinf.getGroupVol(), BattCapFactory.CapType_Real);
+            Float restcap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Rest);
+            data.setRealCap(realCap);
+            data.setRestCap(restcap);
+            data.setPercentCap(String.format("%.5f",(realCap/binf.getMoncapstd()*100)));
+        }
         return new Response().setII(1,list.size()>0,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 e2eb5c4..e288db4 100644
--- a/src/main/java/com/whyc/service/BatttestdataInfService.java
+++ b/src/main/java/com/whyc/service/BatttestdataInfService.java
@@ -997,4 +997,12 @@
     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);
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1