Administrator
2023-08-25 7f21d4f22ec711d6aa89900b07e0b5ac31dbac42
ard-work/src/main/resources/mapper/alarm/ArdAlarmRadarMapper.xml
@@ -2,7 +2,7 @@
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.alarm.radarAlarm.mapper.ArdAlarmRadarMapper">
<mapper namespace="com.ruoyi.alarm.radar.mapper.ArdAlarmRadarMapper">
    <resultMap type="ArdAlarmRadar" id="ArdAlarmRadarResult">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
@@ -16,6 +16,8 @@
        <result property="createTime" column="create_time"/>
        <result property="userId" column="user_id"/>
        <result property="deptId" column="dept_id"/>
        <result property="recordUrl1" column="record_url1"/>
        <result property="recordUrl2" column="record_url2"/>
    </resultMap>
    <sql id="selectArdAlarmRadarVo">
@@ -30,7 +32,9 @@
               create_by,
               create_time,
               user_id,
               dept_id
               dept_id,
               record_url1,
               record_url2
        from ard_alarm_radar
    </sql>
@@ -40,7 +44,14 @@
            <if test="name != null  and name != ''">and name like '%'||#{name}||'%'</if>
            <if test="alarmType != null  and alarmType != ''">and alarm_type = #{alarmType}</if>
            <if test="deptId != null ">and dept_id = #{deptId}</if>
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                AND alarm_time &gt;= to_timestamp(#{params.beginTime},'yyyy-MM-DD HH24:MI:ss')
            </if>
            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
                AND alarm_time &lt;= to_timestamp(#{params.endTime},'yyyy-MM-DD HH24:MI:ss')
            </if>
        </where>
        order by alarm_time desc
    </select>
    <select id="selectArdAlarmRadarById" parameterType="String" resultMap="ArdAlarmRadarResult">
@@ -63,6 +74,7 @@
            <if test="createTime != null">create_time,</if>
            <if test="userId != null">user_id,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="guideFlag != null">guide_flag,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
@@ -77,6 +89,7 @@
            <if test="createTime != null">#{createTime},</if>
            <if test="userId != null">#{userId},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="guideFlag != null">#{guideFlag},</if>
        </trim>
    </insert>
@@ -94,6 +107,9 @@
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="recordUrl1 != null">record_url1 = #{recordUrl1},</if>
            <if test="recordUrl2 != null">record_url2 = #{recordUrl2},</if>
            <if test="guideFlag != null">guide_flag = #{guideFlag},</if>
        </trim>
        where id = #{id}
    </update>
@@ -112,32 +128,66 @@
    </delete>
    <select id="selectListAllByCommand" resultMap="ArdAlarmRadarResult">
        SELECT T
                   .*
        FROM (
                 SELECT aar.ID,
                        aar.target_id,
                        aar.NAME,
                        aar.alarm_type,
                        aar.alarm_time,
                        aar.longitude,
                        aar.latitude,
                        ROW_NUMBER() OVER ( PARTITION BY aar.NAME ORDER BY aar.alarm_time DESC ) AS rn, COUNT(CASE WHEN aar.view_time IS NULL THEN 1 END) OVER ( PARTITION BY aar.NAME ) AS COUNT,
      COUNT ( aar.alarm_time ) OVER ( PARTITION BY aar.NAME ) AS total
                 FROM
                     ard_alarm_radar aar
                 WHERE
                     aar.alarm_time >= ( CURRENT_TIMESTAMP - INTERVAL '%${refreshTime}%' MINUTE )
                   AND aar.alarm_type = #{alarmType}
                 ORDER BY
                     aar.alarm_time DESC
             ) T
        WHERE T.rn = 1
                select aaar.ID,
               aaar.target_id,
               aaar.NAME,
               aaar.alarm_type,
               aaar.alarm_time,
               aaar.longitude,
               aaar.latitude,
               r.COUNT,
               r.total  from
            (SELECT
                 aar.NAME,
                 max(aar.create_time) as create_time1,
                 count(case when aar.view_time is null THEN 1  END) as count,
                count(aar.id) as total
             FROM
                 ard_alarm_radar aar
             WHERE
                 aar.create_time >= ( CURRENT_TIMESTAMP - INTERVAL '%${refreshTime}%' MINUTE )
               AND aar.alarm_type = #{alarmType}
             GROUP BY aar.NAME
            ) r
                INNER JOIN ard_alarm_radar aaar ON r.create_time1 = aaar.create_time
    </select>
    <select id="selectCountByAlarmTime" resultType="Integer">
        SELECT COUNT(DISTINCT aar.name)
        FROM ard_alarm_radar aar
        WHERE aar.alarm_time >= CURRENT_TIMESTAMP - INTERVAL '%${refreshTime}%' MINUTE
          and aar.alarm_type = #{alarmType}
          and aar.view_time is null
    </select>
    <select id="getCameraByRadar" resultType="String">
        select ac.id
        from ard_equip_radar aer
                 INNER JOIN ard_towers at
        on aer.tower_id= at.id
            INNER JOIN ard_cameras ac on aer.tower_id=ac.tower_id
    </select>
    <select id="getArdAlarmRadarWithGuide" resultMap="ArdAlarmRadarResult">
        select *
        from ard_alarm_radar
        where create_time > current_timestamp - interval '5' minute
          and guide_flag = #{guideFlag}
          and alarm_type =#{alarmType}
          and name = #{name}
        ORDER BY create_time desc  limit 1
    </select>
    <select id="getArdAlarmRadarWithNotGuide" resultType="Integer">
        select count(*)
        from ard_alarm_radar
        where create_time >= #{guideTime}
          and guide_flag = #{ardAlarmRadar.guideFlag}
          and alarm_type =#{ardAlarmRadar.alarmType}
          and name = #{ardAlarmRadar.name}
    </select>
    <update id="updateViewTimeByCondition" parameterType="String">
        update ard_alarm_radar
        set view_time=#{viewTime}
        where name = #{name}
          and alarm_type=#{alarmType}
          and alarm_time&lt;=#{alarmTime}
          and view_time is null
    </update>
</mapper>