You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
backend/xymanager_dao/src/main/resources/mappers/TerminalImgAlarmsDao.xml

190 lines
7.8 KiB
XML

<?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.shxy.xymanager_dao.dao.TerminalImgAlarmsDao">
<resultMap id="BaseResultMap" type="com.shxy.xymanager_common.entity.TerminalImgAlarms">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="term_id" jdbcType="INTEGER" property="termId"/>
<result column="channel_id" jdbcType="TINYINT" property="channelId"/>
<result column="preset_id" jdbcType="TINYINT" property="presetId"/>
<result column="photo_org_id" jdbcType="INTEGER" property="photoOrgId"/>
<result column="alarm_time" jdbcType="BIGINT" property="alarmTime"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="alarm_info" jdbcType="LONGVARCHAR" property="alarmInfo"/>
</resultMap>
<resultMap id="AlarmsAndDetailsMap" type="com.shxy.xymanager_common.dto.TerminalImgAlarmsDto">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="term_id" jdbcType="INTEGER" property="termId"/>
<result column="channel_id" jdbcType="TINYINT" property="channelId"/>
<result column="preset_id" jdbcType="TINYINT" property="presetId"/>
<result column="photo_org_id" jdbcType="BIGINT" property="photoOrgId"/>
<result column="alarm_time" jdbcType="BIGINT" property="alarmTime"/>
<result column="label" jdbcType="INTEGER" property="label"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="en_name" jdbcType="VARCHAR" property="enname"/>
<result column="prob" jdbcType="REAL" property="prob"/>
<result column="x" jdbcType="REAL" property="x"/>
<result column="y" jdbcType="REAL" property="y"/>
<result column="width" jdbcType="REAL" property="width"/>
<result column="height" jdbcType="REAL" property="height"/>
<result column="isread" jdbcType="INTEGER" property="isread"/>
</resultMap>
<sql id="Base_Column_List">
id, term_id, channel_id, preset_id, photo_org_id,alarm_info, alarm_time, create_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminal_img_alarms
where id = #{id,jdbcType=BIGINT}
</select>
<select id="selectAlarmsDetails" resultMap="AlarmsAndDetailsMap">
select
b.id as id,
a.term_id as term_id,
a.channel_id as channel_id,
a.preset_id as preset_id,
a.photo_org_id as photo_org_id,
a.alarm_time as alarm_time,
b.label as label,
b.name as name,
b.en_name as en_name,
b.prob as prob,
b.x as x,
b.y as y,
b.width as width,
b.height as height,
b.isread as isread
from
terminal_img_alarms a left join terminal_img_alarm_details b on a.id = b.alarm_id
where a.alarm_time between #{starttime} and #{endtime}
<if test="terminalidlist != null and terminalidlist.size > 0">
and term_id in
<foreach collection="terminalidlist" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="labellist != null and labellist.size > 0">
and
<foreach collection="labellist" item="item" index="index" separator="or">
(
<if test="item.label != null">
label = #{item.label}
</if>
<if test="item.prob != null">
and prob >= #{item.prob}
</if>
)
</foreach>
</if>
order by a.alarm_time desc
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from terminal_img_alarms
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.shxy.xymanager_common.entity.TerminalImgAlarms">
insert into terminal_img_alarms (id, term_id, channel_id,
preset_id, photo_org_id, alarm_time,
create_time, alarm_info)
values (#{id,jdbcType=BIGINT}, #{termId,jdbcType=INTEGER}, #{channelId,jdbcType=TINYINT},
#{presetId,jdbcType=TINYINT}, #{photoOrgId,jdbcType=INTEGER}, #{alarmTime,jdbcType=BIGINT},
#{createTime,jdbcType=TIMESTAMP}, #{alarmInfo,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.shxy.xymanager_common.entity.TerminalImgAlarms">
insert into terminal_img_alarms
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="termId != null">
term_id,
</if>
<if test="channelId != null">
channel_id,
</if>
<if test="presetId != null">
preset_id,
</if>
<if test="photoOrgId != null">
photo_org_id,
</if>
<if test="alarmTime != null">
alarm_time,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="alarmInfo != null">
alarm_info,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="termId != null">
#{termId,jdbcType=INTEGER},
</if>
<if test="channelId != null">
#{channelId,jdbcType=TINYINT},
</if>
<if test="presetId != null">
#{presetId,jdbcType=TINYINT},
</if>
<if test="photoOrgId != null">
#{photoOrgId,jdbcType=INTEGER},
</if>
<if test="alarmTime != null">
#{alarmTime,jdbcType=BIGINT},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="alarmInfo != null">
#{alarmInfo,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.shxy.xymanager_common.entity.TerminalImgAlarms">
update terminal_img_alarms
<set>
<if test="termId != null">
term_id = #{termId,jdbcType=INTEGER},
</if>
<if test="channelId != null">
channel_id = #{channelId,jdbcType=TINYINT},
</if>
<if test="presetId != null">
preset_id = #{presetId,jdbcType=TINYINT},
</if>
<if test="photoOrgId != null">
photo_org_id = #{photoOrgId,jdbcType=INTEGER},
</if>
<if test="alarmTime != null">
alarm_time = #{alarmTime,jdbcType=BIGINT},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="alarmInfo != null">
alarm_info = #{alarmInfo,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.shxy.xymanager_common.entity.TerminalImgAlarms">
update terminal_img_alarms
set term_id = #{termId,jdbcType=INTEGER},
channel_id = #{channelId,jdbcType=TINYINT},
preset_id = #{presetId,jdbcType=TINYINT},
photo_org_id = #{photoOrgId,jdbcType=INTEGER},
alarm_time = #{alarmTime,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>