qushaowei
2025-06-13 4b27dd367eae2f24958c6bb857fb6959dcdb7a4a
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
<?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.RepairOrderMapper">
    <select id="getRepairOrderList" resultType="org.jeecg.modules.eam.entity.RepairOrder">
        select
        t1.id id,
        t1.status status,
        t1.num num,
        t1.equipment_id equipmentId,
        t1.team_id teamId,
        t1.recipient_user_id recipientUserId,
        t1.report_repair_id reportRepairId,
        t1.project_maintenance_order_id projectMaintenanceOrderId,
        t1.fault_reason faultReason,
        t1.fault_phenomenon faultPhenomenon,
        t1.preventive_measure preventiveMeasure,
        t1.fault_remove faultRemove,
        t1.fault_description faultDescription,
        t1.photo photo,
        t1.is_stop isStop,
        t1.maintenance_method maintenanceMethod,
        t1.working_hour_quota workingHourQuota,
        t1.create_by createBy,
        t1.create_time createTime,
        t1.plan_start_time planStartTime,
        t1.plan_end_time planEndTime,
        t1.actual_start_time actualStartTime,
        t1.actual_end_time actualEndTime,
        t1.report_user_id reportUserId,
        t1.depart_id departId,
        t1.dispatch_method dispatchMethod,
        t1.urgency urgency,
        t1.business_type businessType,
        t1.responsibility_id responsibilityId,
        t1.outsourcing_unit outsourcingUnit,
        t1.actual_hour actualHour,
        t1.remark,
        t1.repair_order_uda1 repairOrderUda1,
        t1.repair_order_uda2 repairOrderUda2,
        t1.repair_order_uda3 repairOrderUda3,
        t1.repair_order_uda4 repairOrderUda4,
        t1.repair_order_uda5 repairOrderUda5,
        t1.spare_time spareTime,
        t1.part_time partTime,
        report.err_uda2 errUda2,
        report.accept_time acceptTime,
        report.err_uda3 errUda3,
        report.fault_hour faultHour,
        report.fault_time faultTime,
        t2.num equipmentNum,
        t2.name equipmentName,
        t2.model equipmentModel,
        t2.specific_equipment specificEquipment,
        t2.equipment_importance_id equipmentImportanceId,
        t3.depart_name departName,
        t4.name outsourcingUnitName,
        t5.realname responsibilityName,
        t6.name teamName
        from mom_eam_repair_order t1
        left join(select * from mom_eam_equipment_report_repair where del_flag = 0 ) report on report.id = t1.report_repair_id
        left join(select * from mom_eam_equipment where del_flag = 0 and status = 1) t2 on t1.equipment_id= t2.id
        left join sys_depart t3 on t3.id = t1.depart_id
        left join mom_base_supplier t4 on t1.outsourcing_unit = t4.id
        left join sys_user t5 on t5.id = t1.responsibility_id
        left join mom_base_team t6 on t6.id=t1.team_id
        left join mom_eam_repair_order_fault_analysis t7 on t7.repair_order_id=t1.id
        where t1.del_flag = 0
        <if test="id != null and id != ''">
            and t1.id = #{id}
        </if>
        <if test="num != null and num != ''">
            and t1.num like concat('%',#{num},'%')
        </if>
        <if test="equipNums.size!=0">
            and t2.num in
            <foreach collection="equipNums" open="(" separator="," close=")" item="num">
                #{num}
            </foreach>
        </if>
        <if test="equipmentNum != null and equipmentNum != ''">
            and t2.num like concat('%',#{equipmentNum},'%')
        </if>
        <if test="equipmentName != null and equipmentName != ''">
            and t2.name like concat('%',#{equipmentName},'%')
        </if>
        <if test="status != null and status != ''">
            and t1.status = #{status}
        </if>
        <if test="repairOrderUda1 != null and repairOrderUda1 != ''">
            and t1.repair_order_uda1 = #{repairOrderUda1}
        </if>
        <if test="equipmentCategoryId != null and equipmentCategoryId != ''">
            and t2.equipment_category_id = #{equipmentCategoryId}
        </if>
        <if test="factoryModelId != null and factoryModelId != ''">
            and t2.factory_model_id = #{factoryModelId}
        </if>
        <if test="specificEquipment != null and specificEquipment != ''">
            and t2.specific_equipment = #{specificEquipment}
        </if>
        <if test="equipmentImportanceId != null and  equipmentImportanceId != ''">
            and t2.equipment_importance_id = #{equipmentImportanceId}
        </if>
        <if test="faultCause != null and  faultCause != ''">
            and t7.repair_order_fault_analysis_uda2 = #{faultCause}
        </if>
        <if test="teamId != null and teamId != ''">
            and t1.team_id = #{teamId}
        </if>
        <if test="repairOrderType != null and repairOrderType != ''">
            and t1.repair_order_type = #{repairOrderType}
        </if>
        <if test="faultStartTime != null">
            and report.fault_time &gt;= #{faultStartTime}
        </if>
        <if test="faultEndTime != null">
            and report.fault_time &lt;= #{faultEndTime}
        </if>
        <if test="createStartTime != null">
            and t1.create_time &gt;= #{createStartTime}
        </if>
        <if test="createEndTime != null">
            and t1.create_time &lt;= #{createEndTime}
        </if>
 
        <if test="workCenterIds != null">
            and t2.work_center_id in
            <foreach collection="workCenterIds" open="(" separator="," close=")" item="workCenterId">
                #{workCenterId}
            </foreach>
        </if>
        <if test="equipmentId != null">
            and t1.equipment_id = #{equipmentId}
        </if>
        <if test="statusEnums != null">
            and t1.status not in
            <foreach collection="statusEnums" open="(" separator="," close=")" item="statusEnum">
                #{statusEnum}
            </foreach>
        </if>
        order by t1.create_time desc
    </select>
 
 
    <select id="getUserTeam" resultType="org.jeecg.modules.eam.vo.UsetTeamVo">
        select
        t1.realname as realName,
        t1.id,
        t1.username as userCode
--         t3.name as teamName,
--         t3.id as teamId
        FROM sys_user t1
--         LEFT JOIN mom_base_team_class t2 on t2.id =t1.team_class_id
--         LEFT JOIN mom_base_team t3 on t3.id =t2.team_id
        where t1.realname IS NOT NULL
        <if test="realname != null and realname != ''">
            and t1.realname like concat('%',#{realname},'%')
        </if>
        order by t1.create_time desc
    </select>
 
 
    <select id="getMaterialSpareList" resultType="org.jeecg.modules.eam.vo.SparePartListVo">
 
        select
        t1.id,
        t1.spare_part_id as sparePartId,
        ISNULL(t1.use_quantity,0) as useQuantity,
        t2.num,
        t2.id as outboundOrderId,
        ISNULL(t1.outbound_main_quantity,0) as mainQuantity,
        (ISNULL(t1.outbound_main_quantity,0)-ISNULL(t1.use_quantity,0)) as availableQuantity,
        t3.num as spareNum,
        t3.name as  spareName,
        t3.model,
        t3.specification,
        t4.name as constructorName,
        t4.id as  constructorId,
        t5.name as mainUnitName,
        t5.id as mainUnitId
        FROM   mom_eam_spare_part_outbound_detail  t1
        LEFT JOIN  mom_eam_spare_part_outbound t2 on t2.id = t1.spare_part_outbound_id
        LEFT JOIN  mom_eam_spare_part   t3  on  t3.id =t1.spare_part_id
        LEFT JOIN  mom_base_constructor   t4  on  t4.id =t3.constructor_id
        LEFT JOIN  mom_base_unit   t5  on  t5.id =t1.main_unit_id
        where t1.del_flag = 0 and t3.del_flag = 0 and t1.outbound_main_quantity != 0 and  (ISNULL(t1.outbound_main_quantity,0)-ISNULL(t1.use_quantity,0)) != 0
        <if test="status != null and status != ''">
            and t1.status = #{status}
        </if>
        <if test="num != null and num != ''">
            and t2.num like concat('%',#{num},'%')
        </if>
        order by t1.create_time desc
 
 
    </select>
 
    <select id="getAllFaultCause"  parameterType="Map" resultType="Map">
        SELECT
            t1.repair_order_fault_analysis_uda2,
            COUNT ( t1.repair_order_fault_analysis_uda2 ) AS total,
            t2.item_text AS faultCause
        FROM
        ( SELECT * FROM v_sys_dict WHERE dict_code = 'repair_order_fault_cause' ) t2
        LEFT JOIN mom_eam_repair_order_fault_analysis t1 ON t1.repair_order_fault_analysis_uda2 = t2.item_value
        WHERE
            del_flag = '0'
        GROUP BY
            t1.repair_order_fault_analysis_uda2,
            t2.item_text
 
    </select>
 
    <select id="getFaultCause"  parameterType="Map" resultType="Map">
        SELECT
            t3.item_text  as  faultCause,
            count(t4.repair_order_fault_analysis_uda2) as total
        FROM
                ( SELECT * FROM v_sys_dict WHERE dict_code = 'repair_order_fault_cause' ) t3
                    LEFT JOIN (
                SELECT
                    t1.repair_order_fault_analysis_uda2
                FROM
                    mom_eam_repair_order_fault_analysis t1
                        LEFT JOIN mom_eam_repair_order t2 ON t1.repair_order_id = t2.id
                WHERE
                    t1.del_flag = 0
                  AND t2.del_flag = 0
                  AND t2.equipment_id = #{equipmentId}
            ) t4 ON t3.item_value = t4.repair_order_fault_analysis_uda2
        group by t3.item_text
    </select>
 
    <select id="getFaultCausePie"  parameterType="Map" resultType="Map">
        SELECT
            t3.item_text  as  x,
            count(t4.repair_order_fault_analysis_uda2) as y
        FROM
                ( SELECT * FROM v_sys_dict WHERE dict_code = 'repair_order_fault_cause' ) t3
                    LEFT JOIN (
                SELECT
                    t1.repair_order_fault_analysis_uda2
                FROM
                    mom_eam_repair_order_fault_analysis t1
                    LEFT JOIN mom_eam_repair_order t2 ON t1.repair_order_id = t2.id
                    left join mom_eam_equipment t11 on t2.equipment_id = t11.id
                WHERE
                    t1.del_flag = 0
                  AND t2.del_flag = 0
                 <if test="params.equipmentNum != null and params.equipmentNum != ''">
                     and t11.num like concat('%',#{params.equipmentNum},'%')
                 </if>
                <if test="params.useId != null and params.useId != ''">
                    and t11.use_id = #{params.useId}
                </if>
                <if test="params.faultStartTime != null">
                    and t2.create_time &gt;= #{params.faultStartTime}
                </if>
                <if test="params.faultEndTime != null">
                    and t2.create_time &lt;= #{params.faultEndTime}
                </if>
            ) t4 ON t3.item_value = t4.repair_order_fault_analysis_uda2
        group by t3.item_text
    </select>
 
    <select id="getFaultCauseBar"  parameterType="Map" resultType="Map">
        SELECT
            t3.item_text  as  item,
            count(t4.repair_order_fault_analysis_uda2) as count
        FROM
            ( SELECT * FROM v_sys_dict WHERE dict_code = 'repair_order_fault_cause' ) t3
            LEFT JOIN (
                SELECT
                 t1.repair_order_fault_analysis_uda2
                 FROM
                mom_eam_repair_order_fault_analysis t1
                    LEFT JOIN mom_eam_repair_order t2 ON t1.repair_order_id = t2.id
                    left join mom_eam_equipment t11 on t2.equipment_id = t11.id
                WHERE
                t1.del_flag = 0
                AND t2.del_flag = 0
            <if test="params.equipmentNum != null and params.equipmentNum != ''">
                and t11.num like concat('%',#{params.equipmentNum},'%')
            </if>
            <if test="params.useId != null and params.useId != ''">
                and t11.use_id = #{params.useId}
            </if>
            <if test="params.faultStartTime != null">
                and t2.create_time &gt;= #{params.faultStartTime}
            </if>
            <if test="params.faultEndTime != null">
                and t2.create_time &lt;= #{params.faultEndTime}
            </if>
        ) t4 ON t3.item_value = t4.repair_order_fault_analysis_uda2
        group by t3.item_text
    </select>
 
    <select id="getEquipmentFaultCause"  parameterType="Map" resultType="Map">
        select count(SUBSTRING(CONVERT(VARCHAR(10), t1.fault_time, 120), 1, 10)) as '设备故障次数',
        SUBSTRING(CONVERT(VARCHAR(10), t1.fault_time, 120), 1, 10) as type from mom_eam_equipment_report_repair t1
        left join mom_eam_equipment t2 on t1.equipment_id = t2.id
        where 1=1
        <if test="params.equipmentNum != null and params.equipmentNum != ''">
            and t2.num like concat('%',#{params.equipmentNum},'%')
        </if>
        <if test="params.useId != null and params.useId != ''">
            and t2.use_id = #{params.useId}
        </if>
        <if test="params.faultStartTime != null">
            and t1.fault_time &gt;= #{params.faultStartTime}
        </if>
        <if test="params.faultEndTime != null">
            and t1.fault_time &lt;= #{params.faultEndTime}
        </if>
        GROUP BY SUBSTRING(CONVERT(VARCHAR(10), t1.fault_time, 120), 1, 10)
    </select>
 
    <select id="getMTPF"  parameterType="Map" resultType="Map">
        SELECT
            t3.item_text  as  item,
            count(t4.repair_order_fault_analysis_uda2) as count
            FROM
            ( SELECT * FROM v_sys_dict WHERE dict_code = 'repair_order_fault_cause' ) t3
                LEFT JOIN (
                    SELECT
                        t1.repair_order_fault_analysis_uda2
                        FROM
                    mom_eam_repair_order_fault_analysis t1
                    LEFT JOIN mom_eam_repair_order t2 ON t1.repair_order_id = t2.id
                    left join mom_eam_equipment t11 on t2.equipment_id = t11.id
                        WHERE
                        t1.del_flag = 0
                        AND t2.del_flag = 0
            <if test="params.equipmentNum != null and params.equipmentNum != ''">
                and t11.num like concat('%',#{params.equipmentNum},'%')
            </if>
            <if test="params.useId != null and params.useId != ''">
                and t11.use_id = #{params.useId}
            </if>
            <if test="params.faultStartTime != null">
                and t2.create_time &gt;= #{params.faultStartTime}
            </if>
            <if test="params.faultEndTime != null">
                and t2.create_time &lt;= #{params.faultEndTime}
            </if>
            ) t4 ON t3.item_value = t4.repair_order_fault_analysis_uda2
        group by t3.item_text
    </select>
 
    <update id="updateRepair" parameterType="String">
        UPDATE mom_eam_repair_order
        SET actual_end_time = null,
            status = '3'
        WHERE id = #{id}
    </update>
</mapper>