From 21db6e4c4c11099eb053c837a0a207a537bb6453 Mon Sep 17 00:00:00 2001
From: 李宇 <986321569@qq.com>
Date: 星期一, 18 一月 2021 16:31:12 +0800
Subject: [PATCH] 添加危废全年统计接口

---
 src/main/java/com/nanometer/smartlab/service/HazardousWasteServiceImpl.java |    5 ++
 src/main/java/com/nanometer/smartlab/dao/HazardousWasteMapper.java          |    2 +
 src/main/java/com/nanometer/smartlab/service/HazardousWasteService.java     |    2 +
 src/main/java/com/nanometer/smartlab/api/ApiAction.java                     |   33 +++++++++++++++-
 src/main/java/com/nanometer/smartlab/dao/HazardousWasteMapper.xml           |   50 +++++++++++++++++-------
 智慧实验室接口.docx                                                                |    0 
 6 files changed, 75 insertions(+), 17 deletions(-)

diff --git a/src/main/java/com/nanometer/smartlab/api/ApiAction.java b/src/main/java/com/nanometer/smartlab/api/ApiAction.java
index 9f38637..c13f87d 100644
--- a/src/main/java/com/nanometer/smartlab/api/ApiAction.java
+++ b/src/main/java/com/nanometer/smartlab/api/ApiAction.java
@@ -1576,7 +1576,7 @@
      */
     @ResponseBody
     @RequestMapping("hazardousWaste/getWasteInfo")
-    public Object getLabAndUser(@RequestParam(required=true) int adminFlag,@RequestParam(required=true) String name,@RequestParam(required=false) String status
+    public Object getWasteInfo(@RequestParam(required=true) int adminFlag,@RequestParam(required=true) String name,@RequestParam(required=false) String status
     ,@RequestParam(required=false) String starttime,@RequestParam(required=false) String endtime){
         try {
             if (StringUtils.isBlank(name)){
@@ -1601,7 +1601,7 @@
      */
     @ResponseBody
     @RequestMapping("hazardousWaste/changeStatus")
-    public Object getLabAndUser(@RequestParam(required=true) String tid,@RequestParam(required=true) String status,
+    public Object changeStatus(@RequestParam(required=true) String tid,@RequestParam(required=true) String status,
                                 @RequestParam(required=true) String updator){
         try {
             if (StringUtils.isBlank(tid) || StringUtils.isBlank(status)){
@@ -1688,4 +1688,33 @@
     }
 
 
+    /**
+     * 根据用户名获取危废全年统计列表
+     *
+     */
+    @ResponseBody
+    @RequestMapping("hazardousWaste/getWasteStatistics")
+    public Object getWasteStatistics(@RequestParam(required=true) int adminFlag,@RequestParam(required=true) String name){
+        try {
+            if (StringUtils.isBlank(name)){
+                return  ResponseModel.getErrInstance("姓名不能为空");
+            }
+            Calendar calendar = Calendar.getInstance();
+            int year = calendar.get(Calendar.YEAR);
+            String status = "已确认";
+            String starttime = year+"-01-01 00:00:00";
+            String endtime = year+"-12-31 23:59:59";
+            List<HazardousWaste> hazardousWasters = new ArrayList<>();
+            if (adminFlag == 2){
+                hazardousWasters = hazardousWasteService.setAllWasterCount(starttime,endtime,status,null);
+            }else if (adminFlag == 1) {
+                hazardousWasters = hazardousWasteService.setAllWasterCount(starttime,endtime,status,name);
+            }
+            return ResponseModel.getOkInstence(hazardousWasters);
+        }catch (Exception e){
+            e.printStackTrace();
+            logger.info(e);
+            return ResponseModel.getErrInstance("系统出错");
+        }
+    }
 }
diff --git a/src/main/java/com/nanometer/smartlab/dao/HazardousWasteMapper.java b/src/main/java/com/nanometer/smartlab/dao/HazardousWasteMapper.java
index 1f24a3a..5825e2e 100644
--- a/src/main/java/com/nanometer/smartlab/dao/HazardousWasteMapper.java
+++ b/src/main/java/com/nanometer/smartlab/dao/HazardousWasteMapper.java
@@ -33,4 +33,6 @@
     List<HazardousWaste> setAllWasters(@Param("starttime") String starttime,@Param("endtime") String endtime,@Param("status") String status,@Param("applyPerson") String applyPerson);
 
     HazardousWaste selectByTid(@Param("tid") String tid);
+
+    List<HazardousWaste> setAllWasterCount(@Param("starttime") String starttime,@Param("endtime") String endtime,@Param("status") String status,@Param("applyPerson") String applyPerson);
 }
diff --git a/src/main/java/com/nanometer/smartlab/dao/HazardousWasteMapper.xml b/src/main/java/com/nanometer/smartlab/dao/HazardousWasteMapper.xml
index b6b49f4..1d5b686 100644
--- a/src/main/java/com/nanometer/smartlab/dao/HazardousWasteMapper.xml
+++ b/src/main/java/com/nanometer/smartlab/dao/HazardousWasteMapper.xml
@@ -226,17 +226,37 @@
       updatetime = #{updatetime,jdbcType=TIMESTAMP}
     where id = #{id,jdbcType=BIGINT}
   </update>
-  <select id="setAllWasters" resultMap="BaseResultMap">
+  <select id="setAllWasterCount" resultType="com.nanometer.smartlab.entity.HazardousWaste">
+    select
+    sum(acid) as acid,sum(alkali) as alkali, sum(organic) as organic,sum(solid) as solid,sum(medical) as medical
+    from sys_hazardous_waste
+    <where>
+      1 = 1
+      <if test="starttime != null and starttime != ''">
+        and create_time &gt;= #{starttime}
+      </if>
+      <if test="endtime != null and endtime != ''">
+        and create_time &lt;= #{endtime}
+      </if>
+      <if test="status != null and status != ''">
+        and status = #{status}
+      </if>
+      <if test="applyPerson != null and applyPerson != ''">
+        and apply_person = #{applyPerson}
+      </if>
+    </where>
+  </select>
+    <select id="setAllWasters" resultMap="BaseResultMap">
     select
     <include refid="Base_Column_List" />
     from sys_hazardous_waste
     <where>
       1 = 1
       <if test="starttime != null and starttime != ''">
-        and create_time &gt; #{starttime}
+        and create_time &gt;= #{starttime}
       </if>
       <if test="endtime != null and endtime != ''">
-        and create_time &lt; #{endtime}
+        and create_time &lt;= #{endtime}
       </if>
       <if test="status != null and status != ''">
         and status = #{status}
@@ -255,10 +275,10 @@
     <where>
       1 = 1
       <if test="startTime != null and startTime != ''">
-        and create_time &gt; #{startTime}
+        and create_time &gt;= #{startTime}
       </if>
       <if test="endTime != null and endTime != ''">
-        and create_time &lt; #{endTime}
+        and create_time &lt;= #{endTime}
       </if>
       <if test="status != null and status != ''">
         and status = #{status}
@@ -289,10 +309,10 @@
     <where>
       1 = 1
       <if test="startTime != null and startTime != ''">
-        and create_time &gt; #{startTime}
+        and create_time &gt;= #{startTime}
       </if>
       <if test="endTime != null and endTime != ''">
-        and create_time &lt; #{endTime}
+        and create_time &lt;= #{endTime}
       </if>
       <if test="status != null and status != ''">
         and status = #{status}
@@ -319,10 +339,10 @@
     <where>
       1 = 1
       <if test="startTime != null and startTime != ''">
-        and create_time &gt; #{startTime}
+        and create_time &gt;= #{startTime}
       </if>
       <if test="endTime != null and endTime != ''">
-        and create_time &lt; #{endTime}
+        and create_time &lt;= #{endTime}
       </if>
       <if test="status != null and status != ''">
         and status = #{status}
@@ -348,10 +368,10 @@
     <where>
       1 = 1
       <if test="startTime != null and startTime != ''">
-        and create_time &gt; #{startTime}
+        and create_time &gt;= #{startTime}
       </if>
       <if test="endTime != null and endTime != ''">
-        and create_time &lt; #{endTime}
+        and create_time &lt;= #{endTime}
       </if>
       <if test="status != null and status != ''">
         and status = #{status}
@@ -376,10 +396,10 @@
     <where>
       1 = 1
       <if test="startTime != null and startTime != ''">
-        and create_time &gt; #{startTime}
+        and create_time &gt;= #{startTime}
       </if>
       <if test="endTime != null and endTime != ''">
-        and create_time &lt; #{endTime}
+        and create_time &lt;= #{endTime}
       </if>
       <if test="status != null and status != ''">
         and status = #{status}
@@ -408,10 +428,10 @@
     <where>
       1 = 1
       <if test="startTime != null and startTime != ''">
-        and create_time &gt; #{startTime}
+        and create_time &gt;= #{startTime}
       </if>
       <if test="endTime != null and endTime != ''">
-        and create_time &lt; #{endTime}
+        and create_time &lt;= #{endTime}
       </if>
       <if test="status != null and status != ''">
         and status = #{status}
diff --git a/src/main/java/com/nanometer/smartlab/service/HazardousWasteService.java b/src/main/java/com/nanometer/smartlab/service/HazardousWasteService.java
index 55d5219..fd1882a 100644
--- a/src/main/java/com/nanometer/smartlab/service/HazardousWasteService.java
+++ b/src/main/java/com/nanometer/smartlab/service/HazardousWasteService.java
@@ -31,4 +31,6 @@
     HazardousWaste selectByTid(String tid);
 
     void updateWaste(HazardousWaste hazardousWaste);
+
+    List<HazardousWaste> setAllWasterCount(String starttime, String endtime, String status, String applyPerson);
 }
diff --git a/src/main/java/com/nanometer/smartlab/service/HazardousWasteServiceImpl.java b/src/main/java/com/nanometer/smartlab/service/HazardousWasteServiceImpl.java
index 5e8c800..12f8062 100644
--- a/src/main/java/com/nanometer/smartlab/service/HazardousWasteServiceImpl.java
+++ b/src/main/java/com/nanometer/smartlab/service/HazardousWasteServiceImpl.java
@@ -162,4 +162,9 @@
         hazardousWasteMapper.updateByPrimaryKeySelective(hazardousWaste);
     }
 
+    @Override
+    public List<HazardousWaste> setAllWasterCount(String starttime, String endtime, String status, String applyPerson) {
+        return hazardousWasteMapper.setAllWasterCount(starttime, endtime, status, applyPerson);
+    }
+
 }
diff --git "a/\346\231\272\346\205\247\345\256\236\351\252\214\345\256\244\346\216\245\345\217\243.docx" "b/\346\231\272\346\205\247\345\256\236\351\252\214\345\256\244\346\216\245\345\217\243.docx"
index 602a34f..8ceb12e 100644
--- "a/\346\231\272\346\205\247\345\256\236\351\252\214\345\256\244\346\216\245\345\217\243.docx"
+++ "b/\346\231\272\346\205\247\345\256\236\351\252\214\345\256\244\346\216\245\345\217\243.docx"
Binary files differ

--
Gitblit v1.9.2