wlcb-smart-city-case/src/main/resources/mybatis/mapper/warning/warning-mapper.xml

522 lines
17 KiB
XML
Raw Normal View History

2021-11-04 10:52:21 +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="cn.com.tenlion.dao.warning.IWarningDao">
<resultMap id="warningDTO" type="cn.com.tenlion.pojo.dtos.warning.WarningDTO">
<result column="warning_id" property="warningId"/>
<result column="report_id" property="reportId"/>
2021-11-30 15:15:21 +08:00
<result column="report_code" property="reportCode"/>
<result column="task_name" property="taskName"/>
<result column="task_id" property="taskId"/>
<result column="task_user_id" property="taskUserId"/>
<result column="task_user_name" property="taskUserName"/>
<result column="warning_type" property="warningType"/>
<result column="warning_level" property="warningLevel"/>
<result column="warning_status" property="warningStatus"/>
<result column="gmt_create" property="gmtCreate"/>
2021-11-04 10:52:21 +08:00
</resultMap>
<resultMap id="warningBO" type="cn.com.tenlion.pojo.bos.warning.WarningBO">
<result column="warning_id" property="warningId"/>
<result column="report_id" property="reportId"/>
2021-11-30 15:15:21 +08:00
<result column="task_name" property="taskName"/>
<result column="task_id" property="taskId"/>
<result column="task_user_id" property="taskUserId"/>
<result column="warning_type" property="warningType"/>
<result column="warning_level" property="warningLevel"/>
<result column="warning_status" property="warningStatus"/>
2021-11-04 10:52:21 +08:00
<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="warningPO" type="cn.com.tenlion.pojo.pos.warning.WarningPO">
<result column="warning_id" property="warningId"/>
<result column="report_id" property="reportId"/>
2021-11-30 15:15:21 +08:00
<result column="task_name" property="taskName"/>
<result column="task_id" property="taskId"/>
<result column="task_user_id" property="taskUserId"/>
<result column="warning_type" property="warningType"/>
<result column="warning_level" property="warningLevel"/>
<result column="warning_status" property="warningStatus"/>
2021-11-04 10:52:21 +08:00
<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>
2021-11-10 17:31:22 +08:00
<resultMap id="warningReportDTO" type="cn.com.tenlion.pojo.dtos.warning.WarningReportDTO">
<result column="warning_id" property="warningId"/>
<result column="report_id" property="reportId"/>
<result column="report_code" property="reportCode"/>
<result column="report_area_name" property="reportAreaName"/>
<result column="report_address" property="reportAddress"/>
<result column="report_lng" property="reportLng"/>
<result column="report_lat" property="reportLat"/>
<result column="b_g_id" property="bGId"/>
<result column="case_type_name1" property="caseTypeName1"/>
<result column="case_type_name2" property="caseTypeName2"/>
<result column="case_parts_obj_id" property="casePartsObjId"/>
<result column="case_parts_obj_name" property="casePartsObjName"/>
<result column="report_photos" property="reportPhotos"/>
<result column="report_audio" property="reportAudio"/>
<result column="report_video" property="reportVideo"/>
<result column="report_source" property="reportSource"/>
<result column="report_content" property="reportContent"/>
<result column="is_self" property="isSelf"/>
<result column="handle_status" property="handleStatus"/>
<result column="report_result" property="reportResult"/>
<result column="is_archive" property="isArchive"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="creator" property="creator"/>
</resultMap>
<!-- 统计单位下的预警事件 -->
<select id="countDept" parameterType="map" resultType="Integer">
SELECT
COUNT(t1.id)
FROM
case_warning t1
LEFT JOIN
case_report t2
ON
t1.report_id = t2.report_id
WHERE
t1.is_delete = 0 AND t2.is_delete = 0 AND t1.task_dept_id IS NOT NULL AND t1.task_dept_id != '' AND t1.warning_status = #{warningStatus} AND t1.task_dept_id REGEXP '${departmentListIds}'
</select>
2021-11-10 17:31:22 +08:00
<!-- 单位案件预警列表 -->
<select id="listDept" parameterType="map" resultMap="warningDTO">
SELECT
t1.warning_id,
t1.report_id,
t1.report_code,
t1.task_name,
t1.task_id,
t1.task_user_id,
t1.task_user_name,
t1.warning_type,
t1.warning_level,
t1.warning_status,
t1.gmt_create
FROM
case_warning t1
LEFT JOIN
case_report t2
ON
t1.report_id = t2.report_id
WHERE
t1.is_delete = 0 AND t2.is_delete = 0 AND t1.task_dept_id IS NOT NULL AND t1.task_dept_id != '' AND t1.warning_status = #{warningStatus}
<if test="keywords != null and keywords != ''">
AND (
t1.task_name LIKE CONCAT('%', #{keywords}, '%')
OR
t1.report_code LIKE CONCAT('%', #{keywords}, '%')
OR
t2.report_area_name LIKE CONCAT('%', #{keywords}, '%')
OR
t2.case_parts_obj_name LIKE CONCAT('%', #{keywords}, '%')
OR
t2.case_type_name1 LIKE CONCAT('%', #{keywords}, '%')
OR
t2.case_type_name2 LIKE CONCAT('%', #{keywords}, '%')
OR
t2.report_content LIKE CONCAT('%', #{keywords}, '%')
)
</if>
AND
t1.task_dept_id REGEXP '${departmentListIds}'
ORDER BY
t1.gmt_create DESC
</select>
2021-11-10 17:31:22 +08:00
2021-11-04 10:52:21 +08:00
<!-- 新增案件预警 -->
<insert id="save" parameterType="map">
INSERT INTO case_warning(
warning_id,
report_id,
2021-11-30 15:15:21 +08:00
report_code,
task_name,
task_id,
task_user_id,
task_user_name,
task_dept_id,
2021-11-30 15:15:21 +08:00
warning_type,
warning_level,
warning_status,
2021-11-04 10:52:21 +08:00
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{warningId},
#{reportId},
2021-11-30 15:15:21 +08:00
#{reportCode},
#{taskName},
#{taskId},
#{taskUserId},
#{taskUserName},
#{taskDeptId},
2021-11-30 15:15:21 +08:00
#{warningType},
#{warningLevel},
#{warningStatus},
2021-11-04 10:52:21 +08:00
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除案件预警 -->
<update id="remove" parameterType="map">
UPDATE
case_warning
SET
gmt_modified = #{gmtModified},
modifier = #{modifier},
is_delete = 1
WHERE
warning_id IN
<foreach collection="warningIds" index="index" open="(" separator="," close=")">
#{warningIds[${index}]}
</foreach>
</update>
<!-- 删除案件预警(物理) -->
<update id="delete" parameterType="map">
DELETE FROM
case_warning
WHERE
warning_id IN
<foreach collection="warningIds" index="index" open="(" separator="," close=")">
#{warningIds[${index}]}
</foreach>
</update>
<!-- 修改案件预警 -->
<update id="update" parameterType="map">
UPDATE
case_warning
SET
<if test="reportId != null and reportId != ''">
report_id = #{reportId},
</if>
gmt_modified = #{gmtModified},
2021-11-30 15:15:21 +08:00
modifier = #{modifier}
2021-11-04 10:52:21 +08:00
WHERE
warning_id = #{warningId}
</update>
2021-11-30 15:15:21 +08:00
<!-- 修改案件预警 -->
<update id="updateByTaskId" parameterType="map">
UPDATE
case_warning
SET
<if test="warningStatus != null and warningStatus != ''">
warning_status = #{warningStatus},
</if>
<if test="warningLevel != null and warningLevel != ''">
warning_level = #{warningLevel},
</if>
gmt_modified = #{gmtModified},
modifier = #{modifier}
WHERE
2021-12-03 10:08:47 +08:00
<if test="taskId != '' and taskId != null">
task_id = #{taskId}
</if>
<if test="reportId != '' and reportId != null">
report_id = #{reportId}
</if>
2021-11-30 15:15:21 +08:00
</update>
2021-11-04 10:52:21 +08:00
<!-- 案件预警详情 -->
<select id="get" parameterType="map" resultMap="warningDTO">
SELECT
t1.report_id,
2021-11-30 15:15:21 +08:00
t1.warning_id,
t1.task_name,
t1.task_id,
t1.task_user_id,
t1.warning_type,
t1.warning_level,
t1.warning_status
2021-11-04 10:52:21 +08:00
FROM
case_warning t1
WHERE
t1.is_delete = 0
2021-11-30 15:15:21 +08:00
<if test="warningId != null and warningId != ''">
AND
2021-11-04 10:52:21 +08:00
t1.warning_id = #{warningId}
2021-11-30 15:15:21 +08:00
</if>
<if test="taskId != null and taskId != ''">
AND
t1.task_id = #{taskId}
</if>
2021-11-04 10:52:21 +08:00
</select>
<!-- 案件预警详情 -->
<select id="getBO" parameterType="map" resultMap="warningBO">
SELECT
t1.warning_id,
t1.report_id,
2021-11-30 15:15:21 +08:00
t1.task_name,
t1.task_id,
t1.task_user_id,
t1.warning_type,
t1.warning_level,
t1.warning_status
2021-11-04 10:52:21 +08:00
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
case_warning t1
WHERE
t1.is_delete = 0
<if test="warningId != null and warningId != ''">
AND
t1.warning_id = #{warningId}
</if>
</select>
<!-- 案件预警详情 -->
<select id="getPO" parameterType="map" resultMap="warningPO">
SELECT
t1.warning_id,
t1.report_id,
2021-11-30 15:15:21 +08:00
t1.task_name,
t1.task_id,
t1.task_user_id,
t1.warning_type,
t1.warning_level,
t1.warning_status
2021-11-04 10:52:21 +08:00
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
case_warning t1
WHERE
t1.is_delete = 0
<if test="warningId != null and warningId != ''">
AND
t1.warning_id = #{warningId}
</if>
</select>
<!-- 案件预警列表 -->
<select id="list" parameterType="map" resultMap="warningDTO">
SELECT
t1.warning_id,
t1.report_id,
2021-11-30 15:15:21 +08:00
t1.report_code,
t1.task_name,
t1.task_id,
t1.task_user_id,
t1.task_user_name,
t1.warning_type,
t1.warning_level,
t1.warning_status,
t1.gmt_create
2021-11-04 10:52:21 +08:00
FROM
case_warning t1
2021-11-30 15:15:21 +08:00
LEFT JOIN case_report t2
ON t1.report_id = t2.report_id
2021-11-04 10:52:21 +08:00
WHERE
t1.is_delete = 0
2021-11-30 15:15:21 +08:00
AND t1.warning_status = '0'
2021-11-04 10:52:21 +08:00
<if test="keywords != null and keywords != ''">
AND (
2021-11-30 15:15:21 +08:00
t1.report_code LIKE CONCAT('%', #{keywords}, '%')
2021-11-04 10:52:21 +08:00
)
</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>
2021-11-30 15:15:21 +08:00
<if test="areaCode != null and areaCode != ''">
AND t2.report_area_code LIKE CONCAT('%', #{areaCode}, '%')
2021-11-04 10:52:21 +08:00
</if>
2021-11-30 15:15:21 +08:00
ORDER BY t1.gmt_create DESC
2021-11-04 10:52:21 +08:00
</select>
2021-11-30 15:15:21 +08:00
2021-11-10 17:31:22 +08:00
<!-- 案件预警列表 -->
<select id="listArea" parameterType="map" resultMap="warningReportDTO">
SELECT
t1.warning_id,
t2.report_id,
t2.report_code,
t2.report_area_name,
t2.report_address,
t2.report_lng,
t2.report_lat,
t2.b_g_id,
t2.case_type_name1,
t2.case_type_name2,
t2.case_parts_obj_name,
t2.report_photos,
t2.report_source,
t2.report_content,
t2.is_self,
t2.handle_status,
t2.report_result,
t2.is_archive,
t2.creator,
t2.gmt_create
FROM
case_warning 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.id LIKE CONCAT('%', #{keywords}, '%')
2021-11-30 15:15:21 +08:00
)
</if>
<if test="areaCode != null and areaCode != ''">
AND t2.report_area_code LIKE CONCAT('%', #{areaCode}, '%')
2021-11-10 17:31:22 +08:00
</if>
</select>
2021-11-04 10:52:21 +08:00
<!-- 案件预警列表 -->
<select id="listBO" parameterType="map" resultMap="warningBO">
SELECT
t1.warning_id,
t1.report_id,
2021-11-30 15:15:21 +08:00
t1.task_name,
t1.task_id,
t1.task_user_id,
t1.warning_type,
t1.warning_level,
t1.warning_status,
2021-11-04 10:52:21 +08:00
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
case_warning 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="warningIds != null and warningIds.size > 0">
AND
t1.warning_id IN
<foreach collection="warningIds" index="index" open="(" separator="," close=")">
#{warningIds[${index}]}
</foreach>
</if>
</select>
<!-- 案件预警列表 -->
<select id="listPO" parameterType="map" resultMap="warningPO">
SELECT
t1.warning_id,
t1.report_id,
2021-11-30 15:15:21 +08:00
t1.task_name,
t1.task_id,
t1.task_user_id,
t1.warning_type,
t1.warning_level,
t1.warning_status,
2021-11-04 10:52:21 +08:00
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
case_warning 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="warningIds != null and warningIds.size > 0">
AND
t1.warning_id IN
<foreach collection="warningIds" index="index" open="(" separator="," close=")">
#{warningIds[${index}]}
</foreach>
</if>
</select>
<!-- 案件预警统计 -->
<select id="count" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
case_warning t1
WHERE
t1.is_delete = 0
<if test="reportId != null and reportId != ''">
AND t1.report_id = #{reportId}
</if>
2021-11-30 15:15:21 +08:00
<if test="taskId != null and taskId != ''">
AND t1.task_id = #{taskId}
</if>
<if test="warningLevel != null and warningLevel != ''">
AND t1.warning_level = #{warningLevel}
</if>
</select>
<select id="countByAreaCode" parameterType="map" resultType="Integer">
SELECT
COUNT(t1.id)
FROM
case_warning t1
LEFT JOIN case_report t2
ON t1.report_id = t2.report_id
WHERE
t1.is_delete = 0
AND
t2.is_delete = 0
AND
t1.warning_status = #{warningStatus}
AND
t2.report_area_code LIKE CONCAT('%', #{areaCode}, '%')
2021-11-04 10:52:21 +08:00
</select>
</mapper>