2023-08-10 21:09:49 +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">
<mapper namespace= "com.yanzhu.jh.work.mapper.WorkTrainMapper" >
<resultMap type= "WorkTrain" id= "WorkTrainResult" >
<result property= "id" column= "id" />
2023-08-11 22:15:06 +08:00
<result property= "projectId" column= "project_id" />
<result property= "projectName" column= "project_name" />
2023-08-10 21:09:49 +08:00
<result property= "mainImage" column= "main_image" />
<result property= "trainType" column= "train_type" />
2023-08-13 22:10:35 +08:00
<result property= "trainTitle" column= "train_title" />
2023-08-10 21:09:49 +08:00
<result property= "trainNature" column= "train_nature" />
<result property= "trainParticipants" column= "train_participants" />
<result property= "beginDate" column= "begin_date" />
<result property= "endDate" column= "end_date" />
<result property= "trainContent" column= "train_content" />
2023-08-18 17:58:35 +08:00
<result property= "trainFile" column= "train_file" />
2023-08-10 21:09:49 +08:00
<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" />
2023-08-11 22:15:06 +08:00
<result property= "vDel" column= "v_del" />
2023-08-12 01:05:00 +08:00
<result property= "trainNatureName" column= "train_nature_name" />
2023-08-10 21:09:49 +08:00
</resultMap>
<resultMap id= "WorkTrainWorkTrainDeptResult" type= "WorkTrain" extends= "WorkTrainResult" >
<collection property= "workTrainDeptList" notNullColumn= "sub_train_id" javaType= "java.util.List" resultMap= "WorkTrainDeptResult" />
</resultMap>
<resultMap type= "WorkTrainDept" id= "WorkTrainDeptResult" >
<result property= "trainId" column= "sub_train_id" />
<result property= "deptId" column= "sub_dept_id" />
2023-08-11 22:15:06 +08:00
<result property= "deptName" column= "sub_dept_name" />
2023-08-10 21:09:49 +08:00
<result property= "isMain" column= "sub_is_main" />
</resultMap>
<sql id= "selectWorkTrainVo" >
2023-08-18 17:58:35 +08:00
select id, project_id, project_name, main_image, train_type, train_title,train_nature, train_participants, begin_date, end_date, train_content, train_file, is_del, create_by, create_time, update_by, update_time, remark from work_train
2023-08-10 21:09:49 +08:00
</sql>
<select id= "selectWorkTrainList" parameterType= "WorkTrain" resultMap= "WorkTrainResult" >
2023-08-18 17:58:35 +08:00
select wt.id, wt.project_id, wt.project_name, wt.main_image, wt.train_type, wt.train_title, wt.train_nature, wt.train_participants, wt.begin_date, wt.end_date, wt.train_content, wt.train_file, wt.is_del, wt.create_by, wt.create_time, wt.update_by, wt.update_time, wt.remark, group_concat(sd.dept_id) as trainDeptIds, group_concat(sd.dept_name) as trainDeptNames,
2023-08-11 22:15:06 +08:00
CASE
WHEN (
wt.create_by = #{nowUserName}
OR #{nowRole} IN ('1', '2', '3', '4')
)
2023-08-17 19:47:56 +08:00
AND begin_date > NOW() THEN
2023-08-11 22:15:06 +08:00
0
ELSE
1
END v_del
from work_train wt
left join work_train_dept wtd on wtd.train_id = wt.id
left join sys_dept sd on sd.dept_id = wtd.dept_id
2023-08-12 12:18:27 +08:00
left join sur_project sp on sp.id = wt.project_id
<!-- 监理单位/总包公司/分包单位 -->
<if test= 'nowRole == "5" or nowRole == "6" or nowRole == "7"' > left join sur_project_unit_info spui on spui.projectId = sp.id</if>
<!-- 普通用户查询项目人员 -->
<if test= 'nowRole == "99"' > left join sur_project_userinfo spu on spu.project_id = sp.id</if>
2023-08-11 22:15:06 +08:00
<where >
<if test= "projectId != null" > and wt.project_id = #{projectId}</if>
<if test= "projectName != null and projectName != ''" > and wt.project_name like concat('%', #{projectName}, '%')</if>
2023-08-10 21:09:49 +08:00
<if test= "trainType != null and trainType != ''" > and train_type = #{trainType}</if>
2023-08-14 22:51:52 +08:00
<if test= "trainTitle != null and trainTitle != ''" > and train_title like concat('%', #{trainTitle}, '%')</if>
2023-08-11 22:15:06 +08:00
<if test= "trainNature != null and trainNature != ''" > and wt.train_nature = #{trainNature}</if>
<if test= "isDel != null " > and wt.is_del = #{isDel}</if>
2023-08-17 19:39:25 +08:00
<if test= "params.beginMarksTime != null and params.beginMarksTime != '' and params.endMarksTime != null and params.endMarksTime != ''" > and wt.begin_date between #{params.beginMarksTime} and #{params.endMarksTime}</if>
2023-08-12 12:18:27 +08:00
<!-- 查询条件 - 项目部门 -->
<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 spui.unitId = #{nowDept}</if>
<!-- 监理单位/总包公司/分包单位查询当前关联数据 -->
<if test= 'nowRole == "5" or nowRole == "6" or nowRole == "7"' > and spui.unitId = #{nowDept}</if>
<!-- 普通用户查询项目人员 -->
<if test= 'nowRole == "99"' > and spu.user_id = #{nowUser} and spu.is_del=0</if>
2023-08-10 21:09:49 +08:00
</where>
2023-08-12 01:05:00 +08:00
group by wt.id
order by wt.create_time desc
</select>
<select id= "selectBgscreenWorkTrainList" parameterType= "WorkTrain" resultMap= "WorkTrainResult" >
2023-08-18 17:58:35 +08:00
select wt.id, wt.project_id, wt.project_name, wt.main_image, wt.train_type, wt.train_title, wt.train_nature, sdd.dict_label as train_nature_name, wt.train_participants, wt.begin_date, wt.end_date, wt.train_content, wt.train_file, wt.is_del, wt.create_by, wt.create_time, wt.update_by, wt.update_time, wt.remark, group_concat(sd.dept_id) as trainDeptIds, group_concat(sd.dept_name) as trainDeptNames
2023-08-12 01:05:00 +08:00
from work_train wt
left join work_train_dept wtd on wtd.train_id = wt.id
left join sys_dept sd on sd.dept_id = wtd.dept_id
<if test= 'trainType != null and trainType == "0"' > left join sys_dict_data sdd on sdd.dict_type = 'train_nature_zxpx' and wt.train_nature = sdd.dict_value</if>
<if test= 'trainType != null and trainType == "1"' > left join sys_dict_data sdd on sdd.dict_type = 'train_nature_yjyl' and wt.train_nature = sdd.dict_value</if>
RIGHT JOIN (
select gr.train_nature as gr_type ,max(gr.id) as maxid from work_train gr
left join sur_project sp on sp.id = gr.project_id
<where >
and gr.is_del=0
<if test= "deptId != null" > and sp.deptId = #{deptId}</if>
<if test= "trainType != null and trainType != ''" > and gr.train_type = #{trainType}</if>
</where>
group by gr.train_nature) as group_train on group_train.maxid = wt.id
where wt.is_del=0
group by wt.id
2023-08-11 22:15:06 +08:00
order by wt.create_time desc
2023-08-10 21:09:49 +08:00
</select>
2023-08-13 22:10:35 +08:00
<select id= "selectBgscreenWorkTrainListv2" parameterType= "WorkTrain" resultMap= "WorkTrainResult" >
2023-08-18 17:58:35 +08:00
select wt.id, wt.project_id, wt.project_name, wt.main_image, wt.train_type, wt.train_title, wt.train_nature, sdd.dict_label as train_nature_name, wt.train_participants, wt.begin_date, wt.end_date, wt.train_content, wt.train_file, wt.is_del, wt.create_by, wt.create_time, wt.update_by, wt.update_time, wt.remark, group_concat(sd.dept_id) as trainDeptIds, group_concat(sd.dept_name) as trainDeptNames
2023-08-13 22:10:35 +08:00
from work_train wt
left join work_train_dept wtd on wtd.train_id = wt.id
left join sys_dept sd on sd.dept_id = wtd.dept_id
2023-08-14 10:50:09 +08:00
left join sur_project sp on sp.id = wt.project_id
2023-08-13 22:10:35 +08:00
<if test= 'trainType != null and trainType == "0"' > left join sys_dict_data sdd on sdd.dict_type = 'train_nature_zxpx' and wt.train_nature = sdd.dict_value</if>
<if test= 'trainType != null and trainType == "1"' > left join sys_dict_data sdd on sdd.dict_type = 'train_nature_yjyl' and wt.train_nature = sdd.dict_value</if>
<where >
and wt.is_del=0
2023-08-15 17:48:24 +08:00
<if test= "nowDept != null and nowDept != ''" > and sp.deptId = #{nowDept}</if>
2023-08-13 22:10:35 +08:00
<if test= "trainType != null and trainType != ''" > and wt.train_type = #{trainType}</if>
<if test= "projectId != null" > and wt.project_id = #{projectId}</if>
</where>
group by wt.id
order by wt.create_time desc
limit 2
</select>
2023-08-10 21:09:49 +08:00
<select id= "selectWorkTrainById" parameterType= "Long" resultMap= "WorkTrainWorkTrainDeptResult" >
2023-08-18 17:58:35 +08:00
select a.id, a.project_id, a.project_name, a.main_image, a.train_type, a.train_title, a.train_nature, a.train_participants, a.begin_date, a.end_date, a.train_content, a.train_file, a.is_del, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
2023-08-15 17:48:24 +08:00
b.train_id as sub_train_id, b.dept_id as sub_dept_id, b.is_main as sub_is_main
2023-08-10 21:09:49 +08:00
from work_train a
2023-08-18 17:58:35 +08:00
left join work_train_dept b on b.train_id = a.id
2023-08-10 21:09:49 +08:00
where a.id = #{id}
2023-08-18 17:58:35 +08:00
and b.is_main ='N'
2023-08-10 21:09:49 +08:00
</select>
<insert id= "insertWorkTrain" parameterType= "WorkTrain" useGeneratedKeys= "true" keyProperty= "id" >
insert into work_train
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
2023-08-11 22:15:06 +08:00
<if test= "projectId != null" > project_id,</if>
<if test= "projectName != null" > project_name,</if>
2023-08-10 21:09:49 +08:00
<if test= "mainImage != null" > main_image,</if>
<if test= "trainType != null" > train_type,</if>
2023-08-13 22:10:35 +08:00
<if test= "trainTitle != null" > train_title,</if>
2023-08-10 21:09:49 +08:00
<if test= "trainNature != null" > train_nature,</if>
<if test= "trainParticipants != null" > train_participants,</if>
<if test= "beginDate != null" > begin_date,</if>
<if test= "endDate != null" > end_date,</if>
<if test= "trainContent != null" > train_content,</if>
2023-08-18 17:58:35 +08:00
<if test= "trainFile != null" > train_file,</if>
2023-08-10 21:09:49 +08:00
<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= "," >
2023-08-11 22:15:06 +08:00
<if test= "projectId != null" > #{projectId},</if>
<if test= "projectName != null" > #{projectName},</if>
2023-08-10 21:09:49 +08:00
<if test= "mainImage != null" > #{mainImage},</if>
<if test= "trainType != null" > #{trainType},</if>
2023-08-13 22:10:35 +08:00
<if test= "trainTitle != null" > #{trainTitle},</if>
2023-08-10 21:09:49 +08:00
<if test= "trainNature != null" > #{trainNature},</if>
<if test= "trainParticipants != null" > #{trainParticipants},</if>
<if test= "beginDate != null" > #{beginDate},</if>
<if test= "endDate != null" > #{endDate},</if>
<if test= "trainContent != null" > #{trainContent},</if>
2023-08-18 17:58:35 +08:00
<if test= "trainFile != null" > #{trainFile},</if>
2023-08-10 21:09:49 +08:00
<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= "updateWorkTrain" parameterType= "WorkTrain" >
update work_train
<trim prefix= "SET" suffixOverrides= "," >
2023-08-11 22:15:06 +08:00
<if test= "projectId != null" > project_id = #{projectId},</if>
<if test= "projectName != null" > project_name = #{projectName},</if>
2023-08-10 21:09:49 +08:00
<if test= "mainImage != null" > main_image = #{mainImage},</if>
<if test= "trainType != null" > train_type = #{trainType},</if>
2023-08-13 22:10:35 +08:00
<if test= "trainTitle != null" > train_title = #{trainTitle},</if>
2023-08-10 21:09:49 +08:00
<if test= "trainNature != null" > train_nature = #{trainNature},</if>
<if test= "trainParticipants != null" > train_participants = #{trainParticipants},</if>
<if test= "beginDate != null" > begin_date = #{beginDate},</if>
<if test= "endDate != null" > end_date = #{endDate},</if>
<if test= "trainContent != null" > train_content = #{trainContent},</if>
2023-08-18 17:58:35 +08:00
<if test= "trainFile != null" > train_file = #{trainFile},</if>
2023-08-10 21:09:49 +08:00
<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>
<delete id= "deleteWorkTrainById" parameterType= "Long" >
delete from work_train where id = #{id}
</delete>
<delete id= "deleteWorkTrainByIds" parameterType= "String" >
delete from work_train where id in
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
<delete id= "deleteWorkTrainDeptByTrainIds" parameterType= "String" >
delete from work_train_dept where train_id in
<foreach item= "trainId" collection= "array" open= "(" separator= "," close= ")" >
#{trainId}
</foreach>
</delete>
<delete id= "deleteWorkTrainDeptByTrainId" parameterType= "Long" >
delete from work_train_dept where train_id = #{trainId}
</delete>
<insert id= "batchWorkTrainDept" >
insert into work_train_dept( train_id, dept_id, is_main) values
<foreach item= "item" index= "index" collection= "list" separator= "," >
( #{item.trainId}, #{item.deptId}, #{item.isMain})
</foreach>
</insert>
</mapper>