Przeglądaj źródła

修改查询条件bug

hanqingsong 4 miesięcy temu
rodzic
commit
b794d4bb82

+ 27 - 10
unis-plugin/unis-plugin-biz/src/main/java/com/unis/emergencySupportCenter/modular/planExecute/mapper/mapping/PlanExecuteMapper.xml

@@ -3,17 +3,34 @@
3 3
 <mapper namespace="com.unis.emergencySupportCenter.modular.planExecute.mapper.PlanExecuteMapper">
4 4
     <select id="pageList" parameterType="com.baomidou.mybatisplus.core.conditions.Wrapper" resultType="com.unis.emergencySupportCenter.modular.planExecute.entity.PlanExecute">
5 5
         SELECT
6
-            pe.id,
7
-            pf.plan_name planName,
8
-	        pf.emergency_level emergencyLevel,
9
-	        pf.disaster_level disasterLevel,
10
-            CASE WHEN COUNT(ee.es_plan_execute_id)=0 THEN NULL END enterpriseCount,
11
-            SUM(ee.quantity) grainCount,
12
-            pe.create_time
6
+            t1.id,
7
+            t1.planName,
8
+            t1.emergencyLevel,
9
+            t1.disasterLevel,
10
+            t1.enterpriseCount,
11
+            t1.grainCount,
12
+            t1.create_time
13 13
         FROM
14
-            biz_es_ep_plan_execute pe
15
-        LEFT JOIN biz_es_ep_online_plan_formulation pf ON pe.es_online_plan_formulation_id = pf.id
16
-        LEFT JOIN biz_es_ep_plan_execute_enterprise ee ON pe.id = ee.es_plan_execute_id
14
+            (
15
+                SELECT
16
+                    pe.id,
17
+                    pf.plan_name planName,
18
+                    pf.emergency_level emergencyLevel,
19
+                    pf.disaster_level disasterLevel,
20
+                    CASE
21
+                WHEN COUNT(ee.es_plan_execute_id) = 0 THEN
22
+                    NULL
23
+                END enterpriseCount,
24
+                SUM(ee.quantity) grainCount,
25
+                pe.create_time,
26
+                ee.sys_org_id,
27
+                pe.create_user,
28
+                pe.es_online_plan_formulation_id
29
+            FROM
30
+                biz_es_ep_plan_execute pe
31
+            LEFT JOIN biz_es_ep_online_plan_formulation pf ON pe.es_online_plan_formulation_id = pf.id
32
+            LEFT JOIN biz_es_ep_plan_execute_enterprise ee ON pe.id = ee.es_plan_execute_id
33
+            ) t1
17 34
         ${ew.customSqlSegment}
18 35
     </select>
19 36
 </mapper>

+ 11 - 11
unis-plugin/unis-plugin-biz/src/main/java/com/unis/emergencySupportCenter/modular/planExecute/service/impl/PlanExecuteServiceImpl.java

@@ -58,22 +58,22 @@ public class PlanExecuteServiceImpl extends ServiceImpl<PlanExecuteMapper, PlanE
58 58
     @Override
59 59
     public Page<PlanExecute> page(PlanExecutePageParam planExecutePageParam) {
60 60
         QueryWrapper<PlanExecute> queryWrapper = new QueryWrapper<>();
61
-        // 自定义查询条件
62
-        if (StringUtils.isNotEmpty(planExecutePageParam.getPlanName())) {
63
-            queryWrapper.like("pf.plan_name", planExecutePageParam.getPlanName());
64
-        }
65
-        if (ObjectUtil.isNotEmpty(planExecutePageParam.getEmergencyLevel())) {
66
-            queryWrapper.eq("pf.emergency_level", planExecutePageParam.getEmergencyLevel());
67
-        }
68 61
         // 权限范围
69 62
         List<String> loginUserDataScope = StpLoginUserUtil.getLoginUserDataScope();
70 63
         // 创建人权限
71 64
         String loginUserId = StpLoginUserUtil.getLoginUser().getId();
72 65
         if (CollectionUtils.isNotEmpty(loginUserDataScope)) {
73
-            queryWrapper.in("ee.sys_org_id", loginUserDataScope)
74
-                    .or().eq("pe.create_user", loginUserId);
66
+            queryWrapper.in("t1.sys_org_id", loginUserDataScope)
67
+                    .or().eq("t1.create_user", loginUserId);
75 68
         } else {
76
-            queryWrapper.eq("pe.create_user", StpUtil.getLoginIdAsString());
69
+            queryWrapper.eq("t1.create_user", StpUtil.getLoginIdAsString());
70
+        }
71
+        // 自定义查询条件
72
+        if (StringUtils.isNotEmpty(planExecutePageParam.getPlanName())) {
73
+            queryWrapper.like("t1.planName", planExecutePageParam.getPlanName());
74
+        }
75
+        if (ObjectUtil.isNotEmpty(planExecutePageParam.getEmergencyLevel())) {
76
+            queryWrapper.eq("t1.emergencyLevel", planExecutePageParam.getEmergencyLevel());
77 77
         }
78 78
         // 排序
79 79
         if (ObjectUtil.isAllNotEmpty(planExecutePageParam.getSortField(), planExecutePageParam.getSortOrder())) {
@@ -83,7 +83,7 @@ public class PlanExecuteServiceImpl extends ServiceImpl<PlanExecuteMapper, PlanE
83 83
         } else {
84 84
             queryWrapper.lambda().orderByDesc(PlanExecute::getId);
85 85
         }
86
-        queryWrapper.groupBy("pe.es_online_plan_formulation_id");
86
+        queryWrapper.groupBy("t1.es_online_plan_formulation_id");
87 87
         return planExecuteMapper.pageList(CommonPageRequest.defaultPage(), queryWrapper);
88 88
     }
89 89