<?xml version="1.0" encoding="UTF-8" ?>
|
<!DOCTYPE mapper
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.ruoyi.alarm.camera.mapper.ArdAlarmCameraMapper">
|
|
<resultMap type="ArdAlarmCamera" id="ArdAlarmCameraResult">
|
<result property="id" column="id" />
|
<result property="cameraId" column="camera_id" />
|
<result property="cameraName" column="camera_name" />
|
<result property="cameraChannel" column="camera_channel" />
|
<result property="cameraType" column="camera_type" />
|
<result property="alarmType" column="alarm_type" />
|
<result property="alarmTime" column="alarm_time" />
|
<result property="longitude" column="longitude" />
|
<result property="latitude" column="latitude" />
|
<result property="ruleId" column="rule_id" />
|
<result property="picUrl" column="pic_url" />
|
<result property="viewTime" column="view_time" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="userId" column="user_id" />
|
<result property="deptId" column="dept_id" />
|
</resultMap>
|
|
<sql id="selectArdAlarmCameraVo">
|
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">
|
<include refid="selectArdAlarmCameraVo"/>
|
<where>
|
<if test="cameraId != null and cameraId != ''"> and camera_id = #{cameraId}</if>
|
<if test="cameraName != null and cameraName != ''"> and camera_name like '%'||#{cameraName}||'%'</if>
|
<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="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
AND alarm_time >= to_timestamp(#{params.beginTime},'yyyy-MM-DD HH24:MI:ss')
|
</if>
|
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
AND alarm_time <= to_timestamp(#{params.endTime},'yyyy-MM-DD HH24:MI:ss')
|
</if>
|
<if test="longitude != null "> and longitude = #{longitude}</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="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>
|
</where>
|
order by alarm_time desc
|
</select>
|
|
<select id="selectArdAlarmCameraById" parameterType="String" resultMap="ArdAlarmCameraResult">
|
<include refid="selectArdAlarmCameraVo"/>
|
where id = #{id}
|
</select>
|
|
<insert id="insertArdAlarmCamera" parameterType="ArdAlarmCamera">
|
insert into ard_alarm_camera
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">id,</if>
|
<if test="cameraId != null">camera_id,</if>
|
<if test="cameraName != null">camera_name,</if>
|
<if test="cameraChannel != null">camera_channel,</if>
|
<if test="cameraType != null">camera_type,</if>
|
<if test="alarmType != null">alarm_type,</if>
|
<if test="alarmTime != null">alarm_time,</if>
|
<if test="longitude != null">longitude,</if>
|
<if test="latitude != null">latitude,</if>
|
<if test="ruleId != null">rule_id,</if>
|
<if test="picUrl != null">pic_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="userId != null">user_id,</if>
|
<if test="deptId != null">dept_id,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="id != null">#{id},</if>
|
<if test="cameraId != null">#{cameraId},</if>
|
<if test="cameraName != null">#{cameraName},</if>
|
<if test="cameraChannel != null">#{cameraChannel},</if>
|
<if test="cameraType != null">#{cameraType},</if>
|
<if test="alarmType != null">#{alarmType},</if>
|
<if test="alarmTime != null">#{alarmTime},</if>
|
<if test="longitude != null">#{longitude},</if>
|
<if test="latitude != null">#{latitude},</if>
|
<if test="ruleId != null">#{ruleId},</if>
|
<if test="picUrl != null">#{picUrl},</if>
|
<if test="viewTime != null">#{viewTime},</if>
|
<if test="createBy != null">#{createBy},</if>
|
<if test="createTime != null">#{createTime},</if>
|
<if test="userId != null">#{userId},</if>
|
<if test="deptId != null">#{deptId},</if>
|
</trim>
|
</insert>
|
|
<update id="updateArdAlarmCamera" parameterType="ArdAlarmCamera">
|
update ard_alarm_camera
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="cameraId != null">camera_id = #{cameraId},</if>
|
<if test="cameraName != null">camera_name = #{cameraName},</if>
|
<if test="cameraChannel != null">camera_channel = #{cameraChannel},</if>
|
<if test="cameraType != null">camera_type = #{cameraType},</if>
|
<if test="alarmType != null">alarm_type = #{alarmType},</if>
|
<if test="alarmTime != null">alarm_time = #{alarmTime},</if>
|
<if test="longitude != null">longitude = #{longitude},</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="viewTime != null">view_time = #{viewTime},</if>
|
<if test="createBy != null">create_by = #{createBy},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="userId != null">user_id = #{userId},</if>
|
<if test="deptId != null">dept_id = #{deptId},</if>
|
</trim>
|
where id = #{id}
|
</update>
|
|
<delete id="deleteArdAlarmCameraById" parameterType="String">
|
delete from ard_alarm_camera where id = #{id}
|
</delete>
|
|
<delete id="deleteArdAlarmCameraByIds" parameterType="String">
|
delete from ard_alarm_camera where id in
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</delete>
|
<select id="selectListAllByCommand" resultMap="ArdAlarmCameraResult">
|
SELECT T.*
|
FROM
|
(
|
SELECT
|
aac.ID,
|
aac.camera_id,
|
aac.camera_name,
|
aac.alarm_time,
|
aac.longitude,
|
aac.latitude,
|
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
|
FROM
|
ard_alarm_camera aac
|
WHERE
|
aac.alarm_time >= ( CURRENT_TIMESTAMP - INTERVAL '%${refreshTime}%' MINUTE )
|
ORDER BY
|
aac.alarm_time DESC
|
) T
|
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>
|
|
<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 >= #{start} and alarm_time <= #{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 >= #{start} and alarm_time <= #{end} group by date order by date
|
</select>
|
</mapper>
|