ProcurementPlanMapper.xml
16.4 KB
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<?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.lframework.xingyun.sc.procurement.mappers.plan.ProcurementPlanMapper">
<resultMap id="ProcurementPlan" type="com.lframework.xingyun.sc.procurement.entity.ProcurementPlan">
<id column="id" property="id"/>
<result column="parent_id" property="parentId"/>
<result column="code" property="code"/>
<result column="company_short_id" property="companyShortId"/>
<result column="company_short_name" property="companyShortName"/>
<result column="company_full_name" property="companyFullName"/>
<result column="supplier_id" property="supplierId"/>
<result column="supplier_name" property="supplierName"/>
<result column="purchase_department" property="purchaseDepartment"/>
<result column="purchase_department_name" property="purchaseDepartmentName"/>
<result column="region" property="region"/>
<result column="region_name" property="regionName"/>
<result column="date" property="date"/>
<result column="validity_period" property="validityPeriod"/>
<result column="quoter_id" property="quoterId"/>
<result column="quoter_name" property="quoterName"/>
<result column="long_term_operation" property="longTermOperation"/>
<result column="terminal_customer" property="terminalCustomer"/>
<result column="priced" property="priced"/>
<result column="pricing_deadline" property="pricingDeadline"/>
<result column="temporary_price" property="temporaryPrice"/>
<result column="other_expense_settlement" property="otherExpenseSettlement"/>
<result column="delivery_mode" property="deliveryMode"/>
<result column="commodity_buyout" property="commodityBuyout"/>
<result column="quality_buyout" property="qualityBuyout"/>
<result column="quantity_buyout" property="quantityBuyout"/>
<result column="door_delivery" property="doorDelivery"/>
<result column="shipping_cost" property="shippingCost"/>
<result column="loading_fee" property="loadingFee"/>
<result column="invoice_product_name" property="invoiceProductName"/>
<result column="delivery_date" property="deliveryDate"/>
<result column="settlement_method" property="settlementMethod"/>
<result column="settlement_ratio" property="settlementRatio"/>
<result column="price_id" property="priceId"/>
<result column="price_code" property="priceCode"/>
<result column="coordination_reason" property="coordinationReason"/>
<result column="invoice_type_status" property="invoiceTypeStatus"/>
<result column="total_quantity" property="totalQuantity"/>
<result column="remark" property="remark"/>
<result column="material_condition_enabled" property="materialConditionEnabled"/>
<result column="material_condition_copper_rice" property="materialConditionCopperRice"/>
<result column="material_condition_bright_copper" property="materialConditionBrightCopper"/>
<result column="material_condition_first_class" property="materialConditionFirstClass"/>
<result column="material_condition_second_class" property="materialConditionSecondClass"/>
<result column="material_condition_tin_coated" property="materialConditionTinCoated"/>
<result column="material_condition_scrap" property="materialConditionScrap"/>
<result column="material_condition_white_yellow" property="materialConditionWhiteYellow"/>
<result column="material_condition_phosphor_copper" property="materialConditionPhosphorCopper"/>
<result column="approval_status" property="approvalStatus"/>
<result column="process_status" property="processStatus"/>
<result column="process_node" property="processNode"/>
<result column="frozen" property="frozen"/>
<result column="plan_type" property="planType"/>
<result column="change_status" property="changeStatus"/>
<result column="replenishment_status" property="replenishmentStatus"/>
<result column="workshop_id" property="workshopId"/>
<result column="workshop_name" property="workshopName"/>
<result column="salesman_quotation_id" property="salesmanQuotationId"/>
<result column="attachment_file_ids" property="attachmentFileIds"/>
<result column="attachment_file_names" property="attachmentFileNames"/>
<result column="deleted" property="deleted"/>
<result column="general_manager_name" property="generalManagerName"/>
<result column="marketing_manager_name" property="marketingManagerName"/>
<result column="supply_manager_name" property="supplyManagerName"/>
<result column="management_dept_name" property="managementDeptName"/>
<result column="purchase_dept_name" property="purchaseDeptName"/>
<result column="approval_pass_time" property="approvalPassTime"/>
<result column="create_by_id" property="createById"/>
<result column="create_by" property="createBy"/>
<result column="update_by_id" property="updateById"/>
<result column="update_by" property="updateBy"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<sql id="ProcurementPlan_sql">
SELECT
pp.id,
pp.parent_id,
pp.code,
pp.company_short_id,
bdcs.short_name AS company_short_name,
bdcs.company_name AS company_full_name,
pp.supplier_id,
pdc.unit_name AS supplier_name,
pp.purchase_department,
sd.name AS purchase_department_name,
pp.region,
sd1.name AS region_name,
pp.date,
pp.validity_period,
pp.quoter_id,
pp.quoter_name,
pp.long_term_operation,
pp.terminal_customer,
pp.priced,
pp.pricing_deadline,
pp.temporary_price,
pp.other_expense_settlement,
pp.delivery_mode,
pp.commodity_buyout,
pp.quality_buyout,
pp.quantity_buyout,
pp.door_delivery,
pp.shipping_cost,
pp.loading_fee,
pp.invoice_product_name,
pp.delivery_date,
pp.settlement_method,
pp.settlement_ratio,
pp.price_id,
dp.code AS price_code,
pp.coordination_reason,
pp.invoice_type_status,
pp.total_quantity,
pp.remark,
pp.material_condition_enabled,
pp.material_condition_copper_rice,
pp.material_condition_bright_copper,
pp.material_condition_first_class,
pp.material_condition_second_class,
pp.material_condition_tin_coated,
pp.material_condition_scrap,
pp.material_condition_white_yellow,
pp.material_condition_phosphor_copper,
pp.approval_status,
pp.process_status,
pp.process_node,
pp.frozen,
pp.plan_type,
pp.change_status,
pp.replenishment_status,
pp.workshop_id,
ws.name AS workshop_name,
pp.salesman_quotation_id,
pp.attachment_file_ids,
pp.attachment_file_names,
pp.deleted,
pp.general_manager_name,
pp.marketing_manager_name,
pp.supply_manager_name,
pp.management_dept_name,
pp.purchase_dept_name,
pp.approval_pass_time,
pp.create_by_id,
pp.create_by,
pp.update_by_id,
pp.update_by,
pp.create_time,
pp.update_time
FROM procurement_plan AS pp
LEFT JOIN base_data_company_short AS bdcs ON bdcs.id = pp.company_short_id
LEFT JOIN procurement_domestic_customer_credit pdc ON pdc.id = pp.supplier_id
LEFT JOIN sys_dept sd ON sd.id = pp.purchase_department
LEFT JOIN sys_dept sd1 ON sd1.id = pp.region
LEFT JOIN base_data_workshop as ws on ws.id = pp.workshop_id
LEFT JOIN base_data_price as dp on dp.id = pp.price_id
</sql>
<select id="query" resultMap="ProcurementPlan">
<include refid="ProcurementPlan_sql"/>
<where>
AND pp.deleted = 0
<if test="vo != null">
<if test="vo.code != null and vo.code != ''">
AND pp.code LIKE CONCAT('%', #{vo.code}, '%')
</if>
<if test="vo.companyShortId != null and vo.companyShortId != ''">
AND pp.company_short_id = #{vo.companyShortId}
</if>
<if test="vo.companyName != null and vo.companyName != ''">
AND (
bdcs.company_name LIKE CONCAT('%', #{vo.companyName}, '%')
OR bdcs.short_name LIKE CONCAT('%', #{vo.companyName}, '%')
)
</if>
<if test="vo.purchaseDepartment != null and vo.purchaseDepartment != ''">
AND pp.purchase_department = #{vo.purchaseDepartment}
</if>
<if test="vo.startDate != null">
AND pp.date >= #{vo.startDate}
</if>
<if test="vo.endDate != null">
<![CDATA[
AND pp.date <= #{vo.endDate}
]]>
</if>
<if test="vo.supplierId != null and vo.supplierId != ''">
AND pp.supplier_id = #{vo.supplierId}
</if>
<if test="vo.supplierName != null and vo.supplierName != ''">
AND pdc.unit_name LIKE CONCAT('%', #{vo.supplierName}, '%')
</if>
<if test="vo.processStatus != null and vo.processStatus != ''">
AND pp.process_status = #{vo.processStatus}
</if>
<if test="vo.processNode != null and vo.processNode != ''">
AND pp.process_node = #{vo.processNode}
</if>
<if test="vo.frozen != null">
AND pp.frozen = #{vo.frozen}
</if>
<if test="vo.planType != null and vo.planType != ''">
AND pp.plan_type LIKE CONCAT('%', #{vo.planType}, '%')
</if>
<if test="vo.workshopId != null and vo.workshopId != ''">
AND pp.workshop_id = #{vo.workshopId}
</if>
</if>
</where>
ORDER BY pp.create_time DESC
</select>
<select id="findById" resultMap="ProcurementPlan">
<include refid="ProcurementPlan_sql"/>
WHERE pp.id = #{id}
</select>
<select id="queryCanChangeOrReplenishmentList" resultMap="ProcurementPlan">
<include refid="ProcurementPlan_sql"/>
<where>
pp.parent_id IS NULL
AND pp.deleted = 0
AND NOT EXISTS (
SELECT 1 FROM procurement_plan p
WHERE p.id = pp.parent_id
AND (p.change_status = 'CHANGING' OR p.replenishment_status = 'REPLENISHING')
)
<if test="vo != null">
<if test="vo.code != null and vo.code != ''">
AND pp.code LIKE CONCAT('%', #{vo.code}, '%')
</if>
<if test="vo.companyShortId != null and vo.companyShortId != ''">
AND pp.company_short_id = #{vo.companyShortId}
</if>
<if test="vo.companyName != null and vo.companyName != ''">
AND (
bdcs.company_name LIKE CONCAT('%', #{vo.companyName}, '%')
OR bdcs.short_name LIKE CONCAT('%', #{vo.companyName}, '%')
)
</if>
<if test="vo.purchaseDepartment != null and vo.purchaseDepartment != ''">
AND pp.purchase_department = #{vo.purchaseDepartment}
</if>
<if test="vo.startDate != null">
AND pp.date >= #{vo.startDate}
</if>
<if test="vo.endDate != null">
<![CDATA[
AND pp.date <= #{vo.endDate}
]]>
</if>
<if test="vo.supplierId != null and vo.supplierId != ''">
AND pp.supplier_id = #{vo.supplierId}
</if>
<if test="vo.supplierName != null and vo.supplierName != ''">
AND pdc.unit_name LIKE CONCAT('%', #{vo.supplierName}, '%')
</if>
<if test="vo.workshopId != null and vo.workshopId != ''">
AND pp.workshop_id = #{vo.workshopId}
</if>
<choose>
<when test="vo.queryType == 'CHANGE'">
AND pp.process_status IN ('COMPLETED', 'ABORTED')
AND (pp.change_status = '' OR pp.change_status IS NULL OR pp.change_status = 'CHANGED')
AND (pp.replenishment_status = '' OR pp.replenishment_status IS NULL OR pp.replenishment_status
= 'REPLENISHED')
</when>
<when test="vo.queryType == 'REPLENISHMENT'">
AND pp.process_status IN ('COMPLETED', 'ABORTED')
AND pp.plan_type NOT LIKE '%补%'
AND (pp.replenishment_status = '' OR pp.replenishment_status IS NULL OR pp.replenishment_status
= 'REPLENISHED')
AND (pp.change_status = '' OR pp.change_status IS NULL OR pp.change_status = 'CHANGED')
</when>
<otherwise>
AND 1 = 0
</otherwise>
</choose>
</if>
</where>
ORDER BY pp.create_time DESC
</select>
<select id="queryCanFastChangeList" resultMap="ProcurementPlan">
<include refid="ProcurementPlan_sql"/>
<where>
pp.process_status IN ('COMPLETED', 'ABORTED')
AND (pp.change_status = '' OR pp.change_status IS NULL OR pp.change_status = 'CHANGED')
AND (pp.replenishment_status = '' OR pp.replenishment_status IS NULL OR pp.replenishment_status
= 'REPLENISHED')
AND pp.deleted = 0
AND NOT EXISTS (
SELECT 1 FROM procurement_plan p
WHERE p.id = pp.parent_id
AND (p.change_status = 'CHANGING' OR p.replenishment_status = 'REPLENISHING')
)
<if test="vo != null">
<if test="vo.code != null and vo.code != ''">
AND pp.code LIKE CONCAT('%', #{vo.code}, '%')
</if>
<if test="vo.companyShortId != null and vo.companyShortId != ''">
AND pp.company_short_id = #{vo.companyShortId}
</if>
<if test="vo.companyName != null and vo.companyName != ''">
AND (
bdcs.company_name LIKE CONCAT('%', #{vo.companyName}, '%')
OR bdcs.short_name LIKE CONCAT('%', #{vo.companyName}, '%')
)
</if>
<if test="vo.purchaseDepartment != null and vo.purchaseDepartment != ''">
AND pp.purchase_department = #{vo.purchaseDepartment}
</if>
<if test="vo.startDate != null">
AND pp.date >= #{vo.startDate}
</if>
<if test="vo.endDate != null">
<![CDATA[
AND pp.date <= #{vo.endDate}
]]>
</if>
<if test="vo.supplierId != null and vo.supplierId != ''">
AND pp.supplier_id = #{vo.supplierId}
</if>
<if test="vo.supplierName != null and vo.supplierName != ''">
AND pdc.unit_name LIKE CONCAT('%', #{vo.supplierName}, '%')
</if>
<if test="vo.workshopId != null and vo.workshopId != ''">
AND pp.workshop_id = #{vo.workshopId}
</if>
</if>
</where>
ORDER BY pp.create_time DESC
</select>
</mapper>