|  |  |  | 
|---|
|  |  |  | <!DOCTYPE mapper | 
|---|
|  |  |  | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | 
|---|
|  |  |  | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 
|---|
|  |  |  | <mapper namespace="com.ruoyi.alarm.tubeAlarm.mapper.ArdAlarmTubeMapper"> | 
|---|
|  |  |  | <mapper namespace="com.ruoyi.alarm.tube.mapper.ArdAlarmTubeMapper"> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <resultMap type="ArdAlarmTube" id="ArdAlarmTubeResult"> | 
|---|
|  |  |  | <result property="id"    column="id"    /> | 
|---|
|  |  |  | <result property="host"    column="host"    /> | 
|---|
|  |  |  | <result property="tubeId"    column="tube_id"    /> | 
|---|
|  |  |  | <result property="tubeName"    column="tube_name"    /> | 
|---|
|  |  |  | <result property="tubeType"    column="tube_type"    /> | 
|---|
|  |  |  | <result property="pipeDiameter"    column="pipe_diameter"    /> | 
|---|
|  |  |  | <result property="color"    column="color"    /> | 
|---|
|  |  |  | <result property="position"    column="position"    /> | 
|---|
|  |  |  | <result property="type"    column="type"    /> | 
|---|
|  |  |  | <result property="alarmType"    column="alarm_type"    /> | 
|---|
|  |  |  | <result property="alarmTime"    column="alarm_time"    /> | 
|---|
|  |  |  | <result property="watcher"    column="watcher"    /> | 
|---|
|  |  |  | <result property="createTime"    column="create_time"    /> | 
|---|
|  |  |  | <result property="longitude"    column="longitude"    /> | 
|---|
|  |  |  | <result property="latitude"    column="latitude"    /> | 
|---|
|  |  |  | <result property="altitude"    column="altitude"    /> | 
|---|
|  |  |  | <result property="recordUrl"    column="record_url"    /> | 
|---|
|  |  |  | <result property="viewTime"    column="view_time"    /> | 
|---|
|  |  |  | <result property="id" column="id"/> | 
|---|
|  |  |  | <result property="host" column="host"/> | 
|---|
|  |  |  | <result property="tubeId" column="tube_id"/> | 
|---|
|  |  |  | <result property="tubeName" column="tube_name"/> | 
|---|
|  |  |  | <result property="tubeType" column="tube_type"/> | 
|---|
|  |  |  | <result property="pipeDiameter" column="pipe_diameter"/> | 
|---|
|  |  |  | <result property="color" column="color"/> | 
|---|
|  |  |  | <result property="position" column="position"/> | 
|---|
|  |  |  | <result property="type" column="type"/> | 
|---|
|  |  |  | <result property="alarmType" column="alarm_type"/> | 
|---|
|  |  |  | <result property="alarmTime" column="alarm_time"/> | 
|---|
|  |  |  | <result property="watcher" column="watcher"/> | 
|---|
|  |  |  | <result property="createTime" column="create_time"/> | 
|---|
|  |  |  | <result property="longitude" column="longitude"/> | 
|---|
|  |  |  | <result property="latitude" column="latitude"/> | 
|---|
|  |  |  | <result property="altitude" column="altitude"/> | 
|---|
|  |  |  | <result property="recordUrl" column="record_url"/> | 
|---|
|  |  |  | <result property="viewTime" column="view_time"/> | 
|---|
|  |  |  | </resultMap> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <sql id="selectArdAlarmTubeVo"> | 
|---|
|  |  |  | select id, host, tube_id, tube_name, tube_type, pipe_diameter, color, position, type, alarm_type, alarm_time, watcher, create_time, longitude, latitude, altitude,, record_url, view_time from ard_alarm_tube | 
|---|
|  |  |  | select id, | 
|---|
|  |  |  | host, | 
|---|
|  |  |  | tube_id, | 
|---|
|  |  |  | tube_name, | 
|---|
|  |  |  | tube_type, | 
|---|
|  |  |  | pipe_diameter, | 
|---|
|  |  |  | color, | 
|---|
|  |  |  | position, | 
|---|
|  |  |  | type, | 
|---|
|  |  |  | alarm_type, | 
|---|
|  |  |  | alarm_time, | 
|---|
|  |  |  | watcher, | 
|---|
|  |  |  | create_time, | 
|---|
|  |  |  | longitude, | 
|---|
|  |  |  | latitude, | 
|---|
|  |  |  | altitude, | 
|---|
|  |  |  | record_url, | 
|---|
|  |  |  | view_time | 
|---|
|  |  |  | from ard_alarm_tube | 
|---|
|  |  |  | </sql> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectArdAlarmTubeList" parameterType="ArdAlarmTube" resultMap="ArdAlarmTubeResult"> | 
|---|
|  |  |  | <include refid="selectArdAlarmTubeVo"/> | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="host != null  and host != ''"> and host = #{host}</if> | 
|---|
|  |  |  | <if test="tubeId != null  and tubeId != ''"> and tube_id = #{tubeId}</if> | 
|---|
|  |  |  | <if test="tubeName != null  and tubeName != ''"> and tube_name like '%'||#{tubeName}||'%'</if> | 
|---|
|  |  |  | <if test="tubeType != null  and tubeType != ''"> and tube_type = #{tubeType}</if> | 
|---|
|  |  |  | <if test="pipeDiameter != null  and pipeDiameter != ''"> and pipe_diameter = #{pipeDiameter}</if> | 
|---|
|  |  |  | <if test="color != null  and color != ''"> and color = #{color}</if> | 
|---|
|  |  |  | <if test="position != null  and position != ''"> and position = #{position}</if> | 
|---|
|  |  |  | <if test="type != null  and type != ''"> and type = #{type}</if> | 
|---|
|  |  |  | <if test="alarmType != null  and alarmType != ''"> and alarm_type = #{alarmType}</if> | 
|---|
|  |  |  | <if test="alarmTime != null "> and alarm_time = #{alarmTime}</if> | 
|---|
|  |  |  | <if test="watcher != null  and watcher != ''"> and watcher = #{watcher}</if> | 
|---|
|  |  |  | <if test="longitude != null  and longitude != ''"> and longitude = #{longitude}</if> | 
|---|
|  |  |  | <if test="latitude != null  and latitude != ''"> and latitude = #{latitude}</if> | 
|---|
|  |  |  | <if test="altitude != null  and altitude != ''"> and altitude = #{altitude}</if> | 
|---|
|  |  |  | <if test="recordUrl != null  and recordUrl != ''"> and record_url = #{recordUrl}</if> | 
|---|
|  |  |  | <if test="viewTime != null "> and view_time = #{viewTime}</if> | 
|---|
|  |  |  | <if test="host != null  and host != ''">and host = #{host}</if> | 
|---|
|  |  |  | <if test="tubeId != null  and tubeId != ''">and tube_id = #{tubeId}</if> | 
|---|
|  |  |  | <if test="tubeName != null  and tubeName != ''">and tube_name like '%'||#{tubeName}||'%'</if> | 
|---|
|  |  |  | <if test="tubeType != null  and tubeType != ''">and tube_type = #{tubeType}</if> | 
|---|
|  |  |  | <if test="pipeDiameter != null  and pipeDiameter != ''">and pipe_diameter = #{pipeDiameter}</if> | 
|---|
|  |  |  | <if test="color != null  and color != ''">and color = #{color}</if> | 
|---|
|  |  |  | <if test="position != null  and position != ''">and position = #{position}</if> | 
|---|
|  |  |  | <if test="type != null  and type != ''">and type = #{type}</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="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 --> | 
|---|
|  |  |  | AND alarm_time <= to_timestamp(#{params.endTime},'yyyy-MM-DD HH24:MI:ss') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="watcher != null  and watcher != ''">and watcher = #{watcher}</if> | 
|---|
|  |  |  | <if test="longitude != null  and longitude != ''">and longitude = #{longitude}</if> | 
|---|
|  |  |  | <if test="latitude != null  and latitude != ''">and latitude = #{latitude}</if> | 
|---|
|  |  |  | <if test="altitude != null  and altitude != ''">and altitude = #{altitude}</if> | 
|---|
|  |  |  | <if test="recordUrl != null  and recordUrl != ''">and record_url = #{recordUrl}</if> | 
|---|
|  |  |  | <if test="viewTime != null ">and view_time = #{viewTime}</if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | order by alarm_time desc | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectArdAlarmTubeById" parameterType="String" resultMap="ArdAlarmTubeResult"> | 
|---|
|  |  |  | 
|---|
|  |  |  | </update> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <delete id="deleteArdAlarmTubeById" parameterType="String"> | 
|---|
|  |  |  | delete from ard_alarm_tube where id = #{id} | 
|---|
|  |  |  | delete | 
|---|
|  |  |  | from ard_alarm_tube | 
|---|
|  |  |  | where id = #{id} | 
|---|
|  |  |  | </delete> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <delete id="deleteArdAlarmTubeByIds" parameterType="String"> | 
|---|
|  |  |  | 
|---|
|  |  |  | aat.latitude, | 
|---|
|  |  |  | aat.altitude, | 
|---|
|  |  |  | aat.record_url, | 
|---|
|  |  |  | ROW_NUMBER() OVER ( PARTITION BY aat.tube_id ORDER BY aat.alarm_time DESC ) AS rn, | 
|---|
|  |  |  | COUNT(CASE WHEN aat.view_time IS NULL THEN 1 END) OVER ( PARTITION BY aat.tube_id ) AS COUNT, | 
|---|
|  |  |  | ROW_NUMBER() OVER ( PARTITION BY aat.tube_id ORDER BY aat.alarm_time DESC ) AS rn, COUNT(CASE WHEN aat.view_time IS NULL THEN 1 END) OVER ( PARTITION BY aat.tube_id ) AS COUNT, | 
|---|
|  |  |  | COUNT ( aat.alarm_time ) OVER ( PARTITION BY tube_id ) AS total | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | ard_alarm_tube aat | 
|---|
|  |  |  | 
|---|
|  |  |  | ) T | 
|---|
|  |  |  | WHERE T.rn = 1 | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <select id="selectCountByStartTime" resultType="Integer"> | 
|---|
|  |  |  | <select id="selectCountByAlarmTime" resultType="Integer"> | 
|---|
|  |  |  | SELECT COUNT(DISTINCT aat.tube_id) | 
|---|
|  |  |  | FROM ard_alarm_tube aat | 
|---|
|  |  |  | WHERE aat.alarm_time >= CURRENT_TIMESTAMP - INTERVAL '%${refreshTime}%' MINUTE | 
|---|
|  |  |  | and aat.view_time is null | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <update id="updateViewTimeByTubeId" parameterType="String"> | 
|---|
|  |  |  | update ard_alarm_tube | 
|---|
|  |  |  | set view_time=#{viewTime} | 
|---|
|  |  |  | where tube_id = #{tubeId} | 
|---|
|  |  |  | and alarm_time<=#{alarmTime} | 
|---|
|  |  |  | and alarm_time <= #{alarmTime} | 
|---|
|  |  |  | and view_time is null | 
|---|
|  |  |  | </update> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </mapper> | 
|---|