From 6971c195601ecc91b2b7b52af83efed9956dcfe0 Mon Sep 17 00:00:00 2001
From: zengh <123456>
Date: Fri, 09 Apr 2021 09:22:49 +0800
Subject: [PATCH] 接口提供:根据设备编码

---
 blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/animalheat/mapper/AnimalHeatMapper.xml |   85 ++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 80 insertions(+), 5 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 6b7ea6b..f871bc3 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
@@ -32,13 +32,23 @@
     <!--查询体温数据的分页数据-->
     <select id="selectAnimalHeatPageList" resultType="org.springblade.jfpt.animalheat.entity.BladeAnimalHeat">
         SELECT * FROM blade_animal_heat
-        <if test="animalHeatVo.begTime!=null and animalHeatVo.begTime!=''">
-            and create_time &gt;=#{animalHeatVo.begTime}
+        where 1=1
+        <if test="animalHeatVo.type==0">
+            and to_days(create_time)=to_days(now())
         </if>
-        <if test="animalHeatVo.endTime!=null and animalHeatVo.endTime!=''">
-            and create_time &lt;=#{animalHeatVo.endTime}
+        <if test="animalHeatVo.type==1">
+            and YEARWEEK(date_format(create_time,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
         </if>
-        ORDER BY create_time asc
+        <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>
+        ORDER BY create_time desc
     </select>
 
     <!--查询本周每天的体温数据(按礼拜一开始计算)-->
@@ -79,4 +89,69 @@
             date_format(create_time,'%Y-%m-%d')=DATE(DATE_ADD(subdate(curdate(),date_format(curdate(),'%w')-1), interval 6 day))
     </select>
 
+
+    <!--统计7天内每天体温异常的的总人数-->
+    <select id="selectAnimalHeatDataStatis" resultType="java.lang.Integer">
+        select ifnull(b.count,0) as count from
+        (
+        SELECT DATE_FORMAT(date_sub(curdate(), interval 6 day),'%Y-%m-%d') as click_date
+            union all
+        SELECT DATE_FORMAT(date_sub(curdate(), interval 5 day),'%Y-%m-%d') as click_date
+            union all
+        SELECT DATE_FORMAT(date_sub(curdate(), interval 4 day),'%Y-%m-%d') as click_date
+            union all
+        SELECT DATE_FORMAT(date_sub(curdate(), interval 3 day),'%Y-%m-%d') as click_date
+            union all
+        SELECT DATE_FORMAT(date_sub(curdate(), interval 2 day),'%Y-%m-%d') as click_date
+            union all
+        SELECT DATE_FORMAT(date_sub(curdate(), interval 1 day),'%Y-%m-%d') as click_date
+            union all
+        SELECT DATE_FORMAT(curdate(),'%Y-%m-%d')  as click_date
+        ) 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.click_date = b.datetime
+		 order by a.click_date asc
+    </select>
+
+    <!--查询当前时间段体温异常总次数-->
+    <select id="selAnimalTimeCount" resultType="java.lang.Integer">
+        select count(*) from blade_animal_heat
+        where status=1
+        <if test="conditionVo.startTime!=null and conditionVo.startTime!='' and conditionVo.endTime!=null and conditionVo.endTime!=''">
+            and create_time between #{conditionVo.startTime} and #{conditionVo.endTime}
+        </if>
+    </select>
+
+    <!--查询当前时间段区间时间体温异常次数-->
+    <select id="selAnimalTimeData" resultType="org.springblade.jfpt.animalheat.entity.BladeAnimalHeat">
+        select status,create_time from blade_animal_heat
+            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>
 </mapper>

--
Gitblit v1.9.3