From c10d6358b9f014375a13821465bc978d0c0da22e Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Wed, 29 May 2024 17:17:08 +0800
Subject: [PATCH] 通过E呼即办数据统计

---
 src/main/java/org/springblade/modules/place/mapper/PlaceCheckMapper.xml |  369 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 363 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/springblade/modules/place/mapper/PlaceCheckMapper.xml b/src/main/java/org/springblade/modules/place/mapper/PlaceCheckMapper.xml
index 3626570..8777b93 100644
--- a/src/main/java/org/springblade/modules/place/mapper/PlaceCheckMapper.xml
+++ b/src/main/java/org/springblade/modules/place/mapper/PlaceCheckMapper.xml
@@ -3,29 +3,386 @@
 <mapper namespace="org.springblade.modules.place.mapper.PlaceCheckMapper">
 
     <!-- 通用查询映射结果 -->
-    <resultMap id="placeCheckResultMap" type="org.springblade.modules.place.entity.PlaceCheckEntity">
+    <resultMap id="placeCheckResultMap" type="org.springblade.modules.place.vo.PlaceCheckVO">
         <result column="id" property="id"/>
         <result column="house_code" property="houseCode"/>
         <result column="remark" property="remark"/>
-        <result column="image_urls" property="imageUrls"/>
         <result column="signature_path" property="signaturePath"/>
         <result column="create_user" property="createUser"/>
         <result column="create_time" property="createTime"/>
         <result column="is_deleted" property="isDeleted"/>
+        <result column="image_urls" property="imageUrls"/>
+        <result column="place_name" property="placeName"/>
+        <result column="location" property="location"/>
+        <result column="grid_name" property="gridName"/>
+        <result column="principal" property="principal"/>
+        <result column="principal_phone" property="principalPhone"/>
+        <result column="town_name" property="streetName"/>
+        <result column="village_name" property="communityName"/>
+        <result property="rectificationNoticeFlag"    column="rectification_notice_flag"    />
+        <result property="punishFlag"    column="punish_flag"    />
+        <result property="rectificationEndTime"    column="rectification_end_time"    />
+        <result property="punishRemark"    column="punish_remark"    />
+
+        <collection property="placePoiLabelVOList" column="jpid" javaType="java.util.List" select="selectPlacePoiLabelList"
+                    ofType="org.springblade.modules.place.vo.PlacePoiLabelVO"
+                    autoMapping="true">
+        </collection>
+
+        <collection property="patrolRecordVOList" column="id" select="selectPatrolRecordList"
+                    javaType="java.util.List" ofType="org.springblade.modules.patrol.entity.PatrolRecord"
+                    autoMapping="true">
+        </collection>
     </resultMap>
+
+    <select id="selectPlacePoiLabelList" parameterType="Long"
+            resultType="org.springblade.modules.place.vo.PlacePoiLabelVO">
+            SELECT
+            jppl.id,
+            jppl.place_id,
+            jppl.poi_code,
+            jppl.type,
+            jppl.color,
+            jppl.remark,
+            jc.category_name labelName
+        FROM
+            jczz_place_poi_label jppl
+            LEFT JOIN jczz_category jc ON jppl.poi_code = jc.category_no
+        WHERE
+            jppl.type = '3'
+             and  place_id = #{jpid}
+        </select>
+
+
+    <select id="selectPatrolRecordList" parameterType="Long"
+            resultType="org.springblade.modules.patrol.entity.PatrolRecord">
+            select
+            id,
+	        item_id,
+	        place_check_id,
+	        state,
+	        remark,
+	        image_urls,
+	        create_user,
+	        create_time,
+	        is_deleted,
+	        rectification_image_urls,
+	        rectification_remark,
+	        rectification_time
+            from
+            jczz_patrol_record where place_check_id = #{id}
+        </select>
+
 
     <!--自定义分页查询-->
     <select id="selectPlaceCheckPage" resultMap="placeCheckResultMap">
-        select * from jczz_place_check where is_deleted = 0
+        SELECT
+        jpc.*,
+        jp.id jpid,
+        jp.place_name,
+        jp.location,
+        jg.grid_name,
+        jp.principal,
+        jp.principal_phone,
+        jp.nine_type,
+        jp.is_nine,
+        br.town_name,
+        br.village_name,
+        bu.`name`,
+        jpe.legal_tel,
+        jpe.legal_person
+        FROM
+        jczz_place_check jpc
+        LEFT JOIN jczz_place jp ON jpc.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 and jpe.is_deleted = 0
+        LEFT JOIN blade_user bu ON bu.id = jpc.create_user and bu.is_deleted = 0
+        LEFT JOIN jczz_police_affairs_grid jpag on jp.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
+        where jpc.is_deleted = 0
         <if test="placeCheck.houseCode!=null and placeCheck.houseCode!=''">
-            and house_code = #{placeCheck.houseCode}
+            and jpc.house_code = #{placeCheck.houseCode}
         </if>
+
+        <if test="placeCheck.streetName!=null and placeCheck.streetName!=''">
+            and br.town_name like concat('%', #{placeCheck.streetName},'%')
+        </if>
+
+        <if test="placeCheck.communityName!=null and placeCheck.communityName!=''">
+            and br.village_name like concat('%', #{placeCheck.communityName},'%')
+        </if>
+
+        <if test="placeCheck.gridName!=null and placeCheck.gridName!=''">
+            and jg.grid_name like concat('%', #{placeCheck.gridName},'%')
+        </if>
+
+        <if test="placeCheck.placeName!=null and placeCheck.placeName!=''">
+            and jp.place_name like concat('%', #{placeCheck.placeName},'%')
+        </if>
+
+        <if test="placeCheck.principal!=null and placeCheck.principal!=''">
+            and jp.principal like concat('%', #{placeCheck.principal},'%')
+        </if>
+
+        <if test="placeCheck.principalPhone!=null and placeCheck.principalPhone!=''">
+            and jp.principal_phone like concat('%', #{placeCheck.principalPhone},'%')
+        </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="placeCheck.startTime!=null and placeCheck.startTime!=''">
-            and date_format(create_time,'%Y-%m-%d') &gt;= #{placeCheck.startTime}
+            and date_format(jpc.create_time,'%Y-%m-%d') &gt;= #{placeCheck.startTime}
         </if>
         <if test="placeCheck.endTime!=null and placeCheck.endTime!=''">
-            and date_format(create_time,'%Y-%m-%d') &lt;= #{placeCheck.endTime}
+            and date_format(jpc.create_time,'%Y-%m-%d') &lt;= #{placeCheck.endTime}
         </if>
+        <if test="isAdministrator==2">
+            <choose>
+                <when test="placeCheck.roleName != null and placeCheck.roleName != ''">
+                    <if test="placeCheck.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="placeCheck.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 ('')
+                            )
+                        </otherwise>
+                    </choose>
+                </otherwise>
+            </choose>
+        </if>
+        order by jpc.create_time desc
+    </select>
+
+
+    <sql id="selectPlaceCheck">
+    	select
+	        id,
+	        house_code,
+	        remark,
+	        image_urls,
+	        signature_path,
+	        create_user,
+	        create_time,
+	        rectification_notice_flag,
+	        punish_flag,
+	        rectification_end_time,
+	        punish_remark,
+	        is_deleted
+		from
+        	jczz_place_check
+    </sql>
+
+    <select id="selectPlaceCheckById" parameterType="long" resultMap="placeCheckResultMap">
+        SELECT
+        jpc.*,
+        jp.id jpid,
+        jp.place_name,
+        jp.location,
+        jg.grid_name,
+        jp.principal,
+        jp.principal_phone,
+        br.town_name,
+        br.village_name,
+        bu.`name`,
+        jpe.legal_tel,
+        jpe.legal_person
+        FROM
+        jczz_place_check jpc
+        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 jczz_place_ext jpe ON jpe.place_id = jp.id
+        LEFT JOIN blade_user bu ON bu.id = jpc.create_user
+        where
+            jpc.is_deleted = 0
+            and  jpc.id = #{id}
+        </select>
+
+    <select id="selectPlaceCheckList" parameterType="org.springblade.modules.place.dto.PlaceCheckDTO"
+            resultMap="placeCheckResultMap">
+        <include refid="selectPlaceCheck"/>
+        <where>
+            <if test="id != null ">and id = #{id}</if>
+            <if test="houseCode != null  and houseCode != ''">and house_code = #{houseCode}</if>
+            <if test="remark != null  and remark != ''">and remark = #{remark}</if>
+            <if test="signaturePath != null  and signaturePath != ''">and signature_path = #{signaturePath}</if>
+            <if test="createUser != null ">and create_user = #{createUser}</if>
+            <if test="createTime != null ">and create_time = #{createTime}</if>
+            <if test="isDeleted != null ">and is_deleted = #{isDeleted}</if>
+        </where>
+    </select>
+
+    <!--查询列表数据导出-->
+    <select id="selectPlaceCheckListExcel" resultType="org.springblade.modules.place.excel.PlaceCheckExcel">
+        SELECT
+        jpc.*,
+        jp.id jpid,
+        jp.place_name,
+        jp.location,
+        jg.grid_name,
+        jp.principal,
+        jp.principal_phone,
+        jp.nine_type,
+        jp.is_nine,
+        br.town_name as streetName,
+        br.village_name as communityName,
+        bu.`name`,
+        jpe.legal_tel,
+        jpe.legal_person
+        FROM
+        jczz_place_check jpc
+        LEFT JOIN jczz_place jp ON jpc.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 and jpe.is_deleted = 0
+        LEFT JOIN blade_user bu ON bu.id = jpc.create_user and bu.is_deleted = 0
+        LEFT JOIN jczz_police_affairs_grid jpag on jp.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
+        where jpc.is_deleted = 0
+        <if test="placeCheck.houseCode!=null and placeCheck.houseCode!=''">
+            and jpc.house_code = #{placeCheck.houseCode}
+        </if>
+
+        <if test="placeCheck.streetName!=null and placeCheck.streetName!=''">
+            and br.town_name like concat('%', #{placeCheck.streetName},'%')
+        </if>
+
+        <if test="placeCheck.communityName!=null and placeCheck.communityName!=''">
+            and br.village_name like concat('%', #{placeCheck.communityName},'%')
+        </if>
+
+        <if test="placeCheck.gridName!=null and placeCheck.gridName!=''">
+            and jg.grid_name like concat('%', #{placeCheck.gridName},'%')
+        </if>
+
+        <if test="placeCheck.placeName!=null and placeCheck.placeName!=''">
+            and jp.place_name like concat('%', #{placeCheck.placeName},'%')
+        </if>
+
+        <if test="placeCheck.principal!=null and placeCheck.principal!=''">
+            and jp.principal like concat('%', #{placeCheck.principal},'%')
+        </if>
+
+        <if test="placeCheck.principalPhone!=null and placeCheck.principalPhone!=''">
+            and jp.principal_phone like concat('%', #{placeCheck.principalPhone},'%')
+        </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="placeCheck.startTime!=null and placeCheck.startTime!=''">
+            and date_format(jpc.create_time,'%Y-%m-%d') &gt;= #{placeCheck.startTime}
+        </if>
+        <if test="placeCheck.endTime!=null and placeCheck.endTime!=''">
+            and date_format(jpc.create_time,'%Y-%m-%d') &lt;= #{placeCheck.endTime}
+        </if>
+        <if test="isAdministrator==2">
+            <choose>
+                <when test="placeCheck.roleName != null and placeCheck.roleName != ''">
+                    <if test="placeCheck.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="placeCheck.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 ('')
+                            )
+                        </otherwise>
+                    </choose>
+                </otherwise>
+            </choose>
+        </if>
+        order by jpc.create_time desc
     </select>
 
 

--
Gitblit v1.9.3