2023-08-25 23:22:16 +08:00
<?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">
2023-08-26 18:08:05 +08:00
<mapper namespace= "com.yanzhu.jh.video.mapper.SurProjectVideoConfigMapper" >
2023-08-25 23:22:16 +08:00
<resultMap type= "SurProjectVideoConfig" id= "SurProjectVideoConfigResult" >
<result property= "id" column= "id" />
<result property= "projectId" column= "project_id" />
<result property= "projectName" column= "projectName" />
2023-08-26 00:36:09 +08:00
<result property= "videoName" column= "video_name" />
2023-08-25 23:22:16 +08:00
<result property= "videoOnlyType" column= "video_only_type" />
<result property= "videoDvrNumber" column= "video_dvr_number" />
<result property= "videoDvrSecurity" column= "video_dvr_security" />
<result property= "videoPassageCount" column= "video_passage_count" />
2023-08-26 18:08:05 +08:00
<result property= "passagePassCount" column= "passage_pass_count" />
<result property= "videoSort" column= "video_sort" />
2023-08-25 23:22:16 +08:00
<result property= "signalType" column= "signal_type" />
<result property= "signalState" column= "signal_state" />
<result property= "signalCode" column= "signal_code" />
<result property= "isDel" column= "is_del" />
<result property= "createBy" column= "create_by" />
<result property= "createTime" column= "create_time" />
<result property= "updateBy" column= "update_by" />
<result property= "updateTime" column= "update_time" />
<result property= "remark" column= "remark" />
</resultMap>
<resultMap id= "SurProjectVideoConfigSurProjectVideoPassageResult" type= "SurProjectVideoConfig" extends= "SurProjectVideoConfigResult" >
<collection property= "surProjectVideoPassageList" notNullColumn= "sub_id" javaType= "java.util.List" resultMap= "SurProjectVideoPassageResult" />
</resultMap>
<resultMap type= "SurProjectVideoPassage" id= "SurProjectVideoPassageResult" >
<result property= "id" column= "sub_id" />
<result property= "videoId" column= "sub_video_id" />
<result property= "videoDvrNumber" column= "sub_video_dvr_number" />
<result property= "passageName" column= "sub_passage_name" />
<result property= "passageValue" column= "sub_passage_value" />
2023-08-26 22:21:19 +08:00
<result property= "passageState" column= "sub_passage_state" />
2023-08-25 23:22:16 +08:00
</resultMap>
<sql id= "selectSurProjectVideoConfigVo" >
2023-08-26 18:08:05 +08:00
select spvc.id, spvc.project_id, spvc.video_name, spvc.video_only_type, spvc.video_dvr_number, spvc.video_dvr_security, spvc.video_passage_count, spvc.passage_pass_count, spvc.video_sort, spvc.signal_type, spvc.signal_state, spvc.signal_code, spvc.is_del, spvc.create_by, spvc.create_time, spvc.update_by, spvc.update_time, spvc.remark, sp.projectName from sur_project_video_config spvc
2023-08-25 23:22:16 +08:00
left join sur_project sp on sp.id=spvc.project_id
</sql>
<select id= "selectSurProjectVideoConfigList" parameterType= "SurProjectVideoConfig" resultMap= "SurProjectVideoConfigResult" >
<include refid= "selectSurProjectVideoConfigVo" />
<where >
and spvc.is_del='0'
<if test= "projectId != null " > and spvc.project_id = #{projectId}</if>
<if test= "projectName != null " > and sp.projectName like concat('%', #{projectName}, '%')</if>
2023-08-26 00:36:09 +08:00
<if test= "videoName != null " > and spvc.video_name like concat('%', #{videoName}, '%')</if>
2023-08-25 23:22:16 +08:00
<if test= "videoOnlyType != null and videoOnlyType != ''" > and spvc.video_only_type = #{videoOnlyType}</if>
<if test= "videoDvrNumber != null and videoDvrNumber != ''" > and spvc.video_dvr_number like concat('%', #{videoDvrNumber}, '%')</if>
<if test= "videoDvrSecurity != null and videoDvrSecurity != ''" > and spvc.video_dvr_security = #{videoDvrSecurity}</if>
<if test= "signalType != null and signalType != ''" > and spvc.signal_type = #{signalType}</if>
<if test= "signalState != null and signalState != ''" > and spvc.signal_state = #{signalState}</if>
<if test= "signalCode != null and signalCode != ''" > and spvc.signal_code = #{signalCode}</if>
<if test= "isDel != null and isDel != ''" > and spvc.is_del = #{isDel}</if>
<!-- 查询条件 - 项目部门 -->
<if test= "projectDeptId != null " > and sp.deptId = #{projectDeptId}</if>
<!-- 子部门数据 -->
<if test= 'nowRole == "4"' > and sp.deptId = #{nowDept}</if>
<!-- 监理单位/总包公司/分包单位查询当前关联数据 -->
<if test= 'nowRole == "5" or nowRole == "6" or nowRole == "7"' > and sp.id in (select DISTINCT spui.projectId from sur_project_unit_info spui where spui.unitId = #{nowDept})</if>
2023-09-05 00:45:38 +08:00
<if test= 'nowRole == "15" or nowRole == "16" or nowRole == "17" or nowRole == "99"' > and sp.id in (select DISTINCT spu.project_id from sur_project_userinfo spu where spu.user_id = #{nowUser} and spu.is_del=0)</if>
2023-08-25 23:22:16 +08:00
</where>
2023-08-26 18:08:05 +08:00
order by spvc.video_sort asc, spvc.video_name
2023-08-25 23:22:16 +08:00
</select>
<select id= "selectSurProjectVideoConfigById" parameterType= "Long" resultMap= "SurProjectVideoConfigSurProjectVideoPassageResult" >
2023-08-26 18:08:05 +08:00
select a.id, a.project_id, a.video_name, a.video_only_type, a.video_dvr_number, a.video_dvr_security, a.video_passage_count, a.passage_pass_count, a.video_sort, a.signal_type, a.signal_state, a.signal_code, a.is_del, a.create_by, a.create_time, a.update_by, a.update_time, a.remark, p.projectName,
2023-08-25 23:22:16 +08:00
b.id as sub_id, b.video_id as sub_video_id, b.video_dvr_number as sub_video_dvr_number, b.passage_name as sub_passage_name, b.passage_value as sub_passage_value
from sur_project_video_config a
left join sur_project p on a.project_id=p.id
left join sur_project_video_passage b on b.video_id = a.id
where a.id = #{id}
</select>
2023-08-26 18:08:05 +08:00
<select id= "selectSurProjectVideoConfigByDvrNumber" parameterType= "String" resultMap= "SurProjectVideoConfigSurProjectVideoPassageResult" >
select a.id, a.project_id, a.video_name, a.video_only_type, a.video_dvr_number, a.video_dvr_security, a.video_passage_count, a.passage_pass_count, a.video_sort, a.signal_type, a.signal_state, a.signal_code, a.is_del, a.create_by, a.create_time, a.update_by, a.update_time, a.remark, p.projectName,
2023-08-26 22:21:19 +08:00
b.id as sub_id, b.video_id as sub_video_id, b.video_dvr_number as sub_video_dvr_number, b.passage_name as sub_passage_name, b.passage_value as sub_passage_value, b.passage_state as sub_passage_state
2023-08-26 18:08:05 +08:00
from sur_project_video_config a
left join sur_project p on a.project_id=p.id
left join sur_project_video_passage b on b.video_id = a.id
where a.video_dvr_number = #{videoDvrNumber}
</select>
2023-08-25 23:22:16 +08:00
<insert id= "insertSurProjectVideoConfig" parameterType= "SurProjectVideoConfig" useGeneratedKeys= "true" keyProperty= "id" >
insert into sur_project_video_config
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "projectId != null" > project_id,</if>
2023-08-26 00:36:09 +08:00
<if test= "videoName != null" > video_name,</if>
2023-08-25 23:22:16 +08:00
<if test= "videoOnlyType != null" > video_only_type,</if>
<if test= "videoDvrNumber != null" > video_dvr_number,</if>
<if test= "videoDvrSecurity != null" > video_dvr_security,</if>
<if test= "videoPassageCount != null" > video_passage_count,</if>
2023-08-26 18:08:05 +08:00
<if test= "passagePassCount != null" > passage_pass_count,</if>
<if test= "videoSort != null" > video_sort,</if>
2023-08-25 23:22:16 +08:00
<if test= "signalType != null" > signal_type,</if>
<if test= "signalState != null" > signal_state,</if>
<if test= "signalCode != null" > signal_code,</if>
<if test= "isDel != null" > is_del,</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>
<if test= "remark != null" > remark,</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "projectId != null" > #{projectId},</if>
2023-08-26 00:36:09 +08:00
<if test= "videoName != null" > #{videoName},</if>
2023-08-25 23:22:16 +08:00
<if test= "videoOnlyType != null" > #{videoOnlyType},</if>
<if test= "videoDvrNumber != null" > #{videoDvrNumber},</if>
<if test= "videoDvrSecurity != null" > #{videoDvrSecurity},</if>
<if test= "videoPassageCount != null" > #{videoPassageCount},</if>
2023-08-26 18:08:05 +08:00
<if test= "passagePassCount != null" > #{passagePassCount},</if>
<if test= "videoSort != null" > #{videoSort},</if>
2023-08-25 23:22:16 +08:00
<if test= "signalType != null" > #{signalType},</if>
<if test= "signalState != null" > #{signalState},</if>
<if test= "signalCode != null" > #{signalCode},</if>
<if test= "isDel != null" > #{isDel},</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>
<if test= "remark != null" > #{remark},</if>
</trim>
</insert>
<update id= "updateSurProjectVideoConfig" parameterType= "SurProjectVideoConfig" >
update sur_project_video_config
<trim prefix= "SET" suffixOverrides= "," >
2023-08-26 18:08:05 +08:00
<if test= "projectId != null and projectId>0" > project_id = #{projectId},</if>
<if test= "projectId == 0" > project_id = NULL,</if>
2023-08-26 00:36:09 +08:00
<if test= "videoName != null" > video_name = #{videoName},</if>
2023-08-25 23:22:16 +08:00
<if test= "videoOnlyType != null" > video_only_type = #{videoOnlyType},</if>
<if test= "videoDvrNumber != null" > video_dvr_number = #{videoDvrNumber},</if>
<if test= "videoDvrSecurity != null" > video_dvr_security = #{videoDvrSecurity},</if>
<if test= "videoPassageCount != null" > video_passage_count = #{videoPassageCount},</if>
2023-08-26 18:08:05 +08:00
<if test= "passagePassCount != null" > passage_pass_count = #{passagePassCount},</if>
<if test= "videoSort != null" > video_sort = #{videoSort},</if>
2023-08-25 23:22:16 +08:00
<if test= "signalType != null" > signal_type = #{signalType},</if>
<if test= "signalState != null" > signal_state = #{signalState},</if>
<if test= "signalCode != null" > signal_code = #{signalCode},</if>
<if test= "isDel != null" > is_del = #{isDel},</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>
<if test= "remark != null" > remark = #{remark},</if>
</trim>
where id = #{id}
</update>
2023-08-26 18:08:05 +08:00
<update id= "deleteSurProjectVideoConfigById" parameterType= "Long" >
update sur_project_video_config set is_del=1 where id = #{id}
</update>
2023-08-25 23:22:16 +08:00
2023-08-26 18:08:05 +08:00
<update id= "deleteSurProjectVideoConfigByIds" parameterType= "String" >
update sur_project_video_config set is_del=1 where id in
2023-08-25 23:22:16 +08:00
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
2023-08-26 18:08:05 +08:00
</update>
2023-08-25 23:22:16 +08:00
<delete id= "deleteSurProjectVideoPassageByVideoIds" parameterType= "String" >
delete from sur_project_video_passage where video_id in
<foreach item= "videoId" collection= "array" open= "(" separator= "," close= ")" >
#{videoId}
</foreach>
</delete>
<delete id= "deleteSurProjectVideoPassageByVideoId" parameterType= "Long" >
delete from sur_project_video_passage where video_id = #{videoId}
</delete>
<insert id= "batchSurProjectVideoPassage" >
2023-08-26 22:21:19 +08:00
insert into sur_project_video_passage( id, video_id, video_dvr_number, passage_name, passage_value,passage_state) values
2023-08-25 23:22:16 +08:00
<foreach item= "item" index= "index" collection= "list" separator= "," >
2023-08-26 22:21:19 +08:00
( #{item.id}, #{item.videoId}, #{item.videoDvrNumber}, #{item.passageName}, #{item.passageValue}, #{item.passageState})
2023-08-25 23:22:16 +08:00
</foreach>
</insert>
2023-08-26 18:08:05 +08:00
<update id= "updateProjectVideoPassageState" parameterType= "SurProjectVideoPassage" >
update sur_project_video_passage set passage_state=#{passageState} where id = #{id}
</update>
2023-08-25 23:22:16 +08:00
</mapper>