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

531 lines
22 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="thumb" jdbcType="VARCHAR" property="thumb"/>
<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>
<resultMap id="PhotoMarkMap" type="com.shxy.xymanager_common.dto.PhotoMarkDto">
<result column="id" jdbcType="INTEGER" property="markId"/>
<result column="term_id" jdbcType="INTEGER" property="termId"/>
<result column="channel_id" jdbcType="INTEGER" property="channelId"/>
<result column="width" jdbcType="INTEGER" property="width"/>
<result column="mark_id" jdbcType="INTEGER" property="markId"/>
<result column="height" jdbcType="INTEGER" property="height"/>
<result column="color" jdbcType="VARCHAR" property="color"/>
<result column="boder_width" jdbcType="SMALLINT" property="boderWidth"/>
<result column="path" jdbcType="VARCHAR" property="path"/>
<collection property="list" javaType="list" ofType="com.shxy.xymanager_common.dto.TermChannelCoordinateDto">
<result column="x1" jdbcType="FLOAT" property="x1"/>
<result column="x2" jdbcType="FLOAT" property="x2"/>
<result column="y1" jdbcType="FLOAT" property="y1"/>
<result column="y2" jdbcType="FLOAT" property="y2"/>
</collection>
</resultMap>
<resultMap id="TermAndChannelLatestPhotoMap"
type="com.shxy.xymanager_common.dto.TermAndChannelLatestPhotoMapperDto">
<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="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"/>
</resultMap>
<resultMap id="PhotoResultMap" 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="thumb" jdbcType="VARCHAR" property="thumb"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="width" jdbcType="INTEGER" property="markWidth"/>
<result column="height" jdbcType="INTEGER" property="markHeight"/>
<result column="color" jdbcType="VARCHAR" property="color"/>
<result column="boder_width" jdbcType="SMALLINT" property="boderWidth"/>
<collection property="lineList" javaType="list" ofType="com.shxy.xymanager_common.dto.TermChannelCoordinateDto">
<result column="x1" jdbcType="FLOAT" property="x1"/>
<result column="x2" jdbcType="FLOAT" property="x2"/>
<result column="y1" jdbcType="FLOAT" property="y1"/>
<result column="y2" jdbcType="FLOAT" property="y2"/>
</collection>
</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, thumb,create_time
</sql>
<select id="selectPhotoList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminal_photos
where photo_time between #{starttime} and #{endtime}
<if test="terminalid != null">
and term_id = #{terminalid}
</if>
<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="selectPhotoListByOrginIdList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminal_photos
<if test="orginidlist != null and orginidlist.size > 0">
where orginal_id in
<foreach collection="orginidlist" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="selectPhotoListByTermList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminal_photos
where photo_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="channelidlist != null and channelidlist.size > 0">
and channel_id in
<foreach collection="channelidlist" 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.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="selectTermAndChannelLatestPhotoList" resultMap="TermAndChannelLatestPhotoMap">
SELECT
a.id as id,
a.term_id as term_id,
a.channel_id as channel_id,
a.path as path,
a.preset_id as preset_id,
a.orginal_id as orginal_id,
a.photo_time as photo_time,
a.recv_time as recv_time,
a.media_type as media_type
FROM terminal_photos a
JOIN (SELECT max(id) AS id FROM terminal_photos WHERE term_id in
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
GROUP BY term_id , channel_id) b ON a.id = b.id
WHERE term_id in
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
GROUP BY term_id , channel_id
</select>
<select id="getLatestPhoto" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
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 tm left join schedule_details 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} and tip.channel_id = #{channelId,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
data
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>
<insert id="addPhotoMark" keyProperty="id" useGeneratedKeys="true"
parameterType="com.shxy.xymanager_common.vo.PhotoMarkVo">
insert into terminal_photo_marks (term_id, channel_id,
color, width, height,boder_width ,create_time
)
values (#{termId,jdbcType=INTEGER}, #{channelId,jdbcType=INTEGER},
#{color,jdbcType=INTEGER}, #{width,jdbcType=INTEGER}, #{height,jdbcType=INTEGER},
#{boderWidth,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="addPhotoMarkPath" parameterType="java.util.List">
insert into terminal_photo_mark_paths (mark_id, x1,
x2, y1, y2
)
values
<foreach collection="list" item="item" separator=",">
(#{markId,jdbcType=INTEGER}, #{item.x1,jdbcType=INTEGER}, #{item.x2,jdbcType=INTEGER},
#{item.y1,jdbcType=INTEGER}, #{item.y2,jdbcType=INTEGER}
)
</foreach>
</insert>
<update id="updatePhotoMark" parameterType="com.shxy.xymanager_common.vo.PhotoMarkVo">
update `terminal_photo_marks`
<set>
<if test="termId != null">
term_id = #{termId,jdbcType=VARCHAR},
</if>
<if test="channelId != null">
channel_id = #{channelId,jdbcType=INTEGER},
</if>
<if test="color != null">
color = #{color,jdbcType=INTEGER},
</if>
<if test="width != null">
width = #{width,jdbcType=INTEGER},
</if>
<if test="height != null">
height = #{height,jdbcType=INTEGER},
</if>
<if test="boderWidth != null">
boder_width = #{boderWidth,jdbcType=INTEGER},
</if>
</set>
where id = #{id}
</update>
<delete id="deleteByMarkId">
delete from terminal_photo_mark_paths
where mark_id = #{markId}
</delete>
<select id="selectPhotoMark" resultMap="PhotoMarkMap" parameterType="com.shxy.xymanager_common.vo.MarkReqVo">
select
tpm.term_id as term_id,
tpm.channel_id as channel_id,
tpm.id as id,
tpm.width as width,
tpm.height as height,
tpm.color as color,
tpm.boder_width as boder_width,
tpm.id as mark_id,
tpmp.x1 as x1,
tpmp.x2 as x2,
tpmp.y1 as y1,
tpmp.y2 as y2,
tp.path as path
from
(
SELECT path,term_id,channel_id
from terminal_photos where id = (select max(id) from terminal_photos where media_type =0 and
term_id = #{termId} and channel_id = #{channelId})
)tp left join terminal_photo_marks tpm on tpm.term_id = tp.term_id and tpm.channel_id = tp.channel_id
left join terminal_photo_mark_paths tpmp on tpmp.mark_id = tpm.id
where tp.term_id = #{termId} and tp.channel_id = #{channelId}
</select>
<select id="selectPhotoWithoutPic" resultMap="PhotoMarkMap" parameterType="com.shxy.xymanager_common.vo.MarkReqVo">
select
tpm.term_id as term_id,
tpm.channel_id as channel_id,
tpm.id as id,
tpm.width as width,
tpm.height as height,
tpm.color as color,
tpm.boder_width as boder_width,
tpm.id as mark_id,
tpmp.x1 as x1,
tpmp.x2 as x2,
tpmp.y1 as y1,
tpmp.y2 as y2
from
terminal_photo_marks tpm left join terminal_photo_mark_paths tpmp on tpmp.mark_id = tpm.id
where tpm.term_id = #{termId} and tpm.channel_id = #{channelId}
</select>
</mapper>