李林
2023-10-07 658d4927d468c47208fd012d9128b09249c07eff
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
<?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="com.chinaztt.mes.production.mapper.ProductInputMapper">
 
    <resultMap id="productInputMap" type="com.chinaztt.mes.production.dto.ProductInputDTO">
        <id property="id" column="id"/>
        <result property="inputQuantity" column="input_quantity"/>
        <result property="productMainId" column="product_main_id"/>
        <result property="productNo" column="product_no"/>
        <result property="partNo" column="part_no"/>
        <result property="partName" column="part_name"/>
        <result property="description" column="description"/>
        <result property="unit" column="unit"/>
        <result property="systemNo" column="system_no"/>
        <result property="partId" column="part_id"/>
        <result property="stockId" column="stock_id"/>
        <result property="ifsLineItemNo" column="ifs_line_item_no"/>
        <result property="ifsBatchNo" column="ifs_batch_no"/>
        <result property="operationStockStatus" column="operation_stock_status"/>
        <result property="availableStockQuantity" column="available_stock_quantity"/>
        <result property="createTime" column="create_time"/>
        <result property="createUser" column="create_user"/>
        <result property="updateTime" column="update_time"/>
        <result property="updateUser" column="update_user"/>
    </resultMap>
 
    <select id="queryList" resultMap="productInputMap">
        SELECT
            i."id",
            i.part_batch_no,
            P.part_no,
            P.part_name,
            P.description part_description,
            i.input_quantity,
            P.unit,
            P.id part_id,
            M.product_no,
            i.stock_id,
            i.system_no,
            i.ifs_batch_no,
            s.available_stock_quantity
            FROM
            production_product_input i
            LEFT JOIN production_product_main M ON i.product_main_id = M."id"
            LEFT JOIN basic_part P ON P."id" = i.part_id
            LEFT JOIN warehouse_stock s ON s."id" = i.stock_id
        <where>
            i.product_main_id =#{mainId}
            <if test="partId!=null">
                and p.id = #{partId}
            </if>
        </where>
    </select>
 
 
 
    <select id="queryListByDelete" resultMap="productInputMap">
        SELECT
        i.product_main_id,
        P.part_no
        FROM
        production_product_input i
        LEFT JOIN production_product_main M ON i.product_main_id = M."id"
        LEFT JOIN basic_part P ON P."id" = i.part_id
        LEFT JOIN basic_workstation_location wl ON M.workstation_id = wl.workstation_id
        AND wl.location_type = 5
        LEFT JOIN ( SELECT part_id, part_batch_no, ifs_batch_no, location_id, SUM ( available_stock_quantity ) available_stock_quantity FROM warehouse_stock GROUP BY part_id, part_batch_no, ifs_batch_no, location_id ) s ON s.location_id = wl.location_id
        AND i.part_id = s.part_id
        AND i.part_batch_no = s.part_batch_no
        AND i.ifs_batch_no = s.ifs_batch_no
        <where>
            i.product_main_id =#{mainId}
            <if test="iId!=null">
                and i.id != #{iId}
            </if>
        </where>
    </select>
 
 
 
 
 
 
 
    <select id="countPartNumber" resultType="java.lang.Integer">
        SELECT COUNT
        ( DISTINCT part_id )
        FROM
            production_product_input
        WHERE
            product_main_id = #{productMainId}
    </select>
</mapper>