|  |  |  | 
|---|
|  |  |  | <!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"    /> | 
|---|
|  |  |  | 
|---|
|  |  |  | <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"    /> | 
|---|
|  |  |  | 
|---|
|  |  |  | </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"> | 
|---|
|  |  |  | 
|---|
|  |  |  | <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 >= to_timestamp(#{params.beginTime},'yyyy-MM-DD HH24:MI:ss') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | 
|---|
|  |  |  | <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> | 
|---|
|  |  |  | 
|---|
|  |  |  | <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> | 
|---|
|  |  |  | 
|---|
|  |  |  | <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> | 
|---|
|  |  |  | 
|---|
|  |  |  | <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> | 
|---|
|  |  |  | 
|---|
|  |  |  | </foreach> | 
|---|
|  |  |  | </delete> | 
|---|
|  |  |  | <select id="selectListAllByCommand" resultMap="ArdAlarmCameraResult"> | 
|---|
|  |  |  | SELECT T | 
|---|
|  |  |  | .* | 
|---|
|  |  |  | SELECT T.* | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | ( | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | 
|---|
|  |  |  | 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<=#{alarmTime} | 
|---|
|  |  |  | and view_time is null | 
|---|
|  |  |  | </update> | 
|---|
|  |  |  | </mapper> | 
|---|