zhangherong
2025-05-09 a092e089316c05c6f7732d779e8fdff6060592c0
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
<?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="org.jeecg.modules.eam.mapper.EamReportRepairMapper">
 
    <select id="pageList" resultType="org.jeecg.modules.eam.entity.EamReportRepair">
        SELECT
            t1.*,
            t2.equipment_name
        FROM
            eam_report_repair t1
                LEFT JOIN eam_equipment t2 ON t1.equipment_id = t2.id
        <where>
            <choose>
                <when test="equipmentIds != null and equipmentIds.size() > 0 ">
                    AND t2.equipment_code IN
                    <foreach collection="equipmentIds" item="equipmentId" index="index" open="(" close=")" separator=",">
                        #{equipmentId}
                    </foreach>
                </when>
                <otherwise>
                    EXISTS ( SELECT 1 FROM mdc_user_production t3 WHERE t3.user_id = #{userId} AND t3.pro_id= t2.org_id )
                </otherwise>
            </choose>
            <if test="eamReportRepair.equipmentId != null and eamReportRepair.equipmentId != ''">
                AND t2.id = #{ eamReportRepair.equipmentId }
            </if>
            <if test="eamReportRepair.equipmentCode != null and eamReportRepair.equipmentCode != ''">
                AND t2.equipment_code LIKE CONCAT(CONCAT('%',#{ eamReportRepair.equipmentCode }),'%')
            </if>
            <if test="eamReportRepair.equipmentName != null and eamReportRepair.equipmentName != ''">
                AND t2.equipment_name = LIKE CONCAT(CONCAT('%',#{ eamReportRepair.equipmentName }),'%')
            </if>
            <if test="eamReportRepair.breakdownFlag != null and eamReportRepair.breakdownFlag != ''">
                AND t1.breakdown_flag = #{ eamReportRepair.breakdownFlag }
            </if>
            <if test="eamReportRepair.faultType != null and eamReportRepair.faultType != ''">
                AND t1.fault_type = #{ eamReportRepair.faultType }
            </if>
            <if test="eamReportRepair.reportStatus != null and eamReportRepair.reportStatus != ''">
                AND t1.report_status = #{ eamReportRepair.reportStatus }
            </if>
            <if test="eamReportRepair.faultName != null and eamReportRepair.faultName != ''">
                AND t1.fault_name = #{ eamReportRepair.faultName }
            </if>
            <if test="eamReportRepair.startTime != null and eamReportRepair.startTime != '' and eamReportRepair.endTime != null and eamReportRepair.endTime != ''">
                AND t1.fault_start_time BETWEEN #{ eamReportRepair.startTime } AND #{ eamReportRepair.endTime }
            </if>
        </where>
        ORDER BY t1.create_time DESC
    </select>
 
    <select id="equipmentRepairStatistics" resultType="org.jeecg.modules.eam.vo.EquipmentRepairStatistics">
        select FORMAT(err.create_time, 'yyyy-MM') as monthStr,
               COUNT(1) as reportNumber,
               SUM(CASE WHEN err.report_status = 'COMPLETE' THEN 1 ELSE 0 END) as repairedNumber
        from eam_report_repair err
        inner join eam_equipment e
        on err.equipment_id = e.id
        where err.report_status != 'ABOLISH' and err.del_flag = 0 and e.del_flag = 0
        <if test="productionIds != null">
            AND e.org_id IN
            <foreach collection="productionIds" item="productionId" index="index" open="(" close=")" separator=",">
                #{productionId}
            </foreach>
        </if>
        and err.create_time &gt;= #{start}
        and err.create_time &lt; #{end}
        group by FORMAT(err.create_time, 'yyyy-MM')
    </select>
    <select id="repairStatusStatistics" resultType="org.jeecg.modules.eam.vo.EquipmentRepairStatusStatistics">
        SELECT
            SUM(CASE WHEN t.report_status='WAIT_REPAIR' THEN 1 ELSE 0 END) AS waitRepair,
            SUM(CASE WHEN t.report_status='UNDER_REPAIR' THEN 1 ELSE 0 END) AS underRepair,
            SUM(CASE WHEN t.report_status='WAIT_SPARES' THEN 1 ELSE 0 END) AS waitSpares,
            SUM(CASE WHEN t.report_status='WAIT_CONFIRM' THEN 1 ELSE 0 END) AS waitConfirm
        from eam_report_repair t
        where t.report_status not in ('ABOLISH', 'COMPLETE') and t.del_flag = 0
    </select>
 
    <select id="repairList" resultType="org.jeecg.modules.eam.vo.EquipmentRepairListVO">
        select e.equipment_code,
               e.equipment_name,
               e.org_id,
               e.installation_position,
               err.create_by as reportOperator,
               err.fault_start_time,
               ero.repairer as repairOperator,
               ero.actual_start_time as repairStartTime,
               err.report_status
        from eam_report_repair err
                 left join eam_equipment e
                           on err.equipment_id = e.id
                 left join eam_repair_order ero
                           on ero.report_id = err.id
        where err.report_status not in ('ABOLISH', 'COMPLETE')
          and err.del_flag = 0
        order by e.org_id, err.fault_start_time
    </select>
</mapper>