南昌市物联网技防平台-后台
zengh
2021-03-10 fa9ffa9012d7b1df7692bb99e71be6592f48cd4b
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/animalheat/mapper/AnimalHeatMapper.xml
@@ -3,20 +3,20 @@
<mapper namespace="org.springblade.jfpt.animalheat.mapper.AnimalHeatMapper">
    <!--查询当天体温数据统计-->
    <select id="getAnimalStatis" resultType="org.springblade.jfpt.animalheat.vo.StatisVo">
        SELECT 1 `status`,count(`status`) number FROM `blade_animal_heat` where
    <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 `status`,count(`status`) number FROM `blade_animal_heat` where
        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="org.springblade.jfpt.animalheat.vo.StatisVo">
        SELECT 1 `status`,count(`status`) number FROM `blade_animal_heat` where
    <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')) = YEARWEEK(now()) and `status`=1
        UNION
        SELECT 0 `status`,count(`status`) number FROM `blade_animal_heat` where
        SELECT 0 `name`,count(`status`) value FROM `blade_animal_heat` where
            YEARWEEK(date_format(create_time,'%Y-%m-%d')) = YEARWEEK(now()) and `status`=0
    </select>
@@ -31,4 +31,42 @@
        ORDER BY create_time asc
    </select>
    <!--查询本周每天的体温数据(按礼拜一开始计算)-->
    <select id="selWeekDayAnimalStatis" resultType="java.util.HashMap">
        select DATE_FORMAT(date(subdate(curdate(),date_format(curdate(),'%w')-1)),'%m-%d') time,ifNull(count(*),0) as number
            from blade_animal_heat
      where
            date_format(create_time,'%Y-%m-%d')=date(subdate(curdate(),date_format(curdate(),'%w')-1))
      union all
      select DATE_FORMAT(DATE(DATE_ADD(subdate(curdate(),date_format(curdate(),'%w')-1), interval 1 day)),'%m-%d') time,ifNull(count(*),0) as number
            from blade_animal_heat
      where
        date_format(create_time,'%Y-%m-%d')=DATE(DATE_ADD(subdate(curdate(),date_format(curdate(),'%w')-1), interval 1 day))
      union all
      select DATE_FORMAT(DATE(DATE_ADD(subdate(curdate(),date_format(curdate(),'%w')-1), interval 2 day)),'%m-%d') time,ifNull(count(*),0) as number
            from blade_animal_heat
      where
            date_format(create_time,'%Y-%m-%d')=DATE(DATE_ADD(subdate(curdate(),date_format(curdate(),'%w')-1), interval 2 day))
      union all
      select DATE_FORMAT(DATE(DATE_ADD(subdate(curdate(),date_format(curdate(),'%w')-1), interval 3 day)),'%m-%d') time,ifNull(count(*),0) as number
            from blade_animal_heat
      where
            date_format(create_time,'%Y-%m-%d')=DATE(DATE_ADD(subdate(curdate(),date_format(curdate(),'%w')-1), interval 3 day))
      union all
      select DATE_FORMAT(DATE(DATE_ADD(subdate(curdate(),date_format(curdate(),'%w')-1), interval 4 day)),'%m-%d') time,ifNull(count(*),0) as number
            from blade_animal_heat
      where
            date_format(create_time,'%Y-%m-%d')=DATE(DATE_ADD(subdate(curdate(),date_format(curdate(),'%w')-1), interval 4 day))
      union all
      select DATE_FORMAT(DATE(DATE_ADD(subdate(curdate(),date_format(curdate(),'%w')-1), interval 5 day)),'%m-%d') time,ifNull(count(*),0) as number
            from blade_animal_heat
      where
            date_format(create_time,'%Y-%m-%d')=DATE(DATE_ADD(subdate(curdate(),date_format(curdate(),'%w')-1), interval 5 day))
      union all
      select DATE_FORMAT(DATE(DATE_ADD(subdate(curdate(),date_format(curdate(),'%w')-1), interval 6 day)),'%m-%d') time,ifNull(count(*),0) as number
            from blade_animal_heat
      where
            date_format(create_time,'%Y-%m-%d')=DATE(DATE_ADD(subdate(curdate(),date_format(curdate(),'%w')-1), interval 6 day))
    </select>
</mapper>