sfd
2025-05-26 2a64b537e8e3bce9ce030585a3da17d48379c0ad
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
<?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.aps.job.mapper.ApsBomLineJobMapper">
    
    <resultMap type="com.aps.job.domain.ApsBomLineJob" id="ApsBomLineJobResult">
        <result property="id"    column="id"    />
        <result property="bomLineId"    column="bom_line_id"    />
        <result property="bomHeaderId"    column="bom_header_id"    />
        <result property="itemCode"    column="item_code"    />
        <result property="itemName"    column="item_name"    />
        <result property="startDate"    column="start_date"    />
        <result property="endDate"    column="end_date"    />
        <result property="orgCode"    column="org_code"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="drawingNo"    column="drawing_no"    />
        <result property="processNo"    column="process_no"    />
        <result property="unit"    column="unit"    />
        <result property="num"    column="num"    />
        <result property="totalNum"    column="total_num"    />
        <result property="preparationTime"    column="preparation_time"    />
        <result property="processingTime"    column="processing_time"    />
    </resultMap>
 
    <sql id="selectApsBomLineJobVo">
        select id, bom_line_id, bom_header_id, item_code, item_name, start_date, end_date, org_code, del_flag, create_by, create_time, update_by, update_time, drawing_no, process_no, unit, num, total_num, preparation_time, processing_time from aps_bom_line_job
    </sql>
 
    <select id="selectApsBomLineJobList" parameterType="com.aps.job.domain.ApsBomLineJob" resultMap="ApsBomLineJobResult">
        <include refid="selectApsBomLineJobVo"/>
        <where>  
            <if test="bomLineId != null  and bomLineId != ''"> and bom_line_id = #{bomLineId}</if>
            <if test="bomHeaderId != null  and bomHeaderId != ''"> and bom_header_id = #{bomHeaderId}</if>
            <if test="itemCode != null  and itemCode != ''"> and item_code = #{itemCode}</if>
            <if test="itemName != null  and itemName != ''"> and item_name like concat('%', #{itemName}, '%')</if>
            <if test="startDate != null "> and start_date = #{startDate}</if>
            <if test="endDate != null "> and end_date = #{endDate}</if>
            <if test="orgCode != null  and orgCode != ''"> and org_code = #{orgCode}</if>
            <if test="drawingNo != null  and drawingNo != ''"> and drawing_no = #{drawingNo}</if>
            <if test="processNo != null  and processNo != ''"> and process_no = #{processNo}</if>
            <if test="unit != null  and unit != ''"> and unit = #{unit}</if>
            <if test="num != null "> and num = #{num}</if>
            <if test="totalNum != null "> and total_num = #{totalNum}</if>
            <if test="preparationTime != null "> and preparation_time = #{preparationTime}</if>
            <if test="processingTime != null "> and processing_time = #{processingTime}</if>
        </where>
    </select>
    
    <select id="selectApsBomLineJobById" parameterType="Long" resultMap="ApsBomLineJobResult">
        <include refid="selectApsBomLineJobVo"/>
        where id = #{id}
    </select>
 
    <insert id="insertApsBomLineJob" parameterType="com.aps.job.domain.ApsBomLineJob">
        insert into aps_bom_line_job
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="bomLineId != null">bom_line_id,</if>
            <if test="bomHeaderId != null">bom_header_id,</if>
            <if test="itemCode != null">item_code,</if>
            <if test="itemName != null">item_name,</if>
            <if test="startDate != null">start_date,</if>
            <if test="endDate != null">end_date,</if>
            <if test="orgCode != null">org_code,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="drawingNo != null">drawing_no,</if>
            <if test="processNo != null">process_no,</if>
            <if test="unit != null">unit,</if>
            <if test="num != null">num,</if>
            <if test="totalNum != null">total_num,</if>
            <if test="preparationTime != null">preparation_time,</if>
            <if test="processingTime != null">processing_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="bomLineId != null">#{bomLineId},</if>
            <if test="bomHeaderId != null">#{bomHeaderId},</if>
            <if test="itemCode != null">#{itemCode},</if>
            <if test="itemName != null">#{itemName},</if>
            <if test="startDate != null">#{startDate},</if>
            <if test="endDate != null">#{endDate},</if>
            <if test="orgCode != null">#{orgCode},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="drawingNo != null">#{drawingNo},</if>
            <if test="processNo != null">#{processNo},</if>
            <if test="unit != null">#{unit},</if>
            <if test="num != null">#{num},</if>
            <if test="totalNum != null">#{totalNum},</if>
            <if test="preparationTime != null">#{preparationTime},</if>
            <if test="processingTime != null">#{processingTime},</if>
         </trim>
    </insert>
 
    <update id="updateApsBomLineJob" parameterType="com.aps.job.domain.ApsBomLineJob">
        update aps_bom_line_job
        <trim prefix="SET" suffixOverrides=",">
            <if test="bomLineId != null">bom_line_id = #{bomLineId},</if>
            <if test="bomHeaderId != null">bom_header_id = #{bomHeaderId},</if>
            <if test="itemCode != null">item_code = #{itemCode},</if>
            <if test="itemName != null">item_name = #{itemName},</if>
            <if test="startDate != null">start_date = #{startDate},</if>
            <if test="endDate != null">end_date = #{endDate},</if>
            <if test="orgCode != null">org_code = #{orgCode},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="drawingNo != null">drawing_no = #{drawingNo},</if>
            <if test="processNo != null">process_no = #{processNo},</if>
            <if test="unit != null">unit = #{unit},</if>
            <if test="num != null">num = #{num},</if>
            <if test="totalNum != null">total_num = #{totalNum},</if>
            <if test="preparationTime != null">preparation_time = #{preparationTime},</if>
            <if test="processingTime != null">processing_time = #{processingTime},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteApsBomLineJobById" parameterType="Long">
        delete from aps_bom_line_job where id = #{id}
    </delete>
 
    <delete id="deleteApsBomLineJobByIds" parameterType="String">
        delete from aps_bom_line_job where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
    <insert id="insertApsBomLineJobBatch">
        INSERT INTO aps_bom_line_job (
        id,
        bom_line_id,
        bom_header_id,
        item_code,
        item_name,
        start_date,
        end_date,
        org_code,
        num,
        create_by,
        create_time
        ) VALUES
        <foreach collection="list" item="item" separator=",">
            (
            #{item.id},
            #{item.bomLineId},
            #{item.bomHeaderId},
            #{item.itemCode},
            #{item.itemName},
            #{item.startDate},
            #{item.endDate},
            #{item.orgCode},
            #{item.num},
            #{item.createBy},
            now()
            )
        </foreach>
    </insert>
 
    <!-- 插入数据到 aps_bom_line -->
    <insert id="insertIntoApsBomLine">
        INSERT INTO aps_bom_line (
            id,
            bom_line_id,
            bom_header_id,
            item_code,
            item_name,
            start_date,
            end_date,
            org_code,
            num,
            create_by,
            create_time
        )
        SELECT
            id,
            bom_line_id,
            bom_header_id,
            item_code,
            item_name,
            start_date,
            end_date,
            org_code,
            num,
            create_by,
            now()
        FROM aps_bom_line_job
--         FROM aps_bom_line_job as a
--         LEFT JOIN aps_material_storage_management as b ON a.item_code = b.item_number
--         where b.material_type='制造件'
    </insert>
 
    <!-- 删除 aps_bom_line 表中的数据 -->
    <delete id="deleteApsBomLine">
        DELETE FROM aps_bom_line
    </delete>
 
    <!-- 删除 aps_bom_line_job 表中的数据 -->
    <delete id="deleteApsBomLineJob">
        DELETE FROM aps_bom_line_job
    </delete>
 
</mapper>