cuijian
2023-08-19 bdd0875d4b13a3f1ef472f64d4b6a95e0ef64b22
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
<?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.RepairOrderActualMaterialMapper">
 
    <delete id="deleteByMainId" parameterType="java.lang.String">
        DELETE
        FROM mom_eam_repair_order_actual_material
        WHERE repair_order_id = #{mainId}
    </delete>
 
    <select id="selectByMainId" parameterType="java.lang.String"
            resultType="org.jeecg.modules.eam.entity.RepairOrderActualMaterial">
 
         SELECT DISTINCT t1.id,
               t1.repair_order_id                          as repairOrderId,
               t1.actual_quantity                          as actualQuantity,
                             t2.id sparePartId,
               t2.num                                      as sparePartNum,
               t2.name                                     as sparePartName,
               t2.model as sparePartModel,
               t2.specification as sparePartSpecification,
               t3.id                                       as constructorId,
               t3.name                                     as constructorName,
               t4.num                                      as num,
               t6.name                                     as mainUnitName,
               t6.id                                       as mainUnitId,
                             t1.outbound_order_id outboundOrderId,
                             t1.outbound_order_detail_id outboundOrderDetailId,
                             t8.id equipmentId,
                             t1.is_lock isLock,
                             IFNULL(t5.use_quantity,0) useQuantity,
                             IFNULL(t5.outbound_main_quantity,0) mainQuantity,
                             (IFNULL(t5.outbound_main_quantity,0)-IFNULL(t5.use_quantity,0)) as availableQuantity
 
 
        FROM mom_eam_repair_order_actual_material t1
                 LEFT JOIN mom_eam_spare_part t2 on t2.id = t1.spare_part_id
                 LEFT JOIN mom_base_constructor t3 on t3.id = t2.constructor_id
                 LEFT JOIN mom_eam_spare_part_outbound_detail t5 on t1.outbound_order_detail_id = t5.id
                 LEFT JOIN mom_eam_spare_part_outbound t4 on t4.id = t5.spare_part_outbound_id
                 LEFT JOIN mom_base_unit t6 on t6.id = t5.main_unit_id
                 LEFT JOIN mom_eam_repair_order t7 on t7.id = t1.repair_order_id
                 LEFT JOIN mom_eam_equipment t8 on t8.id = t7.equipment_id
 
        WHERE t1.repair_order_id = #{mainId}
 
          and t1.del_flag = 0
 
    </select>
 
    <select id="selectAfterByMainId" parameterType="java.lang.String"
            resultType="org.jeecg.modules.eam.entity.RepairOrderActualMaterial">
 
      SELECT DISTINCT t1.id,
               t1.report_after_repair_id                          as reportAfterRepairId,
                             t7.num as num,
               t1.actual_quantity                          as actualQuantity,
               t2.num                                      as sparePartNum,
               t2.name                                     as sparePartName,
               t2.model as sparePartModel,
               t2.specification as sparePartSpecification,
               t3.id                                       as constructorId,
               t3.name                                     as constructorName,
               t4.num                                      as outboundNum,
               t6.name                                     as mainUnitName,
               t2.main_unit_id                                       as mainUnitId,
               concat(t8.num, '/', t8.name, '/', t8.model) as equipmentId
        FROM mom_eam_repair_order_actual_material t1
                 LEFT JOIN mom_eam_spare_part t2 on t2.id = t1.spare_part_id
                 LEFT JOIN mom_base_constructor t3 on t3.id = t2.constructor_id
                 LEFT JOIN mom_eam_spare_part_outbound t4 on t4.id = t1.outbound_order_id
                 LEFT JOIN mom_eam_spare_part_outbound_detail t5 on t5.spare_part_outbound_id = t4.id
                 LEFT JOIN mom_base_unit t6 on t6.id = t2.main_unit_id
                 LEFT JOIN mom_eam_report_after_repair t7 on t7.id = t1.report_after_repair_id
                 LEFT JOIN mom_eam_equipment t8 on t8.id = t7.equipment_id
 
        WHERE t1.report_after_repair_id = #{mainId}
 
          and t1.del_flag = 0
 
 
 
    </select>
</mapper>