From 47a458ca867f700ad8dfe8bccdbb6bf59ca2d301 Mon Sep 17 00:00:00 2001
From: zengh <123456>
Date: Tue, 11 May 2021 15:54:02 +0800
Subject: [PATCH] APP接口调整

---
 blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/animalheat/mapper/AnimalHeatMapper.xml |  107 +++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 95 insertions(+), 12 deletions(-)

diff --git a/blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/animalheat/mapper/AnimalHeatMapper.xml b/blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/animalheat/mapper/AnimalHeatMapper.xml
index 869e1af..2dcdb60 100644
--- a/blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/animalheat/mapper/AnimalHeatMapper.xml
+++ b/blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/animalheat/mapper/AnimalHeatMapper.xml
@@ -2,6 +2,59 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.springblade.jfpt.animalheat.mapper.AnimalHeatMapper">
 
+    <sql id="animalHeatCondition">
+        <if test="animalHeatVo.type==0">
+            and to_days(create_time)=to_days(now())
+        </if>
+        <if test="animalHeatVo.type==1">
+            and YEARWEEK(date_format(create_time,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
+        </if>
+        <if test="animalHeatVo.type==2">
+            and date_format(create_time,'%Y%m') = date_format(now(),'%Y%m')
+        </if>
+        <if test="animalHeatVo.begTime!=null and animalHeatVo.begTime!='' and animalHeatVo.endTime!=null and animalHeatVo.endTime!='' and animalHeatVo.begTime!='undefined' and animalHeatVo.endTime!='undefined' ">
+            and date(create_time) between #{animalHeatVo.begTime} and #{animalHeatVo.endTime}
+        </if>
+        <if test="animalHeatVo.timeDesc!=null and animalHeatVo.timeDesc!='' and animalHeatVo.timeDesc!='undefined'">
+            <if test="animalHeatVo.timeDesc=='0-2'">
+                and hour(create_time)>=0 and hour(create_time) &lt;2
+            </if>
+            <if test="animalHeatVo.timeDesc=='2-4'">
+                and hour(create_time)>=2 and hour(create_time) &lt;4
+            </if>
+            <if test="animalHeatVo.timeDesc=='4-6'">
+                and hour(create_time)>=4 and hour(create_time) &lt;6
+            </if>
+            <if test="animalHeatVo.timeDesc=='6-8'">
+                and hour(create_time)>=6 and hour(create_time) &lt;8
+            </if>
+            <if test="animalHeatVo.timeDesc=='8-10'">
+                and hour(create_time)>=8 and hour(create_time) &lt;10
+            </if>
+            <if test="animalHeatVo.timeDesc=='10-12'">
+                and hour(create_time)>=10 and hour(create_time) &lt;12
+            </if>
+            <if test="animalHeatVo.timeDesc=='12-14'">
+                and hour(create_time)>=12 and hour(create_time) &lt;14
+            </if>
+            <if test="animalHeatVo.timeDesc=='14-16'">
+                and hour(create_time)>=14 and hour(create_time) &lt;16
+            </if>
+            <if test="animalHeatVo.timeDesc=='16-18'">
+                and hour(create_time)>=16 and hour(create_time) &lt;18
+            </if>
+            <if test="animalHeatVo.timeDesc=='18-20'">
+                and hour(create_time)>=18 and hour(create_time) &lt;20
+            </if>
+            <if test="animalHeatVo.timeDesc=='20-22'">
+                and hour(create_time)>=20 and hour(create_time) &lt;22
+            </if>
+            <if test="animalHeatVo.timeDesc=='22-24'">
+                and hour(create_time)>=22 and hour(create_time) &lt;24
+            </if>
+        </if>
+    </sql>
+
     <!--查询当天体温数据统计-->
     <select id="getAnimalStatis" resultType="java.util.HashMap">
         SELECT 1 `name`,count(`status`) value FROM `blade_animal_heat` where
@@ -33,21 +86,10 @@
     <select id="selectAnimalHeatPageList" resultType="org.springblade.jfpt.animalheat.entity.BladeAnimalHeat">
         SELECT * FROM blade_animal_heat
         where 1=1
-        <if test="animalHeatVo.type==0">
-            and to_days(create_time)=to_days(now())
-        </if>
-        <if test="animalHeatVo.type==1">
-            and YEARWEEK(date_format(create_time,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
-        </if>
-        <if test="animalHeatVo.type==2">
-            and date_format(create_time,'%Y%m') = date_format(now(),'%Y%m')
-        </if>
         <if test="animalHeatVo.status!=null">
             and status=#{animalHeatVo.status}
         </if>
-        <if test="animalHeatVo.begTime!=null and animalHeatVo.begTime!='' and animalHeatVo.endTime!=null and animalHeatVo.endTime!='' ">
-            and date(create_time) between #{animalHeatVo.begTime} and #{animalHeatVo.endTime}
-        </if>
+        <include refid="animalHeatCondition"></include>
         ORDER BY create_time desc
     </select>
 
@@ -134,4 +176,45 @@
             where status=1
         and create_time between #{conditionVo.startTime} and #{conditionVo.endTime}
     </select>
+
+    <!--统计时间段内体温异常人数数量数据-->
+    <select id="selectAnimalTimeData" resultType="java.lang.Integer">
+        select ifnull(count,0) count from
+        (
+            SELECT @date := DATE_ADD( @date, INTERVAL + 1 DAY ) days FROM
+            (
+                SELECT @date := DATE_ADD( #{conditionVo.startTime}, INTERVAL - 1 DAY ) FROM sys_date
+            ) time
+            WHERE to_days( @date ) &lt; to_days( #{conditionVo.endTime} )
+        ) a
+        left join
+        (
+            select DATE_FORMAT(create_time,'%Y-%m-%d') as datetime, count(*) as count from blade_animal_heat
+            where status=1
+            group by DATE_FORMAT(create_time,'%Y-%m-%d')
+        ) b
+        on
+        a.days = b.datetime
+    </select>
+
+
+    <!--导出体温数据列表-->
+    <select id="exportAnimalHeat" resultType="org.springblade.common.entity.AnimalHeatExcel">
+        SELECT * FROM blade_animal_heat
+        where 1=1
+        <if test="animalHeatVo.status!=null and animalHeatVo.status!='' and animalHeatVo.status!='undefined'">
+            and status=#{animalHeatVo.status}
+        </if>
+        <include refid="animalHeatCondition"></include>
+        ORDER BY create_time desc
+    </select>
+
+    <select id="getAnimalHeatPie" resultType="org.springblade.common.entity.ReportReturnData">
+        select if(1=1,'正常',0) type,ifnull(count(*),0) count from blade_animal_heat where status=0
+        <include refid="animalHeatCondition"></include>
+        union all
+        select if(1=1,'异常',0) type,ifnull(count(*),0) count from blade_animal_heat where status=1
+        <include refid="animalHeatCondition"></include>
+    </select>
+
 </mapper>

--
Gitblit v1.9.3