zhanghl
2025-05-19 668eed92806a814d0ea20fbab1caa7d1e6d197ea
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
219
220
221
222
223
224
225
226
227
228
229
230
231
<?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.core.mapper.ApsPlateStandardRequireMapper">
    
    <resultMap type="com.aps.core.domain.ApsPlate.ApsPlateStandardRequire" id="ApsPlateStandardRequireResult">
        <result property="id"    column="id"    />
        <result property="requireTrackId"    column="require_track_id"    />
        <result property="bomLineId"    column="bom_line_id"    />
        <result property="bomLineCode"    column="bom_line_code"    />
        <result property="bomLineLevel"    column="bom_line_level"    />
        <result property="bomUseAmount"    column="bom_use_amount"    />
        <result property="processRouteId"    column="process_route_id"    />
        <result property="processRouteHours"    column="process_route_hours"    />
        <result property="requireAmount"    column="require_amount"    />
        <result property="netRequirement"    column="net_requirement"    />
        <result property="startDate"    column="start_date"    />
        <result property="completeDate"    column="complete_date"    />
        <result property="demandDate"    column="demand_date"    />
        <result property="orgCode"    column="org_code"    />
        <result property="productionBase"    column="production_base"    />
        <result property="matchState"    column="match_state"    />
        <result property="matchMode"    column="match_mode"    />
        <result property="unmatchedDemandAmount"    column="unmatched_demand_amount"    />
        <result property="suggestedCompletionDate"    column="suggested_completion_date"    />
        <result property="hasDelayRisk"    column="has_delay_risk"    />
        <result property="batchNumber"    column="batch_number"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="orderCreateTime"    column="order_create_time"    />
    </resultMap>
 
    <sql id="selectApsPlateStandardRequireVo">
        select id, require_track_id, bom_line_id, bom_line_code, bom_line_level, bom_use_amount,
               process_route_id, process_route_hours, require_amount, net_requirement, start_date,
               complete_date, demand_date, org_code, production_base, match_state, match_mode,
               unmatched_demand_amount, suggested_completion_date, has_delay_risk, batch_number,
               del_flag, create_time, create_by, update_by, update_time,order_create_time
        from aps_plate_standard_require
    </sql>
 
    <select id="selectApsPlateStandardRequireList" parameterType="com.aps.core.domain.ApsPlate.ApsPlateStandardRequire" resultMap="ApsPlateStandardRequireResult">
        <include refid="selectApsPlateStandardRequireVo"/>
        <where>  
            <if test="requireTrackId != null  and requireTrackId != ''"> and require_track_id = #{requireTrackId}</if>
            <if test="bomLineId != null  and bomLineId != ''"> and bom_line_id = #{bomLineId}</if>
            <if test="bomLineCode != null  and bomLineCode != ''"> and bom_line_code = #{bomLineCode}</if>
            <if test="bomLineLevel != null "> and bom_line_level = #{bomLineLevel}</if>
            <if test="bomUseAmount != null  and bomUseAmount != ''"> and bom_use_amount = #{bomUseAmount}</if>
            <if test="processRouteId != null  and processRouteId != ''"> and process_route_id = #{processRouteId}</if>
            <if test="processRouteHours != null  and processRouteHours != ''"> and process_route_hours = #{processRouteHours}</if>
            <if test="requireAmount != null  and requireAmount != ''"> and require_amount = #{requireAmount}</if>
            <if test="netRequirement != null  and netRequirement != ''"> and net_requirement = #{netRequirement}</if>
            <if test="startDate != null  and startDate != ''"> and start_date = #{startDate}</if>
            <if test="completeDate != null  and completeDate != ''"> and complete_date = #{completeDate}</if>
            <if test="demandDate != null  and demandDate != ''"> and demand_date = #{demandDate}</if>
            <if test="orgCode != null  and orgCode != ''"> and org_code = #{orgCode}</if>
            <if test="productionBase != null  and productionBase != ''"> and production_base = #{productionBase}</if>
            <if test="matchState != null  and matchState != ''"> and match_state = #{matchState}</if>
            <if test="matchMode != null  and matchMode != ''"> and match_mode = #{matchMode}</if>
            <if test="unmatchedDemandAmount != null  and unmatchedDemandAmount != ''"> and unmatched_demand_amount = #{unmatchedDemandAmount}</if>
            <if test="suggestedCompletionDate != null  and suggestedCompletionDate != ''"> and suggested_completion_date = #{suggestedCompletionDate}</if>
            <if test="hasDelayRisk != null  and hasDelayRisk != ''"> and has_delay_risk = #{hasDelayRisk}</if>
            <if test="batchNumber != null  and batchNumber != ''"> and batch_number = #{batchNumber}</if>
        </where>
    </select>
    
    <select id="selectApsPlateStandardRequireById" parameterType="Long" resultMap="ApsPlateStandardRequireResult">
        <include refid="selectApsPlateStandardRequireVo"/>
        where id = #{id}
    </select>
 
    <insert id="insertApsPlateStandardRequire" parameterType="com.aps.core.domain.ApsPlate.ApsPlateStandardRequire">
        insert into aps_plate_standard_require
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="requireTrackId != null">require_track_id,</if>
            <if test="bomLineId != null">bom_line_id,</if>
            <if test="bomLineCode != null">bom_line_code,</if>
            <if test="bomLineLevel != null">bom_line_level,</if>
            <if test="bomUseAmount != null">bom_use_amount,</if>
            <if test="processRouteId != null">process_route_id,</if>
            <if test="processRouteHours != null">process_route_hours,</if>
            <if test="requireAmount != null">require_amount,</if>
            <if test="netRequirement != null">net_requirement,</if>
            <if test="startDate != null">start_date,</if>
            <if test="completeDate != null">complete_date,</if>
            <if test="demandDate != null">demand_date,</if>
            <if test="orgCode != null">org_code,</if>
            <if test="productionBase != null">production_base,</if>
            <if test="matchState != null">match_state,</if>
            <if test="matchMode != null">match_mode,</if>
            <if test="unmatchedDemandAmount != null">unmatched_demand_amount,</if>
            <if test="suggestedCompletionDate != null">suggested_completion_date,</if>
            <if test="hasDelayRisk != null">has_delay_risk,</if>
            <if test="batchNumber != null">batch_number,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="requireTrackId != null">#{requireTrackId},</if>
            <if test="bomLineId != null">#{bomLineId},</if>
            <if test="bomLineCode != null">#{bomLineCode},</if>
            <if test="bomLineLevel != null">#{bomLineLevel},</if>
            <if test="bomUseAmount != null">#{bomUseAmount},</if>
            <if test="processRouteId != null">#{processRouteId},</if>
            <if test="processRouteHours != null">#{processRouteHours},</if>
            <if test="requireAmount != null">#{requireAmount},</if>
            <if test="netRequirement != null">#{netRequirement},</if>
            <if test="startDate != null">#{startDate},</if>
            <if test="completeDate != null">#{completeDate},</if>
            <if test="demandDate != null">#{demandDate},</if>
            <if test="orgCode != null">#{orgCode},</if>
            <if test="productionBase != null">#{productionBase},</if>
            <if test="matchState != null">#{matchState},</if>
            <if test="matchMode != null">#{matchMode},</if>
            <if test="unmatchedDemandAmount != null">#{unmatchedDemandAmount},</if>
            <if test="suggestedCompletionDate != null">#{suggestedCompletionDate},</if>
            <if test="hasDelayRisk != null">#{hasDelayRisk},</if>
            <if test="batchNumber != null">#{batchNumber},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>
 
    <update id="updateApsPlateStandardRequire" parameterType="com.aps.core.domain.ApsPlate.ApsPlateStandardRequire">
        update aps_plate_standard_require
        <trim prefix="SET" suffixOverrides=",">
            <if test="requireTrackId != null">require_track_id = #{requireTrackId},</if>
            <if test="bomLineId != null">bom_line_id = #{bomLineId},</if>
            <if test="bomLineCode != null">bom_line_code = #{bomLineCode},</if>
            <if test="bomLineLevel != null">bom_line_level = #{bomLineLevel},</if>
            <if test="bomUseAmount != null">bom_use_amount = #{bomUseAmount},</if>
            <if test="processRouteId != null">process_route_id = #{processRouteId},</if>
            <if test="processRouteHours != null">process_route_hours = #{processRouteHours},</if>
            <if test="requireAmount != null">require_amount = #{requireAmount},</if>
            <if test="netRequirement != null">net_requirement = #{netRequirement},</if>
            <if test="startDate != null">start_date = #{startDate},</if>
            <if test="completeDate != null">complete_date = #{completeDate},</if>
            <if test="demandDate != null">demand_date = #{demandDate},</if>
            <if test="orgCode != null">org_code = #{orgCode},</if>
            <if test="productionBase != null">production_base = #{productionBase},</if>
            <if test="matchState != null">match_state = #{matchState},</if>
            <if test="matchMode != null">match_mode = #{matchMode},</if>
            <if test="unmatchedDemandAmount != null">unmatched_demand_amount = #{unmatchedDemandAmount},</if>
            <if test="suggestedCompletionDate != null">suggested_completion_date = #{suggestedCompletionDate},</if>
            <if test="hasDelayRisk != null">has_delay_risk = #{hasDelayRisk},</if>
            <if test="batchNumber != null">batch_number = #{batchNumber},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteApsPlateStandardRequireById" parameterType="Long">
        delete from aps_plate_standard_require where id = #{id}
    </delete>
 
    <delete id="deleteApsPlateStandardRequireByIds" parameterType="String">
        delete from aps_plate_standard_require where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
    <select id="selectPlateSupplyGapList" parameterType="com.aps.core.domain.ApsPlate.ApsPlateStandardRequire" resultMap="ApsPlateStandardRequireResult">
        select id, require_track_id, bom_line_code, bom_line_level,
               match_state, match_mode, unmatched_demand_amount, start_date,
               complete_date, demand_date, org_code, production_base
        from aps_plate_standard_require where unmatched_demand_amount>0 and del_flag='0' and bom_line_level>0
        <if test="requireTrackId != null and requireTrackId != ''"> and require_track_id like '%' || #{requireTrackId} || '%'</if>
        <if test="bomLineCode != null and bomLineCode != ''"> and bom_line_code like '%' || #{bomLineCode} || '%'</if>
    </select>
 
    <insert id="batchInsert" parameterType="java.util.List">
        insert into aps_plate_standard_require
        (id, require_track_id,doc_num,batch_number, org_code, bom_header_code,bom_line_id, bom_line_code, bom_line_level, bom_use_amount, process_route_id,
         process_route_hours, require_amount, net_requirement, start_date, complete_date, demand_date,
         production_base, match_state, match_mode, unmatched_demand_amount, suggested_completion_date,
         has_delay_risk, del_flag, create_time, create_by,order_create_time)
        values
        <foreach collection="list" item="item" separator=",">
        (
            #{item.id},
            #{item.requireTrackId},
            #{item.docNum},
            #{item.batchNumber},
            #{item.orgCode},
            #{item.bomHeaderCode},
            #{item.bomLineId},
            #{item.bomLineCode},
            #{item.bomLineLevel},
            #{item.bomUseAmount},
            #{item.processRouteId},
            #{item.processRouteHours},
            #{item.requireAmount},
            #{item.netRequirement},
            #{item.startDate},
            #{item.completeDate},
            #{item.demandDate},
            #{item.productionBase},
            #{item.matchState},
            #{item.matchMode},
            #{item.unmatchedDemandAmount},
            #{item.suggestedCompletionDate},
            #{item.hasDelayRisk},
            #{item.delFlag},
            #{item.createTime},
            #{item.createBy},
            #{item.orderCreateTime}
        )
        </foreach>
    </insert>
    <update id="deleteLastPatch" parameterType="String">
        update aps_plate_standard_require set del_flag = '1' where batch_number = #{batchNumber}
    </update>
</mapper>