liusuyi
2024-10-10 38f29e38fcc668171dc05c53d40a36b895c86102
ard-work/src/main/resources/mapper/alarm/ArdAlarmCameraMapper.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.cameraAlarm.mapper.ArdAlarmCameraMapper">
<mapper namespace="com.ruoyi.alarm.camera.mapper.ArdAlarmCameraMapper">
    
    <resultMap type="ArdAlarmCamera" id="ArdAlarmCameraResult">
        <result property="id"    column="id"    />
@@ -16,7 +16,6 @@
        <result property="latitude"    column="latitude"    />
        <result property="ruleId"    column="rule_id"    />
        <result property="picUrl"    column="pic_url"    />
        <result property="recordUrl"    column="record_url"    />
        <result property="viewTime"    column="view_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
@@ -25,7 +24,7 @@
    </resultMap>
    <sql id="selectArdAlarmCameraVo">
        select id, camera_id, camera_name, camera_channel, camera_type, alarm_type, alarm_time, longitude, latitude, rule_id, pic_url, record_url, view_time, create_by, create_time, user_id, dept_id from ard_alarm_camera
        select id, camera_id, camera_name, camera_channel, camera_type, alarm_type, alarm_time, longitude, latitude, rule_id, pic_url, view_time, create_by, create_time, user_id, dept_id from ard_alarm_camera
    </sql>
    <select id="selectArdAlarmCameraList" parameterType="ArdAlarmCamera" resultMap="ArdAlarmCameraResult">
@@ -36,7 +35,6 @@
            <if test="cameraChannel != null "> and camera_channel = #{cameraChannel}</if>
            <if test="cameraType != null  and cameraType != ''"> and camera_type = #{cameraType}</if>
            <if test="alarmType != null  and alarmType != ''"> and alarm_type = #{alarmType}</if>
<!--            <if test="alarmTime != null "> and alarm_time = #{alarmTime}</if>-->
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                AND alarm_time &gt;= to_timestamp(#{params.beginTime},'yyyy-MM-DD HH24:MI:ss')
            </if>
@@ -47,7 +45,6 @@
            <if test="latitude != null "> and latitude = #{latitude}</if>
            <if test="ruleId != null "> and rule_id = #{ruleId}</if>
            <if test="picUrl != null  and picUrl != ''"> and pic_url = #{picUrl}</if>
            <if test="recordUrl != null  and recordUrl != ''"> and record_url = #{recordUrl}</if>
            <if test="viewTime != null "> and view_time = #{viewTime}</if>
            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
@@ -74,7 +71,6 @@
            <if test="latitude != null">latitude,</if>
            <if test="ruleId != null">rule_id,</if>
            <if test="picUrl != null">pic_url,</if>
            <if test="recordUrl != null">record_url,</if>
            <if test="viewTime != null">view_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
@@ -93,7 +89,6 @@
            <if test="latitude != null">#{latitude},</if>
            <if test="ruleId != null">#{ruleId},</if>
            <if test="picUrl != null">#{picUrl},</if>
            <if test="recordUrl != null">#{recordUrl},</if>
            <if test="viewTime != null">#{viewTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
@@ -115,7 +110,6 @@
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="ruleId != null">rule_id = #{ruleId},</if>
            <if test="picUrl != null">pic_url = #{picUrl},</if>
            <if test="recordUrl != null">record_url = #{recordUrl},</if>
            <if test="viewTime != null">view_time = #{viewTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
@@ -136,8 +130,7 @@
        </foreach>
    </delete>
    <select id="selectListAllByCommand" resultMap="ArdAlarmCameraResult">
        SELECT T
                   .*
        SELECT T.*
        FROM
            (
                SELECT
@@ -147,7 +140,6 @@
                    aac.alarm_time,
                    aac.longitude,
                    aac.latitude,
                    aac.record_url,
                    ROW_NUMBER () OVER ( PARTITION BY aac.camera_id ORDER BY aac.alarm_time DESC ) AS rn,
                        COUNT ( CASE WHEN aac.view_time IS NULL THEN 1 END ) OVER ( PARTITION BY aac.camera_id ) AS COUNT,
      COUNT ( aac.alarm_time ) OVER ( PARTITION BY camera_id ) AS total
@@ -161,4 +153,28 @@
        WHERE
            T.rn = 1
    </select>
    <select id="selectCountByAlarmTime" resultType="Integer">
        SELECT COUNT(DISTINCT aac.camera_name)
        FROM ard_alarm_camera aac
        WHERE aac.alarm_time >= CURRENT_TIMESTAMP - INTERVAL '%${refreshTime}%' MINUTE
          and aac.view_time is null
    </select>
    <update id="updateViewTimeByCameraName" parameterType="String">
        update ard_alarm_camera
        set view_time=#{viewTime}
        where camera_name = #{cameraName}
          and alarm_time&lt;=#{alarmTime}
          and view_time is null
    </update>
    <select id="cameraYear" resultType="com.ruoyi.statistical.vo.CountVo">
        select to_char(alarm_time::DATE, 'MM') as date,count(id)
        from ard_alarm_camera
        where alarm_time &gt;= #{start} and  alarm_time &lt;= #{end}  group by date order by date
    </select>
    <select id="cameraMonth" resultType="com.ruoyi.statistical.vo.CountVo">
        select to_char(alarm_time::DATE, 'dd') as date,count(id)
        from ard_alarm_camera
        where alarm_time &gt;= #{start} and  alarm_time &lt;= #{end}  group by date order by date
    </select>
</mapper>