Commit e9af2e9f07a78b1971d6a32ef0dcb7a52b59b66f

Authored by 王富生
1 parent a7e6827a

优化

urbanops-module-garden/src/main/resources/mapper/inspectionplan/InspectionPlanMapper.xml
@@ -24,11 +24,12 @@ @@ -24,11 +24,12 @@
24 a.finish_state, 24 a.finish_state,
25 a.begin_time, 25 a.begin_time,
26 a.end_time 26 a.end_time
27 - FROM garden_inspection_plan a,  
28 - garden_inspection_plan_detail b,  
29 - (select distinct batch_no, dept_id  
30 - from garden_maintain_plan_role  
31 - where deleted = 0 27 + FROM
  28 + garden_inspection_plan a
  29 + INNER JOIN (
  30 + SELECT DISTINCT batch_no
  31 + FROM garden_inspection_plan_role
  32 + WHERE deleted = 0
32 AND dept_id = #{req.deptId} 33 AND dept_id = #{req.deptId}
33 <if test="req.roleIds != null and req.roleIds.size() > 0"> 34 <if test="req.roleIds != null and req.roleIds.size() > 0">
34 AND role_id IN 35 AND role_id IN
@@ -36,14 +37,11 @@ @@ -36,14 +37,11 @@
36 #{roleId} 37 #{roleId}
37 </foreach> 38 </foreach>
38 </if> 39 </if>
39 - ) c  
40 - WHERE a.batch_no = b.batch_no  
41 - AND a.batch_no = c.batch_no  
42 - AND a.dept_id = c.dept_id  
43 - AND a.deleted = b.deleted  
44 - AND a.deleted = 0 40 + ) c ON a.batch_no = c.batch_no
  41 + WHERE
  42 + a.deleted = 0
45 <if test="req.roadName != null and req.roadName !=''"> 43 <if test="req.roadName != null and req.roadName !=''">
46 - AND a.road_name LIKE CONCAT('%',#{req.roadName},'%') 44 + AND a.road_name LIKE CONCAT('%', #{req.roadName}, '%')
47 </if> 45 </if>
48 <if test="req.busiLineList != null and req.busiLineList.size() > 0"> 46 <if test="req.busiLineList != null and req.busiLineList.size() > 0">
49 AND a.busi_line IN 47 AND a.busi_line IN
@@ -51,24 +49,22 @@ @@ -51,24 +49,22 @@
51 #{busiLine} 49 #{busiLine}
52 </foreach> 50 </foreach>
53 </if> 51 </if>
54 - <!--状态 1:未完成;2:已完成;3:已失效 4:终止-->  
55 - and b.finish_state = a.finish_state  
56 - <!--状态 1:未完成;2:已完成;3:已失效-->  
57 - and a.finish_state = b.finish_state 52 + <!-- 状态过滤 -->
58 <if test="req.finishState == 1"> 53 <if test="req.finishState == 1">
59 - and a.finish_state = 1  
60 - <![CDATA[and a.begin_time <= #{req.localDate}  
61 - and a.end_time >= #{req.localDate}]]> 54 + AND a.finish_state = 1
  55 + <![CDATA[AND a.begin_time <= #{req.localDate}
  56 + AND a.end_time >= #{req.localDate}]]>
62 </if> 57 </if>
63 <if test="req.finishState == 2"> 58 <if test="req.finishState == 2">
64 - and a.finish_state = 2 59 + AND a.finish_state = 2
65 </if> 60 </if>
66 <if test="req.finishState == 3"> 61 <if test="req.finishState == 3">
67 - and a.finish_state = 3 62 + AND a.finish_state = 3
68 </if> 63 </if>
69 <if test="req.finishState == 4"> 64 <if test="req.finishState == 4">
70 - and a.finish_state = 4 65 + AND a.finish_state = 4
71 </if> 66 </if>
72 67
  68 +
73 </select> 69 </select>
74 </mapper> 70 </mapper>
urbanops-module-garden/src/main/resources/mapper/maintainplan/MaintainPlanMapper.xml
@@ -25,11 +25,11 @@ @@ -25,11 +25,11 @@
25 a.begin_time, 25 a.begin_time,
26 a.end_time 26 a.end_time
27 FROM 27 FROM
28 - garden_maintain_plan a,  
29 - garden_maintain_plan_detail b,  
30 - (select distinct batch_no, dept_id  
31 - from garden_maintain_plan_role  
32 - where deleted = 0 28 + garden_maintain_plan a
  29 + INNER JOIN (
  30 + SELECT DISTINCT batch_no
  31 + FROM garden_maintain_plan_role
  32 + WHERE deleted = 0
33 AND dept_id = #{req.deptId} 33 AND dept_id = #{req.deptId}
34 <if test="req.roleIds != null and req.roleIds.size() > 0"> 34 <if test="req.roleIds != null and req.roleIds.size() > 0">
35 AND role_id IN 35 AND role_id IN
@@ -37,38 +37,35 @@ @@ -37,38 +37,35 @@
37 #{roleId} 37 #{roleId}
38 </foreach> 38 </foreach>
39 </if> 39 </if>
40 - ) c  
41 - WHERE a.batch_no = b.batch_no  
42 - AND a.batch_no = c.batch_no  
43 - AND a.dept_id = c.dept_id  
44 - AND a.deleted = b.deleted  
45 - AND a.deleted = 0  
46 - <if test="req.roadName != null and req.roadName !=''">  
47 - AND a.road_name LIKE CONCAT('%',#{req.roadName},'%') 40 + ) c ON a.batch_no = c.batch_no
  41 + WHERE
  42 + a.deleted = 0
  43 + <if test="req.roadName != null and req.roadName != ''">
  44 + AND a.road_name LIKE CONCAT('%', #{req.roadName}, '%')
48 </if> 45 </if>
49 -  
50 <if test="req.busiLineList != null and req.busiLineList.size() > 0"> 46 <if test="req.busiLineList != null and req.busiLineList.size() > 0">
51 AND a.busi_line IN 47 AND a.busi_line IN
52 <foreach collection="req.busiLineList" item="busiLine" open="(" separator="," close=")"> 48 <foreach collection="req.busiLineList" item="busiLine" open="(" separator="," close=")">
53 #{busiLine} 49 #{busiLine}
54 </foreach> 50 </foreach>
55 </if> 51 </if>
56 - <!--状态 1:未完成;2:已完成;3:已失效-->  
57 - and a.finish_state = b.finish_state  
58 - <if test="req.finishState == 1">  
59 - and a.finish_state = 1  
60 - <![CDATA[and a.begin_time <= #{req.localDate}  
61 - and a.end_time >= #{req.localDate}]]>  
62 - </if>  
63 - <if test="req.finishState == 2">  
64 - and a.finish_state = 2  
65 - </if>  
66 - <if test="req.finishState == 3">  
67 - and a.finish_state = 3  
68 - </if>  
69 - <if test="req.finishState == 4">  
70 - and a.finish_state = 4  
71 - </if> 52 + <!-- 状态过滤 -->
  53 + <choose>
  54 + <when test="req.finishState == 1">
  55 + AND a.finish_state = 1
  56 + AND a.begin_time <![CDATA[ <= ]]> #{req.localDate}
  57 + AND a.end_time <![CDATA[ >= ]]> #{req.localDate}
  58 + </when>
  59 + <when test="req.finishState == 2">
  60 + AND a.finish_state = 2
  61 + </when>
  62 + <when test="req.finishState == 3">
  63 + AND a.finish_state = 3
  64 + </when>
  65 + <when test="req.finishState == 4">
  66 + AND a.finish_state = 4
  67 + </when>
  68 + </choose>
72 </select> 69 </select>
73 70
74 <select id="appMaintainPlanPlanTypePage" resultType="com.zteits.urbanops.module.garden.controller.app.maintainplan.vo.AppMaintainPlanPagePlanTypeRespVO"> 71 <select id="appMaintainPlanPlanTypePage" resultType="com.zteits.urbanops.module.garden.controller.app.maintainplan.vo.AppMaintainPlanPagePlanTypeRespVO">
@@ -85,9 +82,9 @@ @@ -85,9 +82,9 @@
85 c.begin_time, 82 c.begin_time,
86 c.end_time 83 c.end_time
87 FROM 84 FROM
88 - garden_maintain_plan a,  
89 - garden_maintain_plan_detail c,  
90 - (select distinct batch_no, dept_id 85 + garden_maintain_plan a
  86 + INNER JOIN garden_maintain_plan_detail c ON a.batch_no = c.batch_no
  87 + INNER JOIN (select distinct batch_no, dept_id
91 from garden_maintain_plan_role 88 from garden_maintain_plan_role
92 where deleted = 0 89 where deleted = 0
93 AND dept_id = #{req.deptId} 90 AND dept_id = #{req.deptId}
@@ -97,15 +94,13 @@ @@ -97,15 +94,13 @@
97 #{roleId} 94 #{roleId}
98 </foreach> 95 </foreach>
99 </if> 96 </if>
100 - ) d  
101 - WHERE a.batch_no = c.batch_no  
102 - AND a.batch_no = d.batch_no  
103 - AND a.dept_id = d.dept_id 97 + ) d ON c.batch_no = d.batch_no and c.dept_id = d.dept_id
  98 +
104 AND a.deleted=c.deleted 99 AND a.deleted=c.deleted
105 AND a.deleted=0 100 AND a.deleted=0
106 AND a.plan_type_id = #{req.planTypeId} 101 AND a.plan_type_id = #{req.planTypeId}
107 <if test="req.planName != null and req.planName !=''"> 102 <if test="req.planName != null and req.planName !=''">
108 - AND a.plan_type_id LIKE CONCAT('%',#{req.planName},'%') 103 + AND a.plan_name LIKE CONCAT('%',#{req.planName},'%')
109 </if> 104 </if>
110 <if test="req.busiLineList != null and req.busiLineList.size() > 0"> 105 <if test="req.busiLineList != null and req.busiLineList.size() > 0">
111 AND a.busi_line IN 106 AND a.busi_line IN