hyingbo
2025-06-19 53fa0cd3e1950b02301fa2c15ceaba04a5ef5645
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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
<?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.CalibrationOrderMapper">
    <select id="getPrecisionParameterList"  parameterType="String" resultType="Map">
        SELECT
            t1.id,
            t2.id as precisionParametersId,
            t2.num,
            t2.name,
            t3.id as unitId,
            t3.name as unitName,
            t1.leave_factory_value as leaveFactoryValue,
            t1.actual_value as actualValue,
            t1.allowable_range as allowableRange,
            t1.upper_limit as upperLimit,
            t1.lower_limit AS lowerLimit
        FROM
            mom_eam_equipment_precision_parameters t1
        LEFT JOIN mom_eam_precision_parameters t2 ON t1.precision_parameters_id = t2.id
        LEFT JOIN mom_base_unit t3 ON t2.unit_id = t3.id
        WHERE t1.del_flag = 0 and t1.equipment_id = #{equipmentId}
    </select>
 
    <!--根据模型传入的编码  判断改编码公司/中心/工段的哪一级-->
    <select id="findOrgType" resultType="java.lang.String">
        select TOP 1 org_type as orgType from mdc_production where production_code = #{productionCode}
    </select>
 
 
 
    <!--获取当前登录人是中心及对应的编码-->
    <select id="findProductionCode" resultType="java.lang.String">
        SELECT top 1 t2.production_code  as productionCode FROM mdc_user_production t1 LEFT JOIN mdc_production t2 ON t1.pro_id = t2.id  where t1.user_id =#{userId} and t2.org_type = '2'
    </select>
 
    <!--获取当前登录人是中心及对应的编码-->
    <select id="findAreaProductionCode" resultType="java.lang.String">
        SELECT top 1 t2.production_code  as areaProductionCode FROM mdc_user_production t1 LEFT JOIN mdc_production t2 ON t1.pro_id = t2.id  where t1.user_id =#{userId} and t2.org_type = '3'
    </select>
 
    <!--通过当前登录人的工段编码  获分厂编码-->
    <select id="findSiteProductionCode" resultType="java.lang.String">
        select fa.production_code as siteProductionCode  from mdc_production son left join mdc_production fa on son.parent_id = fa.id where son.production_code =#{productionCode}
    </select>
 
    <select id="getFactoryEquipmentTechnologyStatusList"  parameterType="String" resultType="Map">
        SELECT
            ( SELECT COUNT ( 0 ) FROM mom_eam_equipment WHERE del_flag = '0' and technology_status = 'qualified') as qualifiedCount,
            ( SELECT COUNT ( 0 ) FROM mom_eam_equipment WHERE del_flag = '0' and technology_status = 'limitedUse') as  limitedUseCount,
            ( SELECT COUNT ( 0 ) FROM mom_eam_equipment WHERE del_flag = '0' and technology_status = 'disabled')  as disabledCount
    </select>
 
    <select id="getFactoryReportRepairEquipmentList"  parameterType="String" resultType="Map">
        SELECT
            ( select COUNT(0) from mom_eam_equipment_report_repair t1 left join mom_eam_equipment t2 on t1.equipment_id = t2.id WHERE t1.del_flag = '0' and SUBSTRING(CONVERT(VARCHAR(10), t1.fault_time, 120), 1, 10) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 10)) as failurTotalCount,
            ( select COUNT(0) from mom_eam_equipment_report_repair t1 left join mom_eam_equipment t2 on t1.equipment_id = t2.id where t1.del_flag = '0' and t1.is_stop = '1' and SUBSTRING(CONVERT(VARCHAR(10), t1.fault_time, 120), 1, 10) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 10)) as  noStopCount,
            ( select COUNT(0) from mom_eam_equipment_report_repair t1 left join mom_eam_equipment t2 on t1.equipment_id = t2.id where t1.del_flag = '0' and t1.is_stop = '2' and SUBSTRING(CONVERT(VARCHAR(10), t1.fault_time, 120), 1, 10) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 10)) as  stopCount
    </select>
 
    <select id="getFactoryThisMonthMaintenanceList"  parameterType="String" resultType="Map">
        -- select  count(0) as totalCount from  mom_eam_equipment t1 where t1.del_flag = '0' and  SUBSTRING(CONVERT(VARCHAR(10), t1.next_third_maintenance_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 7)
        select count(0) as totalCount from mom_eam_equipment t1 where t1.del_flag = '0' and SUBSTRING(CONVERT(VARCHAR(10), t1.third_maintenance_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 7)
    </select>
 
    <select id="getFactoryNextMonthMaintenanceList"  parameterType="String" resultType="Map">
        -- select  count(0) as totalCount from  mom_eam_equipment t1 where t1.del_flag = '0' and  SUBSTRING(CONVERT(VARCHAR(10), t1.next_third_maintenance_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), DATEADD(MONTH, 1, GETDATE()), 120), 1, 7)
        select  count(0) as totalCount from  mom_eam_equipment t1 where t1.del_flag = '0' and  SUBSTRING(CONVERT(VARCHAR(10), t1.third_maintenance_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), DATEADD(MONTH, 1, GETDATE()), 120), 1, 7)
    </select>
 
    <select id="getFactoryNextNextMonthMaintenanceList"  parameterType="String" resultType="Map">
        -- select  count(0) as totalCount from  mom_eam_equipment t1 where t1.del_flag = '0' and  SUBSTRING(CONVERT(VARCHAR(10), t1.next_third_maintenance_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), DATEADD(MONTH,2 , GETDATE()), 120), 1, 7)
        select  count(0) as totalCount from  mom_eam_equipment t1 where t1.del_flag = '0' and  SUBSTRING(CONVERT(VARCHAR(10), t1.third_maintenance_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), DATEADD(MONTH,2 , GETDATE()), 120), 1, 7)
    </select>
 
    <select id="getFactoryThisMonthMaintenanceFinishList"  parameterType="String" resultType="Map">
        -- select count(0) as totalCount from     mom_eam_daily_maintenance_order t1 left join mom_eam_equipment t2 on t1.equipment_id = t2.id left join mom_eam_maintenance_cycle t4 on t1.maintenance_cycle_id = t4.id
        -- where t1.del_flag = '0' and t1.status = '5' and t4.maintenance_type = '3' and  SUBSTRING(CONVERT(VARCHAR(10), t1.actual_end_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 7)
        select COUNT(0) as totalCount from mom_eam_equipment t1 where t1.del_flag = '0' and SUBSTRING(CONVERT(VARCHAR(10), t1.third_maintenance_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 7) and T1.next_third_maintenance_time IS NOT NULL;
    </select>
 
    <select id="getEquipmentTechnologyStatusList"  parameterType="String" resultType="Map">
        SELECT
            ( SELECT COUNT ( 0 ) FROM mom_eam_equipment WHERE del_flag = '0' and technology_status = 'qualified'   <if test="workCenterId != null and workCenterId != ''"> and work_center_id = #{workCenterId} </if> <if test="areaId != null and areaId != ''"> and area_id = #{areaId} </if> ) as qualifiedCount,
            ( SELECT COUNT ( 0 ) FROM mom_eam_equipment WHERE del_flag = '0' and technology_status = 'limitedUse'  <if test="workCenterId != null and workCenterId != ''"> and work_center_id = #{workCenterId} </if> <if test="areaId != null and areaId != ''"> and area_id = #{areaId} </if> ) as  limitedUseCount,
            ( SELECT COUNT ( 0 ) FROM mom_eam_equipment WHERE del_flag = '0' and technology_status = 'disabled'    <if test="workCenterId != null and workCenterId != ''"> and work_center_id = #{workCenterId} </if> <if test="areaId != null and areaId != ''"> and area_id = #{areaId} </if> )  as disabledCount
    </select>
 
 
    <select id="getEquipmentByTechnologyStatus"  parameterType="Map" resultType="Map">
        SELECT
            t1.id,
            t2.name as factoryName,
            t3.name as productName,
            t1.num as equipmentNum,
            t1.name as equipmentName,
            t1.model as equipmentModel,
            t1.specification,
            t4.item_text as technologyStatus
        FROM
            mom_eam_equipment t1
        left join mom_base_area t2 on t1.work_center_id = t2.id
        left join mom_base_area t3 on t1.area_id = t3.id
        left join (SELECT * FROM v_sys_dict WHERE dict_code = 'technology_status') t4 ON t4.item_value = t1.technology_status
        WHERE t1.del_flag = '0'
        <if test="workCenterId != null and workCenterId != ''">
            and t1.work_center_id = #{workCenterId}
        </if>
        <if test="areaId != null and areaId != ''">
            and t1.area_id = #{areaId}
        </if>
        <if test="technologyStatus != null and technologyStatus != ''">
            and t1.technology_status = #{technologyStatus}
        </if>
    </select>
 
    <select id="getReportRepairEquipmentList"  parameterType="String" resultType="Map">
        SELECT
            ( select COUNT(0) from mom_eam_equipment_report_repair t1 left join mom_eam_equipment t2 on t1.equipment_id = t2.id WHERE t1.del_flag = '0' and SUBSTRING(CONVERT(VARCHAR(10), t1.fault_time, 120), 1, 10) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 10)  <if test="workCenterId != null and workCenterId != ''"> and t2.work_center_id = #{workCenterId} </if> <if test="areaId != null and areaId != ''"> and t2.area_id = #{areaId} </if> ) as failurTotalCount,
            ( select COUNT(0) from mom_eam_equipment_report_repair t1 left join mom_eam_equipment t2 on t1.equipment_id = t2.id where t1.del_flag = '0' and t1.is_stop = '1' and SUBSTRING(CONVERT(VARCHAR(10), t1.fault_time, 120), 1, 10) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 10)  <if test="workCenterId != null and workCenterId != ''"> and t2.work_center_id = #{workCenterId} </if> <if test="areaId != null and areaId != ''"> and t2.area_id = #{areaId} </if> ) as  noStopCount,
            ( select COUNT(0) from mom_eam_equipment_report_repair t1 left join mom_eam_equipment t2 on t1.equipment_id = t2.id where t1.del_flag = '0' and t1.is_stop = '2' and SUBSTRING(CONVERT(VARCHAR(10), t1.fault_time, 120), 1, 10) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 10)  <if test="workCenterId != null and workCenterId != ''"> and t2.work_center_id = #{workCenterId} </if> <if test="areaId != null and areaId != ''"> and t2.area_id = #{areaId} </if> ) as  stopCount
    </select>
 
    <select id="getEquipmentByReportRepair"  parameterType="Map" resultType="Map">
        SELECT
            t1.id,
            t5.name AS factoryName,
            t3.name AS productName,
            t2.num AS equipmentNum,
            t2.name AS equipmentName,
            t2.model AS equipmentModel,
            t2.specification,
            t4.item_text AS technologyStatus
        FROM
            mom_eam_equipment_report_repair t1
        LEFT JOIN mom_eam_equipment t2 ON t1.equipment_id = t2.id
        LEFT JOIN mom_base_area t5 ON t2.work_center_id = t5.id
        LEFT JOIN mom_base_area t3 ON t2.area_id = t3.id
        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'technology_status' ) t4 ON t4.item_value = t2.technology_status
        WHERE t1.del_flag = '0' and SUBSTRING(CONVERT(VARCHAR(10), t1.fault_time, 120), 1, 10) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 10)
        <if test="workCenterId != null and workCenterId != ''">
            and t2.work_center_id = #{workCenterId}
        </if>
        <if test="areaId != null and areaId != ''">
            and t2.area_id = #{areaId}
        </if>
        <if test="isStop != null and isStop != ''">
            and t1.is_stop = #{isStop}
        </if>
    </select>
 
    <select id="getThisMonthMaintenanceList"  parameterType="String" resultType="Map">
        select  count(0) as totalCount from  mom_eam_equipment t1 where t1.del_flag = '0' and SUBSTRING(CONVERT(VARCHAR(10), t1.next_third_maintenance_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 7)  <if test="workCenterId != null and workCenterId != ''"> and t1.work_center_id = #{workCenterId} </if> <if test="areaId != null and areaId != ''"> and t1.area_id = #{areaId} </if>
    </select>
 
    <select id="showThisMonthMaintenanceList"  parameterType="Map" resultType="Map">
        SELECT
            t1.id,
            t2.name as factoryName,
            t3.name as productName,
            t1.num as equipmentNum,
            t1.name as equipmentName,
            t1.model as equipmentModel,
            t1.specification,
            t4.item_text as technologyStatus
        FROM
            mom_eam_equipment t1
        left join mom_base_area t2 on t1.work_center_id = t2.id
        left join mom_base_area t3 on t1.area_id = t3.id
        left join (SELECT * FROM v_sys_dict WHERE dict_code = 'technology_status') t4 ON t4.item_value = t1.technology_status
        -- WHERE t1.del_flag = '0' and SUBSTRING(CONVERT(VARCHAR(10), t1.next_third_maintenance_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 7)
        WHERE t1.del_flag = '0' and SUBSTRING(CONVERT(VARCHAR(10), t1.third_maintenance_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 7)
        <if test="workCenterId != null and workCenterId != ''">
            and t1.work_center_id = #{workCenterId}
        </if>
        <if test="areaId != null and areaId != ''">
            and t1.area_id = #{areaId}
        </if>
    </select>
 
    <select id="getNextMonthMaintenanceList"  parameterType="String" resultType="Map">
        select  count(0) as totalCount from  mom_eam_equipment t1 where t1.del_flag = '0' and  SUBSTRING(CONVERT(VARCHAR(10), t1.next_third_maintenance_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), DATEADD(MONTH, 1, GETDATE()), 120), 1, 7) <if test="workCenterId != null and workCenterId != ''"> and t1.work_center_id = #{workCenterId} </if> <if test="areaId != null and areaId != ''"> and t1.area_id = #{areaId} </if>
    </select>
 
    <select id="showNextMonthMaintenanceList"  parameterType="Map" resultType="Map">
        SELECT
            t1.id,
            t2.name as factoryName,
            t3.name as productName,
            t1.num as equipmentNum,
            t1.name as equipmentName,
            t1.model as equipmentModel,
            t1.specification,
            t4.item_text as technologyStatus
        FROM
            mom_eam_equipment t1
        left join mom_base_area t2 on t1.work_center_id = t2.id
        left join mom_base_area t3 on t1.area_id = t3.id
        left join (SELECT * FROM v_sys_dict WHERE dict_code = 'technology_status') t4 ON t4.item_value = t1.technology_status
        -- WHERE t1.del_flag = '0' and SUBSTRING(CONVERT(VARCHAR(10), t1.next_third_maintenance_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), DATEADD(MONTH, 1, GETDATE()), 120), 1, 7)
        WHERE t1.del_flag = '0' and SUBSTRING(CONVERT(VARCHAR(10), t1.third_maintenance_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), DATEADD(MONTH, 1, GETDATE()), 120), 1, 7)
        <if test="workCenterId != null and workCenterId != ''">
            and t1.work_center_id = #{workCenterId}
        </if>
        <if test="areaId != null and areaId != ''">
            and t1.area_id = #{areaId}
        </if>
    </select>
 
    <select id="getNextNextMonthMaintenanceList"  parameterType="String" resultType="Map">
        select  count(0) as totalCount from  mom_eam_equipment t1 where t1.del_flag = '0' and  SUBSTRING(CONVERT(VARCHAR(10), t1.next_third_maintenance_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), DATEADD(MONTH,2 , GETDATE()), 120), 1, 7)  <if test="workCenterId != null and workCenterId != ''"> and t1.work_center_id = #{workCenterId} </if> <if test="areaId != null and areaId != ''"> and t1.area_id = #{areaId} </if>
    </select>
 
    <select id="showNextNextMonthMaintenanceList"  parameterType="Map" resultType="Map">
        SELECT
            t1.id,
            t2.name as factoryName,
            t3.name as productName,
            t1.num as equipmentNum,
            t1.name as equipmentName,
            t1.model as equipmentModel,
            t1.specification,
            t4.item_text as technologyStatus
        FROM
            mom_eam_equipment t1
        left join mom_base_area t2 on t1.work_center_id = t2.id
        left join mom_base_area t3 on t1.area_id = t3.id
        left join (SELECT * FROM v_sys_dict WHERE dict_code = 'technology_status') t4 ON t4.item_value = t1.technology_status
        -- WHERE t1.del_flag = '0' and SUBSTRING(CONVERT(VARCHAR(10), t1.next_third_maintenance_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), DATEADD(MONTH,2 , GETDATE()), 120), 1, 7)
        WHERE t1.del_flag = '0' and SUBSTRING(CONVERT(VARCHAR(10), t1.third_maintenance_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), DATEADD(MONTH,2 , GETDATE()), 120), 1, 7)
        <if test="workCenterId != null and workCenterId != ''">
            and t1.work_center_id = #{workCenterId}
        </if>
        <if test="areaId != null and areaId != ''">
            and t1.area_id = #{areaId}
        </if>
    </select>
 
    <select id="getThisMonthMaintenanceFinishList"  parameterType="String" resultType="Map">
        select count(0) as totalCount from     mom_eam_daily_maintenance_order t1 left join mom_eam_equipment t2 on t1.equipment_id = t2.id left join mom_eam_maintenance_cycle t4 on t1.maintenance_cycle_id = t4.id
        where t1.del_flag = '0' and t1.status = '5' and t4.maintenance_type = '3'
        and  SUBSTRING(CONVERT(VARCHAR(10), t1.actual_end_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 7)
        <if test="workCenterId != null and workCenterId != ''">and t2.work_center_id = #{workCenterId} </if>
        <if test="areaId != null and areaId != ''">and t2.area_id = #{areaId} </if>
    </select>
 
    <select id="showThisMonthMaintenanceFinishList"  parameterType="Map" resultType="Map">
--         SELECT
--             t1.id,
--             t20.name AS factoryName,
--             t30.name AS productName,
--             t2.num AS equipmentNum,
--             t2.name AS equipmentName,
--             t2.model AS equipmentModel,
--             t2.specification,
--             t40.item_text AS technologyStatus
--         FROM
--         mom_eam_daily_maintenance_order t1
--         LEFT JOIN mom_eam_equipment t2 ON t1.equipment_id = t2.id
--         LEFT JOIN mom_eam_maintenance_cycle t4 ON t1.maintenance_cycle_id = t4.id
--         LEFT JOIN mom_base_area t20 ON t2.work_center_id = t20.id
--         LEFT JOIN mom_base_area t30 ON t2.area_id = t30.id
--         LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'technology_status' ) t40 ON t40.item_value = t2.technology_status
        -- WHERE t1.del_flag = '0' AND t1.status = '5' AND t4.maintenance_type = '3'
        -- AND SUBSTRING ( CONVERT ( VARCHAR ( 10 ), t1.actual_end_time, 120 ), 1, 7 ) = SUBSTRING ( CONVERT ( VARCHAR ( 10 ), GETDATE( ), 120 ), 1, 7 )
        SELECT
            t2.id,
            t20.name AS factoryName,
            t30.name AS productName,
            t2.num AS equipmentNum,
            t2.name AS equipmentName,
            t2.model AS equipmentModel,
            t2.specification,
            t40.item_text AS technologyStatus
        FROM
        mom_eam_equipment t2
        LEFT JOIN mom_eam_maintenance_cycle t4 ON t2.id = t4.id
        LEFT JOIN mom_base_area t20 ON t2.work_center_id = t20.id
        LEFT JOIN mom_base_area t30 ON t2.area_id = t30.id
        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'technology_status' ) t40 ON t40.item_value = t2.technology_status
        WHERE t2.del_flag = '0' and t2.next_third_maintenance_time IS NOT NULL
        AND SUBSTRING ( CONVERT ( VARCHAR ( 10 ), t2.third_maintenance_time, 120 ), 1, 7 ) = SUBSTRING ( CONVERT ( VARCHAR ( 10 ), GETDATE( ), 120 ), 1, 7 )
        <if test="workCenterId != null and workCenterId != ''">
            and t2.work_center_id = #{workCenterId}
        </if>
        <if test="areaId != null and areaId != ''">
            and t2.area_id = #{areaId}
        </if>
    </select>
 
    <select id="get3MaintenancePostponeCount"  parameterType="String" resultType="Map">
        select count(0) as totalCount from (select DISTINCT  t2.id  from mom_eam_plan_change_apply t1 left join mom_eam_equipment t2 on t1.equipment_id = t2.id
        where  SUBSTRING(CONVERT(VARCHAR(10), t2.next_third_maintenance_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 7)  and t2.area_id = #{areaId} ) t4
    </select>
 
    <select id="show3MaintenancePostponeCount"  parameterType="Map" resultType="Map">
        SELECT DISTINCT
            t2.id,
            t20.name AS factoryName,
            t30.name AS productName,
            t2.num AS equipmentNum,
            t2.name AS equipmentName,
            t2.model AS equipmentModel,
            t2.specification,
            t4.item_text AS technologyStatus
        FROM
            mom_eam_plan_change_apply t1
        LEFT JOIN mom_eam_equipment t2 ON t1.equipment_id = t2.id
        LEFT JOIN mom_base_area t20 ON t2.work_center_id = t20.id
        LEFT JOIN mom_base_area t30 ON t2.area_id = t30.id
        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'technology_status' ) t4 ON t4.item_value = t2.technology_status
        where  SUBSTRING(CONVERT(VARCHAR(10), t2.next_third_maintenance_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 7)
        and t2.area_id = #{areaId}
    </select>
 
    <select id="get3MaintenanceOverdueCount"  parameterType="String" resultType="Map">
        SELECT
            count(0) as totalCount
        FROM
            mom_eam_daily_maintenance_order t1
        LEFT JOIN mom_eam_equipment t2 ON t1.equipment_id = t2.id
        left join mom_eam_maintenance_cycle t4 on t1.maintenance_cycle_id = t4.id
        WHERE
            t1.del_flag = '0'
            and t1.status = '3'
            and t4.maintenance_type = '3'
            and SUBSTRING(CONVERT(VARCHAR(10), t1.plan_start_time, 120), 1, 10) &lt; SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 10)
            and SUBSTRING(CONVERT(VARCHAR(10), t2.next_third_maintenance_time, 120), 1, 10) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 10)
            <if test="areaId != null and areaId != ''"> and t2.area_id = #{areaId} </if>
    </select>
 
    <select id="show3MaintenanceOverdueCount"  parameterType="Map" resultType="Map">
        SELECT DISTINCT
            t2.id,
            t20.name AS factoryName,
            t30.name AS productName,
            t2.num AS equipmentNum,
            t2.name AS equipmentName,
            t2.model AS equipmentModel,
            t2.specification,
            t40.item_text AS technologyStatus
        FROM
            mom_eam_daily_maintenance_order t1
        LEFT JOIN mom_eam_equipment t2 ON t1.equipment_id = t2.id
        LEFT JOIN mom_eam_maintenance_cycle t4 ON t1.maintenance_cycle_id = t4.id
        LEFT JOIN mom_base_area t20 ON t2.work_center_id = t20.id
        LEFT JOIN mom_base_area t30 ON t2.area_id = t30.id
        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'technology_status' ) t40 ON t40.item_value = t2.technology_status
        WHERE t1.del_flag = '0' AND t1.status = '3'  AND t4.maintenance_type = '3'
        and SUBSTRING(CONVERT(VARCHAR(10), t1.plan_start_time, 120), 1, 10) &lt; SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 10)
        and SUBSTRING(CONVERT(VARCHAR(10), t2.next_third_maintenance_time, 120), 1, 10) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 10)
        <if test="areaId != null and areaId != ''"> and t2.area_id = #{areaId} </if>
 
    </select>
 
    <select id="getCenterTwoMaintenancePlanList"  parameterType="String" resultType="Map">
        SELECT
            top 1
            t1.id,
            t5.name centerName,
            SUBSTRING(CONVERT(VARCHAR(10),t1.plan_start_time, 120), 1, 7) maintenanceDate,
            '二级保养' as content
        FROM
            mom_eam_equipment_maintenance_plan_detail t1
            LEFT JOIN mom_eam_equipment_maintenance_plan t2 ON t1.plan_id= t2.id
            left join mom_eam_maintenance_standard t3 on t1.standard_id = t3.id
            left join mom_eam_equipment t4 on t3.equipment_id = t4.id
            left join mom_base_area t5 on t4.work_center_id = t5.id
        where t5.id = #{workCenterId} ORDER BY t1.plan_start_time desc
    </select>
 
    <select id="findMaintenanceDate"  parameterType="String" resultType="java.lang.String">
        SELECT
            top 1
            SUBSTRING(CONVERT(VARCHAR(10),t1.plan_start_time, 120), 1, 7) maintenanceDate
        FROM
            mom_eam_equipment_maintenance_plan_detail t1
            left join mom_eam_maintenance_standard t3 on t1.standard_id = t3.id
            left join mom_eam_equipment t4 on t3.equipment_id = t4.id
            left join mom_base_area t5 on t4.work_center_id = t5.id
        where t5.id = #{workCenterId} ORDER BY t1.plan_start_time desc
    </select>
 
    <!--  工段下 二级保养计划明细  -->
    <select id="getAreTwoMaintenancePlanDetails"  parameterType="String" resultType="Map">
        SELECT
            t1.id,
            t4.num,
            t4.name,
            t4.model,
            t4.specification
        FROM
            mom_eam_equipment_maintenance_plan_detail t1
            LEFT JOIN mom_eam_maintenance_standard t3 ON t1.standard_id = t3.id
            LEFT JOIN mom_eam_equipment t4 ON t3.equipment_id = t4.id
        where t4.area_id = #{areaId} and SUBSTRING(CONVERT(VARCHAR(10), t1.plan_start_time, 120), 1, 7) = #{maintenanceDate}
    </select>
 
    <!--  首页  第四级  对应工区下,设备台账信息展示;  -->
    <select id="getAreaEquipmentList"  parameterType="String" resultType="Map">
        SELECT
            t1.id,
            t1.id as value,
            t1.num,
            t1.num as text,
            t1.name,
            t1.model,
            t1.specification,
            t1.equipment_importance_id as abc,
            t2.name as equipmentCategoryName,
            t3.name as siteName,
            t4.name as areaName,
            t5.name as workShopName,
            t1.system,
            t6.depart_name as manageName,
            t7.item_text as equipmentStatus,
            t8.item_text as technology_status,
            t1.next_second_maintenance_time AS nextSecondMaintenanceTime,
            t1.next_third_maintenance_time as nextThirdMaintenanceTime
        FROM
            mom_eam_equipment t1
            LEFT JOIN mom_eam_equipment_category t2 ON t1.equipment_category_id = t2.id
            left join mom_base_area t3 on t1.work_center_id = t3.id
            left join mom_base_area t4 on t1.factory_model_id = t4.id
            left join mom_base_area t5 on t1.area_id = t5.id
            left join sys_depart t6 on t1.manage_id = t6.id
            LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'equipment_status' ) t7 ON t7.item_value = t1.equipment_status
            LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'technology_status' ) t8 ON t8.item_value = t1.technology_status
        where t1.del_flag = '0'
        <if test="areaId != null and areaId != ''">
            and t1.area_id = #{areaId}
        </if>
        <if test="equipmentNum != null and equipmentNum != ''">
            and t1.num = #{equipmentNum}
        </if>
        <if test="equipmentIds != null">
            and  t1.id in
            <foreach collection='equipmentIds' index='index' item='item' open='(' separator=',' close=')'>#{item}</foreach>
        </if>
    </select>
 
    <!--  首页 第四级 当前登录人的操作证;  -->
    <select id="getOperationCertificate"  parameterType="String" resultType="Map">
        SELECT
            t1.id,
            t1.num,
            SUBSTRING(CONVERT(VARCHAR(10),t1.issue_date, 120), 1, 10) AS issueDate,
            SUBSTRING(CONVERT(VARCHAR(10),t1.end_time, 120), 1, 10) as endTime,
            t1.current_cycle_score AS currentCycleScore,
            t2.realname,
            t1.equipment_ids AS equipmentIds
        FROM
            mom_eam_operation_certificate t1
        LEFT JOIN sys_user t2 on t1.user_id = t2.username
        where t1.del_flag = '0' and t1.user_id = #{username}
    </select>
 
    <select id="getEquipmentReportRepairCount"  parameterType="String" resultType="Map">
        SELECT
            count(0) AS repairCount
        FROM
            mom_eam_equipment_report_repair t1
        where t1.del_flag = '0'
        and SUBSTRING(CONVERT(VARCHAR(10), t1.fault_time, 120), 1, 7) = SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 1, 7)
        and t1.equipment_id = #{equipmentId}
    </select>
 
 
</mapper>