<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="vip.xiaonuo.coldchain.modular.monitornotice.mapper.MonitorNoticeMapper">
    <select id="getDayBeforeYesterday" resultType="Integer">
        SELECT COUNT(*)
        FROM sensor_alarm
        WHERE DATEDIFF(CREATE_TIME, Now()) = -2
          AND (
            DATE_FORMAT(CREATE_TIME, '%H:%i:%S') between #{startTime} and #{endTime}
            )
          AND DELETE_FLAG = 'NOT_DELETE'
          AND CREATE_ORG = #{orgId}
    </select>

    <select id="getYesterday" resultType="Integer">
        SELECT COUNT(*)
        FROM sensor_alarm
        WHERE DATEDIFF(CREATE_TIME, Now()) = -1
          AND (
            DATE_FORMAT(CREATE_TIME, '%H:%i:%S') between #{startTime} and #{endTime}
            )
          AND DELETE_FLAG = 'NOT_DELETE'
          AND CREATE_ORG = #{orgId}
    </select>

    <select id="getToDay" resultType="Integer">
        SELECT COUNT(*)
        FROM sensor_alarm
        where to_days(CREATE_TIME) = to_days(now())
          AND (
            DATE_FORMAT(CREATE_TIME, '%H:%i:%S') between #{startTime} and #{endTime}
            )
          AND DELETE_FLAG = 'NOT_DELETE'
          AND CREATE_ORG = #{orgId}
    </select>
</mapper>