Commit e9af2e9f07a78b1971d6a32ef0dcb7a52b59b66f

Authored by 王富生
1 parent a7e6827a

优化

urbanops-module-garden/src/main/resources/mapper/inspectionplan/InspectionPlanMapper.xml
... ... @@ -24,11 +24,12 @@
24 24 a.finish_state,
25 25 a.begin_time,
26 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 33 AND dept_id = #{req.deptId}
33 34 <if test="req.roleIds != null and req.roleIds.size() > 0">
34 35 AND role_id IN
... ... @@ -36,14 +37,11 @@
36 37 #{roleId}
37 38 </foreach>
38 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 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 45 </if>
48 46 <if test="req.busiLineList != null and req.busiLineList.size() > 0">
49 47 AND a.busi_line IN
... ... @@ -51,24 +49,22 @@
51 49 #{busiLine}
52 50 </foreach>
53 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 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 57 </if>
63 58 <if test="req.finishState == 2">
64   - and a.finish_state = 2
  59 + AND a.finish_state = 2
65 60 </if>
66 61 <if test="req.finishState == 3">
67   - and a.finish_state = 3
  62 + AND a.finish_state = 3
68 63 </if>
69 64 <if test="req.finishState == 4">
70   - and a.finish_state = 4
  65 + AND a.finish_state = 4
71 66 </if>
72 67  
  68 +
73 69 </select>
74 70 </mapper>
... ...
urbanops-module-garden/src/main/resources/mapper/maintainplan/MaintainPlanMapper.xml
... ... @@ -25,11 +25,11 @@
25 25 a.begin_time,
26 26 a.end_time
27 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 33 AND dept_id = #{req.deptId}
34 34 <if test="req.roleIds != null and req.roleIds.size() > 0">
35 35 AND role_id IN
... ... @@ -37,38 +37,35 @@
37 37 #{roleId}
38 38 </foreach>
39 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 45 </if>
49   -
50 46 <if test="req.busiLineList != null and req.busiLineList.size() > 0">
51 47 AND a.busi_line IN
52 48 <foreach collection="req.busiLineList" item="busiLine" open="(" separator="," close=")">
53 49 #{busiLine}
54 50 </foreach>
55 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 69 </select>
73 70  
74 71 <select id="appMaintainPlanPlanTypePage" resultType="com.zteits.urbanops.module.garden.controller.app.maintainplan.vo.AppMaintainPlanPagePlanTypeRespVO">
... ... @@ -85,9 +82,9 @@
85 82 c.begin_time,
86 83 c.end_time
87 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 88 from garden_maintain_plan_role
92 89 where deleted = 0
93 90 AND dept_id = #{req.deptId}
... ... @@ -97,15 +94,13 @@
97 94 #{roleId}
98 95 </foreach>
99 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 99 AND a.deleted=c.deleted
105 100 AND a.deleted=0
106 101 AND a.plan_type_id = #{req.planTypeId}
107 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 104 </if>
110 105 <if test="req.busiLineList != null and req.busiLineList.size() > 0">
111 106 AND a.busi_line IN
... ...