<?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.digitization3.mapper.ArdAlarmDigitization3Mapper">
|
|
<resultMap type="ArdAlarmDigitization3" id="ArdAlarmDigitization3Result">
|
<result property="id" column="id" />
|
<result property="xmmc" column="xmmc" />
|
<result property="fKey" column="f_key" />
|
<result property="fName" column="f_name" />
|
<result property="wellNo" column="well_no" />
|
<result property="alarmTime" column="alarm_time" />
|
<result property="alarmType" column="alarm_type" />
|
<result property="longitude" column="longitude" />
|
<result property="latitude" column="latitude" />
|
<result property="altitude" column="altitude" />
|
<result property="createTime" column="create_time" />
|
<result property="viewTime" column="view_time" />
|
</resultMap>
|
|
<sql id="selectArdAlarmDigitization3Vo">
|
select id, xmmc, f_key, f_name, well_no, alarm_time, alarm_type, longitude, latitude, altitude, create_time, view_time from ard_alarm_digitization3
|
</sql>
|
|
<select id="selectArdAlarmDigitization3List" parameterType="ArdAlarmDigitization3" resultMap="ArdAlarmDigitization3Result">
|
<include refid="selectArdAlarmDigitization3Vo"/>
|
<where>
|
<if test="xmmc != null and xmmc != ''"> and xmmc = #{xmmc}</if>
|
<if test="fKey != null and fKey != ''"> and f_key = #{fKey}</if>
|
<if test="fName != null and fName != ''"> and f_name like '%'||#{fName}||'%'</if>
|
<if test="wellNo != null and wellNo != ''"> and well_no = #{wellNo}</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="alarmType != null and alarmType != ''"> and alarm_type = #{alarmType}</if>
|
<if test="longitude != null "> and longitude = #{longitude}</if>
|
<if test="latitude != null "> and latitude = #{latitude}</if>
|
<if test="altitude != null "> and altitude = #{altitude}</if>
|
<if test="viewTime != null "> and view_time = #{viewTime}</if>
|
</where>
|
</select>
|
|
<select id="selectArdAlarmDigitization3ById" parameterType="String" resultMap="ArdAlarmDigitization3Result">
|
<include refid="selectArdAlarmDigitization3Vo"/>
|
where id = #{id}
|
</select>
|
|
<insert id="insertArdAlarmDigitization3" parameterType="ArdAlarmDigitization3">
|
insert into ard_alarm_digitization3
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">id,</if>
|
<if test="xmmc != null">xmmc,</if>
|
<if test="fKey != null">f_key,</if>
|
<if test="fName != null">f_name,</if>
|
<if test="wellNo != null">well_no,</if>
|
<if test="alarmTime != null">alarm_time,</if>
|
<if test="alarmType != null">alarm_type,</if>
|
<if test="longitude != null">longitude,</if>
|
<if test="latitude != null">latitude,</if>
|
<if test="altitude != null">altitude,</if>
|
<if test="createTime != null">create_time,</if>
|
<if test="viewTime != null">view_time,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="id != null">#{id},</if>
|
<if test="xmmc != null">#{xmmc},</if>
|
<if test="fKey != null">#{fKey},</if>
|
<if test="fName != null">#{fName},</if>
|
<if test="wellNo != null">#{wellNo},</if>
|
<if test="alarmTime != null">#{alarmTime},</if>
|
<if test="alarmType != null">#{alarmType},</if>
|
<if test="longitude != null">#{longitude},</if>
|
<if test="latitude != null">#{latitude},</if>
|
<if test="altitude != null">#{altitude},</if>
|
<if test="createTime != null">#{createTime},</if>
|
<if test="viewTime != null">#{viewTime},</if>
|
</trim>
|
ON conflict(id) DO NOTHING;
|
</insert>
|
|
<update id="updateArdAlarmDigitization3" parameterType="ArdAlarmDigitization3">
|
update ard_alarm_digitization3
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="xmmc != null">xmmc = #{xmmc},</if>
|
<if test="fKey != null">f_key = #{fKey},</if>
|
<if test="fName != null">f_name = #{fName},</if>
|
<if test="wellNo != null">well_no = #{wellNo},</if>
|
<if test="alarmTime != null">alarm_time = #{alarmTime},</if>
|
<if test="alarmType != null">alarm_type = #{alarmType},</if>
|
<if test="longitude != null">longitude = #{longitude},</if>
|
<if test="latitude != null">latitude = #{latitude},</if>
|
<if test="altitude != null">altitude = #{altitude},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="viewTime != null">view_time = #{viewTime},</if>
|
</trim>
|
where id = #{id}
|
</update>
|
|
<delete id="deleteArdAlarmDigitization3ById" parameterType="String">
|
delete from ard_alarm_digitization3 where id = #{id}
|
</delete>
|
|
<delete id="deleteArdAlarmDigitization3ByIds" parameterType="String">
|
delete from ard_alarm_digitization3 where id in
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</delete>
|
<select id="selectListAllByCommand" resultMap="ArdAlarmDigitization3Result">
|
SELECT T
|
.*
|
FROM
|
(
|
SELECT
|
aad.ID,
|
aad.well_no,
|
aad.alarm_type,
|
aad.alarm_time,
|
aad.longitude,
|
aad.latitude,
|
aad.altitude,
|
ROW_NUMBER () OVER ( PARTITION BY aad.well_no ORDER BY aad.alarm_time DESC ) AS rn,
|
COUNT ( CASE WHEN aad.view_time IS NULL THEN 1 END ) OVER ( PARTITION BY aad.well_no ) AS COUNT,
|
COUNT ( aad.alarm_time ) OVER ( PARTITION BY aad.well_no ) AS total
|
FROM
|
ard_alarm_digitization3 aad
|
WHERE
|
aad.alarm_time >= ( CURRENT_TIMESTAMP - INTERVAL '%${refreshTime}%' MINUTE )
|
ORDER BY
|
aad.alarm_time DESC
|
) T
|
WHERE
|
T.rn = 1
|
</select>
|
<select id="selectCountByAlarmTime" resultType="Integer">
|
SELECT COUNT(DISTINCT aat.id)
|
FROM ard_alarm_digitization3 aat
|
WHERE aat.alarm_time >= CURRENT_TIMESTAMP - INTERVAL '%${refreshTime}%' MINUTE
|
and aat.view_time is null
|
</select>
|
<update id="updateViewTimeByWellNo" parameterType="String">
|
update ard_alarm_digitization3
|
set view_time=#{viewTime}
|
where well_no = #{wellNo}
|
and alarm_time <= #{alarmTime}
|
and view_time is null
|
</update>
|
</mapper>
|