MaintainPlanCommitMapper.xml
4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?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.MaintainPlanCommitMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
<resultMap id="BaseResultMap" type="com.zteits.urbanops.module.garden.controller.app.maintainplan.vo.AppMaintainPlanCommitDetailPageRespVO">
<result property="beginImgList" column="begin_img" typeHandler="com.zteits.urbanops.framework.mybatis.core.type.StringArrayToListTypeHandler"/>
</resultMap>
<resultMap id="BaseResultMapTwo" type="com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.MaintainPlanCommitRespVO">
<result property="beginImgList" column="begin_img" typeHandler="com.zteits.urbanops.framework.mybatis.core.type.StringArrayToListTypeHandler"/>
</resultMap>
<select id="selectForPage" resultMap="BaseResultMapTwo">
SELECT
a.batch_no,
a.plan_no,
b.plan_name,
b.road_id,
b.road_name,
b.level_id,
b.plan_attr,
b.plan_type_id,
b.cycle_id,
b.plan_num,
b.busi_line,
b.plan_finish_num,
a.begin_time,
a.end_time,
a.company_id,
a.dept_id,
c.finish_time,
c.begin_img,
c.user_name,
c.sort_num
FROM
garden_maintain_plan_detail a
INNER JOIN garden_maintain_plan b ON a.batch_no = b.batch_no
INNER JOIN garden_maintain_plan_commit c ON a.batch_no = c.batch_no AND a.plan_no = c.plan_no
WHERE a.deleted = 0
<if test="req.planNo != null and req.planNo !=''">
and a.plan_no LIKE CONCAT('%', #{req.planNo},'%')
</if>
<if test="req.planName != null and req.planName !=''">
and b.plan_name LIKE CONCAT('%', #{req.planName},'%')
</if>
<if test="req.roadName != null and req.roadName !=''">
AND b.road_name LIKE CONCAT('%', #{req.roadName},'%')
</if>
<if test="req.levelId != null">
and b.level_id = #{req.levelId}
</if>
<if test="busiLineList != null and busiLineList.size() > 0">
AND b.busi_line IN
<foreach collection="busiLineList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="req.planTypeId != null">
and b.plan_type_id = #{req.planTypeId}
</if>
<if test="req.planAttr != null">
and b.plan_attr = #{req.planAttr}
</if>
<if test="req.companyId != null">
and a.company_id = #{req.companyId}
</if>
<if test="req.deptId != null">
and a.dept_id = #{req.deptId}
</if>
<if test="req.userName != null and req.userName !=''">
AND c.user_name LIKE CONCAT('%', #{req.userName},'%')
</if>
<if test="req.finishTime != null">
AND DATE_FORMAT(c.finish_time, '%Y-%m-%d') = #{req.finishTime}
</if>
<if test="req.createTimeStart != null">
<![CDATA[AND DATE_FORMAT(a.create_time, '%Y-%m-%d') >= #{req.createTimeStart}]]>
</if>
<if test="req.createTimeEnd != null">
<![CDATA[AND DATE_FORMAT(a.create_time, '%Y-%m-%d') <= #{req.createTimeEnd}]]>
</if>
<if test="req.deptIds != null and !req.deptIds.isEmpty()">
and b.dept_id in
<foreach collection="req.deptIds" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
</if>
order by c.id desc
</select>
<select id="appMaintainPlanCommitDetailPage" resultMap="BaseResultMap">
SELECT
a.batch_no,
a.plan_no,
b.plan_name,
b.road_id,
b.road_name,
b.level_id,
b.plan_attr,
b.plan_type_id,
b.cycle_id,
a.plan_num,
b.busi_line,
a.plan_finish_num,
b.rate,
a.begin_time,
a.end_time,
a.company_id,
a.finish_state,
a.dept_id,
c.begin_img,
c.img_host,
c.finish_time,
c.user_name,
c.remark
FROM
garden_maintain_plan_detail a
INNER JOIN garden_maintain_plan b ON a.batch_no = b.batch_no
INNER JOIN garden_maintain_plan_commit c ON a.batch_no = c.batch_no AND a.plan_no = c.plan_no
WHERE a.plan_no = #{req.planNo}
ORDER BY c.id DESC
</select>
</mapper>