<?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.wall.mapper.ArdAlarmWallMapper">
|
|
<resultMap type="ArdAlarmWall" id="ArdAlarmWallResult">
|
<result property="id" column="id"/>
|
<result property="wallId" column="wall_id"/>
|
<result property="wallName" column="wall_name"/>
|
<result property="userId" column="user_id"/>
|
<result property="alarmType" column="alarm_type"/>
|
<result property="alarmTime" column="alarm_time"/>
|
<result property="longitude" column="longitude"/>
|
<result property="latitude" column="latitude"/>
|
<result property="altitude" column="altitude"/>
|
<result property="createBy" column="create_by"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateBy" column="update_by"/>
|
<result property="updateTime" column="update_time"/>
|
</resultMap>
|
|
<sql id="selectArdAlarmWallVo">
|
select id,
|
wall_id,
|
wall_name,
|
user_id,
|
alarm_type,
|
alarm_time,
|
longitude,
|
latitude,
|
altitude,
|
create_by,
|
create_time,
|
update_by,
|
update_time
|
from ard_alarm_wall
|
</sql>
|
|
<select id="selectArdAlarmWallList" parameterType="ArdAlarmWall" resultMap="ArdAlarmWallResult">
|
<include refid="selectArdAlarmWallVo"/>
|
<where>
|
<if test="wallId != null and wallId != ''">and wall_id = #{wallId}</if>
|
<if test="wallName != null and wallName != ''">and wall_name = #{wallName}</if>
|
<if test="userId != null and userId != ''">and user_id = #{userId}</if>
|
<if test="alarmType != null and alarmType != ''">and alarm_type = #{alarmType}</if>
|
<!-- <if test="alarmTime != null ">and alarm_time = #{alarmTime}</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="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>
|
</where>
|
order by alarm_time desc
|
</select>
|
|
<select id="selectArdAlarmWallById" parameterType="String" resultMap="ArdAlarmWallResult">
|
<include refid="selectArdAlarmWallVo"/>
|
where id = #{id}
|
</select>
|
|
<insert id="insertArdAlarmWall" parameterType="ArdAlarmWall">
|
insert into ard_alarm_wall
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">id,</if>
|
<if test="wallId != null">wall_id,</if>
|
<if test="wallName != null">wall_name,</if>
|
<if test="userId != null">user_id,</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="altitude != null">altitude,</if>
|
<if test="createBy != null">create_by,</if>
|
<if test="createTime != null">create_time,</if>
|
<if test="updateBy != null">update_by,</if>
|
<if test="updateTime != null">update_time,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="id != null">#{id},</if>
|
<if test="wallId != null">#{wallId},</if>
|
<if test="wallName != null">#{wallName},</if>
|
<if test="userId != null">#{userId},</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="altitude != null">#{altitude},</if>
|
<if test="createBy != null">#{createBy},</if>
|
<if test="createTime != null">#{createTime},</if>
|
<if test="updateBy != null">#{updateBy},</if>
|
<if test="updateTime != null">#{updateTime},</if>
|
</trim>
|
</insert>
|
|
<update id="updateArdAlarmWall" parameterType="ArdAlarmWall">
|
update ard_alarm_wall
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="wallId != null">wall_id = #{wallId},</if>
|
<if test="wallName != null">wall_name = #{wallName},</if>
|
<if test="userId != null">user_id = #{userId},</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="altitude != null">altitude = #{altitude},</if>
|
<if test="createBy != null">create_by = #{createBy},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
</trim>
|
where id = #{id}
|
</update>
|
|
<delete id="deleteArdAlarmWallById" parameterType="String">
|
delete
|
from ard_alarm_wall
|
where id = #{id}
|
</delete>
|
|
<delete id="deleteArdAlarmWallByIds" parameterType="String">
|
delete from ard_alarm_wall where id in
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</delete>
|
<select id="selectCountByAlarmTime" resultType="Integer">
|
SELECT COUNT(DISTINCT aaw.wall_name)
|
FROM ard_alarm_wall aaw
|
WHERE aaw.alarm_time >= CURRENT_TIMESTAMP - INTERVAL '%${refreshTime}%' MINUTE
|
and aaw.view_time is null
|
</select>
|
<select id="selectListAllByCommand" resultMap="ArdAlarmWallResult">
|
SELECT T.*
|
FROM (
|
SELECT aaa.ID,
|
aaa.user_id,
|
aaa.wall_NAME,
|
aaa.alarm_time,
|
aaa.longitude,
|
aaa.latitude,
|
aaa.altitude,
|
ROW_NUMBER() OVER ( PARTITION BY aaa.wall_NAME ORDER BY aaa.alarm_time DESC ) AS rn, COUNT(CASE WHEN aaa.view_time IS NULL THEN 1 END) OVER ( PARTITION BY aaa.wall_NAME ) AS COUNT,
|
COUNT ( aaa.alarm_time ) OVER ( PARTITION BY aaa.wall_NAME ) AS total
|
FROM
|
ard_alarm_wall aaa
|
WHERE
|
aaa.alarm_time >= ( CURRENT_TIMESTAMP - INTERVAL '%${refreshTime}%' MINUTE )
|
ORDER BY
|
aaa.create_time DESC
|
) T
|
WHERE T.rn = 1
|
</select>
|
<update id="updateViewTimeByUserId" parameterType="String">
|
update ard_alarm_wall
|
set view_time=#{viewTime}
|
where user_id = #{userId}
|
and create_time <= #{createTime}
|
and view_time is null
|
</update>
|
<select id="wallYear" resultType="com.ruoyi.statistical.vo.CountVo">
|
select to_char(alarm_time::DATE, 'MM') as date,count(id)
|
from ard_alarm_wall
|
where alarm_time >= #{start} and alarm_time <= #{end} group by date order by date
|
</select>
|
<select id="wallMonth" resultType="com.ruoyi.statistical.vo.CountVo">
|
select to_char(alarm_time::DATE, 'dd') as date,count(id)
|
from ard_alarm_wall
|
where alarm_time >= #{start} and alarm_time <= #{end} group by date order by date
|
</select>
|
</mapper>
|