From aeb7d068be92312dcdcea75e1240bcf2a78dd0fe Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Mon, 29 Jul 2024 16:49:58 +0800
Subject: [PATCH] 代码优化

---
 src/main/java/org/springblade/modules/grid/mapper/GridPatrolRecordMapper.xml |   94 ++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 81 insertions(+), 13 deletions(-)

diff --git a/src/main/java/org/springblade/modules/grid/mapper/GridPatrolRecordMapper.xml b/src/main/java/org/springblade/modules/grid/mapper/GridPatrolRecordMapper.xml
index 8c7c860..72e420f 100644
--- a/src/main/java/org/springblade/modules/grid/mapper/GridPatrolRecordMapper.xml
+++ b/src/main/java/org/springblade/modules/grid/mapper/GridPatrolRecordMapper.xml
@@ -19,21 +19,89 @@
 
     <!--自定义分页查询-->
     <select id="selectGridPatrolRecordPage" resultType="org.springblade.modules.grid.vo.GridPatrolRecordVO">
-        select jgpr.* from jczz_grid_patrol_record jgpr
-        LEFT JOIN blade_user bu on bu.id = jgpr.create_user and bu.is_deleted = 0
-        LEFT JOIN blade_dept bd on bd.id = bu.dept_id and bd.is_deleted = 0
-        where jgpr.is_deleted = 0
-        <if test="gridPatrolRecord.name!=null and gridPatrolRecord.name!=''">
-            and jgpr.name like concat('%',#{gridPatrolRecord.name},'%')
-        </if>
-        <if test="gridPatrolRecord.context!=null and gridPatrolRecord.context!=''">
-            and jgpr.context like concat('%',#{gridPatrolRecord.context},'%')
-        </if>
-        <if test="gridPatrolRecord.createUser!=null">
-            and jgpr.create_user = #{gridPatrolRecord.createUser}
-        </if>
+        select
+        jgpr.*,
+        bu.name as userName,
+        br.town_name as townStreetName,
+        br.name as neiName
+        FROM
+        jczz_grid_patrol_record jgpr
+        LEFT JOIN blade_user bu ON bu.id = jgpr.create_user
+        LEFT JOIN blade_dept bd ON bd.id = bu.dept_id
+        LEFT JOIN jczz_grid jg on jg.grid_code=jgpr.grid_code
+        LEFT JOIN blade_region br on br.code = jg.community_code
+        <where>
+            <if test="gridPatrolRecord.name!=null and gridPatrolRecord.name!=''">
+                and jgpr.name like concat('%',#{gridPatrolRecord.name},'%')
+            </if>
+
+            <if test="gridPatrolRecord.userName!=null and gridPatrolRecord.userName!=''">
+                and bu.name like concat('%',#{gridPatrolRecord.userName},'%')
+            </if>
+
+            <if test="gridPatrolRecord.townStreetName!=null and gridPatrolRecord.townStreetName!=''">
+                and br.town_name like concat('%',#{gridPatrolRecord.townStreetName},'%')
+            </if>
+
+            <if test="gridPatrolRecord.neiName!=null and gridPatrolRecord.neiName!=''">
+                and br.name like concat('%',#{gridPatrolRecord.neiName},'%')
+            </if>
+
+            <if test="gridPatrolRecord.context!=null and gridPatrolRecord.context!=''">
+                and jgpr.context like concat('%',#{gridPatrolRecord.context},'%')
+            </if>
+            <if test="gridPatrolRecord.createUser!=null">
+                and jgpr.create_user = #{gridPatrolRecord.createUser}
+            </if>
+            and jgpr.is_deleted = 0
+        </where>
+
         order by jgpr.id desc
     </select>
 
 
+    <select id="selectGridPatrolRecordExport"
+            resultType="org.springblade.modules.grid.excel.GridPatrolRecordExcel">
+        select
+        jgpr.*,
+        bu.name as userName,
+        br.town_name as townStreetName,
+        br.name as neiName
+        FROM
+        jczz_grid_patrol_record jgpr
+        LEFT JOIN blade_user bu ON bu.id = jgpr.create_user
+        LEFT JOIN blade_dept bd ON bd.id = bu.dept_id
+        LEFT JOIN jczz_grid jg on jg.grid_code=jgpr.grid_code
+        LEFT JOIN blade_region br on br.code = jg.community_code
+        <where>
+            <if test="gridPatrolRecord.name!=null and gridPatrolRecord.name!=''">
+                and jgpr.name like concat('%',#{gridPatrolRecord.name},'%')
+            </if>
+
+            <if test="gridPatrolRecord.userName!=null and gridPatrolRecord.userName!=''">
+                and bu.name like concat('%',#{gridPatrolRecord.userName},'%')
+            </if>
+
+            <if test="gridPatrolRecord.townStreetName!=null and gridPatrolRecord.townStreetName!=''">
+                and br.town_name like concat('%',#{gridPatrolRecord.townStreetName},'%')
+            </if>
+
+            <if test="gridPatrolRecord.neiName!=null and gridPatrolRecord.neiName!=''">
+                and br.name like concat('%',#{gridPatrolRecord.neiName},'%')
+            </if>
+
+            <if test="gridPatrolRecord.context!=null and gridPatrolRecord.context!=''">
+                and jgpr.context like concat('%',#{gridPatrolRecord.context},'%')
+            </if>
+            <if test="gridPatrolRecord.createUser!=null">
+                and jgpr.create_user = #{gridPatrolRecord.createUser}
+            </if>
+            and jgpr.is_deleted = 0
+        </where>
+
+        order by jgpr.id desc
+
+    </select>
+
+
 </mapper>

--
Gitblit v1.9.3