wlcb-smart-city-case/src/main/resources/mybatis/mapper/timeout/timeout-mapper.xml
2021-12-03 10:08:47 +08:00

390 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="cn.com.tenlion.dao.timeout.ITimeoutDao">
<resultMap id="timeoutDTO" type="cn.com.tenlion.pojo.dtos.timeout.TimeoutDTO">
<result column="timeout_id" property="timeoutId"/>
<result column="report_id" property="reportId"/>
<result column="report_code" property="reportCode"/>
<result column="task_id" property="taskId"/>
<result column="task_name" property="taskName"/>
<result column="task_user_id" property="taskUserId"/>
<result column="task_user_name" property="taskUserName"/>
<result column="status" property="status"/>
<result column="gmt_create" property="gmtCreate"/>
</resultMap>
<resultMap id="timeoutBO" type="cn.com.tenlion.pojo.bos.timeout.TimeoutBO">
<result column="timeout_id" property="timeoutId"/>
<result column="report_id" property="reportId"/>
<result column="task_id" property="taskId"/>
<result column="task_user_id" property="taskUserId"/>
<result column="status" property="status"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
<resultMap id="timeoutPO" type="cn.com.tenlion.pojo.pos.timeout.TimeoutPO">
<result column="timeout_id" property="timeoutId"/>
<result column="report_id" property="reportId"/>
<result column="task_id" property="taskId"/>
<result column="task_user_id" property="taskUserId"/>
<result column="status" property="status"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
<!-- 新增超时事件 -->
<insert id="save" parameterType="map">
INSERT INTO case_timeout(
timeout_id,
report_id,
report_code,
task_id,
task_name,
task_user_id,
task_user_name,
status,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{timeoutId},
#{reportId},
#{reportCode},
#{taskId},
#{taskName},
#{taskUserId},
#{taskUserName},
#{status},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除超时事件 -->
<update id="remove" parameterType="map">
UPDATE
case_timeout
SET
gmt_modified = #{gmtModified},
modifier = #{modifier},
is_delete = 1
WHERE
timeout_id IN
<foreach collection="timeoutIds" index="index" open="(" separator="," close=")">
#{timeoutIds[${index}]}
</foreach>
</update>
<!-- 删除超时事件(物理) -->
<update id="delete" parameterType="map">
DELETE FROM
case_timeout
WHERE
timeout_id IN
<foreach collection="timeoutIds" index="index" open="(" separator="," close=")">
#{timeoutIds[${index}]}
</foreach>
</update>
<!-- 修改超时事件 -->
<update id="update" parameterType="map">
UPDATE
case_timeout
SET
<if test="reportId != null and reportId != ''">
report_id = #{reportId},
</if>
<if test="taskId != null and taskId != ''">
task_id = #{taskId},
</if>
<if test="taskUserId != null and taskUserId != ''">
task_user_id = #{taskUserId},
</if>
<if test="status != null and status != ''">
status = #{status},
</if>
gmt_modified = #{gmtModified},
modifier = #{modifier},
timeout_id = timeout_id
WHERE
timeout_id = #{timeoutId}
</update>
<!-- 超时事件详情 -->
<select id="get" parameterType="map" resultMap="timeoutDTO">
SELECT
t1.timeout_id,
t1.report_id,
t1.report_code,
t1.task_id,
t1.task_name,
t1.task_user_id,
t1.task_user_name,
t1.status,
t1.gmt_create
FROM
case_timeout t1
WHERE
t1.is_delete = 0
<if test="timeoutId != null and timeoutId != ''">
AND
t1.timeout_id = #{timeoutId}
</if>
</select>
<!-- 超时事件详情 -->
<select id="getBO" parameterType="map" resultMap="timeoutBO">
SELECT
t1.timeout_id,
t1.report_id,
t1.task_id,
t1.task_user_id,
t1.status,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
case_timeout t1
WHERE
t1.is_delete = 0
<if test="timeoutId != null and timeoutId != ''">
AND
t1.timeout_id = #{timeoutId}
</if>
</select>
<!-- 超时事件列表 -->
<select id="getPO" parameterType="map" resultMap="timeoutPO">
SELECT
t1.timeout_id,
t1.report_id,
t1.task_id,
t1.task_user_id,
t1.status,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
case_timeout t1
WHERE
t1.is_delete = 0
<if test="timeoutId != null and timeoutId != ''">
AND
t1.timeout_id = #{timeoutId}
</if>
<if test="taskId != null and taskId != ''">
AND
t1.task_id = #{taskId}
</if>
</select>
<!-- 超时事件列表 -->
<select id="list" parameterType="map" resultMap="timeoutDTO">
SELECT
t1.timeout_id,
t1.report_id,
t1.report_code,
t1.task_id,
t1.task_name,
t1.task_user_id,
t1.task_user_name,
t1.status,
t1.gmt_create
FROM
case_timeout t1
LEFT JOIN case_report t2
ON t1.report_id = t2.report_id
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
t1.report_code LIKE CONCAT('%', #{keywords}, '%')
OR
t1.task_name LIKE CONCAT('%', #{keywords}, '%')
OR
t1.task_user_name LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="status != null and status != ''">
AND t1.status = #{status}
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="areaCode != null and areaCode != ''">
AND t2.report_area_code LIKE CONCAT('%', #{areaCode}, '%')
</if>
<if test="timeoutIds != null and timeoutIds.size > 0">
AND
t1.timeout_id IN
<foreach collection="timeoutIds" index="index" open="(" separator="," close=")">
#{timeoutIds[${index}]}
</foreach>
</if>
ORDER BY t1.gmt_create DESC
</select>
<!-- 超时事件列表 -->
<select id="listBO" parameterType="map" resultMap="timeoutBO">
SELECT
t1.timeout_id,
t1.report_id,
t1.task_id,
t1.task_user_id,
t1.status,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
case_timeout t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="timeoutIds != null and timeoutIds.size > 0">
AND
t1.timeout_id IN
<foreach collection="timeoutIds" index="index" open="(" separator="," close=")">
#{timeoutIds[${index}]}
</foreach>
</if>
</select>
<!-- 超时事件统计 -->
<select id="listPO" parameterType="map" resultMap="timeoutPO">
SELECT
t1.timeout_id,
t1.report_id,
t1.task_id,
t1.task_user_id,
t1.status,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
case_timeout t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="timeoutIds != null and timeoutIds.size > 0">
AND
t1.timeout_id IN
<foreach collection="timeoutIds" index="index" open="(" separator="," close=")">
#{timeoutIds[${index}]}
</foreach>
</if>
</select>
<!-- 超时事件详情 -->
<select id="count" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
case_timeout t1
WHERE
t1.is_delete = 0
<if test="taskUserId != null and taskUserId != ''">
AND t1.task_user_id LIKE CONCAT('%', #{taskUserId},'%')
</if>
<if test="taskId != null and taskId != ''">
AND t1.task_id = #{taskId}
</if>
</select>
<!--修改区域超时事件-->
<update id="updateStatus" parameterType="map">
UPDATE
case_timeout
SET
status = #{status},
gmt_modified = #{gmtModified}
WHERE
<if test="reportId != '' and reportId != null">
report_id = #{reportId}
</if>
<if test="timeoutId != '' and timeoutId != null">
timeout_id = #{timeoutId}
</if>
</update>
<!-- 修改超时状态 -->
<select id="countByAreaCode" parameterType="map" resultType="Integer">
SELECT
COUNT(t1.id)
FROM
case_timeout t1
LEFT JOIN case_report t2
ON t1.report_id = t2.report_id
WHERE
t1.is_delete = 0
AND
t1.status = '0'
AND
t2.is_delete = 0
AND
t2.report_area_code LIKE CONCAT('%', #{areaCode}, '%')
</select>
</mapper>