Blame view

urbanops-module-garden/src/main/resources/mapper/maintainplan/MaintainPlanMapper.xml 5.23 KB
669cf0a6   王富生   养护假话提交
1
2
3
4
5
6
7
8
9
10
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  <mapper namespace="com.zteits.urbanops.module.garden.dal.mysql.maintainplan.MaintainPlanMapper">
  
      <!--
          一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
          无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
          代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
          文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
       -->
04ee424b   王富生   养护计划提交
11
12
13
      <delete id="deleteByBatchNo">
          delete from garden_maintain_plan where batch_no =#{batchNo}
      </delete>
95d30924   王富生   app养护计划明细提交
14
15
16
17
  
  
      <select id="appMaintainPlanRoadPage" resultType="com.zteits.urbanops.module.garden.controller.app.maintainplan.vo.AppMaintainPlanPageRoadRespVO">
          SELECT
5ee13661   王富生   按照道路添加批次号
18
          b.batch_no,
95d30924   王富生   app养护计划明细提交
19
20
          a.road_id,
          a.road_name,
e31696ea   王彪总   refactor(maintain...
21
          a.level_id
95d30924   王富生   app养护计划明细提交
22
          FROM
f40903df   王富生   优化
23
          garden_maintain_plan_detail b
9a768976   王富生   优化
24
          INNER JOIN garden_maintain_plan a ON b.batch_no = a.batch_no and a.deleted = b.deleted
e9af2e9f   王富生   优化
25
26
27
28
          INNER JOIN (
          SELECT DISTINCT batch_no
          FROM garden_maintain_plan_role
          WHERE deleted = 0
579de493   王富生   优化
29
30
31
32
33
34
35
          AND dept_id = #{req.deptId}
          <if test="req.roleIds != null and req.roleIds.size() > 0">
              AND role_id IN
              <foreach collection="req.roleIds" item="roleId" open="(" separator="," close=")">
                  #{roleId}
              </foreach>
          </if>
9a768976   王富生   优化
36
          ) c ON b.batch_no = c.batch_no
e9af2e9f   王富生   优化
37
38
39
40
          WHERE
          a.deleted = 0
          <if test="req.roadName != null and req.roadName != ''">
              AND a.road_name LIKE CONCAT('%', #{req.roadName}, '%')
95d30924   王富生   app养护计划明细提交
41
          </if>
95d30924   王富生   app养护计划明细提交
42
43
44
45
46
47
          <if test="req.busiLineList != null and req.busiLineList.size() > 0">
              AND a.busi_line IN
              <foreach collection="req.busiLineList" item="busiLine" open="(" separator="," close=")">
                  #{busiLine}
              </foreach>
          </if>
e9af2e9f   王富生   优化
48
49
50
          <!-- 状态过滤 -->
          <choose>
              <when test="req.finishState == 1">
e1babab1   王富生   养护按照道路-修复状态不一致问题(...
51
                  AND a.finish_state = 1
9a768976   王富生   优化
52
53
                  <![CDATA[AND b.begin_time  <=  #{req.localDateTime}
                  AND b.end_time  >= #{req.localDateTime}]]>
e9af2e9f   王富生   优化
54
55
              </when>
              <when test="req.finishState == 2">
e1babab1   王富生   养护按照道路-修复状态不一致问题(...
56
                  AND a.finish_state = 2
a5805f70   王富生   优化
57
  
e9af2e9f   王富生   优化
58
59
              </when>
              <when test="req.finishState == 3">
e1babab1   王富生   养护按照道路-修复状态不一致问题(...
60
                  AND a.finish_state = 3
a5805f70   王富生   优化
61
62
                  <![CDATA[AND b.begin_time  <=  #{req.localDateTime}
                  AND b.end_time  >= #{req.localDateTime}]]>
e9af2e9f   王富生   优化
63
64
              </when>
              <when test="req.finishState == 4">
e1babab1   王富生   养护按照道路-修复状态不一致问题(...
65
                  AND a.finish_state = 4
dd1c75c7   王富生   优化
66
67
                  <![CDATA[AND b.begin_time  <=  #{req.localDateTime}
                  AND b.end_time  >= #{req.localDateTime}]]>
e9af2e9f   王富生   优化
68
69
              </when>
          </choose>
5ee13661   王富生   按照道路添加批次号
70
          GROUP BY a.road_id, a.road_name, a.level_id,b.batch_no,
95d30924   王富生   app养护计划明细提交
71
72
73
74
      </select>
  
      <select id="appMaintainPlanPlanTypePage" resultType="com.zteits.urbanops.module.garden.controller.app.maintainplan.vo.AppMaintainPlanPagePlanTypeRespVO">
          SELECT
5b76d9ce   王富生   优化
75
76
77
78
79
80
81
82
83
84
85
          c.batch_no,
          c.plan_no,
          a.plan_name,
          a.plan_type_id,
          a.rate,
          a.cycle_id,
          c.plan_num,
          c.plan_finish_num,
          c.finish_state,
          c.begin_time,
          c.end_time
95d30924   王富生   app养护计划明细提交
86
          FROM
e9af2e9f   王富生   优化
87
88
89
          garden_maintain_plan a
          INNER JOIN  garden_maintain_plan_detail c ON a.batch_no = c.batch_no
          INNER JOIN (select distinct batch_no, dept_id
579de493   王富生   优化
90
91
92
93
94
95
96
97
98
          from garden_maintain_plan_role
          where deleted = 0
          AND dept_id = #{req.deptId}
          <if test="req.roleIds != null and req.roleIds.size() > 0">
              AND role_id IN
              <foreach collection="req.roleIds" item="roleId" open="(" separator="," close=")">
                  #{roleId}
              </foreach>
          </if>
e9af2e9f   王富生   优化
99
          )   d ON c.batch_no = d.batch_no and c.dept_id = d.dept_id
5b76d9ce   王富生   优化
100
          AND a.deleted=0
5b76d9ce   王富生   优化
101
          AND a.plan_type_id = #{req.planTypeId}
95d30924   王富生   app养护计划明细提交
102
          <if test="req.planName != null and req.planName !=''">
e9af2e9f   王富生   优化
103
              AND a.plan_name LIKE CONCAT('%',#{req.planName},'%')
95d30924   王富生   app养护计划明细提交
104
          </if>
95d30924   王富生   app养护计划明细提交
105
106
107
108
109
110
          <if test="req.busiLineList != null and req.busiLineList.size() > 0">
              AND a.busi_line IN
              <foreach collection="req.busiLineList" item="busiLine" open="(" separator="," close=")">
                  #{busiLine}
              </foreach>
          </if>
a5cfb23d   王彪总   临时提交
111
          <!--状态 1:未完成;2:已完成;3:已失效-->
db97d633   王富生   修复不打印完成的-按照类型
112
          -- and c.finish_state =a.finish_state
a7e6827a   王富生   优化
113
          <if test="req.finishState == 1">
db97d633   王富生   修复不打印完成的-按照类型
114
              and c.finish_state = 1
a7e6827a   王富生   优化
115
116
117
118
              <![CDATA[and c.begin_time <= #{req.localDateTime}
                       and c.end_time >= #{req.localDateTime}]]>
          </if>
          <if test="req.finishState == 2">
db97d633   王富生   修复不打印完成的-按照类型
119
              and c.finish_state = 2
a7e6827a   王富生   优化
120
121
          </if>
          <if test="req.finishState == 3">
db97d633   王富生   修复不打印完成的-按照类型
122
              and c.finish_state = 3
a5805f70   王富生   优化
123
124
              <![CDATA[and c.begin_time <= #{req.localDateTime}
                       and c.end_time >= #{req.localDateTime}]]>
a7e6827a   王富生   优化
125
126
          </if>
          <if test="req.finishState == 4">
db97d633   王富生   修复不打印完成的-按照类型
127
              and c.finish_state = 4
dd1c75c7   王富生   优化
128
129
              <![CDATA[and c.begin_time <= #{req.localDateTime}
                       and c.end_time >= #{req.localDateTime}]]>
a7e6827a   王富生   优化
130
          </if>
4c567386   王富生   优化
131
          ORDER BY a.id desc
95d30924   王富生   app养护计划明细提交
132
133
      </select>
  
3fdad562   王彪总   feat(garden): 添加计...
134
  </mapper>