wlcb-system-task/src/main/resources/mybatis/mapper/receiveruser/receiver-user-mapper.xml
2021-11-03 18:52:33 +08:00

563 lines
20 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="cn.com.tenlion.systemtask.dao.receiveruser.IReceiverUserDao">
<resultMap id="receiverUserDTO" type="cn.com.tenlion.systemtask.pojo.dtos.receiveruser.ReceiverUserDTO">
<result column="receiver_user_id" property="receiverUserId"/>
<result column="distribute_id" property="distributeId"/>
<result column="distribute_sub_id" property="distributeSubId"/>
<result column="user_id" property="userId"/>
<result column="user_name" property="userName"/>
<result column="is_receive" property="isReceive"/>
<result column="receive_type" property="receiveType"/>
<result column="execute_status" property="executeStatus"/>
<result column="task_score" property="taskScore"/>
<result column="task_type" property="taskType"/>
<result column="check_status" property="checkStatus"/>
<result column="distribute_title" property="distributeTitle"/>
<result column="distribute_summary" property="distributeSummary"/>
<result column="distribute_status" property="distributeStatus"/>
<result column="distribute_time" property="distributeTime"/>
<result column="distribute_deadline" property="distributeDeadline"/>
<result column="task_template" property="taskTemplate"/>
<result column="days" property="days"/>
<result column="hours" property="hours"/>
<result column="reason" property="reason"/>
<result column="is_warning" property="isWarning"/>
<result column="is_supervision" property="isSupervision"/>
</resultMap>
<resultMap id="receiverUserBO" type="cn.com.tenlion.systemtask.pojo.bos.receiveruser.ReceiverUserBO">
<result column="receiver_user_id" property="receiverUserId"/>
<result column="distribute_id" property="distributeId"/>
<result column="distribute_sub_id" property="distributeSubId"/>
<result column="user_id" property="userId"/>
<result column="user_name" property="userName"/>
<result column="is_receive" property="isReceive"/>
<result column="receive_type" property="receiveType"/>
<result column="execute_status" property="executeStatus"/>
<result column="task_score" property="taskScore"/>
<result column="task_type" property="taskType"/>
<result column="check_status" property="checkStatus"/>
<result column="reason" property="reason"/>
<result column="is_warning" property="isWarning"/>
<result column="is_supervision" property="isSupervision"/>
</resultMap>
<resultMap id="receiverUserPO" type="cn.com.tenlion.systemtask.pojo.pos.receiveruser.ReceiverUserPO">
<result column="receiver_user_id" property="receiverUserId"/>
<result column="distribute_id" property="distributeId"/>
<result column="distribute_sub_id" property="distributeSubId"/>
<result column="user_id" property="userId"/>
<result column="user_name" property="userName"/>
<result column="is_receive" property="isReceive"/>
<result column="receive_type" property="receiveType"/>
<result column="execute_status" property="executeStatus"/>
<result column="task_score" property="taskScore"/>
<result column="task_type" property="taskType"/>
<result column="check_status" property="checkStatus"/>
<result column="reason" property="reason"/>
<result column="is_warning" property="isWarning"/>
<result column="is_supervision" property="isSupervision"/>
</resultMap>
<!-- 新增任务接收人 -->
<insert id="save" parameterType="map">
INSERT INTO task_receiver_user(
receiver_user_id,
distribute_id,
distribute_sub_id,
user_id,
user_name,
is_receive,
receive_type,
execute_status,
task_score,
task_type,
check_status,
reason,
is_warning,
is_supervision,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{receiverUserId},
#{distributeId},
#{distributeSubId},
#{userId},
#{userName},
#{isReceive},
#{receiveType},
#{executeStatus},
#{taskScore},
#{taskType},
#{checkStatus},
#{reason},
#{is_warning},
#{is_supervision},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除任务接收人(物理) -->
<update id="delete" parameterType="map">
DELETE FROM
task_receiver_user
WHERE
receiver_user_id IN
<foreach collection="receiverUserIds" index="index" open="(" separator="," close=")">
#{receiverUserIds[${index}]}
</foreach>
</update>
<update id="remove" parameterType="map">
UPDATE
task_receiver_user
SET
gmt_modified = #{gmtModified},
modifier = #{modifier},
is_delete = 1
WHERE
receiver_user_id IN
<foreach collection="receiverUserIds" index="index" open="(" separator="," close=")">
#{receiverUserIds[${index}]}
</foreach>
</update>
<update id="removeAll" parameterType="map">
UPDATE
task_receiver_user
SET
gmt_modified = #{gmtModified},
modifier = #{modifier},
is_delete = 1
WHERE
distribute_id = #{distributeId}
</update>
<!-- 取消任务下派 -->
<update id="cancel" parameterType="map">
UPDATE
task_receiver_user
SET
gmt_modified = #{gmtModified},
modifier = #{modifier}
<if test="taskType != null and taskType != ''">
,task_type = #{taskType}
</if>
<if test="checkStatus != null and checkStatus != ''">
,check_status = #{checkStatus}
</if>
<if test="reason != null and reason != ''">
,reason = #{reason}
</if>
<if test="isWarning != null and isWarning != ''">
,is_warning = #{isWarning}
</if>
<if test="isSupervision != null and isSupervision != ''">
,is_supervision = #{isSupervision}
</if>
WHERE
1 = 1
<if test="receiverUserIds != null and receiverUserIds.size > 0">
AND receiver_user_id IN
<foreach collection="receiverUserIds" index="index" open="(" separator="," close=")">
#{receiverUserIds[${index}]}
</foreach>
</if>
<if test="distributeIds != null and distributeIds.size > 0">
AND distribute_id IN
<foreach collection="distributeIds" index="index" open="(" separator="," close=")">
#{distributeIds[${index}]}
</foreach>
</if>
<if test="userIds != null and userIds.size > 0">
AND user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
<if test="distributeId != null and distributeId != ''">
AND distribute_id = #{distributeId}
</if>
<if test="userId != null and userId != ''">
AND user_id = #{userId}
</if>
</update>
<!-- 修改任务接收人 -->
<update id="update" parameterType="map">
UPDATE
task_receiver_user
SET
<if test="distributeId != null and distributeId != ''">
distribute_id = #{distributeId},
</if>
<if test="distributeSubId != null and distributeSubId != ''">
distribute_sub_id = #{distributeSubId},
</if>
<if test="userId != null and userId != ''">
user_id = #{userId},
</if>
<if test="userName != null and userName != ''">
user_name = #{userName},
</if>
<if test="isReceive != null">
is_receive = #{isReceive},
</if>
<if test="receiveType != null and receiveType != ''">
receive_type = #{receiveType},
</if>
<if test="executeStatus != null and executeStatus != ''">
execute_status = #{executeStatus},
</if>
<if test="taskScore != null">
task_score = #{taskScore},
</if>
<if test="taskType != null and taskType != ''">
task_type = #{taskType},
</if>
<if test="checkStatus != null and checkStatus != ''">
check_status = #{checkStatus},
</if>
<if test="reason != null and reason != ''">
reason = #{reason},
</if>
<if test="isWarning != null and isWarning != ''">
is_warning = #{isWarning},
</if>
<if test="isSupervision != null and isSupervision != ''">
is_supervision = #{isSupervision},
</if>
gmt_modified = #{gmtModified},
modifier = #{modifier},
receiver_user_id = receiver_user_id
WHERE
receiver_user_id = #{receiverUserId}
</update>
<!-- 任务接收人详情 -->
<select id="get" parameterType="map" resultMap="receiverUserDTO">
SELECT
t1.distribute_id,
t1.distribute_sub_id,
t1.user_id,
t1.user_name,
t1.is_receive,
t1.receive_type,
t1.execute_status,
t1.task_score,
t1.task_type,
t1.check_status,
t1.reason,
t1.is_warning,
t1.is_supervision,
t1.receiver_user_id
FROM
task_receiver_user t1
WHERE
t1.is_delete = 0
<if test="receiverUserId != null and receiverUserId != ''">
AND
t1.receiver_user_id = #{receiverUserId}
</if>
</select>
<!-- 任务接收人详情 -->
<select id="getBO" parameterType="map" resultMap="receiverUserBO">
SELECT
t1.receiver_user_id,
t1.distribute_id,
t1.distribute_sub_id,
t1.user_id,
t1.user_name,
t1.is_receive,
t1.receive_type,
t1.execute_status,
t1.task_score,
t1.task_type,
t1.check_status,
t1.is_warning,
t1.is_supervision,
t1.reason
FROM
task_receiver_user t1
WHERE
t1.is_delete = 0
<if test="receiverUserId != null and receiverUserId != ''">
AND
t1.receiver_user_id = #{receiverUserId}
</if>
</select>
<!-- 任务接收人详情 -->
<select id="getPO" parameterType="map" resultMap="receiverUserPO">
SELECT
t1.receiver_user_id,
t1.distribute_id,
t1.distribute_sub_id,
t1.user_id,
t1.user_name,
t1.is_receive,
t1.receive_type,
t1.execute_status,
t1.task_score,
t1.task_type,
t1.check_status,
t1.is_warning,
t1.is_supervision,
t1.reason
FROM
task_receiver_user t1
WHERE
t1.is_delete = 0
<if test="receiverUserId != null and receiverUserId != ''">
AND
t1.receiver_user_id = #{receiverUserId}
</if>
</select>
<!-- 任务接收人列表 -->
<select id="list" parameterType="map" resultMap="receiverUserDTO">
SELECT
t1.receiver_user_id,
t1.distribute_id,
t1.distribute_sub_id,
t1.user_id,
t1.user_name,
t1.is_receive,
t1.receive_type,
t1.execute_status,
t1.task_score,
t1.task_type,
t1.reason,
t1.check_status,
t2.distribute_title,
t2.distribute_status,
t2.distribute_summary,
t2.distribute_time,
t2.distribute_deadline,
t2.task_template,
t2.days,
t2.hours,
t1.is_warning,
t1.is_supervision,
1
FROM
task_receiver_user t1 LEFT JOIN task_distribute t2 ON t1.distribute_id = t2.distribute_id AND t2.is_delete = 0
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
t1.user_name LIKE CONCAT('%', #{keywords}, '%')
OR t2.task_area1_name LIKE CONCAT('%', #{keywords}, '%')
OR t2.task_area2_name LIKE CONCAT('%', #{keywords}, '%')
OR t2.task_area3_name LIKE CONCAT('%', #{keywords}, '%')
OR t2.task_area4_name LIKE CONCAT('%', #{keywords}, '%')
OR t2.task_area5_name LIKE CONCAT('%', #{keywords}, '%')
OR t2.mission_location LIKE CONCAT('%', #{keywords}, '%')
OR t2.distribute_title LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="userId != null and userId != ''">
AND
t1.user_id = #{userId}
</if>
<if test="isWarning != null and isWarning != ''">
AND
t1.is_warning = #{isWarning}
</if>
<if test="isSupervision != null and isSupervision != ''">
AND
t1.is_supervision = #{isSupervision}
</if>
<if test="distributeId != null and distributeId != ''">
AND
t1.distribute_id = #{distributeId}
</if>
<if test="executeStatus != null and executeStatus != ''">
AND
t1.execute_status = #{executeStatus}
</if>
<if test="executeStatusNoOver != null and executeStatusNoOver != ''">
AND
t1.execute_status &lt;&gt; #{executeStatusNoOver}
</if>
<if test="taskType != null and taskType != ''">
AND
t1.task_type = #{taskType}
</if>
<if test="checkStatus != null and checkStatus != ''">
AND
t1.check_status = #{checkStatus}
</if>
<if test="userIds != null and userIds.size > 0">
AND t1.user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
<if test="distributeStatus != null and distributeStatus != ''">
AND
t2.distribute_status = #{distributeStatus}
</if>
<if test="distributeStatusCancel != null and distributeStatusCancel != '' and distributeStatus != null and distributeStatus != ''">
AND
(t2.distribute_status = #{distributeStatus}
OR
t2.distribute_status = #{distributeStatusCancel})
</if>
<if test="distributeDeadline != null and distributeDeadline != ''">
AND
t2.distribute_deadline LIKE CONCAT('%', #{distributeDeadline}, '%')
</if>
<if test="urgentLevel != null and urgentLevel != ''">
AND
t2.urgent_level = #{urgentLevel}
</if>
<if test="reportCount != null and reportCount != ''">
AND
t2.report_count = #{reportCount}
</if>
<if test="taskArea1Id != null and taskArea1Id != ''">
AND
t2.task_area1_id = #{taskArea1Id}
</if>
<if test="taskArea2Id != null and taskArea2Id != ''">
AND
t2.task_area2_id = #{taskArea2Id}
</if>
<if test="taskArea3Id != null and taskArea3Id != ''">
AND
t2.task_area3_id = #{taskArea3Id}
</if>
<if test="taskArea4Id != null and taskArea4Id != ''">
AND
t2.task_area4_id = #{taskArea4Id}
</if>
<if test="taskArea5Id != null and taskArea5Id != ''">
AND
t2.task_area5_id = #{taskArea5Id}
</if>
<if test="receiverUserIds != null and receiverUserIds.size > 0">
AND
t1.receiver_user_id IN
<foreach collection="receiverUserIds" index="index" open="(" separator="," close=")">
#{receiverUserIds[${index}]}
</foreach>
</if>
</select>
<!-- 任务接收人列表(专用于自动下派) -->
<select id="listForAuto" parameterType="map" resultMap="receiverUserDTO">
SELECT
DISTINCT
t1.user_id,
t1.user_name,
t1.distribute_id
FROM
task_receiver_user t1
WHERE
t1.is_delete = 0
<if test="distributeId != null and distributeId != ''">
AND
t1.distribute_id = #{distributeId}
</if>
<if test="taskType != null and taskType != ''">
AND
t1.task_type = #{taskType}
</if>
<if test="receiveType != null and receiveType != ''">
AND
t1.receive_type = #{receiveType}
</if>
</select>
<!-- 任务接收人列表 -->
<select id="listBO" parameterType="map" resultMap="receiverUserBO">
SELECT
t1.receiver_user_id,
t1.distribute_id,
t1.distribute_sub_id,
t1.user_id,
t1.user_name,
t1.is_receive,
t1.receive_type,
t1.execute_status,
t1.task_score,
t1.task_type,
t1.check_status,
t1.is_warning,
t1.is_supervision,
t1.reason
FROM
task_receiver_user t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="receiverUserIds != null and receiverUserIds.size > 0">
AND
t1.receiver_user_id IN
<foreach collection="receiverUserIds" index="index" open="(" separator="," close=")">
#{receiverUserIds[${index}]}
</foreach>
</if>
</select>
<!-- 任务接收人列表 -->
<select id="listPO" parameterType="map" resultMap="receiverUserPO">
SELECT
t1.receiver_user_id,
t1.distribute_id,
t1.distribute_sub_id,
t1.user_id,
t1.user_name,
t1.is_receive,
t1.receive_type,
t1.execute_status,
t1.task_score,
t1.task_type,
t1.check_status,
t1.is_warning,
t1.is_supervision,
t1.reason
FROM
task_receiver_user t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="receiverUserIds != null and receiverUserIds.size > 0">
AND
t1.receiver_user_id IN
<foreach collection="receiverUserIds" index="index" open="(" separator="," close=")">
#{receiverUserIds[${index}]}
</foreach>
</if>
</select>
<!-- 任务接收人统计 -->
<select id="count" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
task_receiver_user t1
WHERE
1 = 1
</select>
</mapper>