From 1b8df606d7af83af8158a300d2614d86fa8828c1 Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期二, 27 五月 2025 15:52:48 +0800
Subject: [PATCH] 蓄电池核容信息统计

---
 src/main/java/com/whyc/service/BatttestdataInfService.java        |   13 ++++
 src/main/resources/mapper/BatttestdataInfMapper.xml               |   41 +++++++++++++
 src/main/java/com/whyc/controller/StatisticController.java        |   43 ++++++++++++++
 src/main/java/com/whyc/mapper/BatttestdataInfMapper.java          |    6 ++
 src/main/java/com/whyc/controller/StationInfController.java       |    7 --
 src/main/java/com/whyc/dto/Statistic/BattTinfStic.java            |   22 +++++++
 src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataInf.java |    6 ++
 7 files changed, 131 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/whyc/controller/StationInfController.java b/src/main/java/com/whyc/controller/StationInfController.java
index 34ffce1..001370e 100644
--- a/src/main/java/com/whyc/controller/StationInfController.java
+++ b/src/main/java/com/whyc/controller/StationInfController.java
@@ -25,12 +25,5 @@
         return service.getLeftStation(uinf.getId());
     }
 
-    @ApiOperation(value = "绔欑偣淇℃伅缁熻")
-    @PostMapping("getStationStatistic")
-    public Response getStationStatistic(@RequestBody StationStic stic){
-        User uinf= ActionUtil.getUser();
-        stic.setUid(uinf.getId());
-        return service.getStationStatistic(stic);
-    }
 
 }
\ 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
new file mode 100644
index 0000000..130ac3a
--- /dev/null
+++ b/src/main/java/com/whyc/controller/StatisticController.java
@@ -0,0 +1,43 @@
+package com.whyc.controller;
+
+import com.whyc.dto.Response;
+import com.whyc.dto.Statistic.BattTinfStic;
+import com.whyc.dto.Statistic.StationStic;
+import com.whyc.pojo.db_user.User;
+import com.whyc.service.BatttestdataInfService;
+import com.whyc.service.StationInfService;
+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("statistic")
+public class StatisticController {
+    @Autowired
+    private StationInfService stationInfService;
+
+    @Autowired
+    private BatttestdataInfService battTinfService;
+
+    @ApiOperation(value = "绔欑偣淇℃伅缁熻")
+    @PostMapping("getStationStatistic")
+    public Response getStationStatistic(@RequestBody StationStic stic){
+        User uinf= ActionUtil.getUser();
+        stic.setUid(uinf.getId());
+        return stationInfService.getStationStatistic(stic);
+    }
+
+    @ApiOperation(value = "钃勭數姹犳牳瀹逛俊鎭粺璁�")
+    @PostMapping("getBattTinfStatistic")
+    public Response getBattTinfStatistic(@RequestBody BattTinfStic stic){
+        User uinf= ActionUtil.getUser();
+        stic.setUid(uinf.getId());
+        return battTinfService.getBattTinfStatistic(stic);
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/com/whyc/dto/Statistic/BattTinfStic.java b/src/main/java/com/whyc/dto/Statistic/BattTinfStic.java
new file mode 100644
index 0000000..30a70aa
--- /dev/null
+++ b/src/main/java/com/whyc/dto/Statistic/BattTinfStic.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 BattTinfStic {
+    private String provice;
+    private String city;
+    private String country;
+    private String stationName;
+    private Integer uid;
+    private Integer pageNum;
+    private Integer pageSize;
+    private Integer testType;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date testStartTime;//寮�濮嬫椂闂�
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date testEndTime;//缁撴潫鏃堕棿
+}
\ No newline at end of file
diff --git a/src/main/java/com/whyc/mapper/BatttestdataInfMapper.java b/src/main/java/com/whyc/mapper/BatttestdataInfMapper.java
index 511a0d7..8652828 100644
--- a/src/main/java/com/whyc/mapper/BatttestdataInfMapper.java
+++ b/src/main/java/com/whyc/mapper/BatttestdataInfMapper.java
@@ -1,6 +1,12 @@
 package com.whyc.mapper;
 
+import com.whyc.dto.Statistic.BattTinfStic;
 import com.whyc.pojo.db_batt_testdata.BatttestdataInf;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface BatttestdataInfMapper extends CustomMapper<BatttestdataInf>{
+    //钃勭數姹犳牳瀹逛俊鎭粺璁�
+    List<BatttestdataInf> getBattTinfStatistic(@Param("stic") BattTinfStic stic);
 }
\ No newline at end of file
diff --git a/src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataInf.java b/src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataInf.java
index 5d16bc1..ef20cef 100644
--- a/src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataInf.java
+++ b/src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataInf.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;
@@ -104,5 +105,10 @@
     @ApiModelProperty(value = "灞辫タ61850鐩戞祴鏀剧數鏁版嵁鏍囪瘑銆�0锛氱洃娴嬫斁鐢碉紱1鍋滅數鏀剧數銆�")
     private Integer testDatatype;
 
+    @TableField(exist = false)
+    private String stationName;
+    @TableField(exist = false)
+    private String battgroupName;
+
 
 }
diff --git a/src/main/java/com/whyc/service/BatttestdataInfService.java b/src/main/java/com/whyc/service/BatttestdataInfService.java
index e9eb6e1..c0fb400 100644
--- a/src/main/java/com/whyc/service/BatttestdataInfService.java
+++ b/src/main/java/com/whyc/service/BatttestdataInfService.java
@@ -1,6 +1,10 @@
 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.Response;
+import com.whyc.dto.Statistic.BattTinfStic;
 import com.whyc.factory.BattCapFactory;
 import com.whyc.mapper.BattInfMapper;
 import com.whyc.mapper.BatttestdataInfMapper;
@@ -8,6 +12,8 @@
 import com.whyc.pojo.db_station.BattInf;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.util.List;
 
 @Service
 public class BatttestdataInfService {
@@ -31,4 +37,11 @@
             return 0f;
         }
     }
+    //钃勭數姹犳牳瀹逛俊鎭粺璁�
+    public Response getBattTinfStatistic(BattTinfStic stic) {
+        PageHelper.startPage(stic.getPageNum(), stic.getPageSize());
+        List<BatttestdataInf> list=mapper.getBattTinfStatistic(stic);
+        PageInfo pageInfo=new PageInfo(list);
+        return new Response().setII(1,list.size()>0,pageInfo,"钃勭數姹犳牳瀹逛俊鎭粺璁�");
+    }
 }
\ No newline at end of file
diff --git a/src/main/resources/mapper/BatttestdataInfMapper.xml b/src/main/resources/mapper/BatttestdataInfMapper.xml
new file mode 100644
index 0000000..0dd9d60
--- /dev/null
+++ b/src/main/resources/mapper/BatttestdataInfMapper.xml
@@ -0,0 +1,41 @@
+<?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.BatttestdataInfMapper">
+
+    <select id="getBattTinfStatistic" resultType="com.whyc.pojo.db_batt_testdata.BatttestdataInf">
+        select tb_batttestdata_inf.*,tb_station_inf.station_name,tb_batt_inf.battgroup_name
+        from db_batt_testdata.tb_batttestdata_inf,db_station.tb_station_inf,db_station.tb_batt_inf
+        <where>
+            tb_batttestdata_inf.battgroup_id=tb_batt_inf.battgroup_id
+            and 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.testType!=null">
+                and tb_batttestdata_inf.test_type= #{stic.testType}
+            </if>
+            <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="stic.uid>100">
+                and tb_station_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