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
<?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.qianwen.smartman.modules.tpm.mapper.MaintainPlanItemMapper">
    <!-- 根据计划Id查询计划下保养项 -->
    <select id="getMaintainPlanItemListByPlanId" resultType="com.qianwen.smartman.modules.tpm.vo.MaintainPlanItemVO">
        SELECT
        pi.id AS id,
        pi.plan_id AS planId,
        pi.item_id AS itemId,
        item.code AS itemCode,
        item.name AS itemName,
        item.requirement AS itemRequirement,
        item.remark AS itemRemark
        FROM
        blade_maintain_plan_item pi
        INNER JOIN blade_maintain_item item ON pi.item_id = item.id
        <where>
            <if test="planId != null">
                AND pi.plan_id = #{planId}
            </if>
            AND pi.is_deleted = 0
            AND item.is_deleted = 0
            <if test="tenantId != null and tenantId != ''">
                AND pi.tenant_id = #{tenantId}
            </if>
        </where>
        ORDER BY
        item.code ASC
    </select>
 
    <!-- 根据计划Id查询计划下保养项(分页) -->
    <select id="queryMaintainPlanItemListPage" resultType="com.qianwen.smartman.modules.tpm.vo.MaintainPlanItemVO">
        SELECT
        pi.id AS id,
        pi.plan_id AS planId,
        pi.item_id AS itemId,
        item.code AS itemCode,
        item.name AS itemName,
        item.requirement AS itemRequirement,
        item.remark AS itemRemark
        FROM
        blade_maintain_plan_item pi
        INNER JOIN blade_maintain_item item ON pi.item_id = item.id
        <where>
            <if test="planId != null">
                AND pi.plan_id = #{planId}
            </if>
            AND pi.is_deleted = 0
            AND item.is_deleted = 0
            <if test="tenantId != null and tenantId != ''">
                AND pi.tenant_id = #{tenantId}
            </if>
        </where>
        ORDER BY
        item.code ASC
    </select>
</mapper>