南昌市物联网技防平台-后台
zengh
2021-04-08 c4e1404f2e78cde3b807e030cf466f956b0de169
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/alarm/mapper/AlarmMapper.xml
@@ -333,24 +333,24 @@
    </select>
    <!--查询警情当前时间段内每天的数据-->
<!--    <select id="selectTimeAlarmData" resultType="java.lang.Integer">-->
<!--       select a.days, 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(alarmTime,'%Y-%m-%d') as datetime, count(*) as count from sys_alarm-->
<!--            where waringType = '紧急求救'-->
<!--            group by DATE_FORMAT(alarmTime,'%Y-%m-%d')-->
<!--            ) b-->
<!--            on-->
<!--            a.days = b.datetime-->
<!--    </select>-->
    <select id="selectTimeAlarmData" resultType="java.lang.Integer">
       select a.days, 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(alarmTime,'%Y-%m-%d') as datetime, count(*) as count from sys_alarm
            where waringType = '紧急求救'
            group by DATE_FORMAT(alarmTime,'%Y-%m-%d')
            ) b
            on
            a.days = b.datetime
    </select>
<!--    &lt;!&ndash;查询本日,本周,本月 主动报警的数量&ndash;&gt;-->
<!--    <select id="selectAlarmSum" resultType="java.util.HashMap">-->
@@ -467,4 +467,53 @@
            and alarmTime between #{conditionVo.startTime} and #{conditionVo.endTime}
        </if>
    </select>
    <!--查询当前时间段内一键求助报警的数据集合-->
    <select id="selectAlarmList" resultType="org.springblade.jfpt.alarm.entity.Alarm">
        SELECT waringType,alarmTime,alarmId,alarmPeople,jtype,czTime FROM `sys_alarm`
        where waringType='紧急求救'
        and alarmTime between #{conditionVo.startTime} and #{conditionVo.endTime}
    </select>
    <!--统计时间段内一键求助警情数量数据-->
    <select id="selectAlarmTimeData" 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(alarmTime,'%Y-%m-%d') as datetime, count(*) as count from sys_alarm
            where waringType = '紧急求救'
            group by DATE_FORMAT(alarmTime,'%Y-%m-%d')
        ) b
        on
        a.days = b.datetime
    </select>
    <!--查询本年所有月份的预警数量-->
    <select id="queryYearAlarm" resultType="java.util.HashMap">
        <if test="childList!=null and childList.size>0">
            <foreach collection="childList" index="index" item="item" open="" separator="union all" close="">
                SELECT
                #{item} as month,count(ce.id) as count
                FROM
                sys_alarm as ce
                WHERE
                YEAR ( alarmTime ) = date_format(now(),'%Y%')
                AND MONTH ( alarmTime ) = #{item}
            </foreach>
        </if>
    </select>
</mapper>