李林
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
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
<?xml version="1.0" encoding="UTF-8"?>
 
<!--
  ~
  ~      Copyright (c) 2018-2025, ztt All rights reserved.
  ~
  ~  Redistribution and use in source and binary forms, with or without
  ~  modification, are permitted provided that the following conditions are met:
  ~
  ~ Redistributions of source code must retain the above copyright notice,
  ~  this list of conditions and the following disclaimer.
  ~  Redistributions in binary form must reproduce the above copyright
  ~  notice, this list of conditions and the following disclaimer in the
  ~  documentation and/or other materials provided with the distribution.
  ~  Neither the name of the pig4cloud.com developer nor the names of its
  ~  contributors may be used to endorse or promote products derived from
  ~  this software without specific prior written permission.
  ~  Author: ztt
  ~
  -->
 
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
<mapper namespace="com.chinaztt.mes.technology.mapper.BomMapper">
    <resultMap id="bomMap" type="com.chinaztt.mes.technology.dto.BomDTO">
        <id property="id" column="id"/>
        <result property="number" column="number"/>
        <result property="insulationColor" column="insulation_color"/>
        <result property="sheathColor" column="sheath_color"/>
        <result property="characteristicOne" column="characteristic_one"/>
        <result property="state" column="state"/>
        <result property="partId" column="part_id"/>
        <result property="partName" column="part_name"/>
        <result property="partNo" column="part_no"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="createUser" column="create_user"/>
        <result property="updateUser" column="update_user"/>
        <result property="version" column="version"/>
        <result property="operationId" column="operation_id"/>
        <result property="bomTypeDb" column="bom_type_db"/>
        <result property="alternativeNo" column="alternative_no"/>
        <result property="alternativeDesc" column="alternative_desc"/>
    </resultMap>
 
    <resultMap id="bomComponentMap" type="com.chinaztt.mes.technology.dto.StructureTree">
        <id property="id" column="id"/>
        <result property="parentId" column="parent"/>
        <result property="partId" column="part_id"/>
        <result property="partName" column="part_name"/>
        <result property="partNo" column="part_no"/>
        <result property="qpa" column="qpa"/>
        <result property="discNum" column="disc_num"/>
        <result property="originalQpa" column="original_qpa"/>
        <result property="unit" column="unit"/>
        <result property="operationName" column="operation_name"/>
        <result property="operationId" column="operation_id"/>
        <result property="operationNo" column="operation_no"/>
        <result property="planningMethod" column="planning_method"/>
        <result property="color" column="color"/>
    </resultMap>
 
 
    <sql id="bomPage">
        SELECT
            b.*,
            P.part_name,
            P.part_no
        FROM
            technology_bom b
                LEFT JOIN basic_part P ON b.part_id = P.ID
    </sql>
 
    <select id="getBomPage" resultMap="bomMap">
        select * from(<include refid="bomPage"/>) a
        <if test="ew.emptyOfWhere == false">
            <where>
                ${ew.SqlSegment}
            </where>
        </if>
    </select>
 
 
    <select id="getBomComponents4Tree" resultMap="bomComponentMap">
        SELECT
            A.*,
            b.part_no,
            b.part_name,
            c.operation_no,
            c.name operation_name
        FROM
            technology_bom_component A
                left join basic_part b on b.id = A.part_id
                left join technology_operation c on c.id = A.operation_id
        WHERE
            A.bom_id = #{bomId}
        order by A."id"
    </select>
 
    <select id="getBomCompontBomPart" resultType="com.chinaztt.mes.basic.entity.Part">
        SELECT
            bp.*
        FROM
            technology_bom_component tbc
                LEFT JOIN basic_part bp ON tbc.part_id = bp."id"
        WHERE
            tbc.parent IS NOT NULL
          AND tbc.bom_id = #{bomId}
          AND bp.planning_method = 'A'
          AND bp.material_type = '1'
        ORDER BY tbc.ID DESC;
    </select>
 
    <select id="getBomComponentsOrderByPartName" resultType="com.chinaztt.mes.technology.dto.BomComponentDTO">
        SELECT
            A.*,
            b.part_no,
            b.part_name
        FROM
            technology_bom_component A,
            basic_part b
        WHERE
            A.part_id = b.ID
          AND a.bom_id = #{bomId}
          AND a.parent = #{parent}
        order by b.part_name
    </select>
 
    <select id="getBomPartIdByBomId" resultType="java.lang.Long">
        SELECT DISTINCT part_id FROM technology_bom_component WHERE bom_id = #{bomId}
    </select>
</mapper>