From 599091b729527d65343ae79a54a74cd194b8e64b Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期三, 19 八月 2026 10:19:51 +0800
Subject: [PATCH] feat: 生产合并下发展示多个销售单号
---
src/main/resources/mapper/stock/StockInRecordMapper.xml | 68 ++++++++++++++--------------------
1 files changed, 28 insertions(+), 40 deletions(-)
diff --git a/src/main/resources/mapper/stock/StockInRecordMapper.xml b/src/main/resources/mapper/stock/StockInRecordMapper.xml
index 55c589b..2c04a10 100644
--- a/src/main/resources/mapper/stock/StockInRecordMapper.xml
+++ b/src/main/resources/mapper/stock/StockInRecordMapper.xml
@@ -30,13 +30,37 @@
WHEN TRIM(sir.record_type) IN ('14', '15') THEN
sl_return.sales_contract_no
WHEN TRIM(sir.record_type) IN ('2', '5') THEN
- COALESCE(po_sales_main.sales_contract_no, po_main.nps_no)
+ COALESCE((
+ select group_concat(distinct sl2.sales_contract_no order by sl2.sales_contract_no separator ',')
+ from production_plan pp2
+ left join sales_ledger sl2 on sl2.id = pp2.sales_ledger_id
+ where find_in_set(pp2.id, replace(replace(replace(po_main.production_plan_ids, '[', ''), ']', ''), ' ', '')) > 0
+ and pp2.product_model_id = sir.product_model_id
+ ), po_main.nps_no)
WHEN TRIM(sir.record_type) = '6' THEN
- COALESCE(po_sales_qi.sales_contract_no, po_qi.nps_no)
+ COALESCE((
+ select group_concat(distinct sl2.sales_contract_no order by sl2.sales_contract_no separator ',')
+ from production_plan pp2
+ left join sales_ledger sl2 on sl2.id = pp2.sales_ledger_id
+ where find_in_set(pp2.id, replace(replace(replace(po_qi.production_plan_ids, '[', ''), ']', ''), ' ', '')) > 0
+ and pp2.product_model_id = sir.product_model_id
+ ), po_qi.nps_no)
WHEN TRIM(sir.record_type) IN ('4', '11') THEN
- COALESCE(po_sales_uq.sales_contract_no, po_uq.nps_no)
+ COALESCE((
+ select group_concat(distinct sl2.sales_contract_no order by sl2.sales_contract_no separator ',')
+ from production_plan pp2
+ left join sales_ledger sl2 on sl2.id = pp2.sales_ledger_id
+ where find_in_set(pp2.id, replace(replace(replace(po_uq.production_plan_ids, '[', ''), ']', ''), ' ', '')) > 0
+ and pp2.product_model_id = sir.product_model_id
+ ), po_uq.nps_no)
WHEN TRIM(sir.record_type) IN ('20', '22') THEN
- COALESCE(po_sales_pick.sales_contract_no, po_pick.nps_no)
+ COALESCE((
+ select group_concat(distinct sl2.sales_contract_no order by sl2.sales_contract_no separator ',')
+ from production_plan pp2
+ left join sales_ledger sl2 on sl2.id = pp2.sales_ledger_id
+ where find_in_set(pp2.id, replace(replace(replace(po_pick.production_plan_ids, '[', ''), ']', ''), ' ', '')) > 0
+ and pp2.product_model_id = sir.product_model_id
+ ), po_pick.nps_no)
ELSE NULL
END
ELSE NULL
@@ -54,56 +78,20 @@
LEFT JOIN production_product_main as ppm_main on TRIM(sir.record_type) IN ('2', '5') and sir.record_id = ppm_main.id
LEFT JOIN production_operation_task as pot_main on ppm_main.production_operation_task_id = pot_main.id
LEFT JOIN production_order as po_main on pot_main.production_order_id = po_main.id
- LEFT JOIN (
- select po2.id as production_order_id,
- group_concat(distinct sl2.sales_contract_no order by sl2.sales_contract_no separator ',') as sales_contract_no
- from production_order po2
- left join production_plan pp2
- on find_in_set(pp2.id, replace(replace(replace(po2.production_plan_ids, '[', ''), ']', ''), ' ', '')) > 0
- left join sales_ledger sl2 on sl2.id = pp2.sales_ledger_id
- group by po2.id
- ) as po_sales_main on po_sales_main.production_order_id = po_main.id
LEFT JOIN quality_inspect as qi_prod on TRIM(sir.record_type) = '6' and sir.record_id = qi_prod.id
LEFT JOIN production_product_main as ppm_qi on qi_prod.product_main_id = ppm_qi.id
LEFT JOIN production_operation_task as pot_qi on ppm_qi.production_operation_task_id = pot_qi.id
LEFT JOIN production_order as po_qi on pot_qi.production_order_id = po_qi.id
- LEFT JOIN (
- select po2.id as production_order_id,
- group_concat(distinct sl2.sales_contract_no order by sl2.sales_contract_no separator ',') as sales_contract_no
- from production_order po2
- left join production_plan pp2
- on find_in_set(pp2.id, replace(replace(replace(po2.production_plan_ids, '[', ''), ']', ''), ' ', '')) > 0
- left join sales_ledger sl2 on sl2.id = pp2.sales_ledger_id
- group by po2.id
- ) as po_sales_qi on po_sales_qi.production_order_id = po_qi.id
LEFT JOIN quality_unqualified as qu on TRIM(sir.record_type) IN ('4', '11') and sir.record_id = qu.id
LEFT JOIN quality_inspect as qi_uq on qu.inspect_id = qi_uq.id
LEFT JOIN production_product_main as ppm_uq on qi_uq.product_main_id = ppm_uq.id
LEFT JOIN production_operation_task as pot_uq on ppm_uq.production_operation_task_id = pot_uq.id
LEFT JOIN production_order as po_uq on pot_uq.production_order_id = po_uq.id
- LEFT JOIN (
- select po2.id as production_order_id,
- group_concat(distinct sl2.sales_contract_no order by sl2.sales_contract_no separator ',') as sales_contract_no
- from production_order po2
- left join production_plan pp2
- on find_in_set(pp2.id, replace(replace(replace(po2.production_plan_ids, '[', ''), ']', ''), ' ', '')) > 0
- left join sales_ledger sl2 on sl2.id = pp2.sales_ledger_id
- group by po2.id
- ) as po_sales_uq on po_sales_uq.production_order_id = po_uq.id
LEFT JOIN production_order_pick as pop on TRIM(sir.record_type) IN ('20', '22') and sir.record_id = pop.id
LEFT JOIN production_order as po_pick on pop.production_order_id = po_pick.id
- LEFT JOIN (
- select po2.id as production_order_id,
- group_concat(distinct sl2.sales_contract_no order by sl2.sales_contract_no separator ',') as sales_contract_no
- from production_order po2
- left join production_plan pp2
- on find_in_set(pp2.id, replace(replace(replace(po2.production_plan_ids, '[', ''), ']', ''), ' ', '')) > 0
- left join sales_ledger sl2 on sl2.id = pp2.sales_ledger_id
- group by po2.id
- ) as po_sales_pick on po_sales_pick.production_order_id = po_pick.id
LEFT JOIN return_sale_product as rsp on TRIM(sir.record_type) IN ('14', '15') and sir.record_id = rsp.id
LEFT JOIN return_management as rm on rsp.return_management_id = rm.id
--
Gitblit v1.9.3