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
85
86
87
88
89
90
91
92
93
94
95
96
97
<?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.spare.mapper.SparesScrapDetailMapper">
 
    <delete id="deleteByMainId" parameterType="java.lang.String">
        DELETE
        FROM mom_eam_spares_scrap_detail
        WHERE spare_part_scrap_id = #{mainId}    </delete>
 
    <select id="selectByMainId" parameterType="java.lang.String"
            resultType="org.jeecg.modules.spare.vo.SparePartVo">
 
        SELECT t1.id                       as id,
               t1.scrap_main_quantity      as scrapMainQuantity,
               t1.scrap_reason             as scrapReason,
               t1.scrap_auxiliary_quantity as scrapAuxiliaryQuantity,
               t2.conversion_ratio         as conversionRatio,
               t1.spare_part_scrap_id      as sparePartScrapId,
               t1.spare_part_id            as sparePartId,
               t2.num                      as spareNum,
               t2.model,
               t2.specification,
               t2.constructor_id           as constructorId,
               t6.name                     as constructorName,
               t3.main_unit_id             as mainUnitId,
               t3.auxiliary_unit_id        as auxiliaryUnitId,
               t3.manufacture_date         as manufactureDate,
               t3.validity_period          as validityPeriod,
               t3.warehouse_area_id        as warehouseAreaId,
               t3.warehouse_location_id    as warehouseLocationId,
               t2.name                     as spareName,
               t3.auxiliary_quantity       as auxiliaryQuantity,
               t3.main_quantity            as mainQuantity,
               t3.batch_num                as batchNum,
               t1.spare_part_inventory_id  as sparePartInventoryId,
               t4.name                     as mainUnitIdName,
               t5.name                     as auxiliaryUnitIdName,
               t8.name                     as warehouseAreaIdName,
               t7.num                      as warehouseLocationIdName
 
        FROM mom_eam_spares_scrap_detail t1
                 LEFT JOIN mom_eam_spare_part t2 ON t1.spare_part_id = t2.id
                 LEFT JOIN mom_base_constructor t6 ON t6.id = t2.constructor_id
                 LEFT JOIN mom_eam_spares_part_inventory t3 ON t1.spare_part_inventory_id = t3.id
                 LEFT JOIN mom_base_unit t4 ON t3.main_unit_id = t4.id
                 LEFT JOIN mom_base_unit t5 ON t3.auxiliary_unit_id = t5.id
                 LEFT JOIN mom_base_warehouse_area t8 ON t8.id = t3.warehouse_area_id
                 LEFT JOIN mom_base_warehouse_location t7 ON t7.id = t3.warehouse_location_id
        WHERE t1.spare_part_scrap_id = #{mainId}
    </select>
 
 
    <select id="getSparesScrapDetailList" parameterType="Map" resultType="org.jeecg.modules.spare.vo.SparePartVo">
 
        SELECT t1.id,
               t1.scrap_main_quantity      as scrapMainQuantity,
               t1.spare_part_id           as  sparePartId,
               t1.spare_part_inventory_id  as sparePartInventoryId,
               t1.scrap_reason             as scrapReason,
               t1.spare_part_scrap_id      as sparePartScrapId,
               t1.scrap_auxiliary_quantity as scrapAuxiliaryQuantity,
               t2.num                      as spareNum,
               t2.model,
               t2.specification,
               t2.conversion_ratio         as conversionRatio,
               t2.constructor_id           as constructorId,
               t6.name                     as constructorName,
               t3.warehouse_area_id        as warehouseAreaId,
               t3.warehouse_location_id    as warehouseLocationId,
               t3.main_unit_id             as mainUnitId,
               t3.auxiliary_unit_id        as auxiliaryUnitId,
               t3.manufacture_date         as manufactureDate,
               t3.validity_period          as validityPeriod,
               t2.name                     as spareName,
               t3.auxiliary_quantity       as auxiliaryQuantity,
               t3.main_quantity            as mainQuantity,
               t3.batch_num                as batchNum,
               t4.name                     as auxiliaryUnitIdName,
               t5.name                     as mainUnitIdName,
               t8.name                     as warehouseAreaIdName,
               t7.num                      as warehouseLocationIdName
        FROM mom_eam_spares_scrap_detail t1
                 LEFT JOIN mom_eam_spare_part t2 ON t1.spare_part_id = t2.id
                 LEFT JOIN mom_eam_spares_part_inventory t3 ON t1.spare_part_inventory_id = t3.id
                 LEFT JOIN mom_base_unit t4 ON t4.id = t3.auxiliary_unit_id
                 LEFT JOIN mom_base_unit t5 ON t5.id = t3.main_unit_id
                 LEFT JOIN mom_base_constructor t6 ON t6.id = t2.constructor_id
                 LEFT JOIN mom_base_warehouse_area t8 ON t8.id = t3.warehouse_area_id
                 LEFT JOIN mom_base_warehouse_location t7 ON t7.id = t3.warehouse_location_id
 
        WHERE t1.spare_part_scrap_id = #{sparePartScrapId}
          and t1.del_flag = 0
 
 
        ORDER BY t1.create_time desc
    </select>
</mapper>