From 7bcd0d2d7510cb2ba67099cd768e1b2b6d047dc2 Mon Sep 17 00:00:00 2001
From: linwei <872216696@qq.com>
Date: Thu, 22 Feb 2024 17:16:27 +0800
Subject: [PATCH] 投票人员查询优化
---
src/main/java/org/springblade/modules/taskPlaceRectification/mapper/TaskPlaceRectificationMapper.xml | 376 ++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 336 insertions(+), 40 deletions(-)
diff --git a/src/main/java/org/springblade/modules/taskPlaceRectification/mapper/TaskPlaceRectificationMapper.xml b/src/main/java/org/springblade/modules/taskPlaceRectification/mapper/TaskPlaceRectificationMapper.xml
index 3ce4954..96246a9 100644
--- a/src/main/java/org/springblade/modules/taskPlaceRectification/mapper/TaskPlaceRectificationMapper.xml
+++ b/src/main/java/org/springblade/modules/taskPlaceRectification/mapper/TaskPlaceRectificationMapper.xml
@@ -118,7 +118,25 @@
<select id="selectTaskPlaceRectificationById" parameterType="long" resultMap="TaskPlaceRectificationDTOResult">
SELECT
- jtpr.*,
+ jtpr.id,
+ jtpr.place_check_id,
+ jtpr.task_id,
+ jtpr.STATUS,
+ jtpr.task_name,
+ jtpr.remark,
+ jtpr.update_time,
+ jtpr.create_time,
+ jtpr.house_code,
+ jtpr.rectification_notice_flag,
+ jtpr.rectification_end_time,
+ jtpr.rectification_complete_time,
+ jtpr.rectification_flag,
+ jtpr.punish_flag,
+ jtpr.police_station,
+ jtpr.rectification_notice_img_url,
+ jtpr.signature_path,
+ jtpr.create_user,
+ jtpr.image_urls,
jp.id jpid,
jp.place_name,
jp.location,
@@ -130,7 +148,8 @@
bu.`name`,
jpe.legal_tel,
jpe.legal_person,
- jt.remark reasonFailure
+ jt.remark reasonFailure,
+ jda.address_name
FROM
jczz_task_place_rectification jtpr
LEFT JOIN jczz_task jt on jt.id = jtpr.task_id
@@ -139,6 +158,7 @@
LEFT JOIN blade_region br ON br.`code` = jg.community_code
LEFT JOIN jczz_place_ext jpe ON jpe.place_id = jp.id
LEFT JOIN blade_user bu ON bu.id = jtpr.create_user
+ LEFT JOIN jczz_doorplate_address jda on jda.address_code=jtpr.house_code
WHERE jtpr.task_id = #{taskId}
</select>
@@ -165,7 +185,7 @@
jtpr.signature_path,
jtpr.create_user,
jtpr.image_urls,
- bd.dept_name,
+ jpag.pcs_name deptName,
jp.id jpid,
jp.place_name,
jp.location,
@@ -178,67 +198,148 @@
bu.`name`,
jpe.legal_tel,
jpe.legal_person,
- jda.address_name
+ jp.location as address_name
FROM
jczz_task_place_rectification jtpr
- LEFT JOIN jczz_place jp ON jtpr.house_code = jp.house_code
- LEFT JOIN jczz_grid jg ON jg.grid_code = jp.grid_code
+ LEFT JOIN jczz_place jp ON jtpr.house_code = jp.house_code and jp.is_deleted = 0
+ LEFT JOIN jczz_grid jg ON jg.grid_code = jp.grid_code and jg.is_deleted = 0
LEFT JOIN blade_region br ON br.`code` = jg.community_code
LEFT JOIN jczz_place_ext jpe ON jpe.place_id = jp.id
LEFT JOIN blade_user bu ON bu.id = jtpr.create_user
- LEFT JOIN blade_dept bd ON bu.dept_id = bd.id
- LEFT JOIN jczz_doorplate_address jda on jda.address_code=jp.house_code
+ LEFT JOIN jczz_police_affairs_grid jpag on jp.jw_grid_code= jpag.jw_grid_code
<where>
- <if test="taskPalce.id != null ">and id = #{taskPalce.id}</if>
- <if test="taskPalce.placeCheckId != null ">and place_check_id = #{taskPalce.placeCheckId}</if>
- <if test="taskPalce.taskId != null ">and task_id = #{taskPalce.taskId}</if>
- <if test="taskPalce.status != null ">and status = #{taskPalce.status}</if>
- <if test="taskPalce.taskName != null and taskPalce.taskName != ''">and task_name = #{taskPalce.taskName}
+ <if test="taskPalce.id != null ">and jtpr.id = #{taskPalce.id}</if>
+ <if test="taskPalce.placeCheckId != null ">and jtpr.place_check_id = #{taskPalce.placeCheckId}</if>
+ <if test="taskPalce.taskId != null ">and jtpr.task_id = #{taskPalce.taskId}</if>
+ <if test="taskPalce.status != null and taskPalce.status != 2 ">and jtpr.status = #{taskPalce.status}</if>
+
+ <if test="taskPalce.status != null and taskPalce.status = 2 ">and jtpr.status in (2,3)</if>
+
+ <if test="taskPalce.taskName != null and taskPalce.taskName != ''">and jtpr.task_name =
+ #{taskPalce.taskName}
</if>
- <if test="taskPalce.placeName != null and taskPalce.placeName != ''">and place_name =
- #{taskPalce.placeName}
+
+ <if test="taskPalce.startTime!=null and taskPalce.startTime!=''">
+ and jtpr.create_time>=#{taskPalce.startTime}
</if>
- <if test="taskPalce.remark != null and taskPalce.remark != ''">and remark = #{taskPalce.remark}</if>
- <if test="taskPalce.updateTime != null ">and update_time = #{taskPalce.updateTime}</if>
- <if test="taskPalce.createTime != null ">and create_time = #{taskPalce.createTime}</if>
- <if test="taskPalce.houseCode != null and taskPalce.houseCode != ''">and house_code =
+ <if test="taskPalce.endTime!=null and taskPalce.endTime!=''">
+ and jtpr.create_time<=#{taskPalce.endTime}
+ </if>
+
+ <if test="taskPalce.placeName!=null and taskPalce.placeName!=''">
+ and jp.place_name like concat('%',#{taskPalce.placeName},'%')
+ </if>
+
+ <if test="taskPalce.addressName!=null and taskPalce.addressName!=''">
+ and jp.location like concat('%',#{taskPalce.addressName},'%')
+ </if>
+
+ <if test="taskPalce.deptName!=null and taskPalce.deptName!=''">
+ and jpag.pcs_name like concat('%',#{taskPalce.deptName},'%')
+ </if>
+
+ <if test="nineTypeList!=null and nineTypeList.size()>0">
+ and jp.nine_type in
+ <foreach collection="nineTypeList" separator="," open="(" close=")" item="nineType">
+ #{nineType}
+ </foreach>
+ </if>
+
+ <if test="taskPalce.punishFlag!=null">
+ and jp.punish_flag = #{taskPalce.punishFlag}
+ </if>
+
+ <if test="taskPalce.remark != null and taskPalce.remark != ''">and jtpr.remark = #{taskPalce.remark}</if>
+ <if test="taskPalce.updateTime != null ">and jtpr.update_time = #{taskPalce.updateTime}</if>
+ <if test="taskPalce.createTime != null ">and jtpr.create_time = #{taskPalce.createTime}</if>
+ <if test="taskPalce.houseCode != null and taskPalce.houseCode != ''">and jtpr.house_code =
#{taskPalce.houseCode}
</if>
- <if test="taskPalce.rectificationNoticeFlag != null ">and rectification_notice_flag =
+ <if test="taskPalce.rectificationNoticeFlag != null ">and jtpr.rectification_notice_flag =
#{taskPalce.rectificationNoticeFlag}
</if>
- <if test="taskPalce.rectificationEndTime != null ">and rectification_end_time =
+ <if test="taskPalce.rectificationEndTime != null ">and jtpr.rectification_end_time =
#{taskPalce.rectificationEndTime}
</if>
- <if test="taskPalce.rectificationCompleteTime != null ">and rectification_complete_time =
+ <if test="taskPalce.rectificationCompleteTime != null ">and jtpr.rectification_complete_time =
#{taskPalce.rectificationCompleteTime}
</if>
- <if test="taskPalce.rectificationFlag != null ">and rectification_flag = #{taskPalce.rectificationFlag}</if>
- <if test="taskPalce.punishFlag != null ">and punish_flag = #{taskPalce.punishFlag}</if>
- <if test="taskPalce.policeStation != null and taskPalce.policeStation != ''">and police_station =
+ <if test="taskPalce.rectificationFlag != null ">and jtpr.rectification_flag =
+ #{taskPalce.rectificationFlag}
+ </if>
+ <if test="taskPalce.punishFlag != null ">and jtpr.punish_flag = #{taskPalce.punishFlag}</if>
+ <if test="taskPalce.policeStation != null and taskPalce.policeStation != ''">and jtpr.police_station =
#{taskPalce.policeStation}
</if>
<if test="taskPalce.rectificationNoticeImgUrl != null and taskPalce.rectificationNoticeImgUrl != ''">and
- rectification_notice_img_url = #{taskPalce.rectificationNoticeImgUrl}
+ jtpr.rectification_notice_img_url = #{taskPalce.rectificationNoticeImgUrl}
</if>
- <if test="taskPalce.signaturePath != null and taskPalce.signaturePath != ''">and signature_path =
+ <if test="taskPalce.signaturePath != null and taskPalce.signaturePath != ''">and jtpr.signature_path =
#{taskPalce.signaturePath}
</if>
- <if test="taskPalce.createUser != null ">and create_user = #{taskPalce.createUser}</if>
- <if test="taskPalce.imageUrls != null and taskPalce.imageUrls != ''">and image_urls =
+ <if test="taskPalce.createUser != null ">and jtpr.create_user = #{taskPalce.createUser}</if>
+ <if test="taskPalce.imageUrls != null and taskPalce.imageUrls != ''">and jtpr.image_urls =
#{taskPalce.imageUrls}
</if>
<if test="isAdministrator==2">
<choose>
- <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
- and jg.grid_code in
- <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
- #{code}
- </foreach>
+ <when test="taskPalce.roleName != null and taskPalce.roleName != ''">
+ <if test="taskPalce.roleName=='wgy'">
+ <choose>
+ <when test="gridCodeList !=null and gridCodeList.size()>0">
+ and jp.grid_code in
+ <foreach collection="gridCodeList" item="code" open="(" close=")" separator=",">
+ #{code}
+ </foreach>
+ </when>
+ <otherwise>
+ and jp.grid_code in ('')
+ </otherwise>
+ </choose>
+ </if>
+ <if test="taskPalce.roleName=='mj'">
+ <choose>
+ <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+ and jpag.community_code in
+ <foreach collection="regionChildCodesList" item="code" open="(" close=")"
+ separator=",">
+ #{code}
+ </foreach>
+ </when>
+ <otherwise>
+ and jpag.community_code in ('')
+ </otherwise>
+ </choose>
+ </if>
</when>
+ <otherwise>
+ <choose>
+ <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+ and
+ (
+ jg.grid_code in
+ <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+ #{code}
+ </foreach>
+ or
+ jpag.community_code in
+ <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+ #{code}
+ </foreach>
+ )
+ </when>
+ <otherwise>
+ and
+ (
+ jg.grid_code in ('') or jpag.community_code in in ('')
+ )
+ </otherwise>
+ </choose>
+ </otherwise>
</choose>
</if>
</where>
+ order by jtpr.create_time desc
</select>
@@ -282,12 +383,13 @@
bd.dict_value,
(
SELECT
- IFNULL(sum( jpc.hidden_danger_number ) ,0)
+ count(jpr.id)
FROM
- jczz_place_check jpc
+ jczz_patrol_record jpr
+ LEFT JOIN jczz_place_check jpc ON jpr.place_check_id = jpc.id
LEFT JOIN jczz_place jp ON jpc.house_code = jp.house_code
LEFT JOIN jczz_grid jg ON jg.grid_code = jp.grid_code
- left join blade_region br on br.code = jg.community_code
+ LEFT JOIN blade_region br ON br.CODE = jg.community_code
<where>
<if test="isAdministrator==2">
<choose>
@@ -299,11 +401,15 @@
</when>
</choose>
</if>
+ and jpr.state = '0'
and jp.nine_type = bd.dict_key
and br.town_code =#{code}
- and jpc.create_time=(
- SELECT MAX(create_time) FROM jczz_place_check where jpc.house_code=house_code
- )
+ <if test="taskPlaceRectification.startTime!=null and taskPlaceRectification.startTime!=''">
+ and jpc.create_time>=#{taskPlaceRectification.startTime}
+ </if>
+ <if test="taskPlaceRectification.endTime!=null and taskPlaceRectification.endTime!=''">
+ and jpc.create_time<=#{taskPlaceRectification.endTime}
+ </if>
</where>
) number
FROM
@@ -316,5 +422,195 @@
</select>
+ <resultMap type="org.springblade.modules.taskPlaceRectification.excel.TaskPlaceRectificationExcel"
+ id="TaskPlaceRectificationExcelResult">
+ <result property="placeName" column="place_name"/>
+ <result property="createTime" column="create_time"/>
+ <result property="rectificationNoticeFlag" column="rectification_notice_flag"/>
+ <result property="rectificationEndTime" column="rectification_end_time"/>
+ <result property="rectificationFlag" column="rectification_flag"/>
+
+ <collection property="patrolRecordVOList" column="place_check_id" select="selectPatrolRecordList"
+ javaType="java.util.List" ofType="org.springblade.modules.patrol.vo.PatrolRecordVO"
+ autoMapping="true">
+ </collection>
+ </resultMap>
+
+ <select id="export"
+ resultMap="TaskPlaceRectificationExcelResult">
+ SELECT
+ jtpr.id,
+ jtpr.place_check_id,
+ jtpr.task_id,
+ jtpr.STATUS,
+ jtpr.task_name,
+ jtpr.remark,
+ jtpr.update_time,
+ jtpr.create_time,
+ jtpr.house_code,
+ jtpr.rectification_notice_flag,
+ jtpr.rectification_end_time,
+ jtpr.rectification_complete_time,
+ jtpr.rectification_flag,
+ jtpr.punish_flag,
+ jtpr.police_station,
+ jtpr.rectification_notice_img_url,
+ jtpr.signature_path,
+ jtpr.create_user,
+ jtpr.image_urls,
+ jpag.pcs_name deptName,
+ jp.id jpid,
+ jp.place_name,
+ jp.location,
+ jg.grid_name,
+ jp.principal,
+ jp.principal_phone,
+ jp.nine_type,
+ br.town_name,
+ br.village_name,
+ bu.`name`,
+ jpe.legal_tel,
+ jpe.legal_person,
+ jp.location as address_name
+ FROM
+ jczz_task_place_rectification jtpr
+ LEFT JOIN jczz_place jp ON jtpr.house_code = jp.house_code
+ LEFT JOIN jczz_grid jg ON jg.grid_code = jp.grid_code
+ LEFT JOIN blade_region br ON br.`code` = jg.community_code
+ LEFT JOIN jczz_place_ext jpe ON jpe.place_id = jp.id
+ LEFT JOIN blade_user bu ON bu.id = jtpr.create_user
+ LEFT JOIN jczz_police_affairs_grid jpag on jp.jw_grid_code= jpag.jw_grid_code
+ <where>
+ <if test="taskPalce.id != null ">and jtpr.id = #{taskPalce.id}</if>
+ <if test="taskPalce.placeCheckId != null ">and jtpr.place_check_id = #{taskPalce.placeCheckId}</if>
+ <if test="taskPalce.taskId != null ">and jtpr.task_id = #{taskPalce.taskId}</if>
+ <if test="taskPalce.status != null ">and jtpr.status = #{taskPalce.status}</if>
+ <if test="taskPalce.taskName != null and taskPalce.taskName != ''">and jtpr.task_name =
+ #{taskPalce.taskName}
+ </if>
+
+ <if test="taskPalce.startTime!=null and taskPalce.startTime!=''">
+ and jtpr.create_time>=#{taskPalce.startTime}
+ </if>
+ <if test="taskPalce.endTime!=null and taskPalce.endTime!=''">
+ and jtpr.create_time<=#{taskPalce.endTime}
+ </if>
+
+ <if test="taskPalce.placeName!=null and taskPalce.placeName!=''">
+ and jp.place_name like concat('%',#{taskPalce.placeName},'%')
+ </if>
+
+ <if test="taskPalce.addressName!=null and taskPalce.addressName!=''">
+ and jp.location like concat('%',#{taskPalce.addressName},'%')
+ </if>
+
+ <if test="taskPalce.deptName!=null and taskPalce.deptName!=''">
+ and jpag.pcs_name like concat('%',#{taskPalce.deptName},'%')
+ </if>
+
+ <if test="nineTypeList!=null and nineTypeList.size()>0">
+ and jp.nine_type in
+ <foreach collection="nineTypeList" separator="," open="(" close=")" item="nineType">
+ #{nineType}
+ </foreach>
+ </if>
+
+ <if test="taskPalce.punishFlag!=null">
+ and jp.punish_flag = #{taskPalce.punishFlag}
+ </if>
+
+ <if test="taskPalce.remark != null and taskPalce.remark != ''">and jtpr.remark = #{taskPalce.remark}</if>
+ <if test="taskPalce.updateTime != null ">and jtpr.update_time = #{taskPalce.updateTime}</if>
+ <if test="taskPalce.createTime != null ">and jtpr.create_time = #{taskPalce.createTime}</if>
+ <if test="taskPalce.houseCode != null and taskPalce.houseCode != ''">and jtpr.house_code =
+ #{taskPalce.houseCode}
+ </if>
+ <if test="taskPalce.rectificationNoticeFlag != null ">and jtpr.rectification_notice_flag =
+ #{taskPalce.rectificationNoticeFlag}
+ </if>
+ <if test="taskPalce.rectificationEndTime != null ">and jtpr.rectification_end_time =
+ #{taskPalce.rectificationEndTime}
+ </if>
+ <if test="taskPalce.rectificationCompleteTime != null ">and jtpr.rectification_complete_time =
+ #{taskPalce.rectificationCompleteTime}
+ </if>
+ <if test="taskPalce.rectificationFlag != null ">and jtpr.rectification_flag =
+ #{taskPalce.rectificationFlag}
+ </if>
+ <if test="taskPalce.punishFlag != null ">and jtpr.punish_flag = #{taskPalce.punishFlag}</if>
+ <if test="taskPalce.policeStation != null and taskPalce.policeStation != ''">and jtpr.police_station =
+ #{taskPalce.policeStation}
+ </if>
+ <if test="taskPalce.rectificationNoticeImgUrl != null and taskPalce.rectificationNoticeImgUrl != ''">and
+ jtpr.rectification_notice_img_url = #{taskPalce.rectificationNoticeImgUrl}
+ </if>
+ <if test="taskPalce.signaturePath != null and taskPalce.signaturePath != ''">and jtpr.signature_path =
+ #{taskPalce.signaturePath}
+ </if>
+ <if test="taskPalce.createUser != null ">and jtpr.create_user = #{taskPalce.createUser}</if>
+ <if test="taskPalce.imageUrls != null and taskPalce.imageUrls != ''">and jtpr.image_urls =
+ #{taskPalce.imageUrls}
+ </if>
+ <if test="isAdministrator==2">
+ <choose>
+ <when test="taskPalce.roleName != null and taskPalce.roleName != ''">
+ <if test="taskPalce.roleName=='wgy'">
+ <choose>
+ <when test="gridCodeList !=null and gridCodeList.size()>0">
+ and jp.grid_code in
+ <foreach collection="gridCodeList" item="code" open="(" close=")" separator=",">
+ #{code}
+ </foreach>
+ </when>
+ <otherwise>
+ and jp.grid_code in ('')
+ </otherwise>
+ </choose>
+ </if>
+ <if test="taskPalce.roleName=='mj'">
+ <choose>
+ <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+ and jpag.community_code in
+ <foreach collection="regionChildCodesList" item="code" open="(" close=")"
+ separator=",">
+ #{code}
+ </foreach>
+ </when>
+ <otherwise>
+ and jpag.community_code in ('')
+ </otherwise>
+ </choose>
+ </if>
+ </when>
+ <otherwise>
+ <choose>
+ <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+ and
+ (
+ jg.grid_code in
+ <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+ #{code}
+ </foreach>
+ or
+ jpag.community_code in
+ <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+ #{code}
+ </foreach>
+ )
+ </when>
+ <otherwise>
+ and
+ (
+ jg.grid_code in ('') or jpag.community_code in in ('')
+ )
+ </otherwise>
+ </choose>
+ </otherwise>
+ </choose>
+ </if>
+ </where>
+ order by jtpr.create_time desc
+ </select>
+
</mapper>
--
Gitblit v1.9.3