From 9ba12dad011e2afa278833f37aba895a632ccb9c Mon Sep 17 00:00:00 2001
From: lin <sbla5888@163.com>
Date: Mon, 06 May 2024 14:45:16 +0800
Subject: [PATCH] 校园安全检查

---
 src/main/java/org/springblade/modules/task/mapper/TaskSchoolEvenMapper.xml |  204 +++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 175 insertions(+), 29 deletions(-)

diff --git a/src/main/java/org/springblade/modules/task/mapper/TaskSchoolEvenMapper.xml b/src/main/java/org/springblade/modules/task/mapper/TaskSchoolEvenMapper.xml
index 2d7275d..d88cd62 100644
--- a/src/main/java/org/springblade/modules/task/mapper/TaskSchoolEvenMapper.xml
+++ b/src/main/java/org/springblade/modules/task/mapper/TaskSchoolEvenMapper.xml
@@ -3,12 +3,77 @@
 <mapper namespace="org.springblade.modules.task.mapper.TaskSchoolEvenMapper">
 
     <!-- 通用查询映射结果 -->
-    <resultMap id="taskSchoolEvenResultMap" type="org.springblade.modules.task.entity.TaskSchoolEvenEntity">
+    <resultMap id="taskSchoolEvenResultMap" type="org.springblade.modules.task.vo.TaskSchoolEvenVO">
     </resultMap>
 
 
     <select id="selectTaskSchoolEvenPage" resultMap="taskSchoolEvenResultMap">
-        select * from jczz_task_school_even
+        select
+        jtse.*,
+        br.town_name streetName,
+        jg.grid_name,
+        jda.aoi_name,
+        br.village_name communityName,
+        bu.name,
+        bu.phone,
+        jp.location,
+        jp.place_name,
+        jda.address_name as addressName
+        from jczz_task_school_even jtse
+        left join jczz_doorplate_address jda on jda.address_code = jtse.house_code
+        LEFT JOIN blade_user bu ON bu.id = jtse.create_user
+        LEFT JOIN jczz_place jp on jp.house_code= jtse.house_code
+        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_police_affairs_grid jpag on jp.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
+        <where>
+            <if test="taskSchoolEven.id != null "> and jtse.id = #{taskSchoolEven.id}</if>
+            <if test="taskSchoolEven.createUser != null "> and jtse.create_user = #{taskSchoolEven.createUser}</if>
+            <if test="taskSchoolEven.images != null  and taskSchoolEven.images != ''"> and jtse.images = #{taskSchoolEven.images}</if>
+            <if test="taskSchoolEven.placeName != null  and taskSchoolEven.placeName != ''"> and jp.place_name like concat('%',#{taskSchoolEven.placeName},'%')</if>
+            <if test="taskSchoolEven.name != null  and taskSchoolEven.name != ''"> and bu.name like concat('%',#{taskSchoolEven.name},'%')</if>
+            <if test="taskSchoolEven.phone != null  and taskSchoolEven.phone != ''"> and bu.phone like concat('%',#{taskSchoolEven.phone},'%')</if>
+            <if test="taskSchoolEven.remark != null  and taskSchoolEven.remark != ''"> and jtse.remark like concat('%',#{taskSchoolEven.remark},'%')</if>
+            <if test="taskSchoolEven.hiddenDangerType != null  and taskSchoolEven.hiddenDangerType != ''"> and jtse.hidden_danger_type = #{taskSchoolEven.hiddenDangerType}</if>
+            <if test="taskSchoolEven.type != null  and taskSchoolEven.type != ''"> and jtse.type = #{taskSchoolEven.type}</if>
+            <if test="taskSchoolEven.isProblem != null  and taskSchoolEven.isProblem != ''"> and jtse.is_problem = #{taskSchoolEven.isProblem}</if>
+            <if test="taskSchoolEven.isHandle != null  and taskSchoolEven.isHandle != ''"> and jtse.is_handle = #{taskSchoolEven.isHandle}</if>
+            <if test="taskSchoolEven.isReporting != null  and taskSchoolEven.isReporting != ''"> and jtse.is_reporting = #{taskSchoolEven.isReporting}</if>
+            <if test="taskSchoolEven.workImage != null  and taskSchoolEven.workImage != ''"> and jtse.work_image = #{taskSchoolEven.workImage}</if>
+            <if test="taskSchoolEven.confirmFlag != null  and taskSchoolEven.confirmFlag != ''"> and jtse.confirm_flag = #{taskSchoolEven.confirmFlag}</if>
+            <if test="taskSchoolEven.confirmTime != null "> and jtse.confirm_time = #{taskSchoolEven.confirmTime}</if>
+            <if test="taskSchoolEven.confirmUserId != null "> and jtse.confirm_user_id = #{taskSchoolEven.confirmUserId}</if>
+            <if test="taskSchoolEven.confirmUserName != null  and taskSchoolEven.confirmUserName != ''"> and jtse.confirm_user_name = #{taskSchoolEven.confirmUserName}</if>
+            <if test="taskSchoolEven.confirmNotion != null  and taskSchoolEven.confirmNotion != ''"> and jtse.confirm_notion = #{taskSchoolEven.confirmNotion}</if>
+            <if test="taskSchoolEven.houseCode != null  and taskSchoolEven.houseCode != ''"> and jtse.house_code = #{taskSchoolEven.houseCode}</if>
+            <if test="taskSchoolEven.createTime != null "> and jtse.create_time = #{taskSchoolEven.createTime}</if>
+            <if test="taskSchoolEven.updateTime != null "> and jtse.update_time = #{taskSchoolEven.updateTime}</if>
+            <if test="taskSchoolEven.startTime != null and taskSchoolEven.startTime != ''">
+                and date_format(jtse.create_time,'%Y-%m-%d') &gt;= #{taskSchoolEven.startTime}
+            </if>
+            <if test="taskSchoolEven.endTime != null and taskSchoolEven.endTime != ''">
+                and date_format(jtse.create_time,'%Y-%m-%d') &lt;= #{taskSchoolEven.endTime}
+            </if>
+
+
+            <if test="isAdministrator==2">
+                <if test="taskSchoolEven.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>
+            </if>
+        </where>
+        order by jtse.create_time desc
     </select>
 
     <resultMap type="org.springblade.modules.task.dto.TaskSchoolEvenDTO" id="TaskSchoolEvenDTOResult">
@@ -54,33 +119,114 @@
             jczz_task_school_even
     </sql>
 
-<!--    <select id="selectTaskSchoolEvenById" parameterType="long" resultMap="TaskSchoolEvenDTOResult">-->
-<!--        <include refid="selectTaskSchoolEven"/>-->
-<!--        where-->
-<!--        id = #{id}-->
-<!--    </select>-->
+    <select id="schoolEvenCount" resultType="java.lang.Integer">
+        select
+        count(1)
+        from jczz_task_school_even jtse
+        left join jczz_doorplate_address jda on jda.address_code = jtse.house_code
+        LEFT JOIN blade_user bu ON bu.id = jtse.create_user
+        LEFT JOIN jczz_place jp on jp.house_code= jtse.house_code
+        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
+        <where>
+            <if test="taskSchoolEven.id != null "> and jtse.id = #{taskSchoolEven.id}</if>
+            <if test="taskSchoolEven.createUser != null "> and jtse.create_user = #{taskSchoolEven.createUser}</if>
+            <if test="taskSchoolEven.images != null  and taskSchoolEven.images != ''"> and jtse.images = #{taskSchoolEven.images}</if>
+            <if test="taskSchoolEven.name != null  and taskSchoolEven.name != ''"> and bu.name like concat('%',#{taskSchoolEven.name},'%')</if>
+            <if test="taskSchoolEven.phone != null  and taskSchoolEven.phone != ''"> and bu.phone like concat('%',#{taskSchoolEven.phone},'%')</if>
+            <if test="taskSchoolEven.remark != null  and taskSchoolEven.remark != ''"> and jtse.remark like concat('%',#{taskSchoolEven.remark},'%')</if>
+            <if test="taskSchoolEven.hiddenDangerType != null  and taskSchoolEven.hiddenDangerType != ''"> and jtse.hidden_danger_type = #{taskSchoolEven.hiddenDangerType}</if>
+            <if test="taskSchoolEven.type != null  and taskSchoolEven.type != ''"> and jtse.type = #{taskSchoolEven.type}</if>
+            <if test="taskSchoolEven.isProblem != null  and taskSchoolEven.isProblem != ''"> and jtse.is_problem = #{taskSchoolEven.isProblem}</if>
+            <if test="taskSchoolEven.isHandle != null  and taskSchoolEven.isHandle != ''"> and jtse.is_handle = #{taskSchoolEven.isHandle}</if>
+            <if test="taskSchoolEven.isReporting != null  and taskSchoolEven.isReporting != ''"> and jtse.is_reporting = #{taskSchoolEven.isReporting}</if>
+            <if test="taskSchoolEven.workImage != null  and taskSchoolEven.workImage != ''"> and jtse.work_image = #{taskSchoolEven.workImage}</if>
+            <if test="taskSchoolEven.confirmFlag != null  and taskSchoolEven.confirmFlag != ''"> and jtse.confirm_flag = #{taskSchoolEven.confirmFlag}</if>
+            <if test="taskSchoolEven.confirmTime != null "> and jtse.confirm_time = #{taskSchoolEven.confirmTime}</if>
+            <if test="taskSchoolEven.confirmUserId != null "> and jtse.confirm_user_id = #{taskSchoolEven.confirmUserId}</if>
+            <if test="taskSchoolEven.confirmUserName != null  and taskSchoolEven.confirmUserName != ''"> and jtse.confirm_user_name = #{taskSchoolEven.confirmUserName}</if>
+            <if test="taskSchoolEven.confirmNotion != null  and taskSchoolEven.confirmNotion != ''"> and jtse.confirm_notion = #{taskSchoolEven.confirmNotion}</if>
+            <if test="taskSchoolEven.houseCode != null  and taskSchoolEven.houseCode != ''"> and jtse.house_code = #{taskSchoolEven.houseCode}</if>
+            <if test="taskSchoolEven.createTime != null "> and jtse.create_time = #{taskSchoolEven.createTime}</if>
+            <if test="taskSchoolEven.updateTime != null "> and jtse.update_time = #{taskSchoolEven.updateTime}</if>
 
-<!--    <select id="selectTaskSchoolEvenList" parameterType="org.springblade.modules..dto.TaskSchoolEvenDTO" resultMap="TaskSchoolEvenDTOResult">-->
-<!--        <include refid="selectTaskSchoolEven"/>-->
-<!--        <where>-->
-<!--            <if test="id != null "> and id = #{id}</if>-->
-<!--            <if test="createUser != null "> and create_user = #{createUser}</if>-->
-<!--            <if test="images != null  and images != ''"> and images = #{images}</if>-->
-<!--            <if test="remark != null  and remark != ''"> and remark = #{remark}</if>-->
-<!--            <if test="hiddenDangerType != null  and hiddenDangerType != ''"> and hidden_danger_type = #{hiddenDangerType}</if>-->
-<!--            <if test="type != null  and type != ''"> and type = #{type}</if>-->
-<!--            <if test="isProblem != null  and isProblem != ''"> and is_problem = #{isProblem}</if>-->
-<!--            <if test="isHandle != null  and isHandle != ''"> and is_handle = #{isHandle}</if>-->
-<!--            <if test="isReporting != null  and isReporting != ''"> and is_reporting = #{isReporting}</if>-->
-<!--            <if test="workImage != null  and workImage != ''"> and work_image = #{workImage}</if>-->
-<!--            <if test="confirmFlag != null  and confirmFlag != ''"> and confirm_flag = #{confirmFlag}</if>-->
-<!--            <if test="confirmTime != null "> and confirm_time = #{confirmTime}</if>-->
-<!--            <if test="confirmUserId != null "> and confirm_user_id = #{confirmUserId}</if>-->
-<!--            <if test="confirmUserName != null  and confirmUserName != ''"> and confirm_user_name = #{confirmUserName}</if>-->
-<!--            <if test="confirmNotion != null  and confirmNotion != ''"> and confirm_notion = #{confirmNotion}</if>-->
-<!--            <if test="createTime != null "> and create_time = #{createTime}</if>-->
-<!--            <if test="updateTime != null "> and update_time = #{updateTime}</if>-->
-<!--        </where>-->
-<!--    </select>-->
+            <if test="isAdministrator==2">
+                <!-- 网格员及其他 -->
+                <if test="taskSchoolEven.roleType ==null and taskSchoolEven.roleName !='inhabitant' and taskSchoolEven.houseCode == null ">
+                    <choose>
+                        <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+                            and (
+                            jg.community_code in
+                            <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+                                #{code}
+                            </foreach>
+                            )
+                        </when>
+                    </choose>
+
+                    <choose>
+                        <when test="gridCodeList !=null and gridCodeList.size()>0">
+                            and (
+                            jg.grid_code in
+                            <foreach collection="gridCodeList" item="code" open="(" close=")" separator=",">
+                                #{code}
+                            </foreach>
+                            )
+                        </when>
+                    </choose>
+
+                    <if test="taskSchoolEven.confirmUserId != null ">
+                        or jtse.confirm_user_id = #{taskSchoolEven.confirmUserId}
+                    </if>
+
+                </if>
+            </if>
+        </where>
+        order by jtse.create_time desc
+    </select>
+
+    <select id="selectTaskSchoolEvenDetail" resultMap="taskSchoolEvenResultMap">
+        select
+        jtse.*,
+        br.town_name streetName,
+        jg.grid_name,
+        jda.aoi_name,
+        br.village_name communityName,
+        bu.name,
+        bu.phone,
+        jp.location,
+        jp.place_name,
+        jda.address_name as addressName
+        from jczz_task_school_even jtse
+        left join jczz_doorplate_address jda on jda.address_code = jtse.house_code
+        LEFT JOIN blade_user bu ON bu.id = jtse.create_user
+        LEFT JOIN jczz_place jp on jp.house_code= jtse.house_code
+        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_police_affairs_grid jpag on jp.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
+        <where>
+            <if test="taskSchoolEven.id != null "> and jtse.id = #{taskSchoolEven.id}</if>
+            <if test="taskSchoolEven.createUser != null "> and jtse.create_user = #{taskSchoolEven.createUser}</if>
+            <if test="taskSchoolEven.images != null  and taskSchoolEven.images != ''"> and jtse.images = #{taskSchoolEven.images}</if>
+            <if test="taskSchoolEven.name != null  and taskSchoolEven.name != ''"> and bu.name like concat('%',#{taskSchoolEven.name},'%')</if>
+            <if test="taskSchoolEven.phone != null  and taskSchoolEven.phone != ''"> and bu.phone like concat('%',#{taskSchoolEven.phone},'%')</if>
+            <if test="taskSchoolEven.remark != null  and taskSchoolEven.remark != ''"> and jtse.remark like concat('%',#{taskSchoolEven.remark},'%')</if>
+            <if test="taskSchoolEven.hiddenDangerType != null  and taskSchoolEven.hiddenDangerType != ''"> and jtse.hidden_danger_type = #{taskSchoolEven.hiddenDangerType}</if>
+            <if test="taskSchoolEven.type != null  and taskSchoolEven.type != ''"> and jtse.type = #{taskSchoolEven.type}</if>
+            <if test="taskSchoolEven.isProblem != null  and taskSchoolEven.isProblem != ''"> and jtse.is_problem = #{taskSchoolEven.isProblem}</if>
+            <if test="taskSchoolEven.isHandle != null  and taskSchoolEven.isHandle != ''"> and jtse.is_handle = #{taskSchoolEven.isHandle}</if>
+            <if test="taskSchoolEven.isReporting != null  and taskSchoolEven.isReporting != ''"> and jtse.is_reporting = #{taskSchoolEven.isReporting}</if>
+            <if test="taskSchoolEven.workImage != null  and taskSchoolEven.workImage != ''"> and jtse.work_image = #{taskSchoolEven.workImage}</if>
+            <if test="taskSchoolEven.confirmFlag != null  and taskSchoolEven.confirmFlag != ''"> and jtse.confirm_flag = #{taskSchoolEven.confirmFlag}</if>
+            <if test="taskSchoolEven.confirmTime != null "> and jtse.confirm_time = #{taskSchoolEven.confirmTime}</if>
+            <if test="taskSchoolEven.confirmUserId != null "> and jtse.confirm_user_id = #{taskSchoolEven.confirmUserId}</if>
+            <if test="taskSchoolEven.confirmUserName != null  and taskSchoolEven.confirmUserName != ''"> and jtse.confirm_user_name = #{taskSchoolEven.confirmUserName}</if>
+            <if test="taskSchoolEven.confirmNotion != null  and taskSchoolEven.confirmNotion != ''"> and jtse.confirm_notion = #{taskSchoolEven.confirmNotion}</if>
+            <if test="taskSchoolEven.houseCode != null  and taskSchoolEven.houseCode != ''"> and jtse.house_code = #{taskSchoolEven.houseCode}</if>
+            <if test="taskSchoolEven.createTime != null "> and jtse.create_time = #{taskSchoolEven.createTime}</if>
+            <if test="taskSchoolEven.updateTime != null "> and jtse.update_time = #{taskSchoolEven.updateTime}</if>
+        </where>
+        order by jtse.create_time desc
+    </select>
 
 </mapper>

--
Gitblit v1.9.3