南昌市物联网技防平台-后台
Administrator
2021-04-16 dfed9c07aa8da5791d568736716bc4b44d59ebaf
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/animalheat/mapper/AnimalHeatMapper.xml
@@ -2,37 +2,7 @@
<!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">
    <!--查询当天体温数据统计-->
    <select id="getAnimalStatis" resultType="java.util.HashMap">
        SELECT 1 `name`,count(`status`) value FROM `blade_animal_heat` where
             TO_DAYS(create_time)=TO_DAYS(now())  and `status`=1
        UNION
        SELECT 0 `name`,count(`status`) value FROM `blade_animal_heat` where
            TO_DAYS(create_time)=TO_DAYS(now())  and `status`=0
    </select>
    <!--获取本周的体温统计数据-->
    <select id="getAnimalStatisWeek" resultType="java.util.HashMap">
        SELECT 1 `name`,count(`status`) value FROM `blade_animal_heat` where
            YEARWEEK(date_format(create_time,'%Y-%m-%d'),1) = YEARWEEK(now(),1) and `status`=1
        UNION
        SELECT 0 `name`,count(`status`) value FROM `blade_animal_heat` where
            YEARWEEK(date_format(create_time,'%Y-%m-%d'),1) = YEARWEEK(now(),1) and `status`=0
    </select>
    <!--获取本月的体温统计数据-->
    <select id="getAnimalStatisMonth" resultType="java.util.HashMap">
        SELECT 1 `name`,count(`status`) value FROM `blade_animal_heat` where
            date_format(create_time,'%Y%m') = date_format(now(),'%Y%m') and `status`=1
        UNION
        SELECT 0 `name`,count(`status`) value FROM `blade_animal_heat` where
            date_format(create_time,'%Y%m') = date_format(now(),'%Y%m') and `status`=0
    </select>
    <!--查询体温数据的分页数据-->
    <select id="selectAnimalHeatPageList" resultType="org.springblade.jfpt.animalheat.entity.BladeAnimalHeat">
        SELECT * FROM blade_animal_heat
        where 1=1
    <sql id="animalHeatCondition">
        <if test="animalHeatVo.type==0">
            and to_days(create_time)=to_days(now())
        </if>
@@ -41,9 +11,6 @@
        </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}
@@ -86,6 +53,43 @@
                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
             TO_DAYS(create_time)=TO_DAYS(now())  and `status`=1
        UNION
        SELECT 0 `name`,count(`status`) value FROM `blade_animal_heat` where
            TO_DAYS(create_time)=TO_DAYS(now())  and `status`=0
    </select>
    <!--获取本周的体温统计数据-->
    <select id="getAnimalStatisWeek" resultType="java.util.HashMap">
        SELECT 1 `name`,count(`status`) value FROM `blade_animal_heat` where
            YEARWEEK(date_format(create_time,'%Y-%m-%d'),1) = YEARWEEK(now(),1) and `status`=1
        UNION
        SELECT 0 `name`,count(`status`) value FROM `blade_animal_heat` where
            YEARWEEK(date_format(create_time,'%Y-%m-%d'),1) = YEARWEEK(now(),1) and `status`=0
    </select>
    <!--获取本月的体温统计数据-->
    <select id="getAnimalStatisMonth" resultType="java.util.HashMap">
        SELECT 1 `name`,count(`status`) value FROM `blade_animal_heat` where
            date_format(create_time,'%Y%m') = date_format(now(),'%Y%m') and `status`=1
        UNION
        SELECT 0 `name`,count(`status`) value FROM `blade_animal_heat` where
            date_format(create_time,'%Y%m') = date_format(now(),'%Y%m') and `status`=0
    </select>
    <!--查询体温数据的分页数据-->
    <select id="selectAnimalHeatPageList" resultType="org.springblade.jfpt.animalheat.entity.BladeAnimalHeat">
        SELECT * FROM blade_animal_heat
        where 1=1
        <if test="animalHeatVo.status!=null">
            and status=#{animalHeatVo.status}
        </if>
        <include refid="animalHeatCondition"></include>
        ORDER BY create_time desc
    </select>
@@ -198,60 +202,19 @@
    <select id="exportAnimalHeat" resultType="org.springblade.common.entity.AnimalHeatExcel">
        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>
        <if test="animalHeatVo.timeDesc!=null and animalHeatVo.timeDesc!=''">
            <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>
        <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>