InspectionPlanMapper.xml
2.92 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
<?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.inspectionplan.InspectionPlanMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
<delete id="deleteByBatchNo">
delete from garden_inspection_plan where batch_no =#{batchNo}
</delete>
<select id="getInspectionPlanAppPage" resultType="com.zteits.urbanops.module.garden.controller.app.inspectionplan.vo.AppInspectionPlanRespVO">
SELECT
b.batch_no,
b.plan_no,
a.road_id,
a.road_name,
a.busi_line,
a.plan_type_id,
a.level_id,
a.finish_state,
a.begin_time,
a.end_time
FROM
garden_inspection_plan_detail b
INNER JOIN garden_inspection_plan a ON a.batch_no = b.batch_no
INNER JOIN (SELECT DISTINCT batch_no
FROM garden_inspection_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>
) c ON b.batch_no = c.batch_no
WHERE
a.deleted = 0
<if test="req.roadName != null and req.roadName !=''">
AND a.road_name LIKE CONCAT('%', #{req.roadName}, '%')
</if>
<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>
<!-- 状态过滤 -->
<if test="req.finishState == 1">
AND b.finish_state = 1
<![CDATA[AND b.begin_time <= #{req.localDateTime}
AND b.end_time >= #{req.localDateTime}]]>
</if>
<if test="req.finishState == 2">
AND b.finish_state = 2
</if>
<if test="req.finishState == 3">
AND b.finish_state = 3
<![CDATA[AND b.begin_time <= #{req.localDateTime}
AND b.end_time >= #{req.localDateTime}]]>
</if>
<if test="req.finishState == 4">
AND b.finish_state = 4
<![CDATA[AND b.begin_time <= #{req.localDateTime}
AND b.end_time >= #{req.localDateTime}]]>
</if>
ORDER BY b.id desc
</select>
</mapper>