南昌市物联网技防平台-后台
tangzy
2021-03-17 7e6b4d0547e1b46df3cb3f0385e5d50ce3ca8a5d
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/alarm/mapper/AlarmMapper.xml
@@ -72,6 +72,9 @@
        <if test="alarm.endTime!=null and alarm.endTime!=''">
            and a.alarmTime&lt;=#{alarm.endTime}
        </if>
        and a.waringType NOT IN("系统测试","主机重新上电")
        ORDER BY
        a.jtype ASC,
        a.alarmTime DESC
@@ -275,4 +278,54 @@
            and
        to_days(alarmTime) = to_days(curdate())
    </select>
    <!--查询警情7天内每天的数据-->
    <select id="selectAlarmData" 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(alarmTime,'%Y-%m-%d') as datetime, count(*) as count from sys_alarm
            group by DATE_FORMAT(alarmTime,'%Y-%m-%d')
       ) b
       on
       a.click_date = b.datetime
    </select>
    <!--查询本日,本周,本月 主动报警的数量-->
    <select id="selectAlarmSum" resultType="java.util.HashMap">
        select sa.alarmType name,IFNULL(sb.count, 0) value from  (select alarmType from sys_alarm GROUP BY alarmType) sa
        left join
        ( select alarmType,count(*) count from sys_alarm
            where 1=1
            <if test="conditionVo.status==0">
                and to_days(alarmTime)  = to_days(now())
            </if>
            <if test="conditionVo.status==1">
                and YEARWEEK(date_format(alarmTime,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
            </if>
            <if test="conditionVo.status==2">
                and date_format(alarmTime,'%Y%m') = date_format(now(),'%Y%m')
            </if>
            group by alarmType
        ) sb
        on
        sa.alarmType = sb.alarmType
    </select>
</mapper>