无关风月
2 天以前 60afc1c228318d136a273cd0b389217f87583277
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
<?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.ruoyi.system.mapper.AssetRepairRecordMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.system.model.AssetRepairRecord">
        <id column="id" property="id" />
        <result column="repair_request_id" property="repairRequestId" />
        <result column="repair_no" property="repairNo" />
        <result column="title" property="title" />
        <result column="repair_time" property="repairTime" />
        <result column="repair_by" property="repairBy" />
        <result column="asset_type_id" property="assetTypeId" />
        <result column="repair_remarks" property="repairRemarks" />
        <result column="attachment_urls" property="attachmentUrls" />
        <result column="repair_status" property="repairStatus" />
        <result column="total_fee" property="totalFee" />
        <result column="create_time" property="createTime" />
        <result column="create_by" property="createBy" />
        <result column="update_time" property="updateTime" />
        <result column="update_by" property="updateBy" />
        <result column="disabled" property="disabled" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, repair_request_id, repair_no, title, repair_time, repair_by, asset_type_id, repair_remarks, attachment_urls, repair_status, total_fee, create_time, create_by, update_time, update_by, disabled
    </sql>
    <select id="pageList" resultType="com.ruoyi.system.vo.AssetRepairRequestVO">
        select t1.*,t2.asset_main_id as assetMainId,t3.nick_name as reporterName from asset_repair_request t1
        left join asset_repair_request_item t2 on t1.id = t2.repair_request_id
                                                    left join sys_user t3 on t1.reporter_id = t3.user_id
        where 1=1
        <if test="query.numberOrTitle != null and query.numberOrTitle != ''">
            AND (t1.repair_no like concat('%', #{query.numberOrTitle}, '%') or t1.title like concat('%', #{query.numberOrTitle}, '%'))
        </if>
          <if test="query.userIds != null and query.userIds.size() > 0">
            AND t1.reporter_id IN
            <foreach item="item" index="index" collection="query.userIds" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        AND t1.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        order by t1.repair_status, t1.urgency_level asc
    </select>
 
    <!-- 分页查询维修记录列表 -->
    <select id="getRepairRecordPageList" resultType="com.ruoyi.system.vo.asset.AssetRepairRecordPageVO">
        SELECT
            arr.repair_no AS repairNo,
            arr.title,
            pt.type_name AS assetTypeFirstLevel,
            ct.type_name AS assetTypeSecondLevel,
            u.nick_name AS reporterName,
            arr.total_fee AS totalFee,
            arr.repair_time AS repairTime,
            arr.repair_status AS repairStatus
        FROM asset_repair_record arr
        LEFT JOIN asset_repair_request req ON arr.repair_request_id = req.id
        LEFT JOIN sys_user u ON req.reporter_id = u.user_id
        LEFT JOIN asset_type ct ON arr.asset_type_id = ct.id
        LEFT JOIN asset_type pt ON ct.parent_id = pt.id
        LEFT JOIN t_dept d ON u.dept_id = d.id
        WHERE arr.disabled = 0
        <if test="query.keyword != null and query.keyword != ''">
            AND (arr.repair_no LIKE CONCAT('%', #{query.keyword}, '%')
                 OR arr.title LIKE CONCAT('%', #{query.keyword}, '%'))
        </if>
        <if test="query.deptId != null">
            AND (d.id = #{query.deptId} OR FIND_IN_SET(#{query.deptId}, d.parent_id))
        </if>
        ORDER BY arr.create_time DESC
    </select>
    <select id="listAll" resultType="com.ruoyi.system.vo.AssetRepairRequestVO">
        select t1.*,t2.asset_main_id as assetMainId from asset_repair_request t1
        left join asset_repair_request_item t2 on t1.id = t2.repair_request_id
        where 1=1
        <if test="query.numberOrTitle != null and query.numberOrTitle != ''">
            AND (t1.repair_no like concat('%', #{query.numberOrTitle}, '%') or t1.title like concat('%', #{query.numberOrTitle}, '%'))
        </if>
        <if test="query.assetMainIds != null and query.assetMainIds.size() > 0">
            AND t2.asset_main_id IN
            <foreach item="item" index="index" collection="query.assetMainIds" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="query.userIds != null and query.userIds.size() > 0">
            AND t1.reporter_id IN
            <foreach item="item" index="index" collection="query.userIds" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        AND t1.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        order by t1.repair_status, t1.urgency_level asc
    </select>
 
    <!-- 查询维修记录关联的资产列表 -->
    <select id="getRepairAssetList" resultType="com.ruoyi.system.vo.asset.AssetRepairRecordAssetVO">
        SELECT
            am.id,
            am.asset_code,
            am.asset_name,
            dept.dept_name,
            parent_type.type_name AS parentAssetType,
            current_type.type_name AS assetType,
            am.asset_status,
            arri.repair_finish_time,
            arri.repair_fee,
            arri.status
        FROM asset_repair_record_item arri
        LEFT JOIN asset_main am ON arri.asset_main_id = am.id
        LEFT JOIN asset_type current_type ON am.asset_type_id = current_type.id
        LEFT JOIN asset_type parent_type ON current_type.parent_id = parent_type.id
        LEFT JOIN t_dept dept ON am.use_dept_id = dept.dept_id
        LEFT JOIN asset_repair_record arr ON arri.repair_record_id = arr.id
        WHERE arri.repair_record_id = #{repairRecordId}
          AND am.disabled = 0
        ORDER BY am.asset_code
    </select>
 
</mapper>