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/TerminalPhotoDao.xml

314 lines
12 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.TerminalPhotoDao">
<resultMap id="BaseResultMap" type="com.shxy.xymanager_common.entity.TerminalPhoto">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="term_id" jdbcType="INTEGER" property="termId"/>
<result column="channel_id" jdbcType="INTEGER" property="channelId"/>
<result column="preset_id" jdbcType="INTEGER" property="presetId"/>
<result column="orginal_id" jdbcType="INTEGER" property="orginalId"/>
<result column="media_type" jdbcType="INTEGER" property="mediaType"/>
<result column="width" jdbcType="INTEGER" property="width"/>
<result column="height" jdbcType="INTEGER" property="height"/>
<result column="file_size" jdbcType="INTEGER" property="fileSize"/>
<result column="photo_time" jdbcType="BIGINT" property="photoTime"/>
<result column="recv_time" jdbcType="BIGINT" property="recvTime"/>
<result column="path" jdbcType="VARCHAR" property="path"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
</resultMap>
<resultMap id="PhotoAndLineAndChannelMap" type="com.shxy.xymanager_common.dto.PhotoAndLineAndChannelDto">
<result column="term_id" jdbcType="INTEGER" property="termid"/>
<result column="display_name" jdbcType="VARCHAR" property="displayname"/>
<result column="line_id" jdbcType="INTEGER" property="lineid"/>
<result column="line_name" jdbcType="VARCHAR" property="linename"/>
<result column="channel_id" jdbcType="INTEGER" property="channelid"/>
<result column="channel_name" jdbcType="VARCHAR" property="channnelname"/>
<result column="preset_id" jdbcType="INTEGER" property="presetId"/>
<result column="orginal_id" jdbcType="BIGINT" property="orginalid"/>
<result column="media_type" jdbcType="INTEGER" property="mediatype"/>
<result column="photo_time" jdbcType="BIGINT" property="photoTime"/>
<result column="recv_time" jdbcType="BIGINT" property="recvTime"/>
<result column="path" jdbcType="VARCHAR" property="path"/>
<result column="media_type" jdbcType="VARCHAR" property="mediatype"/>
</resultMap>
<sql id="Base_Column_List">
id, term_id, channel_id,orginal_id, media_type,preset_id, width, height, file_size, photo_time, recv_time,
path, create_time
</sql>
<select id="selectPhotoList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminal_photos
where term_id = #{terminalid} and photo_time between #{starttime} and #{endtime}
<if test="channelid != null and channelid.size>0">
and channel_id in
<foreach collection="channelid" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
order by photo_time desc
</select>
<!-- <select id="selectPhotos" resultMap="BaseResultMap">-->
<!-- select-->
<!-- <include refid="Base_Column_List"/>-->
<!-- from terminal_photos-->
<!-- order by photo_time desc-->
<!-- </select>-->
<select id="selectPhotos" resultMap="PhotoAndLineAndChannelMap">
select
a.term_id as term_id,
b.display_name as display_name,
b.line_id as line_id,
c.name as line_name,
a.channel_id as channel_id,
d.channel_name as channel_name,
a.preset_id as preset_id,
a.orginal_id as orginal_id,
a.media_type as media_type,
a.photo_time as photo_time,
a.recv_time as recv_time,
a.path as path,
a.media_type as media_type
FROM
(((terminal_photos a
left JOIN terminals b ON a.term_id = b.id )
join `lines` c on b.line_id = c.id)
join terminal_channels d on a.channel_id = d.id)
order by photo_time desc
</select>
<select id="getLatestPhoto" resultType="java.math.BigInteger">
select
recv_time photoTime
from terminal_photos
where term_id = #{termId}
order by recv_time desc limit 1
</select>
<select id="selectPhotoListForOpen" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminal_photos
where term_id = #{termId}
<if test="starttime != null and endtime != null">
and photo_time between #{starttime} and #{endtime}
</if>
<if test="starttime != null and endtime == null">
and photo_time <![CDATA[>=]]> #{starttime}
</if>
<if test="starttime == null and endtime != null">
and photo_time <![CDATA[<=]]> #{endtime}
</if>
order by photo_time desc
</select>
<select id="selectPhotoSchedule" resultType="com.shxy.xymanager_common.dto.TerminalPhotoScheduleDto">
select
t.cmdid cmid,
tscr.start_time startTime,
end_time endTime,
span
from terminal_schedule_mapper tm left join terminal_schedule_rule tscr on tm.schedule_id = tscr.schedule_id
left join terminals t on tm.term_id=t.id
where tm.term_id = #{termId} and tm.channel_id = #{channel}
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminal_photos
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from terminal_photos
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.shxy.xymanager_common.entity.TerminalPhoto">
insert into terminal_photos (id, term_id, channel_id,
preset_id, width, height,
file_size, photo_time, recv_time,
path, create_time
)
values (#{id,jdbcType=BIGINT}, #{termId,jdbcType=INTEGER}, #{channelId,jdbcType=INTEGER},
#{presetId,jdbcType=TINYINT}, #{width,jdbcType=INTEGER}, #{height,jdbcType=INTEGER},
#{fileSize,jdbcType=INTEGER}, #{photoTime,jdbcType=TIMESTAMP}, #{recvTime,jdbcType=TIMESTAMP},
#{path,jdbcType=VARCHAR}, #{createTime,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.shxy.xymanager_common.entity.TerminalPhoto">
insert into terminal_photos
<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="width != null">
width,
</if>
<if test="height != null">
height,
</if>
<if test="fileSize != null">
file_size,
</if>
<if test="photoTime != null">
photo_time,
</if>
<if test="recvTime != null">
recv_time,
</if>
<if test="path != null">
path,
</if>
<if test="createTime != null">
create_time,
</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=INTEGER},
</if>
<if test="presetId != null">
#{presetId,jdbcType=TINYINT},
</if>
<if test="width != null">
#{width,jdbcType=INTEGER},
</if>
<if test="height != null">
#{height,jdbcType=INTEGER},
</if>
<if test="fileSize != null">
#{fileSize,jdbcType=INTEGER},
</if>
<if test="photoTime != null">
#{photoTime,jdbcType=TIMESTAMP},
</if>
<if test="recvTime != null">
#{recvTime,jdbcType=TIMESTAMP},
</if>
<if test="path != null">
#{path,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.shxy.xymanager_common.entity.TerminalPhoto">
update terminal_photos
<set>
<if test="termId != null">
term_id = #{termId,jdbcType=INTEGER},
</if>
<if test="channelId != null">
channel_id = #{channelId,jdbcType=INTEGER},
</if>
<if test="presetId != null">
preset_id = #{presetId,jdbcType=TINYINT},
</if>
<if test="width != null">
width = #{width,jdbcType=INTEGER},
</if>
<if test="height != null">
height = #{height,jdbcType=INTEGER},
</if>
<if test="fileSize != null">
file_size = #{fileSize,jdbcType=INTEGER},
</if>
<if test="photoTime != null">
photo_time = #{photoTime,jdbcType=TIMESTAMP},
</if>
<if test="recvTime != null">
recv_time = #{recvTime,jdbcType=TIMESTAMP},
</if>
<if test="path != null">
path = #{path,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.shxy.xymanager_common.entity.TerminalPhoto">
update terminal_photos
set term_id = #{termId,jdbcType=INTEGER},
channel_id = #{channelId,jdbcType=INTEGER},
preset_id = #{presetId,jdbcType=TINYINT},
width = #{width,jdbcType=INTEGER},
height = #{height,jdbcType=INTEGER},
file_size = #{fileSize,jdbcType=INTEGER},
photo_time = #{photoTime,jdbcType=TIMESTAMP},
recv_time = #{recvTime,jdbcType=TIMESTAMP},
path = #{path,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=INTEGER}
where id = #{id,jdbcType=BIGINT}
</update>
<select id="selectPhotoParams" resultType="com.shxy.xymanager_common.dto.PhotoParamsDto">
select
tip.term_id termId,
tip.color color,
tip.resolution resolution,
tip.luminance luminance,
tip.saturation saturation,
t.cmdid cmdId
from terminal_img_params tip left join terminals t on tip.term_id = t.id
where tip.term_id = #{termId,jdbcType=INTEGER}
</select>
<select id="selectCmdIdById" resultType="java.lang.Integer">
select
cmdid
from terminals
where term_id = #{termId,jdbcType=INTEGER}
</select>
<select id="getRequestResult" resultType="java.lang.String">
select
result
from request_results
where request_id = #{requestId,jdbcType=TINYINT}
</select>
<!--<select id="selectCmdIdById" resultType="java.lang.Integer">
select
term_id as termId
from terminal_img_params
where term_id = #{termId,jdbcType=INTEGER} and channel_id = #{channelId,jdbcType=INTEGER}
</select>-->
<insert id="insertParams" parameterType="com.shxy.xymanager_common.vo.PhotoParamsVo">
insert ignore into terminal_img_params
(term_id,color,resolution,luminance,saturation)
values
(termId,color,resolution,luminance,saturation)
</insert>
<select id="getLatestPhotoParam" resultType="java.lang.Integer">
select
photo_time photoTime
from terminal_img_params
where term_id = #{termId}
order by create_time desc limit 1
</select>
</mapper>