qushaowei
2023-08-29 57e1cd3bbf4b9de87019b5ed5ca428810516976a
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?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.EamEquipmentMapper">
 
    <select id="getResumeUseRecordList"  parameterType="Map" resultType="Map">
        SELECT DISTINCT
            t1.id,
            t1.num,
            '设备领借' AS 'type',
            t3.item_text AS businessType,
            t1.create_time AS createTime,
            t1.create_by AS createBy
        FROM
            mom_eam_equipment_unloading t1
        LEFT JOIN mom_eam_equipment_unloading_borrow_detail t2 ON t1.id = t2.equipment_unloading_id
        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'business_type' ) t3 ON t3.item_value = t1.business_type
        where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
 
        UNION All
 
        SELECT DISTINCT
            t1.id,
            t1.num,
            '设备归还' AS 'type',
            t3.item_text AS businessType,
            t1.create_time AS createTime,
            t1.create_by AS createBy
        FROM
            mom_eam_equipment_unloading t1
        LEFT JOIN mom_eam_equipment_unloading_return_detail t2 ON t1.id = t2.equipment_unloading_id
        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'business_type' ) t3 ON t3.item_value = t1.business_type
        where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
 
        UNION All
 
        SELECT DISTINCT
            t1.id,
            t1.num,
            '设备调入' AS 'type',
            '' as  businessType,
            t1.create_time AS createTime,
            t1.create_by AS createBy
        FROM
            mom_eam_equipment_transfer t1
        left join mom_eam_equipment_transfer_in_detail t2 on t1.id = t2.equipment_transfer_id
        where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
 
        UNION All
 
        SELECT DISTINCT
            t1.id,
            t1.num,
            '设备调出' AS 'type',
            '' as  businessType,
            t1.create_time AS createTime,
            t1.create_by AS createBy
        FROM
            mom_eam_equipment_transfer t1
        left join mom_eam_equipment_transfer_out_detail t2 on t1.id = t2.equipment_transfer_id
        where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
 
        UNION All
 
        SELECT DISTINCT
            t1.id,
            t1.num,
            '设备变动' AS 'type',
            '' as  businessType,
            t1.create_time AS createTime,
            t1.create_by AS createBy
        FROM
            mom_eam_equipment_change t1
        left join mom_eam_equipment_change_detail t2 on t1.id = t2.equipment_change_id
        where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
    </select>
 
    <select id="getResumeInspectionRecordList"  parameterType="Map" resultType="Map">
        SELECT DISTINCT
            t1.id,
            '日常点检' as inspectionType,
            t1.num,
            t1.inspection_time as inspectionTime,
            t3.name as teamName,
            t4.realname as inspectionUserName,
            t1.actual_end_time as actualEndTime
        FROM
            mom_eam_inspection_order t1
        LEFT JOIN mom_eam_daily_inspection_standard t2 ON t1.inspection_standard_id = t2.id
        left join mom_base_team t3 on t1.team_id = t3.id
        left join sys_user t4 on t1.inspection_user_id = t4.id
        left join mom_eam_inspection_cycle t5 on t1.inspection_cycle_id = t5.id
        WHERE t1.del_flag = '0' and t2.del_flag= '0'  and t5.del_flag= '0' and t2.equipment_id = #{params.equipmentId}
 
--         UNION All
--
--         SELECT DISTINCT
--             t1.id,
--             '专业点检' as inspectionType,
--             t1.num,
--             t1.inspection_time as inspectionTime,
--             t3.name as teamName,
--             t4.realname as inspectionUserName,
--             t1.plan_end_time as actualEndTime
--         FROM
--             mom_eam_specialty_inspection_order t1
--         LEFT JOIN mom_eam_specialty_inspection_order_detail t2 on t1.id = t2.specialty_inspection_order_id
--         left join sys_user t4 on t1.inspection_user_id = t4.id
--         left join mom_eam_specialty_inspection_plan t5 on t1.specialty_inspection_plan_id = t5.id
--         left join mom_base_team t3 on t5.team_id = t3.id
--         WHERE t1.del_flag = '0' and t2.del_flag= '0'  and t5.del_flag= '0' and t2.equipment_id = #{params.equipmentId}
    </select>
 
    <select id="getResumeMaintenanceRecordList"  parameterType="Map" resultType="Map">
        SELECT DISTINCT
            t1.id,
            '日常保养' as maintenanceType,
            t1.num,
            t4.name as teamName,
            t5.realname as maintenanceuserName,
            t1.actual_start_time as actualStartTime,
            t1.actual_end_time as actualEndTime
        FROM
            mom_eam_daily_maintenance_order t1
        LEFT JOIN mom_eam_daily_maintenance_order_detail t2 ON t1.id = t2.daily_maintenance_order_id
        left join mom_eam_equipment t3 on t1.equipment_id = t3.id
        left join mom_base_team t4 on t3.team_id = t4.id
        left join sys_user t5 on t5.id= t1.maintenance_user_id
        WHERE t1.del_flag = '0' and t2.del_flag= '0'  and t3.del_flag= '0' and t1.equipment_id = #{params.equipmentId}
 
        UNION All
 
        SELECT DISTINCT
            t1.id,
            '专业保养' AS maintenanceType,
            t1.num,
            t4.name as teamName,
            t5.realname as maintenanceuserName,
            t1.actual_start_time as actualStartTime,
            t1.actual_end_time as actualEndTime
        FROM
            mom_eam_specialty_maintenance_order t1
        left join mom_eam_specialty_maintenance_order_detail t2 on t1.id = t2.specialty_maintenance_order_id
        left join mom_eam_equipment t3 on t2.equipment_id = t3.id
        left join mom_base_team t4 on t3.team_id = t4.id
        left join sys_user t5 on t5.id= t1.maintenance_user_id
        WHERE t1.del_flag = '0' and t2.del_flag= '0'  and t3.del_flag= '0' and t2.equipment_id = #{params.equipmentId}
    </select>
 
    <select id="getResumeRepairRecordList"  parameterType="Map" resultType="Map">
        SELECT
            t1.id,
            t1.num,
            t1.fault_description as faultDescription,
            t1.fault_time as faultTime,
            t2.item_text as maintenanceMethodName,
            t3.name as teamName,
            t4.realname as recipientuserName,
            t1.actual_hour as actualHour,
            t1.actual_start_time AS actualStartTime,
            t1.actual_end_time as  actualEndTime
        FROM
            mom_eam_repair_order t1
        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'maintenance_method' ) t2 ON t2.item_value = t1.maintenance_method
        left join mom_base_team t3 on t1.team_id = t3.id
        left join sys_user t4 on t1.recipient_user_id = t4.id
        WHERE t1.del_flag = '0' and t4.del_flag= '0'  and t3.del_flag= '0' and t1.equipment_id = #{params.equipmentId}
    </select>
 
    <select id="getResumeCalibrationRecordList"  parameterType="Map" resultType="Map">
        SELECT
            t1.id,
            t1.num,
            t2.item_text as calibrationTypeName,
            t3.realname as calibrationUserName,
            t1.calibration_time as calibrationTime,
            t1.management_mode as managementMode,
            t1.status
        FROM
            mom_eam_calibration_order t1
        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'calibration_type' ) t2 ON t2.item_value = t1.calibration_type
        left join sys_user t3 on t1.calibration_user_id = t3.id
        WHERE t1.del_flag = '0' and t3.del_flag= '0' and t1.equipment_id = #{params.equipmentId}
    </select>
 
    <select id="getResumeChangeRecordList"  parameterType="Map" resultType="Map">
        SELECT
            t1.id,
            t1.num,
            (case t1.change_method when 'seal' then '设备封存' when 'unseal' then '设备启封' when 'scrap' then '设备报废' else '设备处置' end) as changeMethod,
            t1.create_by as createBy,
            t1.create_time as createTime
        FROM
            mom_eam_equipment_change t1
        LEFT JOIN mom_eam_equipment_seal_detail t2 ON t1.id = t2.equipment_change_id
        LEFT JOIN mom_eam_equipment_disposal_detail t3 ON t1.id = t3.equipment_change_id
        LEFT JOIN mom_eam_equipment_unseal_detail t4 ON t1.id = t4.equipment_change_id
        LEFT JOIN mom_eam_equipment_scrap_detail t5 ON t1.id = t5.equipment_change_id
        where t1.del_flag = '0'  and (t2.equipment_id = #{params.equipmentId} or t3.equipment_id = #{params.equipmentId} or t4.equipment_id = #{params.equipmentId} or t5.equipment_id = #{params.equipmentId})
    </select>
</mapper>