From f02d0df2f1dfc7a8b775cf50d45375e57628a5ef Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 10 十一月 2026 11:26:22 +0800
Subject: [PATCH] feat(ncr): 完善NCR处置联动逻辑与关闭校验

---
 docs/project-business/mermaid/05-quality-flow.mmd                                                                                     |    8 
 sql/mysql/20261110_misc_issue_rework_type.sql                                                                                         |    4 
 yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmOqcConcessionGuardTest.java                   |   40 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/productsales/MesWmProductSalesLineDO.java                |    2 
 sql/mysql/20261110_mes_qc_ncr_reinspection.sql                                                                                        |    3 
 sql/mysql/20261110_product_sales_ncr_disposition.sql                                                                                  |    3 
 yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcReproductionServiceTest.java                     |  123 ++
 yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrScrapServiceTest.java                               |  122 ++
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/MesQcPurchaseReturnController.java                 |   42 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/productproduce/MesWmProductProduceLineDO.java            |    2 
 yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationDocumentRenderer.java                    |    2 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/MesQcCompletionHelper.java                                      |    5 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/ncr/MesQcPurchaseConcessionMapper.java                        |   13 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/vo/MesQcNcrRespVO.java                             |    3 
 yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcArrivalDispositionServiceTest.java                     |   48 
 yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcConcessionServiceTest.java                       |   83 +
 yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationExcelRenderer.java                       |  100 +
 sql/mysql/20261110_qc_purchase_return.sql                                                                                             |   28 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/MesQcNcrController.java                            |    2 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/itemreceipt/vo/line/MesWmItemReceiptLineSaveReqVO.java |    3 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrService.java                                        |    4 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesServiceImpl.java                    |   16 
 docs/project-business/data/flows.json                                                                                                 |    2 
 sql/mysql/20261110_qc_purchase_concession.sql                                                                                         |   17 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcArrivalDispositionService.java                         |   52 
 docs/mes_qc_ncr_integration.md                                                                                                        |   37 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/itemreceipt/MesWmItemReceiptServiceImpl.java                    |    8 
 yudao-module-mes/src/test/resources/sql/create_tables.sql                                                                             |    3 
 yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrStockClosureGuardTest.java                          |   29 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcSourceClaim.java                                 |   51 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesLineServiceImpl.java                |   17 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/ncr/MesQcPurchaseReturnDO.java                           |   33 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/rqc/MesQcRqcServiceImpl.java                                    |    2 
 sql/mysql/20261110_mes_qc_ncr_return_sales.sql                                                                                        |    3 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesDetailServiceImpl.java            |   33 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrServiceImpl.java                                    |  168 ++
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcReproductionService.java                         |  176 ++
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrReturnSalesLink.java                                |   61 +
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/qc/MesNcrDispositionEnum.java                                        |    3 
 yudao-module-crm/src/test/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationExcelRendererTest.java                   |   52 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/wm/MesWmMiscIssueTypeEnum.java                                       |    3 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmOqcConcessionGuard.java                       |   69 +
 yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/quotation/CrmSaleQuotationController.java                 |   20 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/ncr/MesQcNcrMapper.java                                       |    6 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrPurchaseSourceValidator.java                        |   58 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcPurchaseConcessionService.java                         |   77 +
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrStockClosureGuard.java                              |   31 
 yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcPurchaseReturnServiceTest.java                         |   48 
 sql/mysql/20261110_wm_scrap_return_source.sql                                                                                         |    4 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/vo/MesQcNcrDisposeReqVO.java                       |    7 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesServiceImpl.java                  |   50 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/vo/MesQcNcrCloseReqVO.java                         |    3 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/ncr/MesQcPurchaseReturnMapper.java                            |   34 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/returnsales/MesWmReturnSalesMapper.java                       |    5 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcReworkService.java                               |  398 ++++++
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcPurchaseReturnService.java                             |   74 +
 sql/mysql/20261110_ncr_reproduction_dict.sql                                                                                          |    4 
 yudao-module-crm/src/main/resources/templates/quotation/sale-quotation.xlsx                                                           |    0 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/returnsales/MesWmReturnSalesLineDO.java                  |    2 
 yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcPurchaseConcessionServiceTest.java                     |   63 +
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/ncr/MesQcPurchaseConcessionDO.java                       |   21 
 yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcReworkServiceTest.java                           |  250 ++++
 yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrPurchaseSourceValidatorTest.java                    |   50 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/listener/MesQcNcrStatusListener.java                        |    2 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/arrivalnotice/MesWmArrivalNoticeServiceImpl.java                |   26 
 yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrGuardTest.java                                      |   79 +
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcConcessionService.java                           |  156 ++
 yudao-module-crm/src/main/resources/templates/contract/sale-contract.docx                                                             |    0 
 yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrReinspectionValidatorTest.java                      |  112 +
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrReinspectionValidator.java                          |  148 ++
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrScrapService.java                                   |  169 ++
 docs/project-business/data/objects.json                                                                                               |    4 
 sql/mysql/20261110_product_produce_ncr_disposition.sql                                                                                |    3 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/itemreceipt/MesWmItemReceiptLineServiceImpl.java                |    3 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesLineService.java                    |    3 
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/ncr/MesQcNcrDO.java                                      |    3 
 yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractDocumentRenderer.java                          |  130 +
 yudao-module-crm/src/test/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractDocumentRendererTest.java                      |    9 
 yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/wm/miscissue/MesWmMiscIssueServiceImplTest.java                    |   66 +
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/miscissue/MesWmMiscIssueServiceImpl.java                        |    1 
 80 files changed, 3,493 insertions(+), 101 deletions(-)

diff --git a/docs/mes_qc_ncr_integration.md b/docs/mes_qc_ncr_integration.md
index 0d1d340..c956e51 100644
--- a/docs/mes_qc_ncr_integration.md
+++ b/docs/mes_qc_ncr_integration.md
@@ -11,7 +11,7 @@
 ## 涓氬姟娴佺▼涓庢暟鎹甫鍏�
 
 1. **妫�楠屽垽瀹氫笉鍚堟牸 鈫� NCR 鍒涘缓**锛氬湪鍚勬楠屽崟璇︽儏椤碉紝褰撴楠岀粨鏋滀负"涓嶅悎鏍奸��璐�"鎴�"涓嶅悎鏍兼姤搴�"鏃讹紝鍙偣鍑�"鐢熸垚NCR"鎸夐挳锛岃嚜鍔ㄥ甫鍏ユ楠岀被鍨嬨�佹楠屽崟ID/缂栧彿銆佺墿鏂欎俊鎭�佷笉鍚堟牸鏁伴噺銆佷笉鍚堟牸鎻忚堪锛岃烦杞埌 NCR 鏂板缓椤甸潰銆�
-2. **NCR 寰呰瘎瀹� 鈫� 璇勫**锛氬~鍐欏缃柟寮忥紙閫�璐�/鎶ュ簾/杩斿伐/璁╂鎺ユ敹/闄嶇骇浣跨敤锛夈�佽矗浠婚儴闂ㄣ�佺己闄风瓑绾с�佽瘎瀹℃剰瑙併��
+2. **NCR 寰呰瘎瀹� 鈫� 璇勫**锛氭寜妫�楠岀被鍨嬮�夋嫨澶勭疆鏂瑰紡锛圛QC 閫�璐�/璁╂鏀捐锛汭PQC 鎶ュ簾/杩斿伐/璁╂鏀捐/杩斾慨/閲嶆柊鐢熶骇锛汷QC 杩斿伐/璁╂鏀捐/杩斾慨/閲嶆柊鐢熶骇锛汻QC 鎶ュ簾/杩斿伐/璁╂鏀捐/杩斾慨锛夛紝骞跺~鍐欒矗浠婚儴闂ㄣ�佺己闄风瓑绾с�佽瘎瀹℃剰瑙併��
 3. **NCR 宸茶瘎瀹� 鈫� 澶勭疆**锛氬~鍐欏鐞嗕汉銆佸鐞嗙粨鏋滆鏄庛��
 4. **NCR 宸插缃� 鈫� 鍏抽棴**锛氬~鍐欏叧闂剰瑙併��
 
@@ -65,7 +65,7 @@
 | 鍙傛暟 | 绫诲瀷 | 蹇呭~ | 璇存槑 |
 |------|------|------|------|
 | id | Long | 鏄� | NCR缂栧彿 |
-| disposition | Integer | 鏄� | 澶勭疆鏂瑰紡锛�1=閫�璐�/2=鎶ュ簾/3=杩斿伐/4=璁╂鎺ユ敹/5=闄嶇骇浣跨敤锛� |
+| disposition | Integer | 鏄� | 澶勭疆鏂瑰紡锛�1=閫�璐�/2=鎶ュ簾/3=杩斿伐/4=璁╂鎺ユ敹/5=闄嶇骇浣跨敤/6=杩斾慨/7=閲嶆柊鐢熶骇锛� |
 | responsibleDeptId | Long | 鍚� | 璐d换閮ㄩ棬ID |
 | defectLevel | Integer | 鍚� | 缂洪櫡绛夌骇 |
 | reviewOpinion | String | 鍚� | 璇勫鎰忚 |
@@ -74,18 +74,28 @@
 
 **PUT** `/mes/qc/ncr/dispose`
 
-澶勭疆浼氳仈鍔ㄧ敓鎴愪笟鍔″崟鎹細璁╂鏀捐(4)/鎶ュ簾(2) 鐢熸垚鏉傞」鍏ュ簱鍗曞苟鑷姩鎻愪氦銆佸畬鎴愬叆搴擄紱杩斿伐(3)/杩斾慨(6) 鐢熸垚鑷鐢熶骇绫诲瀷鐢熶骇璁㈠崟锛堣崏绋匡級銆�
+澶勭疆浼氳仈鍔ㄧ敓鎴愪笟鍔″崟鎹細璁╂鏀捐(4)/鎶ュ簾(2) 鐢熸垚鏉傞」鍏ュ簱鍗曞苟鑷姩鎻愪氦銆佸畬鎴愬叆搴擄紱杩斿伐(3)/杩斾慨(6) 鐢熸垚鑷鐢熶骇绫诲瀷鐢熶骇璁㈠崟锛堣崏绋匡級锛涘嚭璐ф楠岋紙OQC锛夌殑杩斿伐/杩斾慨浼氭墸鍑忓師鎵规鎴愬搧搴撳瓨銆佽嚜鍔ㄥ彇娑堝師閿�鍞嚭搴撳崟骞剁敓鎴愬凡涓嬭揪鐨勮繑宸ュ伐鍗曪紱閲嶆柊鐢熶骇(7) 澶嶅埗鍘熷伐鍗曞伐搴忎笌 BOM 涓嬭揪鏂板伐鍗曘��
+
+鍙�夌殑澶勭疆鏂瑰紡鍙栧喅浜庢楠屾潵婧愶紙`qcType`锛夛細
+
+| qcType | 鍙缃柟寮� |
+|---|---|
+| 1 IQC | 閫�璐�(1)銆佽姝ユ斁琛�(4) |
+| 2 IPQC | 鎶ュ簾(2)銆佽繑宸�(3)銆佽姝ユ斁琛�(4)銆佽繑淇�(6)銆侀噸鏂扮敓浜�(7) |
+| 3 OQC | 杩斿伐(3)銆佽姝ユ斁琛�(4)銆佽繑淇�(6)銆侀噸鏂扮敓浜�(7) |
+| 4 RQC | 鎶ュ簾(2)銆佽繑宸�(3)銆佽姝ユ斁琛�(4)銆佽繑淇�(6) |
 
 璇锋眰鍙傛暟锛�
 
 | 鍙傛暟 | 绫诲瀷 | 蹇呭~ | 璇存槑 |
 |------|------|------|------|
 | id | Long | 鏄� | NCR缂栧彿 |
-| disposition | Integer | 鏄� | 澶勭疆鏂瑰紡锛堜粎 2=鎶ュ簾/3=杩斿伐/4=璁╂鏀捐/6=杩斾慨锛� |
+| disposition | Integer | 鏄� | 澶勭疆鏂瑰紡锛屽彇鍊艰寖鍥磋涓婃柟銆屽彲閫夊缃柟寮忋�� |
 | warehouseId | Long | 鏉′欢蹇呭~ | 鍏ュ簱浠撳簱锛涜姝ユ斁琛�/鎶ュ簾鏃跺繀濉紝鍓嶇榛樿甯﹀嚭鍘熸潗鏂欎粨 |
 | locationId | Long | 鏉′欢蹇呭~ | 鍏ュ簱搴撳尯锛涜姝ユ斁琛�/鎶ュ簾鏃跺繀濉� |
 | areaId | Long | 鏉′欢蹇呭~ | 鍏ュ簱搴撲綅锛涜姝ユ斁琛�/鎶ュ簾鏃跺繀濉� |
 | batchCode | String | 鏉′欢蹇呭~ | 鎵规鍙凤紱鐗╂枡鍚敤鎵规绠$悊鏃跺繀濉紝鎵规涓嶅瓨鍦ㄤ細鑷姩鍒涘缓 |
+| materialStockId | Long | 鏉′欢蹇呭~ | 鍘熸壒娆℃垚鍝佸簱瀛樿褰旾D锛汷QC 杩斿伐/杩斾慨蹇呭~銆傛湭浼犳椂鍚庣瑕佹眰鍚岀墿鏂欏悓鎵规浠呬竴鏉″彲鐢ㄥ簱瀛橈紝鍚﹀垯鎻愮ず鍏堥�夋嫨鍏蜂綋搴撳瓨 |
 | handlerUserId | Long | 鍚� | 澶勭悊浜篒D |
 | handleResult | String | 鍚� | 澶勭悊缁撴灉璇存槑 |
 
@@ -126,6 +136,16 @@
 |------|------|------|------|
 | id | Long | 鏄� | NCR缂栧彿 |
 | closeOpinion | String | 鍚� | 鍏抽棴鎰忚 |
+
+鍏抽棴鍓嶆牎楠岋紙鎸夊缃柟寮忥級锛�
+
+| 澶勭疆鏂瑰紡 | 鍏抽棴鍓嶅繀椤绘弧瓒� |
+|---|---|
+| 杩斿伐(3)/杩斾慨(6) | 瀵瑰簲杩斿伐宸ュ崟宸插畬鎴愬苟鎶ュ伐锛涘妫�鍗曞繀椤荤粦瀹氳杩斿伐宸ュ崟鐨勬姤宸ヤ骇鍑鸿锛屾娴嬫暟閲�=涓嶅悎鏍兼暟閲忥紝鍚堟牸浜у嚭鏈夊搴斿叆搴撴祦姘达紱澶嶆鑻ユ湁涓嶅悎鏍兼暟閲忥紝椤诲凡鐢熸垚鍞竴鐨勬柊 NCR |
+| OQC 杩斿伐(3)/杩斾慨(6) | 鍦ㄤ笂涓�琛屽熀纭�涓婏細鍘熼攢鍞嚭搴撳崟宸蹭负銆屽凡鍙栨秷銆嶏紝杩斿伐棰嗙敤鍑哄簱鍗曞凡瀹屾垚涓斿嚭搴撴暟閲�=涓嶅悎鏍兼暟閲� |
+| IQC 閫�璐�(1) | 閲囪喘閫�璐у崟宸茬‘璁ら��璐� |
+| OQC 璁╂鏀捐(4) | 鍘熼攢鍞嚭搴撳崟宸插畬鎴愭嫞璐у強鍑哄簱 |
+| 閲嶆柊鐢熶骇(7) | 褰撳墠鐗堟湰鏆備笉鍏佽鍏抽棴 |
 
 ### 鍒嗛〉鏌ヨ
 
@@ -215,6 +235,7 @@
 | 4 | 璁╂鎺ユ敹 | 鏉傞」鍏ュ簱鍒板師鏉愭枡浠� |
 | 5 | 闄嶇骇浣跨敤 | 鍘嗗彶鏋氫妇锛岃瘎瀹′笉鍐嶅彲閫� |
 | 6 | 杩斾慨 | 鐢熸垚鐢熶骇璁㈠崟 |
+| 7 | 閲嶆柊鐢熶骇 | 澶嶅埗鍘熷伐鍗曞伐搴忓強 BOM锛屼笅杈炬柊鐢熶骇璁㈠崟 |
 
 ### 澶勭疆鑱斿姩瑙勫垯
 
@@ -222,7 +243,9 @@
 |----------|----------|-----------|
 | 璁╂鏀捐(4) | 鏉傞」鍏ュ簱鍗曪紙type=2 璁╂鏀捐鍏ュ簱锛夛紝鑷姩鎻愪氦骞跺畬鎴愬叆搴擄紝搴撳瓨澧炲姞 | 榛樿鍘熸潗鏂欎粨锛屽彲鏀逛粨搴�/搴撳尯/搴撲綅 |
 | 鎶ュ簾(2) | 鏉傞」鍏ュ簱鍗曪紙type=3 鎶ュ簾鍏ュ簱锛夛紝鑷姩鎻愪氦骞跺畬鎴愬叆搴擄紝搴撳瓨澧炲姞 | 榛樿涓嶅悎鏍煎搧浠擄紝鍙敼浠撳簱/搴撳尯/搴撲綅 |
-| 杩斿伐(3)/杩斾慨(6) | 鐢熶骇璁㈠崟锛堣嚜琛岀敓浜э紝鑽夌鎬侊級 | 浜у搧=NCR鐗╂枡銆佹暟閲�=涓嶅悎鏍兼暟閲忥紝BOM/鏉$爜鑷姩鐢熸垚锛屽伐鑹鸿矾绾块渶浜哄伐琛ュ厖鍚庝笅杈� |
+| 杩斿伐(3)/杩斾慨(6)锛圛PQC/RQC锛� | 鐢熶骇璁㈠崟锛堣嚜琛岀敓浜э紝鑽夌鎬侊級 | 浜у搧=NCR鐗╂枡銆佹暟閲�=涓嶅悎鏍兼暟閲忥紝BOM/鏉$爜鑷姩鐢熸垚锛屽伐鑹鸿矾绾块渶浜哄伐琛ュ厖鍚庝笅杈� |
+| 杩斿伐(3)/杩斾慨(6)锛圤QC锛� | 杩斿伐棰嗙敤鍑哄簱鍗曪紙鏉傞」鍑哄簱 type=3锛�+ 鍘熼攢鍞嚭搴撳崟鑷姩鍙栨秷 + 杩斿伐宸ュ崟锛堝凡纭骞剁敓鎴愪换鍔★級 | 蹇呴』閫夊畾鍘熸壒娆℃垚鍝佸簱瀛橈紱鎵e噺鏁伴噺=涓嶅悎鏍兼暟閲忥紱杩斿伐宸ュ崟澶嶅埗鍘熷伐鍗曞伐鑹鸿矾绾夸笌 BOM |
+| 閲嶆柊鐢熶骇(7)锛圛PQC/OQC锛� | 鐢熶骇璁㈠崟锛堣嚜琛岀敓浜э紝宸茬‘璁ゅ苟鐢熸垚浠诲姟锛� | 鎸変笉鍚堟牸鏁伴噺澶嶅埗鍘熷伐鍗曠殑宸ュ簭蹇収涓� BOM锛孊OM 鐢ㄩ噺鎸夋瘮渚嬫崲绠� |
 
 ### 缂洪櫡绛夌骇鏋氫妇
 
@@ -244,4 +267,6 @@
   - 宸插缃細鍏抽棴
   - 宸插叧闂細浠呮煡鐪�
 - 璇︽儏椤靛缓璁垎鍖哄煙灞曠ず锛氫笉鍚堟牸鍝佷俊鎭�佽瘎瀹′俊鎭�佸缃俊鎭�佸叧闂俊鎭�
-- 鐘舵�佸瓧鍏哥被鍨嬩负 `mes_ncr_status`锛屽缃柟寮忓瓧鍏哥被鍨嬩负 `mes_ncr_disposition`
+- 澶勭疆寮圭獥鐨勫缃柟寮忛渶鎸� `qcType` 杩囨护锛汷QC 閫夋嫨杩斿伐/杩斾慨鏃堕渶灞曠ず銆岃繑宸ュ簱瀛樸�嶉�夋嫨鍣紙`materialStockId`锛�
+- 鍑鸿揣妫�楠屼笉鍚堟牸鐨勫嚭搴撹浼氶樆姝㈤攢鍞嚭搴撳崟銆岀‘璁ゃ�嶏紱蹇呴』鍏堝湪涓嶅悎鏍煎搧澶勭悊鍗曚腑瀹屾垚澶勭疆锛堝惈璁╂鏀捐锛夊悗鎵嶈兘缁х画鍑哄簱
+- 鐘舵�佸瓧鍏哥被鍨嬩负 `mes_ncr_status`锛屽缃柟寮忓瓧鍏哥被鍨嬩负 `mes_ncr_disposition`锛屾潅椤瑰嚭搴撶被鍨嬪瓧鍏哥被鍨嬩负 `mes_wm_misc_issue_type`
diff --git a/docs/project-business/data/flows.json b/docs/project-business/data/flows.json
index 70217ff..5c34ba9 100644
--- a/docs/project-business/data/flows.json
+++ b/docs/project-business/data/flows.json
@@ -245,7 +245,7 @@
         },
         {
           "stage": "涓嶅悎鏍�",
-          "action": "NCR: 寰呰瘎瀹�(0)鈫掓彁浜PM瀹℃壒(2)鈫掑鎵归�氳繃宸茶瘎瀹�(6)/椹冲洖鍥炲緟璇勫鈫掕川閲忛儴澶勭疆(璁╂鏀捐/杩斾慨/杩斿伐/鎶ュ簾)鈫掑凡澶勭疆(7)鈫掑叧闂�(8)锛涘缃仈鍔細璁╂鏀捐/鎶ュ簾鐢熸垚鏉傞」鍏ュ簱鍗曞苟鑷姩鎻愪氦瀹屾垚鍏ュ簱(澶勭疆寮圭獥閫変粨搴�/搴撳尯/搴撲綅锛岃姝ユ斁琛岄粯璁ゅ師鏉愭枡浠撱�佹姤搴熼粯璁や笉鍚堟牸鍝佷粨锛屾壒娆$鐞嗙墿鏂欏繀濉壒娆″彿)锛岃繑宸�/杩斾慨鐢熸垚鑷鐢熶骇绫诲瀷鐢熶骇璁㈠崟(浜у搧=NCR鐗╂枡銆佹暟閲�=涓嶅悎鏍兼暟閲忋�丅OM涓庢潯鐮佽嚜鍔ㄧ敓鎴愩�佸伐鑹鸿矾绾夸汉宸ヨˉ鍏�)锛涘鎵规剰瑙佺敱 BPM 娴佽浆璁板綍鎵胯浇锛屾湭鍙戝竷娴佺▼瀹氫箟鎴栧叏灞�鍏嶅鎵规椂鎻愪氦鍚庤嚜鍔ㄩ�氳繃",
+          "action": "NCR: 寰呰瘎瀹�(0)鈫掓彁浜PM瀹℃壒(2)鈫掑鎵归�氳繃宸茶瘎瀹�(6)/椹冲洖鍥炲緟璇勫鈫掕川閲忛儴澶勭疆鈫掑凡澶勭疆(7)鈫掑叧闂�(8)锛涘缃」鎸夋楠岀被鍨嬪睍绀�(IQC閫�璐�/璁╂鏀捐锛孖PQC鎶ュ簾/杩斿伐/璁╂鏀捐/杩斾慨/閲嶆柊鐢熶骇锛孫QC杩斿伐/璁╂鏀捐/杩斾慨/閲嶆柊鐢熶骇锛孯QC鎶ュ簾/杩斿伐/璁╂鏀捐/杩斾慨)锛涜姝ユ斁琛�/鎶ュ簾鐢熸垚鏉傞」鍏ュ簱鍗曞苟鑷姩鎻愪氦瀹屾垚鍏ュ簱(澶勭疆寮圭獥閫変粨搴�/搴撳尯/搴撲綅锛岃姝ユ斁琛岄粯璁ゅ師鏉愭枡浠撱�佹姤搴熼粯璁や笉鍚堟牸鍝佷粨锛屾壒娆$鐞嗙墿鏂欏繀濉壒娆″彿)锛孖PQC/RQC杩斿伐/杩斾慨鐢熸垚鑷鐢熶骇绫诲瀷鐢熶骇璁㈠崟(浜у搧=NCR鐗╂枡銆佹暟閲�=涓嶅悎鏍兼暟閲忋�丅OM涓庢潯鐮佽嚜鍔ㄧ敓鎴愩�佸伐鑹鸿矾绾夸汉宸ヨˉ鍏�)锛孫QC杩斿伐/杩斾慨鍏堥�夊畾鍘熸壒娆℃垚鍝佸簱瀛樻墸鍑忋�佺敓鎴愯繑宸ラ鐢ㄥ嚭搴撳崟(type=3)骞跺畬鎴愬嚭搴撱�佸師閿�鍞嚭搴撳崟鏁村崟鑷姩鍙栨秷锛屽啀澶嶇敤鍘熷伐鍗曞伐搴忎笌BOM鍏嬮殕杩斿伐宸ュ崟骞朵笅杈撅紝閲嶆柊鐢熶骇鎸変笉鍚堟牸鏁伴噺澶嶅埗鍘熷伐鍗曞伐搴忎笌BOM涓嬭揪鏂板伐鍗曪紱瀹℃壒鎰忚鐢� BPM 娴佽浆璁板綍鎵胯浇锛屾湭鍙戝竷娴佺▼瀹氫箟鎴栧叏灞�鍏嶅鎵规椂鎻愪氦鍚庤嚜鍔ㄩ�氳繃",
           "roles": [
             "璐ㄩ噺宸ョ▼甯�"
           ]
diff --git a/docs/project-business/data/objects.json b/docs/project-business/data/objects.json
index 7270654..0bbe339 100644
--- a/docs/project-business/data/objects.json
+++ b/docs/project-business/data/objects.json
@@ -701,12 +701,12 @@
       "name": "NCR涓嶅悎鏍煎搧",
       "module": "璐ㄩ噺",
       "table": "mes_qc_ncr",
-      "doc": "寰呰瘎瀹�0鈫掓彁浜PM瀹℃壒涓�2鈫掑鎵归�氳繃宸茶瘎瀹�6(椹冲洖/鍙栨秷鍥炲緟璇勫)鈫掑凡澶勭疆7鈫掑凡鍏抽棴8锛涘鎵规剰瑙佺敱 BPM 娴佽浆璁板綍鎵胯浇锛岃川閲忛儴鏈�缁堝缃�:璁╂鏀捐/杩斾慨/杩斿伐/鎶ュ簾(閫�璐�/闄嶇骇浠呭巻鍙插睍绀�)",
+      "doc": "寰呰瘎瀹�0鈫掓彁浜PM瀹℃壒涓�2鈫掑鎵归�氳繃宸茶瘎瀹�6(椹冲洖/鍙栨秷鍥炲緟璇勫)鈫掑凡澶勭疆7鈫掑凡鍏抽棴8锛涘鎵规剰瑙佺敱 BPM 娴佽浆璁板綍鎵胯浇锛涙渶缁堝缃寜妫�楠岀被鍨嬪姩鎬佸彲閫夛細IQC閫�璐�/璁╂鏀捐锛孖PQC鎶ュ簾/杩斿伐/璁╂鏀捐/杩斾慨/閲嶆柊鐢熶骇锛孫QC杩斿伐/璁╂鏀捐/杩斾慨/閲嶆柊鐢熶骇锛孯QC鎶ュ簾/杩斿伐/璁╂鏀捐/杩斾慨(闄嶇骇浠呭巻鍙插睍绀�)锛汷QC杩斿伐/杩斾慨闇�閫夊畾鍘熸壒娆℃垚鍝佸簱瀛橈紝鎵e噺骞剁敓鎴愯繑宸ラ鐢ㄥ嚭搴撳崟銆佽嚜鍔ㄥ彇娑堝師閿�鍞嚭搴撳崟鍚庡厠闅嗚繑宸ュ伐鍗曪紝鍏抽棴鍓嶆牳楠岃繑宸ュ畬鎴愩�佸嚭搴撳彇娑堜笌棰嗙敤鏁伴噺",
       "upstream": [
         "IQC/IPQC/OQC/RQC"
       ],
       "downstream": [
-        "閫�璐�/鎶ュ簾/杩斿伐(鍙拌处)"
+        "閲囪喘閫�璐у崟/鏉傞」鍏ュ簱鍗�/杩斿伐棰嗙敤鍑哄簱鍗�/鐢熶骇璁㈠崟(鍙拌处)"
       ],
       "keywords": "NCR 涓嶅悎鏍� 澶勭疆 鐗归噰 鎶ュ簾"
     },
diff --git a/docs/project-business/mermaid/05-quality-flow.mmd b/docs/project-business/mermaid/05-quality-flow.mmd
index e12eb70..b882a96 100644
--- a/docs/project-business/mermaid/05-quality-flow.mmd
+++ b/docs/project-business/mermaid/05-quality-flow.mmd
@@ -34,9 +34,15 @@
   N1A -->|BPM 椹冲洖/鍙栨秷路淇濈暀娴佺▼瀹炰緥鍙煡鎰忚| N1
   N1A -->|BPM 瀹℃壒閫氳繃路瀹℃壒鑺傜偣銆岃川閲忛儴闂ㄥ鎵广�嶆寜璐ㄩ噺閮ㄩ棬瑙掕壊鎴栫路鎰忚鐢� BPM 娴佽浆璁板綍鎵胯浇| N2[宸茶瘎瀹�6路璐ㄩ噺閮ㄥ緟澶勭疆]
   N2 -->|璐ㄩ噺閮ㄦ渶缁堝缃疯姝ユ斁琛�4/鎶ュ簾2| N3A[鐢熸垚鏉傞」鍏ュ簱鍗暵疯嚜鍔ㄦ彁浜ゅ苟瀹屾垚鍏ュ簱路澶勭疆寮圭獥閫変粨搴�/搴撳尯/搴撲綅路璁╂鏀捐榛樿鍘熸潗鏂欎粨路鎶ュ簾榛樿涓嶅悎鏍煎搧浠撀锋壒娆$鐞嗙墿鏂欏繀濉壒娆″彿]
-  N2 -->|璐ㄩ噺閮ㄦ渶缁堝缃疯繑宸�3/杩斾慨6| N3B[鐢熸垚鑷鐢熶骇绫诲瀷鐢熶骇璁㈠崟(鑽夌)路浜у搧=NCR鐗╂枡路鏁伴噺=涓嶅悎鏍兼暟閲徛稡OM涓庢潯鐮佽嚜鍔ㄧ敓鎴惵峰伐鑹鸿矾绾夸汉宸ヨˉ鍏呭悗涓嬭揪]
+  N2 -->|璐ㄩ噺閮ㄦ渶缁堝缃疯繃绋�/閫�璐ф楠�(IPQC/RQC)杩斿伐3/杩斾慨6| N3B[鐢熸垚鑷鐢熶骇绫诲瀷鐢熶骇璁㈠崟(鑽夌)路浜у搧=NCR鐗╂枡路鏁伴噺=涓嶅悎鏍兼暟閲徛稡OM涓庢潯鐮佽嚜鍔ㄧ敓鎴惵峰伐鑹鸿矾绾夸汉宸ヨˉ鍏呭悗涓嬭揪]
+  N2 -->|璐ㄩ噺閮ㄦ渶缁堝缃峰嚭璐ф楠�(OQC)杩斿伐3/杩斾慨6| N3C[閫夊畾鍘熸壒娆℃垚鍝佸簱瀛樺苟鎵e噺路鐢熸垚杩斿伐棰嗙敤鍑哄簱鍗晅ype=3骞跺畬鎴愬嚭搴撀峰師閿�鍞嚭搴撳崟鏁村崟鑷姩鍙栨秷路澶嶇敤鍘熷伐鍗曞伐搴忎笌BOM鍏嬮殕杩斿伐宸ュ崟骞朵笅杈綸
+  N2 -->|璐ㄩ噺閮ㄦ渶缁堝缃烽噸鏂扮敓浜�7(IPQC/OQC)| N3D[鎸変笉鍚堟牸鏁伴噺澶嶅埗鍘熷伐鍗曞伐搴忓揩鐓т笌BOM路鐢熸垚骞剁‘璁ゆ柊鐢熶骇璁㈠崟路鑷姩鐢熸垚浠诲姟鑽夌]
   N3A --> N3[宸插缃�7]
   N3B --> N3
+  N3C --> N3
+  N3D --> N3
+  N3C -.->|鍏抽棴鍓嶆牳楠寍 N4C[杩斿伐宸ュ崟宸插畬鎴惵峰師閿�鍞嚭搴撳崟宸插彇娑埪疯繑宸ラ鐢ㄥ嚭搴撴祦姘存暟閲�=涓嶅悎鏍兼暟閲徛峰妫�缁戝畾杩斿伐鎶ュ伐浜у嚭琛宂
+  N2 -.->|澶勭疆椤规寜妫�楠岀被鍨嬪睍绀郝稩QC閫�璐�/璁╂路IPQC鎶ュ簾/杩斿伐/璁╂/杩斾慨/閲嶆柊鐢熶骇路OQC杩斿伐/璁╂/杩斾慨/閲嶆柊鐢熶骇路RQC鎶ュ簾/杩斿伐/璁╂/杩斾慨| N3E[鍓嶅悗绔悓婧愯繃婊
   N3 -->|鍏抽棴| N4[宸插叧闂�8]
   N1 -.->|鏈彂甯冩祦绋嬪畾涔夋垨鍏ㄥ眬鍏嶅鎵规椂路鎻愪氦鍚庤嚜鍔ㄧ疆涓哄凡璇勫| N2
   Q8[鏀拺鏁版嵁:璐ㄦ鏂规路妫�楠屾寚鏍嚶风己闄峰簱路鎸囨爣缁撴灉] --- A1
diff --git a/sql/mysql/20261110_mes_qc_ncr_reinspection.sql b/sql/mysql/20261110_mes_qc_ncr_reinspection.sql
new file mode 100644
index 0000000..f769a0a
--- /dev/null
+++ b/sql/mysql/20261110_mes_qc_ncr_reinspection.sql
@@ -0,0 +1,3 @@
+-- 杩斿伐/杩斾慨鍏抽棴鏃惰褰曞妫�璇佹嵁锛涢儴缃叉柊浠g爜鍓嶆墽琛屻��
+ALTER TABLE `mes_qc_ncr`
+    ADD COLUMN `reinspection_ipqc_id` bigint NULL COMMENT '杩斿伐/杩斾慨鍏抽棴鏃剁殑澶嶆鍗� ID';
diff --git a/sql/mysql/20261110_mes_qc_ncr_return_sales.sql b/sql/mysql/20261110_mes_qc_ncr_return_sales.sql
new file mode 100644
index 0000000..82977ba
--- /dev/null
+++ b/sql/mysql/20261110_mes_qc_ncr_return_sales.sql
@@ -0,0 +1,3 @@
+-- 瀹㈡埛閫�璐т笉鍚堟牸琛岃浆浜� NCR锛岄伩鍏嶅師閫�璐у崟鍐嶆鍏ュ簱銆�
+ALTER TABLE `mes_wm_return_sales_line`
+    ADD COLUMN `ncr_disposition_id` bigint NULL COMMENT '鎵挎帴涓嶅悎鏍兼暟閲忕殑 NCR ID';
diff --git a/sql/mysql/20261110_misc_issue_rework_type.sql b/sql/mysql/20261110_misc_issue_rework_type.sql
new file mode 100644
index 0000000..e9b6bd6
--- /dev/null
+++ b/sql/mysql/20261110_misc_issue_rework_type.sql
@@ -0,0 +1,4 @@
+INSERT INTO `system_dict_data`
+(`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
+SELECT 3, '杩斿伐棰嗙敤', '3', 'mes_wm_misc_issue_type', 0, 'warning', '', '杩斿伐棰嗙敤鍑哄簱', '1', NOW(), '1', NOW(), b'0'
+WHERE NOT EXISTS (SELECT 1 FROM `system_dict_data` WHERE `dict_type` = 'mes_wm_misc_issue_type' AND `value` = '3' AND `deleted` = b'0');
diff --git a/sql/mysql/20261110_ncr_reproduction_dict.sql b/sql/mysql/20261110_ncr_reproduction_dict.sql
new file mode 100644
index 0000000..fc20750
--- /dev/null
+++ b/sql/mysql/20261110_ncr_reproduction_dict.sql
@@ -0,0 +1,4 @@
+INSERT INTO `system_dict_data`
+(`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
+SELECT 7, '閲嶆柊鐢熶骇', '7', 'mes_ncr_disposition', 0, '', '', '鍑鸿揣涓嶅悎鏍奸噸鏂扮敓浜�', '1', NOW(), '1', NOW(), b'0'
+WHERE NOT EXISTS (SELECT 1 FROM `system_dict_data` WHERE `dict_type` = 'mes_ncr_disposition' AND `value` = '7' AND `deleted` = b'0');
diff --git a/sql/mysql/20261110_product_produce_ncr_disposition.sql b/sql/mysql/20261110_product_produce_ncr_disposition.sql
new file mode 100644
index 0000000..7650043
--- /dev/null
+++ b/sql/mysql/20261110_product_produce_ncr_disposition.sql
@@ -0,0 +1,3 @@
+-- 涓嶅悎鏍间骇鍑鸿琚� NCR 娑堣垂鍚庝繚鐣欏缃叧鑱旓紝闃叉澶氫釜 NCR 閲嶅鍏ュ簱銆�
+ALTER TABLE `mes_wm_product_produce_line`
+    ADD COLUMN `ncr_disposition_id` bigint NULL COMMENT '澶勭疆璇ヤ笉鍚堟牸浜у嚭鐨� NCR ID';
diff --git a/sql/mysql/20261110_product_sales_ncr_disposition.sql b/sql/mysql/20261110_product_sales_ncr_disposition.sql
new file mode 100644
index 0000000..3658814
--- /dev/null
+++ b/sql/mysql/20261110_product_sales_ncr_disposition.sql
@@ -0,0 +1,3 @@
+-- 鍑鸿揣涓嶅悎鏍艰鍙兘杞氦涓�寮犲鐞嗗崟銆�
+ALTER TABLE `mes_wm_product_sales_line`
+    ADD COLUMN `ncr_disposition_id` bigint NULL COMMENT '鎵挎帴涓嶅悎鏍煎嚭璐х殑 NCR ID';
diff --git a/sql/mysql/20261110_qc_purchase_concession.sql b/sql/mysql/20261110_qc_purchase_concession.sql
new file mode 100644
index 0000000..1c1ef57
--- /dev/null
+++ b/sql/mysql/20261110_qc_purchase_concession.sql
@@ -0,0 +1,17 @@
+-- 璁板綍宸叉寜閲囪喘鍏ュ簱杩囪处鐨勮姝ユ暟閲忥紝鍚庣画鍒拌揣鍏ュ簱鍙敹鍘熷悎鏍兼暟閲忋��
+CREATE TABLE IF NOT EXISTS `mes_qc_purchase_concession` (
+ `id` bigint NOT NULL AUTO_INCREMENT,
+ `ncr_id` bigint NOT NULL,
+ `iqc_id` bigint NOT NULL,
+ `notice_id` bigint NOT NULL,
+ `notice_line_id` bigint NOT NULL,
+ `purchase_order_item_id` bigint NOT NULL,
+ `receipt_id` bigint NOT NULL,
+ `quantity` decimal(20,4) NOT NULL,
+ `creator` varchar(64) DEFAULT '', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `updater` varchar(64) DEFAULT '', `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `deleted` bit(1) NOT NULL DEFAULT b'0',
+ `tenant_id` bigint NOT NULL DEFAULT 0,
+ PRIMARY KEY (`id`), UNIQUE KEY `uk_qc_purchase_concession_ncr` (`ncr_id`),
+ UNIQUE KEY `uk_qc_purchase_concession_iqc` (`iqc_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='鏉ユ枡璁╂閲囪喘鍏ュ簱鍏宠仈';
diff --git a/sql/mysql/20261110_qc_purchase_return.sql b/sql/mysql/20261110_qc_purchase_return.sql
new file mode 100644
index 0000000..35cdd5b
--- /dev/null
+++ b/sql/mysql/20261110_qc_purchase_return.sql
@@ -0,0 +1,28 @@
+-- 鏈叆搴撲笉鍚堟牸鍝佺殑鐩存帴閲囪喘閫�璐э紱涓嶇敓鎴愬簱瀛樺嚭鍏ュ簱锛屼篃涓嶅崰鐢ㄥ凡鍏ュ簱閫�璐ф暟閲忋��
+CREATE TABLE IF NOT EXISTS `mes_qc_purchase_return` (
+  `id` bigint NOT NULL AUTO_INCREMENT,
+  `code` varchar(64) NOT NULL,
+  `ncr_id` bigint NOT NULL,
+  `iqc_id` bigint NOT NULL,
+  `notice_id` bigint NOT NULL,
+  `notice_line_id` bigint NOT NULL,
+  `purchase_order_id` bigint NOT NULL,
+  `purchase_order_item_id` bigint NOT NULL,
+  `vendor_id` bigint NOT NULL,
+  `item_id` bigint NOT NULL,
+  `vendor_batch` varchar(100) DEFAULT NULL,
+  `quantity` decimal(20,4) NOT NULL,
+  `status` tinyint NOT NULL DEFAULT 0 COMMENT '0寰呬粨搴撻��璐� 1宸茬‘璁ら��璐�',
+  `confirmed_by` bigint DEFAULT NULL,
+  `confirmed_at` datetime DEFAULT NULL,
+  `confirmation_remark` varchar(500) DEFAULT NULL,
+  `creator` varchar(64) DEFAULT '',
+  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  `updater` varchar(64) DEFAULT '',
+  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  `deleted` bit(1) NOT NULL DEFAULT b'0',
+  `tenant_id` bigint NOT NULL DEFAULT 0,
+  PRIMARY KEY (`id`), UNIQUE KEY `uk_qc_purchase_return_ncr` (`ncr_id`),
+  UNIQUE KEY `uk_qc_purchase_return_iqc` (`iqc_id`),
+  KEY `idx_qc_purchase_return_order_item` (`purchase_order_item_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='寰呭叆搴撴潵鏂欎笉鍚堟牸閲囪喘閫�璐�';
diff --git a/sql/mysql/20261110_wm_scrap_return_source.sql b/sql/mysql/20261110_wm_scrap_return_source.sql
new file mode 100644
index 0000000..7345e8e
--- /dev/null
+++ b/sql/mysql/20261110_wm_scrap_return_source.sql
@@ -0,0 +1,4 @@
+-- 瀹㈡埛閫�璐т骇鐢熺殑搴熸枡娌℃湁鐢熶骇宸ュ崟锛屼互搴熸枡鍗曠紪鐮佸強澶囨敞杩芥函涓嶅悎鏍煎鐞嗗崟銆�
+ALTER TABLE `mes_wm_scrap_receipt`
+    MODIFY COLUMN `work_order_id` bigint NULL COMMENT '鐢熶骇宸ュ崟缂栧彿锛涘鎴烽��璐т负绌�',
+    MODIFY COLUMN `work_order_code` varchar(64) NULL COMMENT '鐢熶骇宸ュ崟鍙峰揩鐓�';
diff --git a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/quotation/CrmSaleQuotationController.java b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/quotation/CrmSaleQuotationController.java
index 0d039ed..870fe71 100644
--- a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/quotation/CrmSaleQuotationController.java
+++ b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/quotation/CrmSaleQuotationController.java
@@ -18,7 +18,8 @@
 import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
 import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
 import cn.iocoder.yudao.module.crm.enums.quotation.CrmSaleQuotationStatusEnum;
-import cn.iocoder.yudao.module.crm.service.quotation.CrmSaleQuotationDocumentRenderer;
+import cn.iocoder.yudao.module.crm.service.quotation.CrmSaleQuotationExcelRenderer;
+import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
 import cn.iocoder.yudao.module.crm.service.quotation.CrmSaleQuotationService;
 import cn.iocoder.yudao.module.system.service.companyconfig.SystemCompanyConfigService;
 import cn.iocoder.yudao.module.mdm.api.item.MdmItemApi;
@@ -76,6 +77,8 @@
     private MdmUnitMeasureApi mdmUnitMeasureApi;
     @Resource
     private CrmCustomerService customerService;
+    @Resource
+    private CrmContactService contactService;
     @Resource
     private CrmBusinessService businessService;
     @Resource
@@ -166,8 +169,8 @@
         ExcelUtils.write(response, "閿�鍞姤浠峰崟.xls", "鏁版嵁", CrmSaleQuotationRespVO.class, list);
     }
 
-    @GetMapping("/export-word")
-    @Operation(summary = "瀵煎嚭閿�鍞姤浠峰崟 Word锛堝甫鐢靛瓙绔狅級")
+    @GetMapping({"/export-word", "/export-quotation-excel"})
+    @Operation(summary = "瀵煎嚭閿�鍞姤浠峰崟 Excel锛堝甫鐢靛瓙绔狅級")
     @Parameter(name = "id", description = "鎶ヤ环鍗曠紪鍙�", required = true)
     @PreAuthorize("@ss.hasPermission('crm:sale-quotation:export')")
     @ApiAccessLog(operateType = EXPORT)
@@ -187,12 +190,17 @@
                 saleQuotationService.getSaleQuotationProductListByQuotationId(id));
         var companyConfig = companyConfigService.getCompanyConfig();
         String companyName = companyConfig != null ? companyConfig.getCompanyName() : null;
-        byte[] content = CrmSaleQuotationDocumentRenderer.render(respVO, companyName);
+        var customer = saleQuotation.getCustomerId() == null ? null : customerService.getCustomer(saleQuotation.getCustomerId());
+        var contact = saleQuotation.getContactId() == null ? null : contactService.getContact(saleQuotation.getContactId());
+        String phone = contact == null ? null : (contact.getMobile() != null && !contact.getMobile().isBlank()
+                ? contact.getMobile() : contact.getTelephone());
+        byte[] content = CrmSaleQuotationExcelRenderer.render(respVO, companyName,
+                customer == null ? null : customer.getDetailAddress(), contact == null ? null : contact.getName(), phone);
 
         String filename = "鎶ヤ环鍗�-" + saleQuotation.getNo()
-                + (respVO.getCustomerName() != null ? "-" + respVO.getCustomerName() : "") + ".docx";
+                + (respVO.getCustomerName() != null ? "-" + respVO.getCustomerName() : "") + ".xlsx";
         String encoded = URLEncoder.encode(filename, StandardCharsets.UTF_8).replace("+", "%20");
-        response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
+        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
         response.setHeader("Content-Disposition", "attachment;filename*=UTF-8''" + encoded);
         response.getOutputStream().write(content);
     }
diff --git a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractDocumentRenderer.java b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractDocumentRenderer.java
index cd05bb6..c3a7102 100644
--- a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractDocumentRenderer.java
+++ b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractDocumentRenderer.java
@@ -4,6 +4,7 @@
 import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractRespVO;
 import org.springframework.core.io.ClassPathResource;
 import org.w3c.dom.*;
+
 import javax.xml.XMLConstants;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.transform.TransformerFactory;
@@ -16,7 +17,7 @@
 import java.util.*;
 import java.util.zip.*;
 
-/** 淇濈暀鐢ㄦ埛鍚堝悓妯℃澘鐨� OOXML 鍖咃紝浠呭~鍐欎笟鍔℃Ы浣嶅苟鎵╁睍浜у搧鏄庣粏琛屻�� */
+/** 鍦ㄩ攢鍞悎鍚屾ā鏉夸腑濉啓鍚堝悓淇℃伅锛屼繚鐣欐ā鏉跨殑鍏朵粬鍐呭鍙婃牸寮忋�� */
 public final class CrmContractDocumentRenderer {
     private static final String W = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
     private CrmContractDocumentRenderer() { }
@@ -49,14 +50,38 @@
             factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
             factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
             var document = factory.newDocumentBuilder().parse(new ByteArrayInputStream(xml));
-            Node rowTemplate = null;
-            var rows = document.getElementsByTagNameNS(W, "tr");
-            for (int i = 0; i < rows.getLength(); i++) {
-                if (rows.item(i).getTextContent().contains("${itemName}")) { rowTemplate = rows.item(i); break; }
+            var paragraphs = document.getElementsByTagNameNS(W, "p");
+            boolean numberFilled = false, dateFilled = false, buyerFilled = false;
+            for (int i = 0; i < paragraphs.getLength(); i++) {
+                Node p = paragraphs.item(i);
+                String value = p.getTextContent();
+                if (value.contains("鍚堝悓缂栧彿锛歋HHT20260102902-F")) {
+                    setParagraphText(p, "鍚堝悓缂栧彿锛�" + text(contract.getNo()));
+                    alignRight(p);
+                    numberFilled = true;
+                } else if (value.trim().equals("绛捐鏃ユ湡锛�")) {
+                    setParagraphText(p, "绛捐鏃ユ湡锛�" + date(contract.getOrderDate()));
+                    alignRight(p);
+                    dateFilled = true;
+                } else if (value.contains("涔版柟锛堢敳鏂癸級锛�") && value.contains("绛捐鍦扮偣锛氭睙鑻忓崡閫�")) {
+                    fillBuyer(p, text(contract.getCustomerName()));
+                    buyerFilled = true;
+                } else if (value.equals("涔欐柟锛堢洊绔狅級锛�")) {
+                    // 鍘熸ā鏉跨殑绌虹櫧涔版柟绛剧珷妗嗚鍐欎负涔欐柟锛涘悓鏃跺鐞� DrawingML 鍜� VML 涓や釜鍏煎鍒嗘敮銆�
+                    setParagraphText(p, "鐢叉柟锛堢洊绔狅級锛�" + text(contract.getCustomerName()));
+                }
             }
-            if (rowTemplate == null) throw new IOException("鍚堝悓妯℃澘缂哄皯浜у搧鏄庣粏妲戒綅");
-            int index = 0;
+            if (!numberFilled || !dateFilled || !buyerFilled) throw new IOException("閿�鍞悎鍚屾ā鏉胯〃澶翠笉瀹屾暣");
+
+            Node table = document.getElementsByTagNameNS(W, "tbl").item(0);
+            List<Node> rows = children(table, "tr");
+            if (rows.size() != 4 || children(rows.get(1), "tc").size() != 7
+                    || !rows.get(3).getTextContent().contains("鍚堣锛堝惈13%澧炲�肩◣锛�")) {
+                throw new IOException("閿�鍞悎鍚屾ā鏉夸骇鍝佽〃鏍间笉瀹屾暣");
+            }
+            Node rowTemplate = rows.get(1);
             BigDecimal productTotal = BigDecimal.ZERO;
+            int index = 0;
             for (var product : contract.getProducts()) {
                 Node row = rowTemplate.cloneNode(true);
                 BigDecimal price = Objects.requireNonNull(product.getContractPrice(), "鍚堝悓鍗曚环涓嶈兘涓虹┖");
@@ -66,25 +91,32 @@
                 productTotal = productTotal.add(amount);
                 String name = text(product.getItemName());
                 if (name.isBlank()) name = text(product.getItemCode());
-                String specification = text(product.getItemSpecification());
-                if (!specification.isBlank()) name += "锛�" + specification + "锛�";
-                replace(row, Map.of("index", String.valueOf(++index), "itemName", name,
-                        "unitName", text(product.getItemUnitName()), "count", count.stripTrailingZeros().toPlainString(),
-                        "price", money(price), "amount", money(amount)));
+                List<Node> cells = children(row, "tc");
+                String[] values = {String.valueOf(++index), name, text(product.getItemSpecification()),
+                        text(product.getItemUnitName()), count.stripTrailingZeros().toPlainString(), money(price), money(amount)};
+                for (int i = 0; i < values.length; i++) {
+                    Node cell = cells.get(i);
+                    Node properties = firstChild(cell, "tcPr");
+                    Node noWrap = firstChild(properties, "noWrap");
+                    if (noWrap != null) properties.removeChild(noWrap);
+                    setParagraphText(firstChild(cell, "p"), values[i]);
+                }
+                Node rowProperties = firstChild(row, "trPr");
+                if (firstChild(rowProperties, "cantSplit") == null) {
+                    rowProperties.appendChild(document.createElementNS(W, "w:cantSplit"));
+                }
                 rowTemplate.getParentNode().insertBefore(row, rowTemplate);
             }
             rowTemplate.getParentNode().removeChild(rowTemplate);
             BigDecimal total = Objects.requireNonNull(contract.getTotalPrice(), "鍚堝悓鎬婚噾棰濅笉鑳戒负绌�");
             BigDecimal discount = productTotal.subtract(total);
-            replace(document, Map.of("customerName", text(contract.getCustomerName()),
-                    "contractNo", text(contract.getNo()),
-                    "contractName", text(contract.getName()),
-                    "contractDate", contract.getOrderDate() == null ? "____________" : contract.getOrderDate().format(DateTimeFormatter.ofPattern("yyyy骞碝M鏈坉d鏃�")),
-                    "startDate", date(contract.getStartTime()),
-                    "endDate", date(contract.getEndTime()),
-                    "totalPrice", money(total), "totalUpper", Convert.digitToChinese(total),
-                    "discountNote", discount.signum() == 0 ? "" : "锛堟槑缁嗗悎璁� " + money(productTotal) + " 鍏冿紝涓庡悎鍚岄噾棰濈殑宸 " + money(discount) + " 鍏冿級"));
-            if (document.getDocumentElement().getTextContent().contains("${")) throw new IOException("鍚堝悓妯℃澘瀛樺湪鏈~鍐欐Ы浣�");
+            String summary = "鍚堣锛堝惈13%澧炲�肩◣锛�  浜烘皯甯侊細" + money(total) + "鍏�  澶у啓锛�" + Convert.digitToChinese(total);
+            if (discount.signum() != 0) summary += "锛堟槑缁嗗悎璁� " + money(productTotal) + " 鍏冿紝涓庡悎鍚岄噾棰濈殑宸 " + money(discount) + " 鍏冿級";
+            Node totalCell = children(rows.get(3), "tc").get(0);
+            Node totalProperties = firstChild(totalCell, "tcPr");
+            Node noWrap = firstChild(totalProperties, "noWrap");
+            if (noWrap != null) totalProperties.removeChild(noWrap);
+            setParagraphText(firstChild(totalCell, "p"), summary);
             var transformerFactory = TransformerFactory.newInstance();
             transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
             transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
@@ -95,16 +127,60 @@
         } catch (Exception exception) { throw new IOException("鐢熸垚鍚堝悓 Word 鏂囦欢澶辫触", exception); }
     }
 
-    private static void replace(Node node, Map<String, String> values) {
-        if (node.getNodeType() == Node.ELEMENT_NODE && "t".equals(node.getLocalName()) && W.equals(node.getNamespaceURI())) {
+    private static void fillBuyer(Node paragraph, String buyer) {
+        var nodes = ((Element) paragraph).getElementsByTagNameNS(W, "t");
+        boolean afterColon = false, inserted = false;
+        for (int i = 0; i < nodes.getLength(); i++) {
+            Node node = nodes.item(i);
             String value = node.getTextContent();
-            for (var entry : values.entrySet()) value = value.replace("${" + entry.getKey() + "}", entry.getValue());
-            node.setTextContent(value);
-            return;
+            if (value.contains("绛捐鍦扮偣锛�")) break;
+            if (afterColon) {
+                node.setTextContent(inserted ? "" : buyer + "  ");
+                inserted = true;
+            } else if (value.equals("锛�")) afterColon = true;
         }
-        for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) replace(child, values);
+        if (!inserted) throw new IllegalStateException("鍚堝悓妯℃澘缂哄皯涔版柟濉啓浣嶇疆");
     }
 
+    private static void alignRight(Node paragraph) {
+        Node properties = firstChild(paragraph, "pPr");
+        Node indent = firstChild(properties, "ind");
+        if (indent != null) properties.removeChild(indent);
+        Node alignment = firstChild(properties, "jc");
+        if (alignment == null) {
+            alignment = paragraph.getOwnerDocument().createElementNS(W, "w:jc");
+            properties.appendChild(alignment);
+        }
+        ((Element) alignment).setAttributeNS(W, "w:val", "right");
+    }
+
+    private static void setParagraphText(Node paragraph, String value) {
+        var nodes = ((Element) paragraph).getElementsByTagNameNS(W, "t");
+        if (nodes.getLength() == 0) {
+            var document = paragraph.getOwnerDocument();
+            Node run = document.createElementNS(W, "w:r");
+            Node text = document.createElementNS(W, "w:t");
+            run.appendChild(text);
+            paragraph.appendChild(run);
+            text.setTextContent(value);
+        } else {
+            nodes.item(0).setTextContent(value);
+            for (int i = 1; i < nodes.getLength(); i++) nodes.item(i).setTextContent("");
+        }
+    }
+
+    private static List<Node> children(Node parent, String localName) {
+        List<Node> result = new ArrayList<>();
+        if (parent == null) return result;
+        for (Node node = parent.getFirstChild(); node != null; node = node.getNextSibling()) {
+            if (W.equals(node.getNamespaceURI()) && localName.equals(node.getLocalName())) result.add(node);
+        }
+        return result;
+    }
+    private static Node firstChild(Node parent, String localName) {
+        List<Node> result = children(parent, localName);
+        return result.isEmpty() ? null : result.get(0);
+    }
     private static String money(BigDecimal value) { return value.setScale(2, RoundingMode.HALF_UP).toPlainString(); }
     private static String date(java.time.LocalDateTime value) { return value == null ? "____________" : value.format(DateTimeFormatter.ofPattern("yyyy骞碝M鏈坉d鏃�")); }
     private static String text(String value) { return value == null ? "" : value; }
diff --git a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationDocumentRenderer.java b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationDocumentRenderer.java
index c7d4fbd..8cd2224 100644
--- a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationDocumentRenderer.java
+++ b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationDocumentRenderer.java
@@ -163,7 +163,7 @@
      * 鎸夊叕鍙稿悕绉板疄鏃剁粯鍒剁孩鑹插渾褰㈢數瀛愮珷锛氬弻鍦嗙幆 + 涓婃柟鐜粫鍏徃鍚� + 涓ぎ浜旇鏄� + 涓嬫柟鈥滄姤浠蜂笓鐢ㄧ珷鈥濄��
      * 涓嶄緷璧栦换浣曢潤鎬佺珷鍥剧墖锛岄伩鍏嶆崲鍏徃鍝佺墝鍚庝粛闇�鍗曠嫭缁存姢鍥剧墖璧勬簮銆�
      */
-    private static byte[] renderSeal(String companyName) throws IOException {
+    static byte[] renderSeal(String companyName) throws IOException {
         int size = 400;
         var image = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
         Graphics2D g = image.createGraphics();
diff --git a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationExcelRenderer.java b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationExcelRenderer.java
new file mode 100644
index 0000000..107d491
--- /dev/null
+++ b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationExcelRenderer.java
@@ -0,0 +1,100 @@
+package cn.iocoder.yudao.module.crm.service.quotation;
+
+import cn.iocoder.yudao.module.crm.controller.admin.quotation.vo.CrmSaleQuotationRespVO;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.springframework.core.io.ClassPathResource;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.time.format.DateTimeFormatter;
+
+/** 浣跨敤瀹㈡埛鎻愪緵鐨� Excel 妯℃澘鐢熸垚鍗曞紶閿�鍞姤浠峰崟銆� */
+public final class CrmSaleQuotationExcelRenderer {
+
+    private static final String TEMPLATE = "templates/quotation/sale-quotation.xlsx";
+    private static final String DEFAULT_COMPANY = "鑻忕彥绾跨紗鍗楅�氭湁闄愬叕鍙�";
+
+    private CrmSaleQuotationExcelRenderer() {
+    }
+
+    public static byte[] render(CrmSaleQuotationRespVO quotation, String companyName,
+                                String address, String contactName, String contactPhone) throws IOException {
+        if (quotation == null || quotation.getItems() == null || quotation.getItems().isEmpty()) {
+            throw new IllegalArgumentException("鎶ヤ环鍗曚笉瀛樺湪鎴栨病鏈変骇鍝佹槑缁嗭紝鏃犳硶鐢熸垚鎶ヤ环鏂囦欢");
+        }
+        String company = companyName == null || companyName.isBlank() ? DEFAULT_COMPANY : companyName;
+        try (var input = new ClassPathResource(TEMPLATE).getInputStream();
+             var workbook = new XSSFWorkbook(input);
+             var output = new ByteArrayOutputStream()) {
+            var sheet = workbook.getSheetAt(0);
+            int extraRows = quotation.getItems().size() - 1;
+            if (extraRows > 0) {
+                sheet.shiftRows(11, sheet.getLastRowNum(), extraRows, true, false);
+            }
+            var templateRow = sheet.getRow(10);
+            for (int i = 0; i < quotation.getItems().size(); i++) {
+                var row = i == 0 ? templateRow : sheet.createRow(10 + i);
+                if (i > 0) {
+                    row.setHeight(templateRow.getHeight());
+                    for (int col = 0; col < 8; col++) {
+                        row.createCell(col).setCellStyle(templateRow.getCell(col).getCellStyle());
+                    }
+                }
+                var item = quotation.getItems().get(i);
+                string(row.getCell(0), item.getItemName() == null || item.getItemName().isBlank()
+                        ? item.getItemCode() : item.getItemName());
+                string(row.getCell(1), item.getItemSpecification());
+                string(row.getCell(2), item.getItemUnitName());
+                number(row.getCell(3), item.getCount());
+                number(row.getCell(4), item.getQuotationPrice());
+                BigDecimal amount = item.getTotalPrice();
+                if (amount == null && item.getCount() != null && item.getQuotationPrice() != null) {
+                    amount = item.getCount().multiply(item.getQuotationPrice());
+                }
+                number(row.getCell(5), amount);
+                string(row.getCell(6), null); // 璋冧环娌℃湁瀵瑰簲鐨勭郴缁熷瓧娈�
+                string(row.getCell(7), item.getRemark());
+            }
+            string(sheet.getRow(0).getCell(0), company);
+            string(sheet.getRow(2).getCell(0), "缂栧彿锛�" + text(quotation.getNo()));
+            string(sheet.getRow(4).getCell(1), quotation.getCustomerName());
+            string(sheet.getRow(5).getCell(1), address);
+            string(sheet.getRow(6).getCell(1), contactName);
+            string(sheet.getRow(7).getCell(1), contactPhone);
+            string(sheet.getRow(13 + extraRows).getCell(6), "鎶ヤ环鍗曚綅锛�" + company);
+            string(sheet.getRow(14 + extraRows).getCell(6), "鑱�  绯� 浜猴細" + text(quotation.getOwnerUserName()));
+            string(sheet.getRow(15 + extraRows).getCell(6), "鎶ヤ环鏃ユ湡锛�" + (quotation.getQuotationTime() == null
+                    ? "" : quotation.getQuotationTime().format(DateTimeFormatter.ofPattern("yyyy骞碝M鏈坉d鏃�"))));
+            workbook.setPrintArea(0, 0, 7, 0, 17 + extraRows);
+
+            int picture = workbook.addPicture(CrmSaleQuotationDocumentRenderer.renderSeal(company), Workbook.PICTURE_TYPE_PNG);
+            var anchor = workbook.getCreationHelper().createClientAnchor();
+            anchor.setCol1(3);
+            anchor.setCol2(5);
+            anchor.setRow1(13 + extraRows);
+            anchor.setRow2(17 + extraRows);
+            sheet.createDrawingPatriarch().createPicture(anchor, picture);
+            workbook.write(output);
+            return output.toByteArray();
+        }
+    }
+
+    private static void string(Cell cell, String value) {
+        cell.setCellValue(text(value));
+    }
+
+    private static void number(Cell cell, BigDecimal value) {
+        if (value == null) {
+            cell.setBlank();
+        } else {
+            cell.setCellValue(value.doubleValue());
+        }
+    }
+
+    private static String text(String value) {
+        return value == null ? "" : value;
+    }
+}
diff --git a/yudao-module-crm/src/main/resources/templates/contract/sale-contract.docx b/yudao-module-crm/src/main/resources/templates/contract/sale-contract.docx
index 58fb169..df59748 100644
--- a/yudao-module-crm/src/main/resources/templates/contract/sale-contract.docx
+++ b/yudao-module-crm/src/main/resources/templates/contract/sale-contract.docx
Binary files differ
diff --git a/yudao-module-crm/src/main/resources/templates/quotation/sale-quotation.xlsx b/yudao-module-crm/src/main/resources/templates/quotation/sale-quotation.xlsx
new file mode 100644
index 0000000..2025021
--- /dev/null
+++ b/yudao-module-crm/src/main/resources/templates/quotation/sale-quotation.xlsx
Binary files differ
diff --git a/yudao-module-crm/src/test/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractDocumentRendererTest.java b/yudao-module-crm/src/test/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractDocumentRendererTest.java
index e5e5018..97f73bd 100644
--- a/yudao-module-crm/src/test/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractDocumentRendererTest.java
+++ b/yudao-module-crm/src/test/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractDocumentRendererTest.java
@@ -36,8 +36,9 @@
         String xml = new String(parts.get("word/document.xml"), StandardCharsets.UTF_8);
         assertTrue(xml.contains("HT20261015001")); assertTrue(xml.contains("2026骞�10鏈�15鏃�"));
         assertTrue(xml.contains("10000.00")); assertTrue(xml.contains("澹逛竾鍏冩暣"));
-        assertTrue(xml.contains("鍐诲共鍐櫕澶忚崏锛�2500绾т竴绛夛級")); assertTrue(xml.contains("浜や粯涓庨獙鏀�"));
-        assertFalse(xml.contains("鍖椾含鍚屼粊鍫�")); assertFalse(xml.contains("28504001040001454"));
+        assertTrue(xml.contains("鍐诲共鍐櫕澶忚崏")); assertTrue(xml.contains("2500绾т竴绛�")); assertTrue(xml.contains("浜よ揣鏉℃"));
+        assertTrue(xml.contains("璐ㄩ噺寮傝鏈熼檺")); assertFalse(xml.contains("SHHT20260102902-F"));
+        assertTrue(xml.contains("鐢叉柟锛堢洊绔狅級锛氫腑鍥界瀛﹂櫌瑗垮寳楂樺師鐢熺墿鐮旂┒鎵�"));
         assertFalse(xml.contains("${"));
         try(var template = new ClassPathResource("templates/contract/sale-contract.docx").getInputStream()) {
             var original = unzip(template.readAllBytes()); assertEquals(original.keySet(),parts.keySet());
@@ -52,10 +53,10 @@
         contract.setTotalPrice(new BigDecimal("249000"));
         String xml = new String(unzip(CrmContractDocumentRenderer.render(contract)).get("word/document.xml"),StandardCharsets.UTF_8);
         assertTrue(xml.contains("瀹㈡埛&lt;&amp;&gt;鍏徃")); assertTrue(xml.contains("涓庡悎鍚岄噾棰濈殑宸 1000.00 鍏�"));
-        assertEquals(25,xml.split("鍐诲共鍐櫕澶忚崏锛�2500绾т竴绛夛級",-1).length-1);
+        assertEquals(25,xml.split("鍐诲共鍐櫕澶忚崏",-1).length-1);
         assertEquals(25,xml.split("<w:cantSplit",-1).length-1);
         assertTrue(xml.contains("249000.00")); assertFalse(xml.contains("${"));
-        assertTrue(xml.contains("涔欐柟锛堥渶鏂癸級锛氬鎴�&lt;&amp;&gt;鍏徃"));
+        assertTrue(xml.contains("鐢叉柟锛堢洊绔狅級锛氬鎴�&lt;&amp;&gt;鍏徃"));
         String output = System.getProperty("contract.document.sample");
         if (output != null) Files.write(Path.of(output).resolveSibling("generated-contract-many.docx"), CrmContractDocumentRenderer.render(contract));
     }
diff --git a/yudao-module-crm/src/test/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationExcelRendererTest.java b/yudao-module-crm/src/test/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationExcelRendererTest.java
new file mode 100644
index 0000000..ba5bfd8
--- /dev/null
+++ b/yudao-module-crm/src/test/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationExcelRendererTest.java
@@ -0,0 +1,52 @@
+package cn.iocoder.yudao.module.crm.service.quotation;
+
+import cn.iocoder.yudao.module.crm.controller.admin.quotation.vo.CrmSaleQuotationRespVO;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayInputStream;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class CrmSaleQuotationExcelRendererTest {
+
+    @Test
+    void fillsMultipleItemsAndPreservesTemplateTermsAndPrintArea() throws Exception {
+        var quote = new CrmSaleQuotationRespVO();
+        quote.setNo("BJ-123");
+        quote.setCustomerName("瀹㈡埛鐢�");
+        quote.setOwnerUserName("閿�鍞憳");
+        quote.setQuotationTime(LocalDateTime.of(2026, 11, 10, 0, 0));
+        var first = new CrmSaleQuotationRespVO.Item();
+        first.setItemName("鐢电紗A");
+        first.setCount(new BigDecimal("2.5"));
+        first.setQuotationPrice(new BigDecimal("3.20"));
+        var second = new CrmSaleQuotationRespVO.Item();
+        second.setItemName("鐢电紗B");
+        second.setRemark("澶囨敞B");
+        quote.setItems(List.of(first, second));
+
+        byte[] bytes = CrmSaleQuotationExcelRenderer.render(quote, "娴嬭瘯鍏徃", "瀹㈡埛鍦板潃", "鑱旂郴浜�", "123456");
+        try (var workbook = new XSSFWorkbook(new ByteArrayInputStream(bytes))) {
+            var sheet = workbook.getSheetAt(0);
+            assertEquals("缂栧彿锛欱J-123", sheet.getRow(2).getCell(0).getStringCellValue());
+            assertEquals("瀹㈡埛鐢�", sheet.getRow(4).getCell(1).getStringCellValue());
+            assertEquals("瀹㈡埛鍦板潃", sheet.getRow(5).getCell(1).getStringCellValue());
+            assertEquals("鑱旂郴浜�", sheet.getRow(6).getCell(1).getStringCellValue());
+            assertEquals("123456", sheet.getRow(7).getCell(1).getStringCellValue());
+            assertEquals(2.5, sheet.getRow(10).getCell(3).getNumericCellValue());
+            assertEquals(8.0, sheet.getRow(10).getCell(5).getNumericCellValue());
+            assertEquals("鐢电紗B", sheet.getRow(11).getCell(0).getStringCellValue());
+            assertEquals("澶囨敞B", sheet.getRow(11).getCell(7).getStringCellValue());
+            String terms = sheet.getRow(13).getCell(0).getStringCellValue();
+            assertTrue(terms.contains("110鍏�/鍏枻"));
+            assertTrue(terms.contains("璐у埌45澶╁唴浠樻"));
+            assertEquals("鎶ヤ环鏃ユ湡锛�2026骞�11鏈�10鏃�", sheet.getRow(16).getCell(6).getStringCellValue());
+            assertTrue(workbook.getPrintArea(0).contains("$H$19"));
+            assertEquals(2, workbook.getAllPictures().size());
+        }
+    }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/MesQcNcrController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/MesQcNcrController.java
index 49eae0d..501d659 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/MesQcNcrController.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/MesQcNcrController.java
@@ -97,7 +97,7 @@
     @Operation(summary = "鍏抽棴涓嶅悎鏍煎搧澶勭悊鍗�")
     @PreAuthorize("@ss.hasPermission('mes:qc-ncr:close')")
     public CommonResult<Boolean> closeNcr(@Valid @RequestBody MesQcNcrCloseReqVO closeReqVO) {
-        ncrService.closeNcr(closeReqVO.getId(), closeReqVO.getCloseOpinion());
+        ncrService.closeNcr(closeReqVO.getId(), closeReqVO.getCloseOpinion(), closeReqVO.getReinspectionIpqcId());
         return success(true);
     }
 
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/MesQcPurchaseReturnController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/MesQcPurchaseReturnController.java
new file mode 100644
index 0000000..aff4f7e
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/MesQcPurchaseReturnController.java
@@ -0,0 +1,42 @@
+package cn.iocoder.yudao.module.mes.controller.admin.qc.ncr;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcPurchaseReturnDO;
+import cn.iocoder.yudao.module.mes.service.qc.ncr.MesQcPurchaseReturnService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.annotation.Resource;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+@Tag(name = "绠$悊鍚庡彴 - 鏉ユ枡涓嶅悎鏍奸噰璐��璐�")
+@RestController
+@RequestMapping("/mes/qc-purchase-return")
+public class MesQcPurchaseReturnController {
+    @Resource private MesQcPurchaseReturnService service;
+
+    @GetMapping("/get-by-ncr")
+    @Operation(summary = "鎸変笉鍚堟牸鍗曟煡鐪嬮噰璐��璐у崟")
+    @PreAuthorize("@ss.hasPermission('mes:qc-ncr:query') or @ss.hasPermission('mes:wm-return-vendor:finish')")
+    public CommonResult<MesQcPurchaseReturnDO> getByNcr(@RequestParam Long ncrId) {
+        return success(service.getByNcrId(ncrId));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "閲囪喘浠撳簱鏌ヨ寰呴��鍜屽凡閫�鍗曟嵁")
+    @PreAuthorize("@ss.hasPermission('mes:wm-return-vendor:finish')")
+    public CommonResult<PageResult<MesQcPurchaseReturnDO>> page(PageParam page, @RequestParam(required = false) Integer status) {
+        return success(service.getPage(page, status));
+    }
+
+    @PutMapping("/confirm")
+    @Operation(summary = "閲囪喘浠撳簱纭宸查��鍥炰緵搴斿晢")
+    @PreAuthorize("@ss.hasPermission('mes:wm-return-vendor:finish')")
+    public CommonResult<Boolean> confirm(@RequestParam Long id, @RequestParam(required = false) String remark) {
+        service.confirm(id, remark);
+        return success(true);
+    }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/vo/MesQcNcrCloseReqVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/vo/MesQcNcrCloseReqVO.java
index d25462e..8c65262 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/vo/MesQcNcrCloseReqVO.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/vo/MesQcNcrCloseReqVO.java
@@ -15,4 +15,7 @@
     @Schema(description = "鍏抽棴鎰忚", example = "澶勭疆瀹屾垚锛屼簣浠ュ叧闂�")
     private String closeOpinion;
 
+    @Schema(description = "杩斿伐鎴栬繑淇畬鎴愬悗鐨勬暣鎵瑰妫�杩囩▼妫�楠屽崟 ID")
+    private Long reinspectionIpqcId;
+
 }
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/vo/MesQcNcrDisposeReqVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/vo/MesQcNcrDisposeReqVO.java
index fadba43..5a02e6b 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/vo/MesQcNcrDisposeReqVO.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/vo/MesQcNcrDisposeReqVO.java
@@ -12,8 +12,8 @@
     @NotNull(message = "NCR缂栧彿涓嶈兘涓虹┖")
     private Long id;
 
-    @Schema(description = "澶勭疆鏂瑰紡锛�2-鎶ュ簾 3-杩斿伐 4-璁╂鏀捐 6-杩斾慨锛�", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
-    @NotNull(message = "澶勭疆鏂瑰紡涓嶈兘涓虹┖锛岃浠嶽璁╂鏀捐銆佽繑淇�佽繑宸ャ�佹姤搴焆涓�夋嫨涓�椤�")
+    @Schema(description = "澶勭疆鏂瑰紡锛�1閫�璐с��2鎶ュ簾銆�3杩斿伐銆�4璁╂鏀捐銆�6杩斾慨銆�7閲嶆柊鐢熶骇锛涘彲閫夐」鍙栧喅浜庢楠屾潵婧�", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
+    @NotNull(message = "澶勭疆鏂瑰紡涓嶈兘涓虹┖")
     private Integer disposition;
 
     @Schema(description = "澶勭悊浜篒D", example = "2")
@@ -34,4 +34,7 @@
     @Schema(description = "鎵规鍙凤紙鐗╂枡鍚敤鎵规绠$悊鏃跺繀濉紝涓嶅瓨鍦ㄤ細鑷姩鍒涘缓鎵规锛�", example = "BATCH20261109001")
     private String batchCode;
 
+    @Schema(description = "鍑鸿揣璁╂鏀捐鎴栬繑宸�/杩斾慨鏃堕�夊畾鐨勫疄闄呭簱瀛樿褰� ID")
+    private Long materialStockId;
+
 }
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/vo/MesQcNcrRespVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/vo/MesQcNcrRespVO.java
index 5a6cc22..ff22ca9 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/vo/MesQcNcrRespVO.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ncr/vo/MesQcNcrRespVO.java
@@ -13,6 +13,9 @@
 @ExcelIgnoreUnannotated
 public class MesQcNcrRespVO {
 
+    @Schema(description = "杩斿伐鎴栬繑淇叧闂椂浣跨敤鐨勫妫�鍗� ID")
+    private Long reinspectionIpqcId;
+
     @Schema(description = "缂栧彿", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
     @ExcelProperty("缂栧彿")
     private Long id;
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/itemreceipt/vo/line/MesWmItemReceiptLineSaveReqVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/itemreceipt/vo/line/MesWmItemReceiptLineSaveReqVO.java
index e9b053b..c1b4662 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/itemreceipt/vo/line/MesWmItemReceiptLineSaveReqVO.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/itemreceipt/vo/line/MesWmItemReceiptLineSaveReqVO.java
@@ -43,6 +43,9 @@
     @Schema(description = "鐢熶骇鎵瑰彿", example = "PB20260110")
     private String lotNumber;
 
+    @Schema(description = "鎸囧畾搴撳瓨鎵规鍙凤紱涓虹┖鏃舵寜瑙勫垯鐢熸垚")
+    private String batchCode;
+
     @Schema(description = "澶囨敞", example = "澶囨敞")
     private String remark;
 
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/ncr/MesQcNcrDO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/ncr/MesQcNcrDO.java
index 7dc778a..f97f98c 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/ncr/MesQcNcrDO.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/ncr/MesQcNcrDO.java
@@ -155,6 +155,9 @@
      */
     private String closeOpinion;
 
+    /** 鍏抽棴杩斿伐/杩斾慨鍗曟椂閲囩敤鐨勫妫�璇佹嵁銆� */
+    private Long reinspectionIpqcId;
+
     // ========== 鐘舵�佷笌娴佺▼ ==========
 
     /**
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/ncr/MesQcPurchaseConcessionDO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/ncr/MesQcPurchaseConcessionDO.java
new file mode 100644
index 0000000..8897be8
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/ncr/MesQcPurchaseConcessionDO.java
@@ -0,0 +1,21 @@
+package cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr;
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import java.math.BigDecimal;
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+@TableName("mes_qc_purchase_concession")
+public class MesQcPurchaseConcessionDO extends BaseDO {
+    @TableId private Long id;
+    private Long ncrId;
+    private Long iqcId;
+    private Long noticeId;
+    private Long noticeLineId;
+    private Long purchaseOrderItemId;
+    private Long receiptId;
+    private BigDecimal quantity;
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/ncr/MesQcPurchaseReturnDO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/ncr/MesQcPurchaseReturnDO.java
new file mode 100644
index 0000000..2c0a2a8
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/ncr/MesQcPurchaseReturnDO.java
@@ -0,0 +1,33 @@
+package cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/** 鏈叆搴撶殑鏉ユ枡涓嶅悎鏍煎搧鐩存帴閫�鍥炰緵搴斿晢锛屼笉浜х敓搴撳瓨鍑哄簱銆� */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@TableName("mes_qc_purchase_return")
+public class MesQcPurchaseReturnDO extends BaseDO {
+    @TableId private Long id;
+    private String code;
+    private Long ncrId;
+    private Long iqcId;
+    private Long noticeId;
+    private Long noticeLineId;
+    private Long purchaseOrderId;
+    private Long purchaseOrderItemId;
+    private Long vendorId;
+    private Long itemId;
+    private String vendorBatch;
+    private BigDecimal quantity;
+    /** 0 寰呬粨搴撻��璐э紝1 浠撳簱宸茬‘璁ら��璐с�� */
+    private Integer status;
+    private Long confirmedBy;
+    private LocalDateTime confirmedAt;
+    private String confirmationRemark;
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/productproduce/MesWmProductProduceLineDO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/productproduce/MesWmProductProduceLineDO.java
index 1d23242..a926ebe 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/productproduce/MesWmProductProduceLineDO.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/productproduce/MesWmProductProduceLineDO.java
@@ -80,6 +80,8 @@
      * 鏋氫妇 {@link cn.iocoder.yudao.module.mes.enums.wm.MesWmQualityStatusEnum}
      */
     private Integer qualityStatus;
+    /** 澶勭疆涓嶅悎鏍间骇鍑烘墍浣跨敤鐨� NCR锛岀┖琛ㄧず灏氭湭澶勭悊銆� */
+    private Long ncrDispositionId;
     /**
      * 澶囨敞
      */
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/productsales/MesWmProductSalesLineDO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/productsales/MesWmProductSalesLineDO.java
index 8747bc3..b744071 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/productsales/MesWmProductSalesLineDO.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/productsales/MesWmProductSalesLineDO.java
@@ -104,6 +104,8 @@
      * 鏋氫妇 {@link MesWmQualityStatusEnum}
      */
     private Integer qualityStatus;
+    /** 涓嶅悎鏍煎嚭璐ц鐨勫缃綊灞烇紝闃叉澶氫釜 NCR 閲嶅澶勭悊銆� */
+    private Long ncrDispositionId;
     /**
      * 澶囨敞
      */
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/returnsales/MesWmReturnSalesLineDO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/returnsales/MesWmReturnSalesLineDO.java
index 648d85c..a8a5e37 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/returnsales/MesWmReturnSalesLineDO.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/returnsales/MesWmReturnSalesLineDO.java
@@ -69,6 +69,8 @@
      * 鏋氫妇 {@link cn.iocoder.yudao.module.mes.enums.wm.MesWmQualityStatusEnum}
      */
     private Integer qualityStatus;
+    /** 宸插叏閲忚浆浜や笉鍚堟牸澶勭悊鐨勯��璐ц锛涘師閫�璐у崟涓嶅緱鍐嶆鍏ュ簱璇ヨ銆� */
+    private Long ncrDispositionId;
     /**
      * 澶囨敞
      */
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/ncr/MesQcNcrMapper.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/ncr/MesQcNcrMapper.java
index 3d7b41d..c5ac5c1 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/ncr/MesQcNcrMapper.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/ncr/MesQcNcrMapper.java
@@ -33,4 +33,10 @@
         return selectOne(MesQcNcrDO::getCode, code);
     }
 
+    /** 涓茶鍖栧悓涓�澶勭悊鍗曠殑鐘舵�佹祦杞強鍏朵笅娓稿崟鎹垱寤恒�� */
+    default MesQcNcrDO selectByIdForUpdate(Long id) {
+        return selectOne(new LambdaQueryWrapperX<MesQcNcrDO>()
+                .eq(MesQcNcrDO::getId, id).last("FOR UPDATE"));
+    }
+
 }
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/ncr/MesQcPurchaseConcessionMapper.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/ncr/MesQcPurchaseConcessionMapper.java
new file mode 100644
index 0000000..87da62c
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/ncr/MesQcPurchaseConcessionMapper.java
@@ -0,0 +1,13 @@
+package cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcPurchaseConcessionDO;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface MesQcPurchaseConcessionMapper extends BaseMapperX<MesQcPurchaseConcessionDO> {
+    default MesQcPurchaseConcessionDO selectByIqcId(Long id) {
+        return selectOne(new LambdaQueryWrapperX<MesQcPurchaseConcessionDO>()
+                .eq(MesQcPurchaseConcessionDO::getIqcId, id));
+    }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/ncr/MesQcPurchaseReturnMapper.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/ncr/MesQcPurchaseReturnMapper.java
new file mode 100644
index 0000000..154bbac
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/ncr/MesQcPurchaseReturnMapper.java
@@ -0,0 +1,34 @@
+package cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr;
+
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcPurchaseReturnDO;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface MesQcPurchaseReturnMapper extends BaseMapperX<MesQcPurchaseReturnDO> {
+    default MesQcPurchaseReturnDO selectByNcrId(Long ncrId) {
+        return selectOne(new LambdaQueryWrapperX<MesQcPurchaseReturnDO>()
+                .eq(MesQcPurchaseReturnDO::getNcrId, ncrId));
+    }
+    default MesQcPurchaseReturnDO selectByIdForUpdate(Long id) {
+        return selectOne(new LambdaQueryWrapperX<MesQcPurchaseReturnDO>()
+                .eq(MesQcPurchaseReturnDO::getId, id).last("FOR UPDATE"));
+    }
+    default MesQcPurchaseReturnDO selectConfirmedByIqcId(Long iqcId) {
+        return selectOne(new LambdaQueryWrapperX<MesQcPurchaseReturnDO>()
+                .eq(MesQcPurchaseReturnDO::getIqcId, iqcId)
+                .eq(MesQcPurchaseReturnDO::getStatus, 1).last("LIMIT 1"));
+    }
+    default MesQcPurchaseReturnDO selectByIqcId(Long iqcId) {
+        return selectOne(new LambdaQueryWrapperX<MesQcPurchaseReturnDO>()
+                .eq(MesQcPurchaseReturnDO::getIqcId, iqcId));
+    }
+    default PageResult<MesQcPurchaseReturnDO> selectPage(PageParam page, Integer status) {
+        return selectPage(page, new LambdaQueryWrapperX<MesQcPurchaseReturnDO>()
+                .eqIfPresent(MesQcPurchaseReturnDO::getStatus, status)
+                .orderByDesc(MesQcPurchaseReturnDO::getId));
+    }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/returnsales/MesWmReturnSalesMapper.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/returnsales/MesWmReturnSalesMapper.java
index 988d14d..d8e0a39 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/returnsales/MesWmReturnSalesMapper.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/returnsales/MesWmReturnSalesMapper.java
@@ -55,4 +55,9 @@
                 .eq(MesWmReturnSalesDO::getCode, code));
     }
 
+    default MesWmReturnSalesDO selectByIdForUpdate(Long id) {
+        return selectOne(new LambdaQueryWrapperX<MesWmReturnSalesDO>()
+                .eq(MesWmReturnSalesDO::getId, id).last("FOR UPDATE"));
+    }
+
 }
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/qc/MesNcrDispositionEnum.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/qc/MesNcrDispositionEnum.java
index 35ef079..5bd6629 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/qc/MesNcrDispositionEnum.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/qc/MesNcrDispositionEnum.java
@@ -20,7 +20,8 @@
     REWORK(3, "杩斿伐"),
     CONCESSION(4, "璁╂鏀捐"),
     DOWNGRADE(5, "闄嶇骇浣跨敤"),
-    REPAIR(6, "杩斾慨");
+    REPAIR(6, "杩斾慨"),
+    REPRODUCTION(7, "閲嶆柊鐢熶骇");
 
     public static final Integer[] ARRAYS = Arrays.stream(values())
             .map(MesNcrDispositionEnum::getType).toArray(Integer[]::new);
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/wm/MesWmMiscIssueTypeEnum.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/wm/MesWmMiscIssueTypeEnum.java
index 5162329..e12faf1 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/wm/MesWmMiscIssueTypeEnum.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/wm/MesWmMiscIssueTypeEnum.java
@@ -11,7 +11,8 @@
 public enum MesWmMiscIssueTypeEnum implements ArrayValuable<Integer> {
 
     ADJUST(1, "搴撳瓨璋冩暣"),
-    SCRAP(2, "鎶ュ簾鍑哄簱");
+    SCRAP(2, "鎶ュ簾鍑哄簱"),
+    REWORK(3, "杩斿伐棰嗙敤");
 
     private final Integer type;
     private final String name;
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/MesQcCompletionHelper.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/MesQcCompletionHelper.java
index aad0c81..3d4bace 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/MesQcCompletionHelper.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/MesQcCompletionHelper.java
@@ -1,7 +1,6 @@
 package cn.iocoder.yudao.module.mes.service.qc;
 
 import cn.iocoder.yudao.framework.common.exception.ServiceException;
-import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi;
 import jakarta.annotation.Resource;
 import org.springframework.stereotype.Component;
 import java.math.BigDecimal;
@@ -9,7 +8,6 @@
 /** 鎸夋暟閲忔眹鎬昏川妫�缁撴灉锛屼笉鎺ㄦ柇涓嶅悎鏍煎搧鐨勫悗缁缃柟寮忋�� */
 @Component
 public class MesQcCompletionHelper {
-    @Resource private StorageAttachmentApi storageApi;
     @Resource private org.springframework.jdbc.core.JdbcTemplate jdbcTemplate;
 
     public void lockDocument(String type, Long id) {
@@ -29,8 +27,7 @@
         if (total.signum() <= 0 || checked == null || total.compareTo(checked) != 0) {
             throw new ServiceException(400, "鍚堟牸鏁伴噺涓庝笉鍚堟牸鏁伴噺涔嬪拰椤诲ぇ浜庨浂涓旂瓑浜庢娴嬫暟閲�");
         }
-        var attachments = storageApi.listAttachments("mes_qc_" + type + "_attachment", id);
-        if (attachments == null || attachments.isEmpty()) throw new ServiceException(400, "璇峰厛涓婁紶妫�楠岄檮浠�");
+        // 妫�楠岄檮浠舵敼涓洪潪蹇呭~锛屽畬鎴愭楠屾椂涓嶅啀寮哄埗鏍¢獙鏄惁宸蹭笂浼犮��
         // 涓庣幇鏈� mes_qc_check_result 瀛楀吀涓�鑷达細1 閫氳繃锛�2 涓嶉�氳繃銆�
         return unqualified.signum() == 0 ? 1 : 2;
     }
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcArrivalDispositionService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcArrivalDispositionService.java
new file mode 100644
index 0000000..120e9d9
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcArrivalDispositionService.java
@@ -0,0 +1,52 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.arrivalnotice.MesWmArrivalNoticeDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr.MesQcPurchaseReturnMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr.MesQcPurchaseConcessionMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.arrivalnotice.MesWmArrivalNoticeLineMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.arrivalnotice.MesWmArrivalNoticeMapper;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcCheckResultEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmArrivalNoticeStatusEnum;
+import jakarta.annotation.Resource;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import java.math.BigDecimal;
+import java.util.Objects;
+
+/** 渚濇嵁鍚勮鍘熷璐ㄦ缁撹鍜岀湡瀹為��璐х‘璁ら噸鏂拌绠楀埌璐у崟鐘舵�併�� */
+@Service
+public class MesQcArrivalDispositionService {
+    @Resource private MesWmArrivalNoticeMapper arrivalNoticeMapper;
+    @Resource private MesWmArrivalNoticeLineMapper lineMapper;
+    @Resource private MesQcPurchaseReturnMapper returnMapper;
+    @Resource private MesQcPurchaseConcessionMapper concessionMapper;
+
+    @Transactional(rollbackFor = Exception.class)
+    public void refresh(Long noticeId) {
+        var notice = arrivalNoticeMapper.selectOne(new LambdaQueryWrapperX<MesWmArrivalNoticeDO>()
+                .eq(MesWmArrivalNoticeDO::getId, noticeId).last("FOR UPDATE"));
+        if (notice == null || !Objects.equals(notice.getStatus(), MesWmArrivalNoticeStatusEnum.PENDING_QC.getStatus())) return;
+        var lines = lineMapper.selectListByNoticeId(noticeId);
+        if (lines.isEmpty()) return;
+        boolean hasReceiptQuantity = false;
+        for (var line : lines) {
+            if (Boolean.TRUE.equals(line.getIqcCheckFlag())) {
+                if (line.getIqcId() == null || line.getIqcCheckResult() == null || line.getQualifiedQuantity() == null) return;
+                if (!MesQcCheckResultEnum.canInbound(line.getIqcCheckResult())) {
+                    var returned = returnMapper.selectConfirmedByIqcId(line.getIqcId());
+                    var concession = concessionMapper.selectByIqcId(line.getIqcId());
+                    boolean returnDone = returned != null && Objects.equals(returned.getNoticeLineId(), line.getId());
+                    boolean concessionDone = concession != null && Objects.equals(concession.getNoticeLineId(), line.getId());
+                    if (!returnDone && !concessionDone) return;
+                }
+            }
+            BigDecimal quantity = line.getQualifiedQuantity() != null ? line.getQualifiedQuantity() : line.getArrivalQuantity();
+            if (quantity == null || quantity.signum() < 0) return;
+            if (quantity.signum() > 0) hasReceiptQuantity = true;
+        }
+        arrivalNoticeMapper.updateById(new MesWmArrivalNoticeDO().setId(noticeId)
+                .setStatus(hasReceiptQuantity ? MesWmArrivalNoticeStatusEnum.PENDING_RECEIPT.getStatus()
+                        : MesWmArrivalNoticeStatusEnum.FINISHED.getStatus()));
+    }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcConcessionService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcConcessionService.java
new file mode 100644
index 0000000..3ab83c4
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcConcessionService.java
@@ -0,0 +1,156 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.hutool.core.util.StrUtil;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.oqc.MesQcOqcDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesLineDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.oqc.MesQcOqcMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales.MesWmProductSalesMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales.MesWmProductSalesLineMapper;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.transaction.MesWmTransactionDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.transaction.MesWmTransactionMapper;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmTransactionTypeEnum;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.ncr.vo.MesQcNcrDisposeReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.wm.productsales.vo.MesWmProductSalesShippingReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.wm.productsales.vo.detail.MesWmProductSalesDetailSaveReqVO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesDetailDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.materialstock.MesWmMaterialStockDO;
+import cn.iocoder.yudao.module.mes.service.wm.materialstock.MesWmMaterialStockService;
+import cn.iocoder.yudao.module.mes.service.wm.productsales.MesWmProductSalesService;
+import cn.iocoder.yudao.module.mes.service.wm.productsales.MesWmProductSalesDetailService;
+import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmProductSalesStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmQualityStatusEnum;
+import cn.iocoder.yudao.module.mes.service.wm.productsales.MesWmProductSalesLineService;
+import jakarta.annotation.Resource;
+import org.springframework.stereotype.Component;
+import java.util.Objects;
+import java.math.BigDecimal;
+import java.util.List;
+
+/** 灏嗚姝ュ喅瀹氬洖鍐欏師鍑哄簱琛岋紱蹇呴』鐢� NCR 澶勭疆浜嬪姟璋冪敤銆� */
+@Component
+public class MesQcNcrOqcConcessionService {
+    @Resource private MesQcOqcMapper oqcMapper;
+    @Resource private MesWmProductSalesMapper salesMapper;
+    @Resource private MesWmProductSalesLineMapper lineMapper;
+    @Resource private MesWmProductSalesLineService lineService;
+    @Resource private MesWmTransactionMapper transactionMapper;
+    @Resource private MesWmMaterialStockService stockService;
+    @Resource private MesWmProductSalesDetailService detailService;
+    @Resource private MesWmProductSalesService salesService;
+
+    public void release(MesQcNcrDO ncr, MesQcNcrDisposeReqVO req) {
+        MesQcOqcDO qc = oqcMapper.selectById(ncr.getQcId());
+        if (qc == null || !Objects.equals(qc.getSourceDocType(), MesBizTypeConstants.WM_PRODUCT_SALES)
+                || qc.getSourceDocId() == null || qc.getSourceLineId() == null || StrUtil.isBlank(qc.getBatchCode())
+                || !Objects.equals(qc.getStatus(), MesQcStatusEnum.FINISHED.getStatus())
+                || !Objects.equals(qc.getCheckResult(), 2) || !Objects.equals(qc.getItemId(), ncr.getItemId())
+                || qc.getUnqualifiedQuantity() == null || ncr.getUnqualifiedQuantity() == null
+                || qc.getUnqualifiedQuantity().signum() <= 0
+                || qc.getUnqualifiedQuantity().compareTo(ncr.getUnqualifiedQuantity()) != 0) {
+            throw new ServiceException(400, "鍑鸿揣璁╂闇�鍏宠仈宸插畬鎴愮殑涓嶅悎鏍煎嚭璐ф楠屻�佸師鍑哄簱琛屽強鏄庣‘鎵规锛岀墿鏂欏拰涓嶅悎鏍兼暟閲忛』涓�鑷�");
+        }
+        MesWmProductSalesDO sales = salesMapper.selectOne(new LambdaQueryWrapperX<MesWmProductSalesDO>()
+                .eq(MesWmProductSalesDO::getId, qc.getSourceDocId()).last("FOR UPDATE"));
+        MesWmProductSalesLineDO line = lineMapper.selectOne(new LambdaQueryWrapperX<MesWmProductSalesLineDO>()
+                .eq(MesWmProductSalesLineDO::getId, qc.getSourceLineId()).last("FOR UPDATE"));
+        if (sales == null || line == null || !Objects.equals(sales.getStatus(), MesWmProductSalesStatusEnum.CONFIRMED.getStatus())
+                || !Objects.equals(line.getSalesId(), sales.getId()) || !Objects.equals(line.getOqcId(), qc.getId())
+                || !Objects.equals(line.getQualityStatus(), MesWmQualityStatusEnum.FAIL.getStatus())
+                || !Objects.equals(line.getItemId(), qc.getItemId()) || line.getQuantity() == null
+                || qc.getCheckQuantity() == null || line.getQuantity().signum() <= 0
+                || qc.getQualifiedQuantity() == null || qc.getQualifiedQuantity().signum() < 0
+                || qc.getQualifiedQuantity().add(qc.getUnqualifiedQuantity()).compareTo(qc.getCheckQuantity()) != 0
+                || (StrUtil.isNotBlank(line.getBatchCode()) && !Objects.equals(line.getBatchCode(), qc.getBatchCode()))
+                || qc.getCheckQuantity().compareTo(line.getQuantity()) != 0) {
+            throw new ServiceException(400, "鍑鸿揣璁╂瑕佹眰鍘熷嚭搴撳崟澶勪簬寰呮楠岀姸鎬侊紝鍘熻浠嶇粦瀹氭湰娆′笉鍚堟牸妫�楠屼笖妫�娴嬫暟閲忚鐩栨暣琛�");
+        }
+        MesWmMaterialStockDO stock = req.getMaterialStockId() == null ? null : stockService.getMaterialStock(req.getMaterialStockId());
+        if (stock == null || !Objects.equals(stock.getItemId(), qc.getItemId())
+                || !Objects.equals(stock.getBatchCode(), qc.getBatchCode())
+                || (line.getMaterialStockId() != null && !Objects.equals(line.getMaterialStockId(), stock.getId()))
+                || stock.getWarehouseId() == null || stock.getLocationId() == null || stock.getAreaId() == null) {
+            throw new ServiceException(400, "璇烽�夋嫨鍘熸楠屾壒娆$殑瀹為檯搴撳瓨鍙婂畬鏁村簱浣嶏紱鍘熻鎸囧畾搴撳瓨鏃跺繀椤婚�夋嫨璇ュ簱瀛�");
+        }
+        var currentDetails = detailService.getProductSalesDetailListByLineId(line.getId());
+        if (!currentDetails.isEmpty()) {
+            throw new ServiceException(400, "璇ュ嚭搴撹宸叉湁鎷h揣鏄庣粏锛岃鍏堟牳瀵瑰苟娓呯悊鍚庨噸鏂伴�夋嫨瀹為檯搴撳瓨");
+        }
+        // 鍏朵粬琛屼篃蹇呴』瀹屾暣涓斿彲鍑哄簱锛涙湰鎿嶄綔浠ユ暣寮犻攢鍞嚭搴撳崟涓轰簨鍔¤竟鐣屻��
+        for (MesWmProductSalesLineDO other : lineService.getProductSalesLineListBySalesId(sales.getId())) {
+            if (Objects.equals(other.getId(), line.getId())) continue;
+            if (Boolean.TRUE.equals(other.getOqcCheckFlag())
+                    && !Objects.equals(other.getQualityStatus(), MesWmQualityStatusEnum.PASS.getStatus())) {
+                throw new ServiceException(400, "鍚屼竴閿�鍞嚭搴撳崟杩樻湁鏈�氳繃璐ㄦ鐨勮锛屼笉鑳芥暣鍗曞嚭搴�");
+            }
+            var details = detailService.getProductSalesDetailListByLineId(other.getId());
+            BigDecimal total = details.stream().map(MesWmProductSalesDetailDO::getQuantity)
+                    .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+            if (details.isEmpty() || other.getQuantity() == null || other.getQuantity().signum() <= 0
+                    || total.compareTo(other.getQuantity()) != 0
+                    || details.stream().anyMatch(d -> d.getQuantity() == null || d.getQuantity().signum() <= 0
+                            || !Objects.equals(d.getSalesId(), sales.getId()) || !Objects.equals(d.getLineId(), other.getId())
+                            || !Objects.equals(d.getItemId(), other.getItemId()))) {
+                throw new ServiceException(400, "鍚屼竴閿�鍞嚭搴撳崟鍏朵粬琛岀殑鎷h揣鏄庣粏鏈榻愶紝涓嶈兘鏁村崟鍑哄簱");
+            }
+        }
+        lineService.updateProductSalesLineWhenOqcFinish(line.getId(), qc.getId(), 1);
+        MesWmProductSalesDetailSaveReqVO detail = new MesWmProductSalesDetailSaveReqVO();
+        detail.setSalesId(sales.getId()); detail.setLineId(line.getId()); detail.setItemId(qc.getItemId());
+        detail.setMaterialStockId(stock.getId()); detail.setQuantity(line.getQuantity());
+        detail.setBatchId(stock.getBatchId()); detail.setBatchCode(stock.getBatchCode());
+        detail.setWarehouseId(stock.getWarehouseId()); detail.setLocationId(stock.getLocationId()); detail.setAreaId(stock.getAreaId());
+        detailService.createProductSalesDetail(detail);
+        if (!salesService.checkProductSalesQuantity(sales.getId())) {
+            throw new ServiceException(400, "閿�鍞嚭搴撳崟鏄庣粏鏁伴噺涓嶅畬鏁达紝涓嶈兘鏁村崟鍑哄簱");
+        }
+        salesService.stockProductSales(sales.getId());
+        MesWmProductSalesShippingReqVO shipping = new MesWmProductSalesShippingReqVO();
+        shipping.setId(sales.getId());
+        salesService.shippingProductSales(shipping);
+        salesService.finishProductSales(sales.getId());
+    }
+
+    /** 瀹為檯鍑哄簱鍚庢墠鑳藉叧闂姝ュ崟锛涗笉鏀瑰彉鍘熷涓嶅悎鏍兼楠岀粨璁恒�� */
+    public void validateBeforeClose(MesQcNcrDO ncr) {
+        MesQcOqcDO qc = oqcMapper.selectById(ncr.getQcId());
+        if (qc == null || !Objects.equals(qc.getSourceDocType(), MesBizTypeConstants.WM_PRODUCT_SALES)
+                || qc.getSourceDocId() == null || qc.getSourceLineId() == null || StrUtil.isBlank(qc.getBatchCode())
+                || !Objects.equals(qc.getItemId(), ncr.getItemId())
+                || qc.getUnqualifiedQuantity() == null || ncr.getUnqualifiedQuantity() == null
+                || qc.getUnqualifiedQuantity().signum() <= 0
+                || qc.getUnqualifiedQuantity().compareTo(ncr.getUnqualifiedQuantity()) != 0) {
+            throw new ServiceException(400, "鏃犳硶鏍搁獙璁╂鍑鸿揣鐨勬潵婧愭楠屽崟鍙婂師鎵规");
+        }
+        MesWmProductSalesDO sales = salesMapper.selectOne(new LambdaQueryWrapperX<MesWmProductSalesDO>()
+                .eq(MesWmProductSalesDO::getId, qc.getSourceDocId()).last("FOR UPDATE"));
+        MesWmProductSalesLineDO line = lineMapper.selectOne(new LambdaQueryWrapperX<MesWmProductSalesLineDO>()
+                .eq(MesWmProductSalesLineDO::getId, qc.getSourceLineId()).last("FOR UPDATE"));
+        if (sales == null || line == null || !Objects.equals(sales.getStatus(), MesWmProductSalesStatusEnum.FINISHED.getStatus())
+                || !Objects.equals(line.getSalesId(), sales.getId()) || !Objects.equals(line.getOqcId(), qc.getId())
+                || !Objects.equals(line.getItemId(), qc.getItemId()) || line.getQuantity() == null
+                || qc.getCheckQuantity() == null || line.getQuantity().compareTo(qc.getCheckQuantity()) != 0) {
+            throw new ServiceException(400, "鍘熼攢鍞嚭搴撳崟灏氭湭瀹屾垚锛屾垨鍑哄簱琛屼笌妫�楠屾潵婧愪笉涓�鑷达紝涓嶈兘鍏抽棴");
+        }
+        List<MesWmTransactionDO> flows = transactionMapper.selectList(new LambdaQueryWrapperX<MesWmTransactionDO>()
+                .eq(MesWmTransactionDO::getBizType, MesBizTypeConstants.WM_PRODUCT_SALES)
+                .eq(MesWmTransactionDO::getBizId, sales.getId()).eq(MesWmTransactionDO::getBizLineId, line.getId())
+                .eq(MesWmTransactionDO::getType, MesWmTransactionTypeEnum.OUT.getType()));
+        BigDecimal out = BigDecimal.ZERO;
+        for (MesWmTransactionDO flow : flows) {
+            if (!Objects.equals(flow.getItemId(), qc.getItemId()) || !Objects.equals(flow.getBatchCode(), qc.getBatchCode())
+                    || flow.getQuantity() == null || flow.getQuantity().signum() >= 0) {
+                throw new ServiceException(400, "鍑哄簱娴佹按鐨勭墿鏂欍�佹壒娆℃垨鏁伴噺涓庤姝ユ楠屼笉涓�鑷�");
+            }
+            out = out.subtract(flow.getQuantity());
+        }
+        if (out.compareTo(line.getQuantity()) != 0) {
+            throw new ServiceException(400, "鍘熼攢鍞嚭搴撴祦姘存暟閲忎笉瀹屾暣锛屼笉鑳藉叧闂姝ュ崟");
+        }
+    }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcReproductionService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcReproductionService.java
new file mode 100644
index 0000000..2e7d60e
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcReproductionService.java
@@ -0,0 +1,176 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.hutool.core.util.StrUtil;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.mes.controller.admin.pro.workorder.vo.MesProWorkOrderSaveReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo.MesProTaskAutoGenerateReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.pro.workorder.vo.process.MesProWorkOrderProcessSaveReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.ncr.vo.MesQcNcrDisposeRespVO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderBomDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.md.item.MesMdItemMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.pro.workorder.MesProWorkOrderMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.pro.workorder.MesProWorkOrderBomMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.oqc.MesQcOqcMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.batch.MesWmBatchMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales.MesWmProductSalesLineMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales.MesWmProductSalesMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productproduce.MesWmProductProduceLineMapper;
+import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants;
+import cn.iocoder.yudao.module.mes.enums.md.autocode.MesMdAutoCodeRuleCodeEnum;
+import cn.iocoder.yudao.module.mes.enums.pro.MesProWorkOrderSourceTypeEnum;
+import cn.iocoder.yudao.module.mes.enums.pro.MesProWorkOrderTypeEnum;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmQualityStatusEnum;
+import cn.iocoder.yudao.module.mes.service.md.autocode.MesMdAutoCodeRecordService;
+import cn.iocoder.yudao.module.mes.service.pro.workorder.MesProWorkOrderProcessService;
+import cn.iocoder.yudao.module.mes.service.pro.workorder.MesProWorkOrderService;
+import cn.iocoder.yudao.module.mes.service.pro.task.MesProTaskService;
+import jakarta.annotation.Resource;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.time.LocalDateTime;
+import java.util.Arrays;
+import java.util.Objects;
+
+/** 鍑鸿揣鎴栬繃绋嬩笉鍚堟牸閲嶆柊鐢熶骇锛屽鍒舵潵婧愬伐鍗曠殑宸ュ簭鍙� BOM 蹇収銆� */
+@Service
+public class MesQcNcrOqcReproductionService {
+    @Resource private MesQcOqcMapper oqcMapper;
+    @Resource private MesWmProductSalesLineMapper salesLineMapper;
+    @Resource private MesWmProductSalesMapper salesMapper;
+    @Resource private MesWmProductProduceLineMapper produceLineMapper;
+    @Resource private MesQcNcrScrapService sourceService;
+    @Resource private MesWmBatchMapper batchMapper;
+    @Resource private MesProWorkOrderMapper orderMapper;
+    @Resource private MesProWorkOrderBomMapper bomMapper;
+    @Resource private MesMdItemMapper itemMapper;
+    @Resource private MesProWorkOrderService orderService;
+    @Resource private MesProWorkOrderProcessService processService;
+    @Resource private MesProTaskService taskService;
+    @Resource private MesMdAutoCodeRecordService autoCodeService;
+
+    @Transactional(rollbackFor = Exception.class)
+    public MesQcNcrDisposeRespVO reproduce(MesQcNcrDO ncr, Integer disposition) {
+        if (!Objects.equals(ncr.getQcType(), MesQcTypeEnum.OQC.getType()) || ncr.getQcId() == null
+                || ncr.getUnqualifiedQuantity() == null || ncr.getUnqualifiedQuantity().signum() <= 0)
+            throw error("閲嶆柊鐢熶骇闇�瑕佸叧鑱斿嚭璐ц川妫�鍙婃湁鏁堜笉鍚堟牸鏁伴噺");
+        var qc = oqcMapper.selectById(ncr.getQcId());
+        if (qc == null || !Objects.equals(qc.getStatus(), MesQcStatusEnum.FINISHED.getStatus())
+                || !Objects.equals(qc.getSourceDocType(), MesBizTypeConstants.WM_PRODUCT_SALES)
+                || qc.getSourceDocId() == null || qc.getSourceLineId() == null
+                || !Objects.equals(qc.getItemId(), ncr.getItemId()) || !same(qc.getUnqualifiedQuantity(), ncr.getUnqualifiedQuantity()))
+            throw error("鍑鸿揣妫�楠屾潵婧愩�佺墿鏂欐垨涓嶅悎鏍兼暟閲忎笉涓�鑷达紝鏃犳硶閲嶆柊鐢熶骇");
+        var line = salesLineMapper.selectById(qc.getSourceLineId());
+        var sales = salesMapper.selectById(qc.getSourceDocId());
+        if (line == null || sales == null || !Objects.equals(line.getSalesId(), sales.getId())
+                || !Objects.equals(line.getOqcId(), qc.getId()) || !Objects.equals(line.getItemId(), ncr.getItemId())
+                || !Objects.equals(line.getQualityStatus(), MesWmQualityStatusEnum.FAIL.getStatus())
+                || !same(line.getQuantity(), qc.getOutQuantity()) || ncr.getUnqualifiedQuantity().compareTo(line.getQuantity()) > 0)
+            throw error("鏃犳硶鍞竴鏍稿鍑鸿揣妫�楠屽搴旂殑涓嶅悎鏍煎嚭璐ц鍜屾暟閲�");
+        if (sales.getClientId() == null || !Objects.equals(sales.getClientId(), qc.getClientId())
+                || line.getBatchId() == null || StrUtil.isBlank(line.getBatchCode())
+                || !Objects.equals(line.getBatchCode(), qc.getBatchCode()))
+            throw error("鍑鸿揣妫�楠岀己灏戜竴鑷寸殑瀹㈡埛鎴栨壒娆★紝鏃犳硶纭畾鍘熺敓浜ц鍗�");
+        var batch = batchMapper.selectById(line.getBatchId());
+        if (batch == null || !Objects.equals(batch.getCode(), line.getBatchCode())
+                || !Objects.equals(batch.getItemId(), ncr.getItemId()) || !Objects.equals(batch.getClientId(), sales.getClientId())
+                || batch.getWorkOrderId() == null || (StrUtil.isNotBlank(qc.getReelNo()) && !Objects.equals(qc.getReelNo(), batch.getReelNo())))
+            throw error("鍑鸿揣鎵规鏈粦瀹氫竴鑷寸殑瀹㈡埛銆佺墿鏂欍�佺洏鍙峰拰鍘熺敓浜ц鍗�");
+        var original = orderMapper.selectById(batch.getWorkOrderId());
+        if (original == null || !Objects.equals(original.getClientId(), sales.getClientId()) || original.getProductId() == null)
+            throw error("鎵规缁戝畾鐨勫師鐢熶骇璁㈠崟涓嶅瓨鍦ㄦ垨瀹㈡埛涓嶄竴鑷�");
+        return createFromOriginal(ncr, disposition, original, sales.getClientId(), batch.getCode(), "閲嶆柊鐢熶骇-");
+    }
+
+    /** 璋冪敤鍓嶉』鍦ㄥ悓涓�浜嬪姟鍐呴�氳繃 claimIpqcSource 閿佸畾骞舵牳閿�璇ヤ笉鍚堟牸浜у嚭銆� */
+    @Transactional(rollbackFor = Exception.class)
+    public MesQcNcrDisposeRespVO reproduceIpqc(MesQcNcrDO ncr, Integer disposition,
+                                               MesQcNcrScrapService.IpqcSource source) {
+        var verified = sourceService.validateIpqcSource(ncr);
+        if (source == null || !Objects.equals(source, verified)) throw error("杩囩▼妫�楠屾潵婧愪骇鍑哄凡鍙樺寲锛岃鍒锋柊鍚庨噸璇�");
+        var line = produceLineMapper.selectById(source.sourceLineId());
+        if (line == null || ncr.getId() == null || !Objects.equals(line.getNcrDispositionId(), ncr.getId()))
+            throw error("杩囩▼涓嶅悎鏍间骇鍑哄皻鏈敱璇ュ鐞嗗崟鏍搁攢");
+        var original = orderMapper.selectById(source.orderId());
+        if (original == null || original.getProductId() == null) throw error("杩囩▼妫�楠屾潵婧愮敓浜ц鍗曚笉瀛樺湪");
+        return createFromOriginal(ncr, disposition, original, original.getClientId(), source.batchCode(), "閲嶆柊鐢熶骇-");
+    }
+
+    /**
+     * 鍑鸿揣涓嶅悎鏍艰繑宸�/杩斾慨锛氬鐢ㄥ師宸ュ崟鐨勫伐鑹鸿矾绾夸笌 BOM 鍏嬮殕涓�寮犺繑宸ュ伐鍗曘��
+     *
+     * <p>璋冪敤鏂归』宸插畬鎴愭潵婧愯棰嗐�佸師鎴愬搧搴撳瓨鍑哄簱鍙婂師閿�鍞嚭搴撳崟鍙栨秷銆�</p>
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public MesQcNcrDisposeRespVO createReworkFromOriginal(MesQcNcrDO ncr, Integer disposition,
+                                                          MesProWorkOrderDO original, Long clientId,
+                                                          String batchCode, String namePrefix) {
+        return createFromOriginal(ncr, disposition, original, clientId, batchCode, namePrefix);
+    }
+
+    private MesQcNcrDisposeRespVO createFromOriginal(MesQcNcrDO ncr, Integer disposition,
+                                                     MesProWorkOrderDO original, Long clientId, String batchCode,
+                                                     String namePrefix) {
+        var product = itemMapper.selectById(original.getProductId());
+        if (product == null || !Objects.equals(product.getMdmItemId(), ncr.getItemId()))
+            throw error("鍘熺敓浜ц鍗曚骇鍝佷笌涓嶅悎鏍肩墿鏂欐槧灏勪笉涓�鑷�");
+        var processes = processService.getWorkOrderProcessListByWorkOrderId(original.getId());
+        if (processes == null || processes.isEmpty()) throw error("鍘熺敓浜ц鍗曟病鏈夊伐搴忓揩鐓э紝鏃犳硶鑷姩涓嬭揪閲嶆柊鐢熶骇");
+        if (original.getRouteId() == null) throw error("鍘熺敓浜ц鍗曟湭璁板綍宸ヨ壓璺嚎锛屾棤娉曡嚜鍔ㄧ敓鎴愮敓浜т换鍔�");
+        var sourceBoms = bomMapper.selectListByWorkOrderId(original.getId());
+        if (sourceBoms == null) throw error("鏃犳硶璇诲彇鍘熷伐鍗曟姇鏂� BOM");
+        if (sourceBoms.stream().anyMatch(b -> b.getItemId() == null || b.getQuantity() == null || b.getQuantity().signum() < 0
+                || (b.getProcessId() == null && (original.getQuantity() == null || original.getQuantity().signum() <= 0))))
+            throw error("鍘熷伐鍗� BOM 鎴栬鍗曟暟閲忔棤鏁堬紝鏃犳硶澶嶅埗鎶曟枡");
+        if (sourceBoms.stream().anyMatch(b -> b.getProcessId() != null && processes.stream()
+                .noneMatch(p -> Objects.equals(p.getProcessId(), b.getProcessId()))))
+            throw error("鍘熷伐鍗� BOM 鍏宠仈浜嗕笉瀛樺湪鐨勫伐搴忥紝鏃犳硶鑷姩澶嶅埗");
+
+        String code = autoCodeService.generateAutoCode(MesMdAutoCodeRuleCodeEnum.PRO_WORK_ORDER_CODE.getCode());
+        var request = new MesProWorkOrderSaveReqVO();
+        request.setCode(code); request.setName(namePrefix + ncr.getCode()); request.setType(MesProWorkOrderTypeEnum.SELF.getType());
+        request.setOrderSourceType(MesProWorkOrderSourceTypeEnum.STORE.getType()); request.setOrderSourceCode(ncr.getCode());
+        request.setProductId(original.getProductId()); request.setReelNo(original.getReelNo());
+        request.setClientId(clientId); request.setQuantity(ncr.getUnqualifiedQuantity());
+        request.setRequestDate(LocalDateTime.now()); request.setFeedbackApprove(original.getFeedbackApprove());
+        request.setProcessDefinitionKey(original.getProcessDefinitionKey()); request.setFeedbackRole(original.getFeedbackRole());
+        request.setRemark("鐢变笉鍚堟牸鍗昜" + ncr.getCode() + "]" + StrUtil.removeSuffix(namePrefix, "-")
+                + "锛屽師宸ュ崟[" + original.getCode() + "]锛屽師鎵规[" + StrUtil.blankToDefault(batchCode, "鏃�") + "]");
+        Long id = orderService.createWorkOrder(request);
+        orderMapper.updateById(new MesProWorkOrderDO().setId(id).setRouteId(original.getRouteId()).setAutoFinishFlag(original.getAutoFinishFlag()));
+        for (var process : processes) {
+            var copy = BeanUtils.toBean(process, MesProWorkOrderProcessSaveReqVO.class);
+            copy.setId(null); copy.setWorkOrderId(id);
+            if (StrUtil.isNotBlank(process.getOutputItemId())) {
+                try { copy.setOutputItemIds(Arrays.stream(process.getOutputItemId().split(",")).map(String::trim).map(Long::valueOf).toList()); }
+                catch (NumberFormatException ex) { throw error("鍘熷伐鍗曞伐搴忎骇鍑虹墿鏂欑紪鍙锋牸寮忛敊璇紝鏃犳硶澶嶅埗"); }
+            }
+            processService.createWorkOrderProcess(copy);
+        }
+        // 宸ュ簭 BOM 鏄崟浣嶇敤閲忥紝鏅�氬伐鍗� BOM 鏄鍗曟�荤敤閲忥紱鍧囦娇鐢ㄥ師宸ュ崟蹇収銆�
+        bomMapper.deleteByWorkOrderId(id);
+        for (var bom : sourceBoms) {
+            BigDecimal amount = bom.getProcessId() != null ? bom.getQuantity()
+                    : bom.getQuantity().multiply(ncr.getUnqualifiedQuantity()).divide(original.getQuantity(), 8, RoundingMode.CEILING);
+            bomMapper.insert(new MesProWorkOrderBomDO().setWorkOrderId(id).setProcessId(bom.getProcessId())
+                    .setItemId(bom.getItemId()).setQuantity(amount).setRemark(bom.getRemark()));
+        }
+        orderService.confirmWorkOrder(id);
+        var taskReq = new MesProTaskAutoGenerateReqVO();
+        taskReq.setWorkOrderId(id); taskReq.setRouteId(original.getRouteId());
+        var taskIds = taskService.autoGenerateTasks(taskReq);
+        if (taskIds == null || taskIds.isEmpty()) throw error("閲嶆柊鐢熶骇宸ュ崟鏈敓鎴愮敓浜т换鍔★紝鏃犳硶涓嬭揪");
+        var result = new MesQcNcrDisposeRespVO();
+        result.setDisposition(disposition); result.setDocType("WORK_ORDER"); result.setDocId(id);
+        result.setDocCode(code); result.setDocName(request.getName()); result.setMessage("宸茬‘璁ら噸鏂扮敓浜ц鍗昜" + code + "]锛岀敓鎴� " + taskIds.size() + " 鏉$敓浜т换鍔¤崏绋匡紝寰呮帓绋�");
+        return result;
+    }
+    private static boolean same(BigDecimal a, BigDecimal b) { return a != null && b != null && a.compareTo(b) == 0; }
+    private static ServiceException error(String message) { return new ServiceException(400, message); }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcReworkService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcReworkService.java
new file mode 100644
index 0000000..026a757
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcReworkService.java
@@ -0,0 +1,398 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.hutool.core.util.StrUtil;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.ncr.vo.MesQcNcrDisposeReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.ncr.vo.MesQcNcrDisposeRespVO;
+import cn.iocoder.yudao.module.mes.controller.admin.wm.miscissue.vo.MesWmMiscIssueSaveReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.wm.miscissue.vo.line.MesWmMiscIssueLineSaveReqVO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.oqc.MesQcOqcDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.batch.MesWmBatchDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.materialstock.MesWmMaterialStockDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.miscissue.MesWmMiscIssueDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesLineDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.transaction.MesWmTransactionDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseAreaDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseLocationDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.pro.workorder.MesProWorkOrderMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.oqc.MesQcOqcMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.batch.MesWmBatchMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.materialstock.MesWmMaterialStockMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.miscissue.MesWmMiscIssueMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales.MesWmProductSalesMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.transaction.MesWmTransactionMapper;
+import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants;
+import cn.iocoder.yudao.module.mes.enums.md.autocode.MesMdAutoCodeRuleCodeEnum;
+import cn.iocoder.yudao.module.mes.enums.pro.MesProWorkOrderSourceTypeEnum;
+import cn.iocoder.yudao.module.mes.enums.pro.MesProWorkOrderStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.qc.MesNcrDispositionEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmMiscIssueStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmMiscIssueTypeEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmProductSalesStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmQualityStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmTransactionTypeEnum;
+import cn.iocoder.yudao.module.mes.service.md.autocode.MesMdAutoCodeRecordService;
+import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService;
+import cn.iocoder.yudao.module.mes.service.wm.materialstock.MesWmMaterialStockService;
+import cn.iocoder.yudao.module.mes.service.wm.miscissue.MesWmMiscIssueLineService;
+import cn.iocoder.yudao.module.mes.service.wm.miscissue.MesWmMiscIssueService;
+import cn.iocoder.yudao.module.mes.service.wm.productsales.MesWmProductSalesService;
+import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseAreaService;
+import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseLocationService;
+import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseService;
+import jakarta.annotation.Resource;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * 鍑鸿揣妫�楠岋紙OQC锛変笉鍚堟牸杩斿伐/杩斾慨闂幆銆�
+ *
+ * <p>澶勭疆鏃舵墸鍑忓師鎴愬搧搴撳瓨骞剁敓鎴愯繑宸ラ鐢ㄥ嚭搴撳崟锛岃嚜鍔ㄥ彇娑堝師閿�鍞嚭搴撳崟锛�
+ * 鍐嶅鐢ㄥ師鐢熶骇宸ュ崟鍏嬮殕涓�寮犺繑宸ュ伐鍗曪紱澶嶆閫氳繃鍚庣敱 NCR 鍏抽棴娴佺▼鏍搁獙銆�</p>
+ */
+@Service
+public class MesQcNcrOqcReworkService {
+
+    /** 杩斿伐棰嗙敤鍑哄簱鍗曠殑鏉ユ簮鍗曟嵁绫诲瀷 */
+    private static final String MISC_ISSUE_SOURCE_TYPE_NCR = "QC_NCR";
+
+    @Resource private MesWmBatchMapper batchMapper;
+    @Resource private MesProWorkOrderMapper orderMapper;
+    @Resource private MesQcOqcMapper oqcMapper;
+    @Resource private MesWmMaterialStockMapper stockMapper;
+    @Resource private MesWmMiscIssueMapper miscIssueMapper;
+    @Resource private MesWmTransactionMapper transactionMapper;
+    @Resource private MesWmProductSalesMapper salesMapper;
+
+    @Resource private MesWmMaterialStockService stockService;
+    @Resource private MesWmProductSalesService salesService;
+    @Resource private MesWmMiscIssueService miscIssueService;
+    @Resource private MesWmMiscIssueLineService miscIssueLineService;
+    @Resource private MesMdAutoCodeRecordService autoCodeRecordService;
+    @Resource private MesMdItemService itemService;
+    @Resource private MesQcNcrOqcReproductionService reproductionService;
+    @Resource private MesWmWarehouseService warehouseService;
+    @Resource private MesWmWarehouseLocationService warehouseLocationService;
+    @Resource private MesWmWarehouseAreaService warehouseAreaService;
+
+    @Transactional(rollbackFor = Exception.class)
+    public MesQcNcrDisposeRespVO dispose(MesQcNcrDO ncr, MesQcNcrOqcSourceClaim.OqcClaimedSource source,
+                                         MesQcNcrDisposeReqVO req) {
+        validateSource(ncr, source);
+        MesWmBatchDO batch = validateBatch(ncr, source);
+        MesProWorkOrderDO original = validateOriginalWorkOrder(batch, source);
+        MesWmMaterialStockDO stock = resolveAndLockStock(ncr, source, req);
+
+        // 鍘熼攢鍞嚭搴撳崟鏁村崟鍙栨秷锛岄噴鏀惧崰鐢紱蹇呴』鍦ㄦ墸鍑忓簱瀛樺墠瀹屾垚
+        salesService.cancelProductSales(source.sales().getId());
+
+        String issueCode = createReworkIssue(ncr, stock, source.sales().getCode());
+        String namePrefix = Objects.equals(req.getDisposition(), MesNcrDispositionEnum.REWORK.getType())
+                ? "杩斿伐-" : "杩斾慨-";
+        MesQcNcrDisposeRespVO result = reproductionService.createReworkFromOriginal(
+                ncr, req.getDisposition(), original, source.sales().getClientId(), batch.getCode(), namePrefix);
+        result.setMessage(String.format(
+                "宸茬敓鎴愯繑宸ラ鐢ㄥ嚭搴撳崟[%s]骞跺畬鎴愬嚭搴擄紝鍘熼攢鍞嚭搴撳崟[%s]宸插彇娑堬紱杩斿伐宸ュ崟[%s]宸蹭笅杈俱��"
+                        + "璇峰畬鎴愯繑宸ュ悗鍋氳繃绋嬫楠屽妫�锛屽妫�鍚堟牸鍚庡叧闂湰鍗�",
+                issueCode, source.sales().getCode(), result.getDocCode()));
+        return result;
+    }
+
+    /**
+     * 鍏抽棴杩斿伐/杩斾慨 NCR 鍓嶆牳楠岋細杩斿伐宸ュ崟宸插畬鎴愩�佸師閿�鍞嚭搴撳崟宸插彇娑堛�佽繑宸ラ鐢ㄥ嚭搴撳凡鎵ц銆�
+     */
+    public void validateBeforeClose(MesQcNcrDO ncr) {
+        List<MesProWorkOrderDO> orders = orderMapper.selectList(new LambdaQueryWrapperX<MesProWorkOrderDO>()
+                .eq(MesProWorkOrderDO::getOrderSourceType, MesProWorkOrderSourceTypeEnum.STORE.getType())
+                .eq(MesProWorkOrderDO::getOrderSourceCode, ncr.getCode()));
+        if (orders.size() != 1) {
+            throw new ServiceException(400, String.format(
+                    "鏃犳硶鍞竴纭畾涓嶅悎鏍煎崟[%s]瀵瑰簲鐨勮繑宸�/杩斾慨鐢熶骇璁㈠崟锛堝綋鍓嶅尮閰峓%s]寮狅級锛岃鍏堟牳瀵规潵婧愮紪鐮�",
+                    ncr.getCode(), orders.size()));
+        }
+        MesProWorkOrderDO order = orders.get(0);
+        if (!Objects.equals(order.getStatus(), MesProWorkOrderStatusEnum.FINISHED.getStatus())
+                || order.getFinishDate() == null) {
+            throw new ServiceException(400, String.format(
+                    "杩斿伐/杩斾慨鐢熶骇璁㈠崟[%s]灏氭湭瀹屾垚鎴栫己灏戝畬鎴愭椂闂达紝璇峰畬鎴愯繑宸ュ苟鎶ュ伐鍚庡啀鍏抽棴",
+                    order.getCode()));
+        }
+
+        MesWmProductSalesDO sales = resolveOriginalSales(ncr);
+        if (sales == null) {
+            throw new ServiceException(400, "鏈壘鍒颁笉鍚堟牸鍗曞叧鑱旂殑鍘熼攢鍞嚭搴撳崟锛屾棤娉曟牳楠岃繑宸ラ棴鐜�");
+        }
+        if (!Objects.equals(sales.getStatus(), MesWmProductSalesStatusEnum.CANCELED.getStatus())) {
+            throw new ServiceException(400, String.format(
+                    "鍘熼攢鍞嚭搴撳崟[%s]褰撳墠鐘舵�佷负[%s]锛岃繑宸ュ缃簲宸茶嚜鍔ㄥ彇娑堣鍑哄簱鍗曪紱"
+                            + "璇锋牳瀵规槸鍚﹁閲嶆柊鎻愪氦鎴栦汉宸ヤ慨鏀�", sales.getCode(), salesStatusName(sales.getStatus())));
+        }
+
+        List<MesWmMiscIssueDO> issues = miscIssueMapper.selectList(new LambdaQueryWrapperX<MesWmMiscIssueDO>()
+                .eq(MesWmMiscIssueDO::getSourceDocType, MISC_ISSUE_SOURCE_TYPE_NCR)
+                .eq(MesWmMiscIssueDO::getSourceDocId, ncr.getId())
+                .eq(MesWmMiscIssueDO::getType, MesWmMiscIssueTypeEnum.REWORK.getType()));
+        if (issues.size() != 1) {
+            throw new ServiceException(400, String.format(
+                    "涓嶅悎鏍煎崟[%s]鍏宠仈鐨勮繑宸ラ鐢ㄥ嚭搴撳崟鏁伴噺涓篬%s]寮狅紝鏃犳硶鏍搁獙杩斿伐棰嗙敤搴撳瓨",
+                    ncr.getCode(), issues.size()));
+        }
+        MesWmMiscIssueDO issue = issues.get(0);
+        if (!Objects.equals(issue.getStatus(), MesWmMiscIssueStatusEnum.FINISHED.getStatus())) {
+            throw new ServiceException(400, String.format(
+                    "杩斿伐棰嗙敤鍑哄簱鍗昜%s]灏氭湭瀹屾垚鍑哄簱锛岃鍏堝湪鏉傞」鍑哄簱涓畬鎴愬悗鍐嶅叧闂�", issue.getCode()));
+        }
+
+        List<MesWmTransactionDO> flows = transactionMapper.selectList(new LambdaQueryWrapperX<MesWmTransactionDO>()
+                .eq(MesWmTransactionDO::getBizType, MesBizTypeConstants.WM_MISC_ISSUE)
+                .eq(MesWmTransactionDO::getBizId, issue.getId())
+                .eq(MesWmTransactionDO::getType, MesWmTransactionTypeEnum.OUT.getType()));
+        BigDecimal out = BigDecimal.ZERO;
+        for (MesWmTransactionDO flow : flows) {
+            if (!Objects.equals(flow.getItemId(), ncr.getItemId())
+                    || flow.getQuantity() == null || flow.getQuantity().signum() >= 0) {
+                throw new ServiceException(400, String.format(
+                        "杩斿伐棰嗙敤鍑哄簱鍗昜%s]瀛樺湪鐗╂枡鎴栨暟閲忎笉涓�鑷寸殑鍑哄簱娴佹按锛岃鏍稿鍚庨噸璇�", issue.getCode()));
+            }
+            out = out.subtract(flow.getQuantity());
+        }
+        if (out.compareTo(ncr.getUnqualifiedQuantity()) != 0) {
+            throw new ServiceException(400, String.format(
+                    "杩斿伐棰嗙敤鍑哄簱鏁伴噺[%s]涓庝笉鍚堟牸鏁伴噺[%s]涓嶄竴鑷达紝璇锋牳瀵硅繑宸ラ鐢ㄥ嚭搴撳崟[%s]",
+                    plain(out), plain(ncr.getUnqualifiedQuantity()), issue.getCode()));
+        }
+    }
+
+    // ==================== 鏍¢獙涓庡畾浣� ====================
+
+    private void validateSource(MesQcNcrDO ncr, MesQcNcrOqcSourceClaim.OqcClaimedSource source) {
+        if (source == null || source.qc() == null || source.sales() == null || source.line() == null) {
+            throw new ServiceException(400, "鍑鸿揣涓嶅悎鏍艰繑宸ョ己灏戝凡璁ら鐨勬潵婧愭楠屽崟銆侀攢鍞嚭搴撳崟鎴栧嚭搴撹");
+        }
+        MesWmProductSalesLineDO line = source.line();
+        if (ncr.getUnqualifiedQuantity() == null || ncr.getUnqualifiedQuantity().signum() <= 0) {
+            throw new ServiceException(400, "涓嶅悎鏍兼暟閲忓繀椤诲ぇ浜� 0 鎵嶈兘杩斿伐/杩斾慨");
+        }
+        if (!Objects.equals(source.sales().getStatus(), MesWmProductSalesStatusEnum.CONFIRMED.getStatus())
+                || !Objects.equals(line.getSalesId(), source.sales().getId())
+                || !Objects.equals(line.getOqcId(), source.qc().getId())
+                || !Objects.equals(line.getQualityStatus(), MesWmQualityStatusEnum.FAIL.getStatus())
+                || !Objects.equals(line.getItemId(), ncr.getItemId())
+                || line.getBatchId() == null || StrUtil.isBlank(line.getBatchCode())
+                || line.getQuantity() == null
+                || ncr.getUnqualifiedQuantity().compareTo(line.getQuantity()) > 0) {
+            throw new ServiceException(400, "鍑鸿揣妫�楠屾潵婧愩�侀攢鍞嚭搴撹銆佺墿鏂欍�佹壒娆℃垨涓嶅悎鏍兼暟閲忎笉涓�鑷达紝鏃犳硶杩斿伐/杩斾慨");
+        }
+    }
+
+    private MesWmBatchDO validateBatch(MesQcNcrDO ncr, MesQcNcrOqcSourceClaim.OqcClaimedSource source) {
+        MesWmProductSalesLineDO line = source.line();
+        MesWmBatchDO batch = batchMapper.selectById(line.getBatchId());
+        if (batch == null || !Objects.equals(batch.getCode(), line.getBatchCode())
+                || !Objects.equals(batch.getItemId(), line.getItemId())
+                || !Objects.equals(batch.getClientId(), source.sales().getClientId())
+                || batch.getWorkOrderId() == null) {
+            throw new ServiceException(400, String.format(
+                    "鍑鸿揣鎵规[%s]鏈粦瀹氫竴鑷寸殑鐗╂枡[%s]銆佸鎴锋垨鍘熺敓浜ц鍗曪紝鏃犳硶杩斿伐/杩斾慨",
+                    StrUtil.blankToDefault(line.getBatchCode(), "鏈~鍐�"), itemLabel(ncr.getItemId())));
+        }
+        return batch;
+    }
+
+    private MesProWorkOrderDO validateOriginalWorkOrder(MesWmBatchDO batch,
+                                                        MesQcNcrOqcSourceClaim.OqcClaimedSource source) {
+        MesProWorkOrderDO original = orderMapper.selectById(batch.getWorkOrderId());
+        if (original == null || original.getProductId() == null
+                || !Objects.equals(original.getClientId(), source.sales().getClientId())) {
+            throw new ServiceException(400, String.format(
+                    "鍑鸿揣鎵规[%s]鍏宠仈鐨勫師鐢熶骇璁㈠崟涓嶅瓨鍦ㄣ�佺己灏戜骇鍝佹垨涓嶅睘浜庡鎴穂ID=%s]锛屾棤娉曡繑宸�/杩斾慨",
+                    batch.getCode(), source.sales().getClientId()));
+        }
+        return original;
+    }
+
+    /**
+     * 瀹氫綅骞堕攣瀹氬師鎴愬搧搴撳瓨锛氫紭鍏堜娇鐢ㄥ墠绔�夊畾鐨勫簱瀛樿褰曪紱鏈寚瀹氭椂瑕佹眰鍚屾壒娆′粎涓�鏉″彲鐢ㄥ簱瀛樸��
+     */
+    private MesWmMaterialStockDO resolveAndLockStock(MesQcNcrDO ncr, MesQcNcrOqcSourceClaim.OqcClaimedSource source,
+                                                     MesQcNcrDisposeReqVO req) {
+        MesWmProductSalesLineDO line = source.line();
+        BigDecimal need = ncr.getUnqualifiedQuantity();
+        MesWmMaterialStockDO stock;
+        if (req.getMaterialStockId() != null) {
+            stock = stockService.getMaterialStock(req.getMaterialStockId());
+            if (stock == null) {
+                throw new ServiceException(400, String.format(
+                        "鎵�閫夎繑宸ュ簱瀛樿褰昜ID=%s]涓嶅瓨鍦紝璇烽噸鏂伴�夋嫨璇ユ壒娆℃垚鍝佸簱瀛�", req.getMaterialStockId()));
+            }
+            if (!Objects.equals(stock.getItemId(), line.getItemId())
+                    || !Objects.equals(stock.getBatchId(), line.getBatchId())) {
+                throw new ServiceException(400, String.format(
+                        "鎵�閫夊簱瀛樹笌涓嶅悎鏍煎嚭璐ф壒娆′笉涓�鑷达細鎵�閫夊簱瀛樼墿鏂橻%s]銆佹壒娆%s]锛�"
+                                + "鍑鸿揣琛岀墿鏂橻%s]銆佹壒娆%s]銆傝閲嶆柊閫夋嫨璇ユ壒娆℃垚鍝佸簱瀛�",
+                        itemLabel(stock.getItemId()), batchLabel(stock.getBatchId(), stock.getBatchCode()),
+                        itemLabel(line.getItemId()), batchLabel(line.getBatchId(), line.getBatchCode())));
+            }
+            if (stock.getWarehouseId() == null || stock.getLocationId() == null || stock.getAreaId() == null) {
+                throw new ServiceException(400, String.format(
+                        "鎵�閫夊簱瀛榌ID=%s]缂哄皯浠撳簱/搴撳尯/搴撲綅淇℃伅锛屾棤娉曞嚭搴擄紱璇烽噸鏂伴�夋嫨瀹屾暣鐨勫簱瀛樿褰�",
+                        stock.getId()));
+            }
+        } else {
+            List<MesWmMaterialStockDO> candidates = stockMapper.selectList(new LambdaQueryWrapperX<MesWmMaterialStockDO>()
+                    .eq(MesWmMaterialStockDO::getItemId, line.getItemId())
+                    .eq(MesWmMaterialStockDO::getBatchId, line.getBatchId())
+                    .gt(MesWmMaterialStockDO::getQuantity, BigDecimal.ZERO));
+            if (candidates.isEmpty()) {
+                throw new ServiceException(400, String.format(
+                        "鏈壘鍒扮墿鏂橻%s]銆佹壒娆%s]鐨勬垚鍝佸簱瀛橈紝鏃犳硶杩斿伐棰嗙敤锛涜鍏堢‘璁ゆ垚鍝佸凡鍏ュ簱鎴栧埛鏂板悗閲嶈瘯",
+                        itemLabel(line.getItemId()), batchLabel(line.getBatchId(), line.getBatchCode())));
+            }
+            List<MesWmMaterialStockDO> available = candidates.stream()
+                    .filter(item -> available(item).compareTo(need) >= 0)
+                    .toList();
+            if (available.size() != 1) {
+                String detail = candidates.stream()
+                        .map(item -> String.format("%s锛堝彲鐢ㄩ噺[%s]锛�", stockLabel(item), plain(available(item))))
+                        .collect(Collectors.joining("锛�"));
+                throw new ServiceException(400, String.format(
+                        "鎵规[%s]搴撳瓨鏃犳硶鑷姩纭畾杩斿伐棰嗙敤璁板綍锛�%s銆�"
+                                + "璇峰湪澶勭疆寮圭獥鐨刐杩斿伐搴撳瓨]涓�夋嫨鍏蜂綋搴撳瓨璁板綍鍚庨噸璇�",
+                        batchLabel(line.getBatchId(), line.getBatchCode()), detail));
+            }
+            stock = available.get(0);
+        }
+
+        // 閲嶆柊鍔犻攣鍚庤绠楀彲鐢ㄩ噺锛岄伩鍏嶅苟鍙戝嚭搴撳鑷磋秴棰�
+        MesWmMaterialStockDO locked = stockMapper.lockById(stock.getId());
+        if (locked == null) {
+            throw new ServiceException(400, String.format(
+                    "杩斿伐搴撳瓨璁板綍[ID=%s]宸蹭笉瀛樺湪锛岃鍒锋柊鍚庨噸鏂伴�夋嫨", stock.getId()));
+        }
+        BigDecimal available = available(locked);
+        if (available.compareTo(need) < 0) {
+            throw new ServiceException(400, String.format(
+                    "鎵规[%s]搴撳瓨鍙敤閲廩%s]涓嶈冻锛屾湰娆¤繑宸ラ渶棰嗙敤[%s]锛�"
+                            + "璇峰厛澶勭悊搴撳瓨鍗犵敤/鍐荤粨锛屾垨鏍稿鎴愬搧鍏ュ簱鏁伴噺",
+                    batchLabel(locked.getBatchId(), locked.getBatchCode()), plain(available), plain(need)));
+        }
+        return locked;
+    }
+
+    // ==================== 鍗曟嵁鐢熸垚 ====================
+
+    private String createReworkIssue(MesQcNcrDO ncr, MesWmMaterialStockDO stock, String salesCode) {
+        String code = autoCodeRecordService.generateAutoCode(
+                MesMdAutoCodeRuleCodeEnum.WM_MISC_ISSUE_CODE.getCode());
+        MesWmMiscIssueSaveReqVO issueReqVO = new MesWmMiscIssueSaveReqVO();
+        issueReqVO.setCode(code);
+        issueReqVO.setName("杩斿伐棰嗙敤鍑哄簱鍗�-" + ncr.getCode());
+        issueReqVO.setType(MesWmMiscIssueTypeEnum.REWORK.getType());
+        issueReqVO.setSourceDocType(MISC_ISSUE_SOURCE_TYPE_NCR);
+        issueReqVO.setSourceDocId(ncr.getId());
+        issueReqVO.setSourceDocCode(ncr.getCode());
+        issueReqVO.setIssueDate(LocalDateTime.now());
+        issueReqVO.setRemark(String.format("鐢变笉鍚堟牸鍝佸鐞嗗崟[%s]杩斿伐棰嗙敤鑷姩鐢熸垚锛涘師閿�鍞嚭搴撳崟[%s]宸插彇娑�",
+                ncr.getCode(), salesCode));
+        Long issueId = miscIssueService.createMiscIssue(issueReqVO);
+
+        MesWmMiscIssueLineSaveReqVO lineReqVO = new MesWmMiscIssueLineSaveReqVO();
+        lineReqVO.setIssueId(issueId);
+        lineReqVO.setItemId(ncr.getItemId());
+        lineReqVO.setQuantity(ncr.getUnqualifiedQuantity());
+        lineReqVO.setMaterialStockId(stock.getId());
+        lineReqVO.setBatchId(stock.getBatchId());
+        lineReqVO.setBatchCode(stock.getBatchCode());
+        lineReqVO.setWarehouseId(stock.getWarehouseId());
+        lineReqVO.setLocationId(stock.getLocationId());
+        lineReqVO.setAreaId(stock.getAreaId());
+        lineReqVO.setRemark(String.format("鏉ユ簮涓嶅悎鏍煎搧澶勭悊鍗昜%s]杩斿伐棰嗙敤", ncr.getCode()));
+        miscIssueLineService.createMiscIssueLine(lineReqVO);
+
+        miscIssueService.submitMiscIssue(issueId);
+        miscIssueService.finishMiscIssue(issueId);
+        return code;
+    }
+
+    /**
+     * 閫氳繃鏉ユ簮妫�楠屽崟瀹氫綅鍘熼攢鍞嚭搴撳崟锛堜粎鐢ㄤ簬鍏抽棴鏍搁獙锛夈��
+     */
+    private MesWmProductSalesDO resolveOriginalSales(MesQcNcrDO ncr) {
+        if (ncr.getQcId() == null) {
+            return null;
+        }
+        MesQcOqcDO qc = oqcMapper.selectById(ncr.getQcId());
+        return qc == null || qc.getSourceDocId() == null ? null : salesMapper.selectById(qc.getSourceDocId());
+    }
+
+    // ==================== 灞曠ず杈呭姪 ====================
+
+    private static BigDecimal available(MesWmMaterialStockDO stock) {
+        BigDecimal quantity = stock.getQuantity() == null ? BigDecimal.ZERO : stock.getQuantity();
+        BigDecimal frozen = stock.getFrozenQuantity() == null ? BigDecimal.ZERO : stock.getFrozenQuantity();
+        BigDecimal reserved = stock.getReservedQuantity() == null ? BigDecimal.ZERO : stock.getReservedQuantity();
+        return quantity.subtract(frozen).subtract(reserved);
+    }
+
+    private String itemLabel(Long itemId) {
+        MesMdItemDO item = itemId == null ? null : itemService.getItem(itemId);
+        if (item == null) {
+            return "ID=" + itemId;
+        }
+        String label = (StrUtil.blankToDefault(item.getCode(), "") + " "
+                + StrUtil.blankToDefault(item.getName(), "")).trim();
+        return label.isEmpty() ? "ID=" + itemId : label;
+    }
+
+    private String batchLabel(Long batchId, String batchCode) {
+        if (StrUtil.isNotBlank(batchCode)) {
+            return batchCode;
+        }
+        return batchId == null ? "鏈~鍐�" : "ID=" + batchId;
+    }
+
+    private String stockLabel(MesWmMaterialStockDO stock) {
+        return String.format("%s/%s/%s", warehouseName(stock.getWarehouseId()),
+                locationName(stock.getLocationId()), areaName(stock.getAreaId()));
+    }
+
+    private String warehouseName(Long id) {
+        MesWmWarehouseDO warehouse = id == null ? null : warehouseService.getWarehouse(id);
+        return warehouse != null && StrUtil.isNotBlank(warehouse.getName()) ? warehouse.getName() : "ID=" + id;
+    }
+
+    private String locationName(Long id) {
+        MesWmWarehouseLocationDO location = id == null ? null : warehouseLocationService.getWarehouseLocation(id);
+        return location != null && StrUtil.isNotBlank(location.getName()) ? location.getName() : "ID=" + id;
+    }
+
+    private String areaName(Long id) {
+        MesWmWarehouseAreaDO area = id == null ? null : warehouseAreaService.getWarehouseArea(id);
+        return area != null && StrUtil.isNotBlank(area.getName()) ? area.getName() : "ID=" + id;
+    }
+
+    private static String salesStatusName(Integer status) {
+        for (MesWmProductSalesStatusEnum value : MesWmProductSalesStatusEnum.values()) {
+            if (Objects.equals(value.getStatus(), status)) {
+                return value.getName();
+            }
+        }
+        return "ID=" + status;
+    }
+
+    private static String plain(BigDecimal value) {
+        return value == null ? "0" : value.stripTrailingZeros().toPlainString();
+    }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcSourceClaim.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcSourceClaim.java
new file mode 100644
index 0000000..9d357e9
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcSourceClaim.java
@@ -0,0 +1,51 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.oqc.MesQcOqcDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesLineDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.oqc.MesQcOqcMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales.MesWmProductSalesLineMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales.MesWmProductSalesMapper;
+import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmProductSalesStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmQualityStatusEnum;
+import jakarta.annotation.Resource;
+import org.springframework.stereotype.Component;
+import java.util.Objects;
+
+/** 璋冪敤鏂归』鎸佹湁 NCR 琛岄攣骞跺湪鍚屼竴浜嬪姟鍐呭畬鎴愬悗缁缃�� */
+@Component
+public class MesQcNcrOqcSourceClaim {
+    @Resource private MesQcOqcMapper oqcMapper;
+    @Resource private MesWmProductSalesMapper salesMapper;
+    @Resource private MesWmProductSalesLineMapper lineMapper;
+
+    public OqcClaimedSource claim(MesQcNcrDO ncr) {
+        var qc = oqcMapper.selectById(ncr.getQcId());
+        if (qc == null || !Objects.equals(qc.getSourceDocType(), MesBizTypeConstants.WM_PRODUCT_SALES)
+                || qc.getSourceDocId() == null || qc.getSourceLineId() == null
+                || !Objects.equals(qc.getItemId(), ncr.getItemId()) || qc.getUnqualifiedQuantity() == null
+                || ncr.getUnqualifiedQuantity() == null || qc.getUnqualifiedQuantity().compareTo(ncr.getUnqualifiedQuantity()) != 0) {
+            throw new ServiceException(400, "鍑鸿揣涓嶅悎鏍煎崟鏉ユ簮鎴栨暟閲忎笉涓�鑷�");
+        }
+        var sales = salesMapper.selectOne(new LambdaQueryWrapperX<MesWmProductSalesDO>()
+                .eq(MesWmProductSalesDO::getId, qc.getSourceDocId()).last("FOR UPDATE"));
+        var line = lineMapper.selectOne(new LambdaQueryWrapperX<MesWmProductSalesLineDO>()
+                .eq(MesWmProductSalesLineDO::getId, qc.getSourceLineId()).last("FOR UPDATE"));
+        if (sales == null || line == null || !Objects.equals(sales.getStatus(), MesWmProductSalesStatusEnum.CONFIRMED.getStatus())
+                || !Objects.equals(line.getSalesId(), sales.getId()) || !Objects.equals(line.getOqcId(), qc.getId())
+                || !Objects.equals(line.getQualityStatus(), MesWmQualityStatusEnum.FAIL.getStatus())
+                || line.getNcrDispositionId() != null) {
+            throw new ServiceException(400, "鍘熷嚭璐ц宸插缃垨涓嶅浜庣瓑寰呮楠屽缃姸鎬�");
+        }
+        lineMapper.updateById(new MesWmProductSalesLineDO().setId(line.getId()).setNcrDispositionId(ncr.getId()));
+        return new OqcClaimedSource(qc, sales, line);
+    }
+
+    /** 宸查攣瀹氱殑鍑鸿揣涓嶅悎鏍兼潵婧愶紙妫�楠屽崟銆侀攢鍞嚭搴撳崟銆侀攢鍞嚭搴撹锛夈�� */
+    public record OqcClaimedSource(MesQcOqcDO qc, MesWmProductSalesDO sales, MesWmProductSalesLineDO line) {
+    }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrPurchaseSourceValidator.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrPurchaseSourceValidator.java
new file mode 100644
index 0000000..137b566
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrPurchaseSourceValidator.java
@@ -0,0 +1,58 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.iqc.MesQcIqcDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.arrivalnotice.MesWmArrivalNoticeDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.arrivalnotice.MesWmArrivalNoticeLineDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.iqc.MesQcIqcMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.arrivalnotice.MesWmArrivalNoticeLineMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.arrivalnotice.MesWmArrivalNoticeMapper;
+import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmArrivalNoticeStatusEnum;
+import jakarta.annotation.Resource;
+import org.springframework.stereotype.Component;
+
+import java.math.BigDecimal;
+import java.util.Objects;
+
+/** 閲囪喘澶勭疆鍓嶉攣瀹氬苟鏍稿妫�楠屽崟鍜屽埌璐ц锛涜皟鐢ㄨ�呴』澶勪簬浜嬪姟涓�� */
+@Component
+public class MesQcNcrPurchaseSourceValidator {
+    @Resource private MesQcIqcMapper iqcMapper;
+    @Resource private MesWmArrivalNoticeMapper arrivalNoticeMapper;
+    @Resource private MesWmArrivalNoticeLineMapper lineMapper;
+
+    public record Source(MesQcIqcDO iqc, MesWmArrivalNoticeDO notice, MesWmArrivalNoticeLineDO line) {}
+
+    public Source validate(MesQcNcrDO ncr) {
+        if (!Objects.equals(ncr.getQcType(), MesQcTypeEnum.IQC.getType()) || ncr.getQcId() == null)
+            throw new ServiceException(400, "閲囪喘涓嶅悎鏍煎缃繀椤诲叧鑱旀潵鏂欐楠屽崟");
+        var iqc = iqcMapper.selectOne(new LambdaQueryWrapperX<MesQcIqcDO>()
+                .eq(MesQcIqcDO::getId, ncr.getQcId()).last("FOR UPDATE"));
+        if (iqc == null || !Objects.equals(iqc.getStatus(), MesQcStatusEnum.FINISHED.getStatus())
+                || !Objects.equals(iqc.getSourceDocType(), MesBizTypeConstants.WM_ARRIVAL_NOTICE)
+                || iqc.getSourceDocId() == null || iqc.getSourceLineId() == null)
+            throw new ServiceException(400, "閲囪喘澶勭疆浠呮敮鎸佸凡瀹屾垚涓斿叧鑱斿埌璐ч�氱煡鍗曡鐨勬潵鏂欐楠�");
+        var notice = arrivalNoticeMapper.selectOne(new LambdaQueryWrapperX<MesWmArrivalNoticeDO>()
+                .eq(MesWmArrivalNoticeDO::getId, iqc.getSourceDocId()).last("FOR UPDATE"));
+        var line = lineMapper.selectOne(new LambdaQueryWrapperX<MesWmArrivalNoticeLineDO>()
+                .eq(MesWmArrivalNoticeLineDO::getId, iqc.getSourceLineId()).last("FOR UPDATE"));
+        if (notice == null || line == null || !Objects.equals(line.getNoticeId(), notice.getId())
+                || !Objects.equals(line.getIqcId(), iqc.getId())
+                || !Objects.equals(notice.getStatus(), MesWmArrivalNoticeStatusEnum.PENDING_QC.getStatus())
+                || !Objects.equals(line.getItemId(), iqc.getItemId())
+                || !Objects.equals(ncr.getItemId(), iqc.getItemId())
+                || !samePositive(ncr.getUnqualifiedQuantity(), iqc.getUnqualifiedQuantity())
+                || !samePositive(iqc.getCheckQuantity(), line.getArrivalQuantity()))
+            throw new ServiceException(400, "鍒拌揣鍗曘�佽川妫�鍗曞強涓嶅悎鏍煎崟鏉ユ簮鎴栨暟閲忎笉涓�鑷达紝鏃犳硶鑷姩澶勭疆");
+        return new Source(iqc, notice, line);
+    }
+
+    private boolean samePositive(BigDecimal a, BigDecimal b) {
+        return a != null && b != null && a.signum() > 0 && a.compareTo(b) == 0;
+    }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrReinspectionValidator.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrReinspectionValidator.java
new file mode 100644
index 0000000..99f52fa
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrReinspectionValidator.java
@@ -0,0 +1,148 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ipqc.MesQcIpqcDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.md.item.MesMdItemMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.pro.workorder.MesProWorkOrderMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ipqc.MesQcIpqcMapper;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productproduce.MesWmProductProduceLineDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productproduce.MesWmProductProduceDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.transaction.MesWmTransactionDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productproduce.MesWmProductProduceLineMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productproduce.MesWmProductProduceMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.transaction.MesWmTransactionMapper;
+import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmQualityStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmTransactionTypeEnum;
+import cn.iocoder.yudao.module.mes.enums.pro.MesProWorkOrderSourceTypeEnum;
+import cn.iocoder.yudao.module.mes.enums.pro.MesProWorkOrderStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr.MesQcNcrMapper;
+import jakarta.annotation.Resource;
+import org.springframework.stereotype.Component;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Objects;
+
+/** 鍏抽棴杩斿伐/杩斾慨 NCR 鍓嶏紝鏍稿疄鎿嶄綔鑰呮槑纭寚瀹氱殑鏁存壒澶嶆璇佹嵁銆� */
+@Component
+public class MesQcNcrReinspectionValidator {
+
+    @Resource private MesProWorkOrderMapper workOrderMapper;
+    @Resource private MesQcIpqcMapper ipqcMapper;
+    @Resource private MesMdItemMapper itemMapper;
+    @Resource private MesWmProductProduceLineMapper produceLineMapper;
+    @Resource private MesWmProductProduceMapper produceMapper;
+    @Resource private MesWmTransactionMapper transactionMapper;
+    @Resource private MesQcNcrMapper ncrMapper;
+
+    public void validate(MesQcNcrDO ncr, Long reinspectionIpqcId) {
+        if (reinspectionIpqcId == null) {
+            throw new ServiceException(400, "杩斿伐/杩斾慨鍏抽棴鍓嶈閫夋嫨鍏宠仈浜у嚭鐨勬暣鎵瑰妫�鍗�");
+        }
+        // 褰撳墠璁㈠崟浠呮寔鏈夋潵婧愮紪鐮侊紱瀛樺湪澶氫釜鍖归厤椤规椂涓嶈兘鐚滄祴鍏宠仈銆�
+        List<MesProWorkOrderDO> orders = workOrderMapper.selectList(new LambdaQueryWrapperX<MesProWorkOrderDO>()
+                .eq(MesProWorkOrderDO::getOrderSourceType, MesProWorkOrderSourceTypeEnum.STORE.getType())
+                .eq(MesProWorkOrderDO::getOrderSourceCode, ncr.getCode()));
+        if (orders.size() != 1) {
+            throw new ServiceException(400, "鏃犳硶鍞竴纭畾姝や笉鍚堟牸鍗曞搴旂殑杩斿伐/杩斾慨鐢熶骇璁㈠崟锛岃鍏堟牳瀵规潵婧愮紪鐮�");
+        }
+        MesProWorkOrderDO order = orders.get(0);
+        if (!Objects.equals(order.getStatus(), MesProWorkOrderStatusEnum.FINISHED.getStatus())
+                || order.getFinishDate() == null) {
+            throw new ServiceException(400, "杩斿伐/杩斾慨鐢熶骇璁㈠崟灏氭湭瀹屾垚鎴栫己灏戝畬鎴愭椂闂达紝涓嶈兘鍏抽棴");
+        }
+        MesMdItemDO product = itemMapper.selectById(order.getProductId());
+        if (product == null || product.getMdmItemId() == null
+                || !Objects.equals(product.getMdmItemId(), ncr.getItemId())) {
+            throw new ServiceException(400, "杩斿伐璁㈠崟浜у搧涓庝笉鍚堟牸鐗╂枡鐨勬槧灏勪笉鏄庣‘锛岃鍏堟牳瀵逛骇鍝佷富鏁版嵁");
+        }
+        MesQcIpqcDO qc = ipqcMapper.selectById(reinspectionIpqcId);
+        // 鍑鸿揣杩斿伐鍚屾牱璧版姤宸ヤ骇鍑哄妫�锛氳繑宸ュ伐鍗曞畬鎴愬悗锛岄渶缁戝畾鍏舵姤宸ヤ骇鍑鸿鐨勮繃绋嬫楠屽崟
+        if (!Objects.equals(ncr.getQcType(), MesQcTypeEnum.IPQC.getType())
+                && !Objects.equals(ncr.getQcType(), MesQcTypeEnum.RQC.getType())
+                && !Objects.equals(ncr.getQcType(), MesQcTypeEnum.OQC.getType())) {
+            validateLegacy(qc, order, ncr);
+            return;
+        }
+        if (qc == null || !Objects.equals(qc.getWorkOrderId(), order.getId())
+                || !Objects.equals(qc.getItemId(), order.getProductId())
+                || !Objects.equals(qc.getSourceDocType(), MesBizTypeConstants.PRO_FEEDBACK)
+                || qc.getSourceDocId() == null || qc.getSourceLineId() == null) {
+            throw new ServiceException(400, "璇烽�夋嫨鍏宠仈杩斿伐璁㈠崟鎶ュ伐浜у嚭琛岀殑杩囩▼妫�楠屽崟浣滀负澶嶆璇佹嵁");
+        }
+        if (ncr.getHandleDate() == null || qc.getCreateTime() == null || qc.getCreateTime().isBefore(ncr.getHandleDate())
+                || qc.getInspectDate() == null || qc.getInspectDate().isBefore(ncr.getHandleDate())) {
+            throw new ServiceException(400, "澶嶆鍗曢』鍦ㄨ繑宸ュ缃悗鍒涘缓骞舵楠岋紝璇锋牳瀵规楠屾棩鏈�");
+        }
+        BigDecimal quantity = ncr.getUnqualifiedQuantity();
+        if (!Objects.equals(qc.getStatus(), MesQcStatusEnum.FINISHED.getStatus())
+                || quantity == null || quantity.signum() <= 0
+                || qc.getCheckQuantity() == null || qc.getCheckQuantity().compareTo(quantity) != 0
+                || qc.getQualifiedQuantity() == null || qc.getQualifiedQuantity().signum() < 0
+                || qc.getUnqualifiedQuantity() == null || qc.getUnqualifiedQuantity().signum() < 0
+                || qc.getQualifiedQuantity().add(qc.getUnqualifiedQuantity()).compareTo(quantity) != 0
+                || !Objects.equals(qc.getCheckResult(), qc.getUnqualifiedQuantity().signum() == 0 ? 1 : 2)) {
+            throw new ServiceException(400, "澶嶆蹇呴』宸插畬鎴愶紝涓斿悎鏍间笌涓嶅悎鏍兼暟閲忎箣鍜岄』绛変簬涓嶅悎鏍煎崟鏁伴噺");
+        }
+        MesWmProductProduceLineDO line = produceLineMapper.selectById(qc.getSourceLineId());
+        MesWmProductProduceDO produce = line == null ? null : produceMapper.selectById(line.getProduceId());
+        if (line == null || produce == null || !Objects.equals(line.getFeedbackId(), qc.getSourceDocId())
+                || !Objects.equals(produce.getWorkOrderId(), order.getId())
+                || !Objects.equals(line.getItemId(), qc.getItemId())
+                || !Objects.equals(line.getQualityStatus(), MesWmQualityStatusEnum.PASS.getStatus())
+                || line.getQuantity() == null || line.getQuantity().compareTo(qc.getQualifiedQuantity()) != 0) {
+            throw new ServiceException(400, "澶嶆浜у嚭琛屼笌杩斿伐璁㈠崟鎴栧悎鏍兼暟閲忎笉涓�鑷�");
+        }
+        List<MesWmTransactionDO> flows = transactionMapper.selectList(new LambdaQueryWrapperX<MesWmTransactionDO>()
+                .eq(MesWmTransactionDO::getBizType, MesBizTypeConstants.WM_PRODUCT_PRODUCE)
+                .eq(MesWmTransactionDO::getBizId, produce.getId())
+                .eq(MesWmTransactionDO::getBizLineId, line.getId())
+                .eq(MesWmTransactionDO::getWorkOrderId, order.getId())
+                .eq(MesWmTransactionDO::getItemId, qc.getItemId())
+                .eq(MesWmTransactionDO::getType, MesWmTransactionTypeEnum.IN.getType()));
+        BigDecimal stocked = flows.stream().map(MesWmTransactionDO::getQuantity)
+                .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+        if (stocked.compareTo(qc.getQualifiedQuantity()) != 0) {
+            throw new ServiceException(400, "杩斿伐澶嶆鍚堟牸浜у嚭鐨勫叆搴撴祦姘存暟閲忎笉鍖归厤锛屾殏涓嶈兘鍏抽棴");
+        }
+        if (qc.getUnqualifiedQuantity().signum() > 0) {
+            List<MesQcNcrDO> children = ncrMapper.selectList(new LambdaQueryWrapperX<MesQcNcrDO>()
+                    .eq(MesQcNcrDO::getQcType, MesQcTypeEnum.IPQC.getType())
+                    .eq(MesQcNcrDO::getQcId, qc.getId()));
+            if (children.size() != 1 || !Objects.equals(children.get(0).getItemId(), ncr.getItemId())
+                    || children.get(0).getUnqualifiedQuantity() == null
+                    || children.get(0).getUnqualifiedQuantity().compareTo(qc.getUnqualifiedQuantity()) != 0) {
+                throw new ServiceException(400, "澶嶆涓嶅悎鏍兼暟閲忛』鍏ㄩ儴绉讳氦鑷冲敮涓�鐨勬柊涓嶅悎鏍煎鐞嗗崟锛岃鏍稿鐗╂枡鍜屾暟閲�");
+            }
+        }
+    }
+
+    /** 鍏朵粬妫�楠屾潵婧愪繚鎸佸師鏈夊叧闂鍒欍�� */
+    private void validateLegacy(MesQcIpqcDO qc, MesProWorkOrderDO order, MesQcNcrDO ncr) {
+        if (qc == null || !Objects.equals(qc.getWorkOrderId(), order.getId())
+                || !Objects.equals(qc.getItemId(), order.getProductId())
+                || qc.getSourceDocType() != null || qc.getSourceDocId() != null || qc.getSourceLineId() != null) {
+            throw new ServiceException(400, "璇烽�夋嫨璇ヨ繑宸ヨ鍗曚骇鍝佺殑鐙珛杩囩▼妫�楠屽崟浣滀负澶嶆璇佹嵁");
+        }
+        if (qc.getCreateTime() == null || qc.getCreateTime().isBefore(order.getFinishDate())
+                || qc.getInspectDate() == null || qc.getInspectDate().isBefore(order.getFinishDate())) {
+            throw new ServiceException(400, "澶嶆鍗曢』鍦ㄨ繑宸ヨ鍗曞畬鎴愬悗鍒涘缓骞舵楠岋紝璇锋牳瀵规楠屾棩鏈�");
+        }
+        BigDecimal quantity = ncr.getUnqualifiedQuantity();
+        if (!Objects.equals(qc.getStatus(), MesQcStatusEnum.FINISHED.getStatus())
+                || !Objects.equals(qc.getCheckResult(), 1)
+                || quantity == null || quantity.signum() <= 0
+                || qc.getCheckQuantity() == null || qc.getCheckQuantity().compareTo(quantity) != 0
+                || qc.getQualifiedQuantity() == null || qc.getQualifiedQuantity().compareTo(quantity) != 0
+                || qc.getUnqualifiedQuantity() == null || qc.getUnqualifiedQuantity().signum() != 0) {
+            throw new ServiceException(400, "澶嶆蹇呴』宸插畬鎴愪笖鏁存壒鍚堟牸锛屾娴嬫暟閲忓拰鍚堟牸鏁伴噺椤荤瓑浜庝笉鍚堟牸鍗曟暟閲�");
+        }
+    }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrReturnSalesLink.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrReturnSalesLink.java
new file mode 100644
index 0000000..b7f3169
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrReturnSalesLink.java
@@ -0,0 +1,61 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.rqc.MesQcRqcDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesLineDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.rqc.MesQcRqcMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.returnsales.MesWmReturnSalesMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.returnsales.MesWmReturnSalesLineMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.returnsales.MesWmReturnSalesDetailMapper;
+import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmQualityStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmReturnSalesStatusEnum;
+import jakarta.annotation.Resource;
+import org.springframework.stereotype.Service;
+import java.util.List;
+import java.util.Objects;
+
+/** 鍦ㄨ皟鐢ㄦ柟浜嬪姟鍐呮妸瀹㈡埛閫�璐х殑涓嶅悎鏍艰鏁磋杞氦 NCR銆� */
+@Service
+public class MesQcNcrReturnSalesLink {
+    @Resource private MesQcRqcMapper rqcMapper;
+    @Resource private MesWmReturnSalesMapper salesMapper;
+    @Resource private MesWmReturnSalesLineMapper lineMapper;
+    @Resource private MesWmReturnSalesDetailMapper detailMapper;
+
+    public String claim(MesQcNcrDO ncr) {
+        MesQcRqcDO qc = rqcMapper.selectById(ncr.getQcId());
+        if (qc == null || !Objects.equals(qc.getSourceDocType(), MesBizTypeConstants.WM_RETURN_SALES)
+                || qc.getSourceDocId() == null || qc.getSourceLineId() == null
+                || !Objects.equals(qc.getItemId(), ncr.getItemId())
+                || qc.getUnqualifiedQuantity() == null || ncr.getUnqualifiedQuantity() == null
+                || qc.getUnqualifiedQuantity().compareTo(ncr.getUnqualifiedQuantity()) != 0) {
+            throw new ServiceException(400, "閫�璐ф楠屼笉鍚堟牸澶勭悊浠呮敮鎸佸彲杩芥函鐨勫鎴烽攢鍞��璐э紝鐗╂枡鍜屾暟閲忛』涓庢楠屽崟涓�鑷�");
+        }
+        MesWmReturnSalesDO sales = salesMapper.selectOne(new LambdaQueryWrapperX<MesWmReturnSalesDO>()
+                .eq(MesWmReturnSalesDO::getId, qc.getSourceDocId()).last("FOR UPDATE"));
+        if (sales == null || Objects.equals(sales.getStatus(), MesWmReturnSalesStatusEnum.FINISHED.getStatus())
+                || Objects.equals(sales.getStatus(), MesWmReturnSalesStatusEnum.CANCELED.getStatus())) {
+            throw new ServiceException(400, "鏉ユ簮閿�鍞��璐у崟涓嶅瓨鍦ㄦ垨宸插畬鎴�/鍙栨秷锛屼笉鑳借浆浜ゅ缃�");
+        }
+        List<MesWmReturnSalesLineDO> lines = lineMapper.selectList(new LambdaQueryWrapperX<MesWmReturnSalesLineDO>()
+                .eq(MesWmReturnSalesLineDO::getReturnId, sales.getId())
+                .eq(MesWmReturnSalesLineDO::getRqcId, qc.getId())
+                .eq(MesWmReturnSalesLineDO::getQualityStatus, MesWmQualityStatusEnum.FAIL.getStatus())
+                .last("FOR UPDATE"));
+        if (lines.size() != 1) {
+            throw new ServiceException(400, "鏃犳硶鍞竴瀹氫綅閫�璐ф楠屽搴旂殑涓嶅悎鏍艰锛岃鏍稿鏉ユ簮鍏宠仈");
+        }
+        MesWmReturnSalesLineDO line = lines.get(0);
+        if (line.getNcrDispositionId() != null || !Objects.equals(line.getItemId(), ncr.getItemId())
+                || line.getQuantity() == null || line.getQuantity().compareTo(ncr.getUnqualifiedQuantity()) != 0
+                || !detailMapper.selectListByLineId(line.getId()).isEmpty()) {
+            throw new ServiceException(400, "閫�璐т笉鍚堟牸琛屽凡琚鐞嗐�佹暟閲忎笉涓�鑷存垨宸叉湁鍏ュ簱鏄庣粏锛屼笉鑳介噸澶嶅缃�");
+        }
+        lineMapper.updateById(new MesWmReturnSalesLineDO().setId(line.getId()).setNcrDispositionId(ncr.getId()));
+        return line.getBatchCode();
+    }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrScrapService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrScrapService.java
new file mode 100644
index 0000000..ea18010
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrScrapService.java
@@ -0,0 +1,169 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.ncr.vo.MesQcNcrDisposeReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.ncr.vo.MesQcNcrDisposeRespVO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.transaction.MesWmTransactionDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productproduce.MesWmProductProduceLineDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.scrap.MesWmScrapReceiptDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.pro.workorder.MesProWorkOrderMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ipqc.MesQcIpqcMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.rqc.MesQcRqcMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productproduce.MesWmProductProduceLineMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productproduce.MesWmProductProduceMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.returnsales.MesWmReturnSalesLineMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.scrap.MesWmScrapReceiptMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.transaction.MesWmTransactionMapper;
+import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants;
+import cn.iocoder.yudao.module.mes.enums.qc.MesNcrDispositionEnum;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmQualityStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmTransactionTypeEnum;
+import cn.iocoder.yudao.module.mes.service.wm.transaction.MesWmTransactionService;
+import cn.iocoder.yudao.module.mes.service.wm.transaction.dto.MesWmTransactionSaveReqDTO;
+import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseAreaService;
+import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseService;
+import jakarta.annotation.Resource;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.Objects;
+
+/** 鍙帴鏀跺凡纭鏈叆搴撶殑杩囩▼涓嶅悎鏍间骇鍑烘垨瀹㈡埛閫�璐э紝涓嶆帹娴嬪叾浠栨潵婧愮殑搴撳瓨鐘舵�併�� */
+@Service
+public class MesQcNcrScrapService {
+    @Resource private MesQcIpqcMapper ipqcMapper;
+    @Resource private MesQcRqcMapper rqcMapper;
+    @Resource private MesProWorkOrderMapper orderMapper;
+    @Resource private MesWmProductProduceLineMapper produceLineMapper;
+    @Resource private MesWmProductProduceMapper produceMapper;
+    @Resource private MesWmReturnSalesLineMapper returnLineMapper;
+    @Resource private MesWmScrapReceiptMapper scrapMapper;
+    @Resource private MesWmTransactionMapper transactionMapper;
+    @Resource private MesWmTransactionService transactionService;
+    @Resource private MesWmWarehouseService warehouseService;
+    @Resource private MesWmWarehouseAreaService areaService;
+
+    @Transactional(rollbackFor = Exception.class)
+    public MesQcNcrDisposeRespVO receive(MesQcNcrDO ncr, MesQcNcrDisposeReqVO req) {
+        if (ncr.getQcId() == null || ncr.getItemId() == null || ncr.getUnqualifiedQuantity() == null
+                || ncr.getUnqualifiedQuantity().signum() <= 0) throw error("涓嶅悎鏍煎崟鏉ユ簮銆佺墿鏂欐垨鏁伴噺涓嶅畬鏁�");
+        Long orderId = null, batchId, sourceLineId;
+        String orderCode = null, batchCode;
+        if (Objects.equals(ncr.getQcType(), MesQcTypeEnum.IPQC.getType())) {
+            var source = validateIpqcSource(ncr);
+            orderId = source.orderId(); orderCode = source.orderCode(); batchId = source.batchId();
+            batchCode = source.batchCode(); sourceLineId = source.sourceLineId();
+        } else if (Objects.equals(ncr.getQcType(), MesQcTypeEnum.RQC.getType())) {
+            var qc = rqcMapper.selectById(ncr.getQcId());
+            if (qc == null || !Objects.equals(qc.getStatus(), MesQcStatusEnum.FINISHED.getStatus())
+                    || !Objects.equals(qc.getSourceDocType(), MesBizTypeConstants.WM_RETURN_SALES) || qc.getSourceDocId() == null
+                    || qc.getSourceLineId() == null || !Objects.equals(qc.getItemId(), ncr.getItemId())
+                    || !same(qc.getUnqualifiedQuantity(), ncr.getUnqualifiedQuantity()))
+                throw error("浠呭叧鑱斿鎴烽攢鍞��璐х殑涓嶅悎鏍兼楠屽彲鍏ュ簾鏂欙紝涓旂墿鏂欐暟閲忓繀椤讳竴鑷�");
+            var lines = returnLineMapper.selectListByReturnId(qc.getSourceDocId()).stream()
+                    .filter(l -> Objects.equals(l.getRqcId(), qc.getId())
+                            && Objects.equals(l.getQualityStatus(), MesWmQualityStatusEnum.FAIL.getStatus())
+                            && Objects.equals(l.getItemId(), ncr.getItemId()) && same(l.getQuantity(), ncr.getUnqualifiedQuantity())
+                            && Objects.equals(l.getBatchCode(), qc.getBatchCode())).toList();
+            if (lines.size() != 1) throw error("鏃犳硶鍞竴瀹氫綅閫�璐ф楠屽搴旂殑涓嶅悎鏍奸��璐ц锛岃鏍稿鍏宠仈");
+            var line = lines.get(0);
+            requireNoTransaction(MesBizTypeConstants.WM_RETURN_SALES, qc.getSourceDocId(), line.getId());
+            batchId = line.getBatchId(); batchCode = line.getBatchCode(); sourceLineId = line.getId();
+        } else {
+            throw error("浠呰繃绋嬫楠屽拰瀹㈡埛閫�璐ф楠屽彲浠ュ叆搴熸枡");
+        }
+        if (req.getWarehouseId() == null || req.getLocationId() == null || req.getAreaId() == null)
+            throw error("璇烽�夋嫨搴熸枡浠撱�佸簱鍖哄拰搴撲綅");
+        var warehouse = warehouseService.validateWarehouseExists(req.getWarehouseId());
+        if (!Objects.equals("搴熸枡浠�", warehouse.getWarehouseType()) && !Objects.equals("搴熸枡", warehouse.getWarehouseType()))
+            throw error("璇烽�夋嫨浠撳簱绫诲瀷涓哄簾鏂欎粨鐨勪粨搴�");
+        areaService.validateWarehouseAreaExists(req.getWarehouseId(), req.getLocationId(), req.getAreaId());
+        String code = "SCR-N" + ncr.getQcType() + "-" + sourceLineId;
+        if (scrapMapper.selectByCode(code) != null) throw error("璇ユ楠屽崟鐨勪笉鍚堟牸鍝佸凡鐧昏搴熸枡锛岃鍕块噸澶嶅缃�");
+        var receipt = new MesWmScrapReceiptDO();
+        receipt.setCode(code); receipt.setWorkOrderId(orderId); receipt.setWorkOrderCode(orderCode);
+        receipt.setItemId(ncr.getItemId()); receipt.setQuantity(ncr.getUnqualifiedQuantity());
+        receipt.setWarehouseId(req.getWarehouseId()); receipt.setLocationId(req.getLocationId()); receipt.setAreaId(req.getAreaId());
+        receipt.setBatchId(batchId); receipt.setBatchCode(batchCode); receipt.setReceiptTime(LocalDateTime.now());
+        receipt.setRemark("鏉ユ簮涓嶅悎鏍煎搧澶勭悊鍗� " + ncr.getCode());
+        scrapMapper.insert(receipt);
+        Long tx = transactionService.createTransaction(new MesWmTransactionSaveReqDTO()
+                .setType(MesWmTransactionTypeEnum.IN.getType()).setBizType(MesBizTypeConstants.WM_SCRAP_RECEIPT)
+                .setBizId(receipt.getId()).setBizLineId(receipt.getId()).setBizCode(code).setWorkOrderId(orderId)
+                .setItemId(receipt.getItemId()).setQuantity(receipt.getQuantity()).setBatchId(batchId).setBatchCode(batchCode)
+                .setWarehouseId(receipt.getWarehouseId()).setLocationId(receipt.getLocationId()).setAreaId(receipt.getAreaId())
+                .setReceiptTime(receipt.getReceiptTime()).setForceCreateNewStock(true));
+        receipt.setTransactionId(tx); scrapMapper.updateById(receipt);
+        var result = new MesQcNcrDisposeRespVO();
+        result.setDisposition(MesNcrDispositionEnum.SCRAP.getType()); result.setDocType("SCRAP_RECEIPT");
+        result.setDocId(receipt.getId()); result.setDocCode(code); result.setDocName("搴熸枡鍏ュ簱鍗�");
+        result.setMessage("宸茬櫥璁板簾鏂欏叆搴撳崟[" + code + "]骞跺叆搴熸枡浠�"); return result;
+    }
+
+    /** 璁╂鍏ュ簱涓庢姤搴熷繀椤诲鐢ㄥ悓涓�涓嶅悎鏍间骇鍑烘潵婧愬拰鎵规锛岃皟鐢ㄨ�呰礋璐d簨鍔″強鏉ユ簮鏍搁攢銆� */
+    public IpqcSource validateIpqcSource(MesQcNcrDO ncr) {
+        if (ncr.getQcId() == null || ncr.getItemId() == null || ncr.getUnqualifiedQuantity() == null
+                || ncr.getUnqualifiedQuantity().signum() <= 0 || !Objects.equals(ncr.getQcType(), MesQcTypeEnum.IPQC.getType()))
+            throw error("涓嶅悎鏍煎崟杩囩▼妫�楠屾潵婧愩�佺墿鏂欐垨鏁伴噺涓嶅畬鏁�");
+        var qc = ipqcMapper.selectById(ncr.getQcId());
+        if (qc == null || !Objects.equals(qc.getStatus(), MesQcStatusEnum.FINISHED.getStatus())
+                || !Objects.equals(qc.getSourceDocType(), MesBizTypeConstants.PRO_FEEDBACK)
+                || qc.getSourceDocId() == null || qc.getSourceLineId() == null
+                || !Objects.equals(qc.getItemId(), ncr.getItemId()) || !same(qc.getUnqualifiedQuantity(), ncr.getUnqualifiedQuantity()))
+            throw error("杩囩▼妫�楠屾湭鍏宠仈瀹屾暣鎶ュ伐浜у嚭鎴栦笉鍚堟牸鏁伴噺涓嶄竴鑷达紝涓嶈兘鍏ュ簱");
+        var original = produceLineMapper.selectById(qc.getSourceLineId());
+        if (original == null || original.getProduceId() == null || !Objects.equals(original.getFeedbackId(), qc.getSourceDocId()))
+            throw error("杩囩▼妫�楠屽師浜у嚭琛屼笉瀛樺湪鎴栨姤宸ヤ笉涓�鑷�");
+        var produce = produceMapper.selectById(original.getProduceId());
+        if (produce == null || !Objects.equals(produce.getFeedbackId(), qc.getSourceDocId())
+                || qc.getWorkOrderId() == null || !Objects.equals(produce.getWorkOrderId(), qc.getWorkOrderId()))
+            throw error("杩囩▼妫�楠屻�佹姤宸ヤ骇鍑哄拰鐢熶骇宸ュ崟鍏宠仈涓嶄竴鑷�");
+        var candidates = produceLineMapper.selectListByFeedbackId(qc.getSourceDocId()).stream()
+                .filter(l -> Objects.equals(l.getProduceId(), original.getProduceId())
+                        && Objects.equals(l.getQualityStatus(), MesWmQualityStatusEnum.FAIL.getStatus())
+                        && Objects.equals(l.getItemId(), ncr.getItemId()) && same(l.getQuantity(), ncr.getUnqualifiedQuantity())
+                        && Objects.equals(l.getBatchId(), original.getBatchId()) && Objects.equals(l.getBatchCode(), original.getBatchCode()))
+                .toList();
+        if (candidates.size() != 1) throw error("鏃犳硶鍞竴瀹氫綅鏈叆搴撶殑涓嶅悎鏍间骇鍑鸿");
+        var line = candidates.get(0);
+        requireNoTransaction(MesBizTypeConstants.WM_PRODUCT_PRODUCE, line.getProduceId(), line.getId());
+        var order = qc.getWorkOrderId() == null ? null : orderMapper.selectById(qc.getWorkOrderId());
+        if (order == null) throw error("杩囩▼妫�楠岀敓浜ц鍗曚笉瀛樺湪");
+        return new IpqcSource(order.getId(), order.getCode(), line.getId(), line.getBatchId(), line.getBatchCode());
+    }
+
+    public record IpqcSource(Long orderId, String orderCode, Long sourceLineId, Long batchId, String batchCode) {}
+
+    /** 鏉′欢鏇存柊鎸佹湁琛岄攣鐩村埌浜嬪姟缁撴潫锛屽拰搴撳瓨涓氬姟涓�鍚屾彁浜ゆ垨鍥炴粴銆� */
+    public void claimIpqcSource(MesQcNcrDO ncr, IpqcSource source) {
+        if (ncr.getId() == null || source == null || source.sourceLineId() == null) throw error("涓嶅悎鏍间骇鍑烘潵婧愪笉瀹屾暣");
+        LambdaUpdateWrapper<MesWmProductProduceLineDO> claim = new LambdaUpdateWrapper<MesWmProductProduceLineDO>()
+                .set(MesWmProductProduceLineDO::getNcrDispositionId, ncr.getId())
+                .eq(MesWmProductProduceLineDO::getId, source.sourceLineId())
+                .eq(MesWmProductProduceLineDO::getQualityStatus, MesWmQualityStatusEnum.FAIL.getStatus())
+                .eq(MesWmProductProduceLineDO::getItemId, ncr.getItemId())
+                .eq(MesWmProductProduceLineDO::getQuantity, ncr.getUnqualifiedQuantity())
+                .isNull(MesWmProductProduceLineDO::getNcrDispositionId);
+        if (source.batchId() == null) claim.isNull(MesWmProductProduceLineDO::getBatchId);
+        else claim.eq(MesWmProductProduceLineDO::getBatchId, source.batchId());
+        if (source.batchCode() == null) claim.isNull(MesWmProductProduceLineDO::getBatchCode);
+        else claim.eq(MesWmProductProduceLineDO::getBatchCode, source.batchCode());
+        int changed = produceLineMapper.update(null, claim);
+        if (changed != 1) throw error("涓嶅悎鏍间骇鍑鸿宸插缃垨鍙戠敓鍙樺寲锛岃鍒锋柊鍚庢牳瀵�");
+    }
+
+    private void requireNoTransaction(Integer type, Long docId, Long lineId) {
+        if (transactionMapper.selectCount(new LambdaQueryWrapperX<MesWmTransactionDO>()
+                .eq(MesWmTransactionDO::getBizType, type).eq(MesWmTransactionDO::getBizId, docId)
+                .eq(MesWmTransactionDO::getBizLineId, lineId)) > 0)
+            throw error("鏉ユ簮涓嶅悎鏍艰宸叉湁搴撳瓨娴佹按锛岃鍏堝璐︼紝涓嶈兘閲嶅鍏ュ簱");
+    }
+    private static boolean same(BigDecimal a, BigDecimal b) { return a != null && b != null && a.compareTo(b) == 0; }
+    private static ServiceException error(String message) { return new ServiceException(400, message); }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrService.java
index 82e420c..d746ea8 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrService.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrService.java
@@ -79,7 +79,7 @@
      * @param id        缂栧彿
      * @param bpmResult BPM 瀹℃壒缁撴灉
      */
-    void updateNcrAuditStatus(Long id, Integer bpmResult);
+    void updateNcrAuditStatus(Long id, String processInstanceId, Integer bpmResult);
 
     /**
      * 鍏抽棴涓嶅悎鏍煎搧澶勭悊鍗�
@@ -87,7 +87,7 @@
      * @param id           缂栧彿
      * @param closeOpinion 鍏抽棴鎰忚
      */
-    void closeNcr(Long id, String closeOpinion);
+    void closeNcr(Long id, String closeOpinion, Long reinspectionIpqcId);
 
     /**
      * 鏍¢獙涓嶅悎鏍煎搧澶勭悊鍗曞瓨鍦�
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrServiceImpl.java
index 3f3bb69..e6b69ea 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrServiceImpl.java
@@ -85,12 +85,29 @@
      */
     private static final Set<Integer> DISPOSITION_ALLOWED_TYPES = Set.of(
             MesNcrDispositionEnum.SCRAP.getType(),
+            MesNcrDispositionEnum.RETURN.getType(),
+            MesNcrDispositionEnum.REPRODUCTION.getType(),
             MesNcrDispositionEnum.REWORK.getType(),
             MesNcrDispositionEnum.CONCESSION.getType(),
             MesNcrDispositionEnum.REPAIR.getType());
 
     @Resource
     private MesQcNcrMapper ncrMapper;
+
+    @Resource
+    private MesQcNcrReinspectionValidator reinspectionValidator;
+
+    @Resource
+    private MesQcNcrStockClosureGuard stockClosureGuard;
+
+    @Resource private MesQcNcrScrapService scrapService;
+    @Resource private MesQcNcrReturnSalesLink returnSalesLink;
+    @Resource private MesQcPurchaseReturnService purchaseReturnService;
+    @Resource private MesQcPurchaseConcessionService purchaseConcessionService;
+    @Resource private MesQcNcrOqcSourceClaim oqcSourceClaim;
+    @Resource private MesQcNcrOqcConcessionService oqcConcessionService;
+    @Resource private MesQcNcrOqcReproductionService oqcReproductionService;
+    @Resource private MesQcNcrOqcReworkService oqcReworkService;
 
     @Resource
     private MdmItemApi mdmItemApi;
@@ -170,6 +187,11 @@
     public void updateNcr(MesQcNcrSaveReqVO updateReqVO) {
         // 1. 鏍¢獙瀛樺湪 + 鍙厑璁稿緟璇勫鐘舵�佺紪杈�
         MesQcNcrDO ncr = validateNcrStatusPendingReview(updateReqVO.getId());
+        if (ncr.getQcId() != null && (!Objects.equals(ncr.getItemId(), updateReqVO.getItemId())
+                || ncr.getUnqualifiedQuantity() == null || updateReqVO.getUnqualifiedQuantity() == null
+                || ncr.getUnqualifiedQuantity().compareTo(updateReqVO.getUnqualifiedQuantity()) != 0)) {
+            throw new ServiceException(400, "鏉ユ簮璐ㄦ鍗曠敓鎴愮殑涓嶅悎鏍肩墿鏂欏拰鏁伴噺涓嶈兘淇敼");
+        }
         validateNcrCodeUnique(updateReqVO.getId(), updateReqVO.getCode());
         validateItemExists(updateReqVO.getItemId());
 
@@ -185,7 +207,10 @@
     @Transactional(rollbackFor = Exception.class)
     public void deleteNcr(Long id) {
         // 鏍¢獙瀛樺湪 + 鍙厑璁稿垹闄ゅ緟璇勫鐘舵��
-        validateNcrStatusPendingReview(id);
+        MesQcNcrDO ncr = validateNcrStatusPendingReview(id);
+        if (ncr.getQcId() != null) {
+            throw new ServiceException(400, "鏉ユ簮璐ㄦ鍗曠敓鎴愮殑涓嶅悎鏍煎鐞嗗崟涓嶈兘鍒犻櫎");
+        }
         ncrMapper.deleteById(id);
     }
 
@@ -194,8 +219,9 @@
     public void reviewNcr(Long id, Integer disposition, Long responsibleDeptId,
                            Integer defectLevel, String reviewOpinion) {
         // 1. 鏍¢獙瀛樺湪 + 寰呰瘎瀹$姸鎬�
-        validateNcrStatusPendingReview(id);
+        MesQcNcrDO ncr = validateNcrStatusPendingReview(id);
         validateDisposition(disposition);
+        validateDispositionForSource(ncr, disposition);
 
         // 2. 鏇存柊璇勫淇℃伅
         MesQcNcrDO updateObj = new MesQcNcrDO()
@@ -216,12 +242,13 @@
     @Transactional(rollbackFor = Exception.class)
     public MesQcNcrDisposeRespVO disposeNcr(MesQcNcrDisposeReqVO disposeReqVO) {
         // 1. 鏍¢獙瀛樺湪 + 宸茶瘎瀹★紙瀹℃壒閫氳繃锛夌姸鎬�
-        MesQcNcrDO ncr = validateNcrExists(disposeReqVO.getId());
+        MesQcNcrDO ncr = validateNcrExistsForUpdate(disposeReqVO.getId());
         if (!MesNcrStatusEnum.REVIEWED.getStatus().equals(ncr.getStatus())) {
             throw exception(QC_NCR_DISPOSE_STATUS_INVALID, ncr.getCode(), resolveStatusName(ncr.getStatus()));
         }
         // 2. 澶勭疆鏂瑰紡蹇呭~锛屼笖蹇呴』鏄悎娉曟灇涓惧��
         validateDisposition(disposeReqVO.getDisposition());
+        validateDispositionForSource(ncr, disposeReqVO.getDisposition());
         // 3. 涓嶅悎鏍兼暟閲忓繀椤诲ぇ浜� 0锛屽惁鍒欐棤娉曠敓鎴愬叆搴撳崟 / 鐢熶骇璁㈠崟
         if (ncr.getUnqualifiedQuantity() == null
                 || ncr.getUnqualifiedQuantity().compareTo(BigDecimal.ZERO) <= 0) {
@@ -230,10 +257,71 @@
 
         // 4. 鎸夊缃柟寮忚仈鍔ㄧ敓鎴愪笟鍔″崟鎹�
         MesQcNcrDisposeRespVO respVO;
-        if (Objects.equals(MesNcrDispositionEnum.CONCESSION.getType(), disposeReqVO.getDisposition())
-                || Objects.equals(MesNcrDispositionEnum.SCRAP.getType(), disposeReqVO.getDisposition())) {
-            // 璁╂鏀捐 / 鎶ュ簾锛氱敓鎴愭潅椤瑰叆搴撳崟骞惰嚜鍔ㄥ畬鎴愬叆搴�
+        MesQcNcrScrapService.IpqcSource processSource = null;
+        MesQcNcrOqcSourceClaim.OqcClaimedSource oqcSource = null;
+        if (Objects.equals(ncr.getQcType(), MesQcTypeEnum.OQC.getType())) {
+            oqcSource = oqcSourceClaim.claim(ncr);
+        }
+        if (Objects.equals(ncr.getQcType(), MesQcTypeEnum.IPQC.getType())) {
+            processSource = scrapService.validateIpqcSource(ncr);
+            scrapService.claimIpqcSource(ncr, processSource);
+            if (StrUtil.isNotBlank(processSource.batchCode()) && StrUtil.isNotBlank(disposeReqVO.getBatchCode())
+                    && !Objects.equals(processSource.batchCode(), StrUtil.trim(disposeReqVO.getBatchCode()))) {
+                throw new ServiceException(400, "澶勭疆鎵规蹇呴』涓庤繃绋嬫楠屽師鎵规涓�鑷�");
+            }
+            if (StrUtil.isNotBlank(processSource.batchCode())) disposeReqVO.setBatchCode(processSource.batchCode());
+        }
+        if (Objects.equals(ncr.getQcType(), MesQcTypeEnum.RQC.getType())) {
+            String originalBatch = returnSalesLink.claim(ncr);
+            if (StrUtil.isNotBlank(originalBatch) && StrUtil.isNotBlank(disposeReqVO.getBatchCode())
+                    && !Objects.equals(originalBatch, StrUtil.trim(disposeReqVO.getBatchCode()))) {
+                throw new ServiceException(400, "澶勭疆鎵规蹇呴』涓庡鎴烽��璐у師鎵规涓�鑷�");
+            }
+            if (StrUtil.isNotBlank(originalBatch)) disposeReqVO.setBatchCode(originalBatch);
+        }
+        if (Objects.equals(disposeReqVO.getDisposition(), MesNcrDispositionEnum.RETURN.getType())) {
+            var doc = purchaseReturnService.createForNcr(ncr);
+            respVO = new MesQcNcrDisposeRespVO();
+            respVO.setDisposition(disposeReqVO.getDisposition());
+            respVO.setDocType("PURCHASE_RETURN");
+            respVO.setDocId(doc.getId());
+            respVO.setDocCode(doc.getCode());
+            respVO.setDocName("閲囪喘閫�璐у崟");
+            respVO.setMessage("閲囪喘閫�璐у崟宸茬敓鎴愶紝璇风敱浠撳簱纭閫�璐�");
+        } else if (Objects.equals(disposeReqVO.getDisposition(), MesNcrDispositionEnum.REPRODUCTION.getType())) {
+            respVO = processSource != null
+                    ? oqcReproductionService.reproduceIpqc(ncr, disposeReqVO.getDisposition(), processSource)
+                    : oqcReproductionService.reproduce(ncr, disposeReqVO.getDisposition());
+        } else if (Objects.equals(disposeReqVO.getDisposition(), MesNcrDispositionEnum.CONCESSION.getType())
+                && Objects.equals(ncr.getQcType(), MesQcTypeEnum.IQC.getType())) {
+            respVO = purchaseConcessionService.dispose(ncr, disposeReqVO);
+        } else if (Objects.equals(disposeReqVO.getDisposition(), MesNcrDispositionEnum.CONCESSION.getType())
+                && Objects.equals(ncr.getQcType(), MesQcTypeEnum.OQC.getType())) {
+            oqcConcessionService.release(ncr, disposeReqVO);
+            respVO = new MesQcNcrDisposeRespVO();
+            respVO.setDisposition(disposeReqVO.getDisposition());
+            respVO.setDocType("PRODUCT_SALES");
+            MesQcOqcDO sourceOqc = oqcService.getOqc(ncr.getQcId());
+            respVO.setDocId(sourceOqc.getSourceDocId());
+            respVO.setDocCode(sourceOqc.getSourceDocCode());
+            respVO.setDocName("閿�鍞嚭搴撳崟");
+            respVO.setMessage("鍑鸿揣璁╂宸插畬鎴愬師閿�鍞嚭搴撳崟鎷h揣鍙婂嚭搴�");
+        } else if (Objects.equals(disposeReqVO.getDisposition(), MesNcrDispositionEnum.SCRAP.getType())
+                && (Objects.equals(ncr.getQcType(), MesQcTypeEnum.IPQC.getType())
+                || Objects.equals(ncr.getQcType(), MesQcTypeEnum.RQC.getType()))) {
+            respVO = scrapService.receive(ncr, disposeReqVO);
+        } else if (Objects.equals(disposeReqVO.getDisposition(), MesNcrDispositionEnum.CONCESSION.getType())
+                && (Objects.equals(ncr.getQcType(), MesQcTypeEnum.IPQC.getType())
+                || Objects.equals(ncr.getQcType(), MesQcTypeEnum.RQC.getType()))) {
             respVO = createMiscReceiptForDispose(ncr, disposeReqVO);
+        } else if (Objects.equals(disposeReqVO.getDisposition(), MesNcrDispositionEnum.CONCESSION.getType())
+                || Objects.equals(disposeReqVO.getDisposition(), MesNcrDispositionEnum.SCRAP.getType())) {
+            stockClosureGuard.validateBeforeDispose(disposeReqVO.getDisposition());
+            throw new ServiceException(400, "璇ユ潵婧愭殏涓嶆敮鎸佹澶勭疆鏂瑰紡");
+        } else if (oqcSource != null && (Objects.equals(disposeReqVO.getDisposition(), MesNcrDispositionEnum.REWORK.getType())
+                || Objects.equals(disposeReqVO.getDisposition(), MesNcrDispositionEnum.REPAIR.getType()))) {
+            // 鍑鸿揣杩斿伐/杩斾慨锛氭墸鍑忓師鎴愬搧搴撳瓨 鈫� 鍙栨秷鍘熼攢鍞嚭搴撳崟 鈫� 鍏嬮殕杩斿伐宸ュ崟
+            respVO = oqcReworkService.dispose(ncr, oqcSource, disposeReqVO);
         } else {
             // 杩斿伐 / 杩斾慨锛氱敓鎴愯嚜琛岀敓浜х被鍨嬬殑鐢熶骇璁㈠崟
             respVO = createReworkWorkOrderForDispose(ncr, disposeReqVO);
@@ -462,7 +550,7 @@
         // 璇ユ柟娉曚細鎶婃墍鏈夊紓甯哥粺涓�鍖呮垚 RuntimeException锛屽洜姝よ繖閲屼笉鑳界洿鎺� catch ServiceException锛�
         // 蹇呴』娌� cause 閾惧垽鏂槸鍚︿负銆屾祦绋嬪畾涔変笉瀛樺湪銆嶃��
         // 1. 鏍¢獙瀛樺湪 + 寰呰瘎瀹★紙鑽夌/瀹℃壒椹冲洖鍚庯級鐘舵��
-        MesQcNcrDO ncr = validateNcrExists(id);
+        MesQcNcrDO ncr = validateNcrExistsForUpdate(id);
         if (!MesNcrStatusEnum.PENDING_REVIEW.getStatus().equals(ncr.getStatus())) {
             throw exception(QC_NCR_SUBMIT_STATUS_INVALID, ncr.getCode(), resolveStatusName(ncr.getStatus()));
         }
@@ -519,10 +607,12 @@
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void updateNcrAuditStatus(Long id, Integer bpmResult) {
+    public void updateNcrAuditStatus(Long id, String processInstanceId, Integer bpmResult) {
         // 1. 鏍¢獙瀛樺湪 + 瀹℃壒涓紙閬垮厤骞跺彂鎴栭噸澶嶅洖璋冭鐩栧凡澶勭疆/宸插叧闂姸鎬侊級
-        MesQcNcrDO ncr = validateNcrExists(id);
-        if (!MesNcrStatusEnum.APPROVING.getStatus().equals(ncr.getStatus())) {
+        MesQcNcrDO ncr = validateNcrExistsForUpdate(id);
+        if (!MesNcrStatusEnum.APPROVING.getStatus().equals(ncr.getStatus())
+                || StrUtil.isBlank(processInstanceId)
+                || !Objects.equals(processInstanceId, ncr.getProcessInstanceId())) {
             return;
         }
 
@@ -545,11 +635,38 @@
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void closeNcr(Long id, String closeOpinion) {
+    public void closeNcr(Long id, String closeOpinion, Long reinspectionIpqcId) {
         // 1. 鏍¢獙瀛樺湪 + 宸插缃姸鎬�
-        MesQcNcrDO ncr = validateNcrExists(id);
+        MesQcNcrDO ncr = validateNcrExistsForUpdate(id);
         if (!MesNcrStatusEnum.DISPOSED.getStatus().equals(ncr.getStatus())) {
             throw exception(QC_NCR_CLOSE_STATUS_INVALID, ncr.getCode(), resolveStatusName(ncr.getStatus()));
+        }
+
+        if (Objects.equals(ncr.getDisposition(), MesNcrDispositionEnum.RETURN.getType())
+                && Objects.equals(ncr.getQcType(), MesQcTypeEnum.IQC.getType())) {
+            purchaseReturnService.validateConfirmed(ncr.getId());
+        } else if (Objects.equals(ncr.getQcType(), MesQcTypeEnum.OQC.getType())
+                && Objects.equals(ncr.getDisposition(), MesNcrDispositionEnum.CONCESSION.getType())) {
+            oqcConcessionService.validateBeforeClose(ncr);
+        } else if (Objects.equals(ncr.getQcType(), MesQcTypeEnum.IQC.getType())
+                && Objects.equals(ncr.getDisposition(), MesNcrDispositionEnum.CONCESSION.getType())) {
+            // 閲囪喘璁╂鐨勫叆搴撳拰 ERP 鍥炲啓涓庡缃湪鍚屼竴浜嬪姟瀹屾垚銆�
+        } else if (Objects.equals(ncr.getDisposition(), MesNcrDispositionEnum.REPRODUCTION.getType())) {
+            throw new ServiceException(400, "閲嶆柊鐢熶骇鍚庨渶瀹屾垚澶嶆骞跺鐞嗗師鍑哄簱鍗曪紝鏆備笉鑳藉叧闂�");
+        } else if (Objects.equals(ncr.getQcType(), MesQcTypeEnum.OQC.getType())
+                && (Objects.equals(ncr.getDisposition(), MesNcrDispositionEnum.REWORK.getType())
+                || Objects.equals(ncr.getDisposition(), MesNcrDispositionEnum.REPAIR.getType()))) {
+            oqcReworkService.validateBeforeClose(ncr);
+        } else if (!Objects.equals(ncr.getQcType(), MesQcTypeEnum.IPQC.getType())
+                && !Objects.equals(ncr.getQcType(), MesQcTypeEnum.RQC.getType())) {
+            stockClosureGuard.validateBeforeClose(ncr);
+        }
+
+        if (Objects.equals(ncr.getDisposition(), MesNcrDispositionEnum.REWORK.getType())
+                || Objects.equals(ncr.getDisposition(), MesNcrDispositionEnum.REPAIR.getType())) {
+            reinspectionValidator.validate(ncr, reinspectionIpqcId);
+        } else {
+            reinspectionIpqcId = null;
         }
 
         // 2. 鏇存柊鍏抽棴淇℃伅
@@ -558,6 +675,7 @@
                 .setCloseUserId(getLoginUserId())
                 .setCloseDate(LocalDateTime.now())
                 .setCloseOpinion(closeOpinion)
+                .setReinspectionIpqcId(reinspectionIpqcId)
                 .setStatus(MesNcrStatusEnum.CLOSED.getStatus()));
     }
 
@@ -572,11 +690,19 @@
         return ncr;
     }
 
+    private MesQcNcrDO validateNcrExistsForUpdate(Long id) {
+        MesQcNcrDO ncr = ncrMapper.selectByIdForUpdate(id);
+        if (ncr == null) {
+            throw exception(QC_NCR_NOT_EXISTS, id);
+        }
+        return ncr;
+    }
+
     /**
      * 鏍¢獙 NCR 瀛樺湪涓斾负寰呰瘎瀹$姸鎬�
      */
     private MesQcNcrDO validateNcrStatusPendingReview(Long id) {
-        MesQcNcrDO ncr = validateNcrExists(id);
+        MesQcNcrDO ncr = validateNcrExistsForUpdate(id);
         if (!MesNcrStatusEnum.PENDING_REVIEW.getStatus().equals(ncr.getStatus())) {
             throw exception(QC_NCR_STATUS_NOT_PENDING, ncr.getCode(), resolveStatusName(ncr.getStatus()));
         }
@@ -595,6 +721,22 @@
         }
     }
 
+    private void validateDispositionForSource(MesQcNcrDO ncr, Integer disposition) {
+        if (Objects.equals(ncr.getQcType(), MesQcTypeEnum.IQC.getType())) {
+            if (!Objects.equals(disposition, MesNcrDispositionEnum.RETURN.getType())
+                    && !Objects.equals(disposition, MesNcrDispositionEnum.CONCESSION.getType())) {
+                throw new ServiceException(400, "閲囪喘妫�楠屼笉鍚堟牸浠呮敮鎸侀��璐ф垨璁╂鏀捐");
+            }
+        } else if (Objects.equals(disposition, MesNcrDispositionEnum.RETURN.getType())) {
+            throw new ServiceException(400, "鍙湁閲囪喘妫�楠屼笉鍚堟牸鏀寔閲囪喘閫�璐�");
+        }
+        if (Objects.equals(disposition, MesNcrDispositionEnum.REPRODUCTION.getType())
+                && !Objects.equals(ncr.getQcType(), MesQcTypeEnum.OQC.getType())
+                && !Objects.equals(ncr.getQcType(), MesQcTypeEnum.IPQC.getType())) {
+            throw new ServiceException(400, "閲嶆柊鐢熶骇浠呮敮鎸佽繃绋嬫垨鍑鸿揣妫�楠屼笉鍚堟牸");
+        }
+    }
+
     /**
      * 鐘舵�佸�艰浆鍚嶇О锛岃В鏋愬け璐ュ洖閫�涓� ID 瀛楃涓�
      */
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrStockClosureGuard.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrStockClosureGuard.java
new file mode 100644
index 0000000..9a2d26f
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrStockClosureGuard.java
@@ -0,0 +1,31 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.enums.qc.MesNcrDispositionEnum;
+import org.springframework.stereotype.Component;
+
+import java.util.Objects;
+
+/** 搴撳瓨闅旂鍜岄攢姣侀棴鐜皻鏈缓绔嬪墠锛岀姝㈤�氳繃鍏ュ簱浼�犲畬鎴愬缃�� */
+@Component
+public class MesQcNcrStockClosureGuard {
+
+    public void validateBeforeDispose(Integer disposition) {
+        if (Objects.equals(disposition, MesNcrDispositionEnum.SCRAP.getType())) {
+            throw new ServiceException(400, "鎶ュ簾澶勭疆鏆備笉鍙墽琛岋細闇�鍏堝缓绔嬩笉鍚堟牸鍝侀殧绂诲叆搴撱�侀攢姣佺‘璁ゅ強閿�姣佸嚭搴撻棴鐜紝閬垮厤閲嶅鍏ュ簱鎴栬处瀹炰笉绗�");
+        }
+        if (Objects.equals(disposition, MesNcrDispositionEnum.CONCESSION.getType())) {
+            throw new ServiceException(400, "璁╂鏀捐鏆備笉鍙墽琛岋細闇�鍏堝畬鎴愭潵婧愬崟鎹�佸師鎵规鍜屽簱瀛樼殑鏀捐闂幆锛岄伩鍏嶉噸澶嶅叆搴撴垨鏀捐閿欒鎵规");
+        }
+    }
+
+    public void validateBeforeClose(MesQcNcrDO ncr) {
+        if (Objects.equals(ncr.getDisposition(), MesNcrDispositionEnum.SCRAP.getType())) {
+            throw new ServiceException(400, "鎶ュ簾澶勭悊鍗曟殏涓嶅彲鍏抽棴锛氬皻鏈缓绔嬮殧绂诲簱瀛樼殑閿�姣佺‘璁ゅ拰閿�姣佸嚭搴撻棴鐜紝璇蜂繚鐣欏崟鎹瓑寰呭鐞�");
+        }
+        if (Objects.equals(ncr.getDisposition(), MesNcrDispositionEnum.CONCESSION.getType())) {
+            throw new ServiceException(400, "璁╂鏀捐澶勭悊鍗曟殏涓嶅彲鍏抽棴锛氬皻鏈畬鎴愭潵婧愬崟鎹�佸師鎵规鍜屽簱瀛樼殑鏀捐鏍搁獙锛岃淇濈暀鍗曟嵁绛夊緟澶勭悊");
+        }
+    }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcPurchaseConcessionService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcPurchaseConcessionService.java
new file mode 100644
index 0000000..e527bfc
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcPurchaseConcessionService.java
@@ -0,0 +1,77 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.ncr.vo.MesQcNcrDisposeReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.ncr.vo.MesQcNcrDisposeRespVO;
+import cn.iocoder.yudao.module.mes.controller.admin.wm.itemreceipt.vo.MesWmItemReceiptSaveReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.wm.itemreceipt.vo.line.MesWmItemReceiptLineSaveReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.wm.itemreceipt.vo.detail.MesWmItemReceiptDetailSaveReqVO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcPurchaseConcessionDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr.MesQcPurchaseConcessionMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr.MesQcPurchaseReturnMapper;
+import cn.iocoder.yudao.module.mes.service.wm.itemreceipt.MesWmItemReceiptService;
+import cn.iocoder.yudao.module.mes.service.wm.itemreceipt.MesWmItemReceiptLineService;
+import cn.iocoder.yudao.module.mes.service.wm.itemreceipt.MesWmItemReceiptDetailService;
+import jakarta.annotation.Resource;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import java.time.LocalDateTime;
+
+/** 璁╂鏁伴噺缁忛噰璐叆搴撹繃璐︼紝鍚堟牸浣欓噺浠嶇敱鍘熷埌璐у崟鍏ュ簱銆� */
+@Service
+public class MesQcPurchaseConcessionService {
+    @Resource private MesQcNcrPurchaseSourceValidator validator;
+    @Resource private MesQcPurchaseConcessionMapper concessionMapper;
+    @Resource private MesQcPurchaseReturnMapper returnMapper;
+    @Resource private MesWmItemReceiptService receipts;
+    @Resource private MesWmItemReceiptLineService lines;
+    @Resource private MesWmItemReceiptDetailService details;
+    @Resource private MesQcArrivalDispositionService arrivalDispositionService;
+
+    /** 蹇呴』鐢遍攣瀹� NCR 鐨勫缃簨鍔¤皟鐢ㄣ�� */
+    @Transactional(rollbackFor = Exception.class)
+    public MesQcNcrDisposeRespVO dispose(MesQcNcrDO ncr, MesQcNcrDisposeReqVO request) {
+        var source = validator.validate(ncr);
+        if (returnMapper.selectByIqcId(ncr.getQcId()) != null || concessionMapper.selectByIqcId(ncr.getQcId()) != null)
+            throw new ServiceException(400, "璇ユ潵鏂欐楠屽凡鏈夐噰璐缃崟锛屼笉鑳介噸澶嶅缃�");
+        if (source.notice().getVendorId() == null || source.notice().getPurchaseOrderId() == null
+                || source.line().getPurchaseOrderItemId() == null)
+            throw new ServiceException(400, "鍒拌揣鍗曠己灏戜緵搴斿晢鎴栭噰璐鍗曟槑缁嗭紝鏃犳硶鐢熸垚閲囪喘鍏ュ簱");
+        if (request.getWarehouseId() == null || request.getLocationId() == null || request.getAreaId() == null)
+            throw new ServiceException(400, "璁╂鍏ュ簱璇烽�夋嫨浠撳簱銆佸簱鍖哄拰搴撲綅");
+        String code = "NCR-IR-" + ncr.getId();
+        var head = new MesWmItemReceiptSaveReqVO();
+        head.setCode(code); head.setName("璁╂鍏ュ簱-" + ncr.getCode());
+        head.setIqcId(ncr.getQcId()); head.setVendorId(source.notice().getVendorId());
+        head.setPurchaseOrderCode(source.notice().getPurchaseOrderCode());
+        head.setReceiptDate(LocalDateTime.now());
+        head.setRemark("鏉ユ枡璁╂鍏ュ簱锛屾潵婧愪笉鍚堟牸鍗� " + ncr.getCode());
+        Long receiptId = receipts.createItemReceipt(head);
+        var line = new MesWmItemReceiptLineSaveReqVO();
+        line.setReceiptId(receiptId); line.setItemId(ncr.getItemId());
+        line.setPurchaseOrderItemId(source.line().getPurchaseOrderItemId());
+        line.setReceivedQuantity(ncr.getUnqualifiedQuantity()); line.setBatchCode(request.getBatchCode());
+        line.setLotNumber(source.iqc().getVendorBatch());
+        Long lineId = lines.createItemReceiptLine(line);
+        var storedLine = lines.getItemReceiptLine(lineId);
+        var detail = new MesWmItemReceiptDetailSaveReqVO();
+        detail.setReceiptId(receiptId); detail.setLineId(lineId); detail.setItemId(ncr.getItemId());
+        detail.setQuantity(ncr.getUnqualifiedQuantity()); detail.setBatchId(storedLine.getBatchId());
+        detail.setWarehouseId(request.getWarehouseId()); detail.setLocationId(request.getLocationId()); detail.setAreaId(request.getAreaId());
+        details.createItemReceiptDetail(detail);
+        receipts.submitItemReceipt(receiptId); receipts.stockItemReceipt(receiptId); receipts.finishItemReceipt(receiptId);
+        var record = new MesQcPurchaseConcessionDO();
+        record.setNcrId(ncr.getId()); record.setIqcId(ncr.getQcId());
+        record.setNoticeId(source.notice().getId()); record.setNoticeLineId(source.line().getId());
+        record.setPurchaseOrderItemId(source.line().getPurchaseOrderItemId());
+        record.setReceiptId(receiptId); record.setQuantity(ncr.getUnqualifiedQuantity());
+        concessionMapper.insert(record);
+        arrivalDispositionService.refresh(source.notice().getId());
+        var response = new MesQcNcrDisposeRespVO();
+        response.setDisposition(request.getDisposition()); response.setDocType("ITEM_RECEIPT");
+        response.setDocId(receiptId); response.setDocCode(code); response.setDocName(head.getName());
+        response.setMessage("璁╂鏁伴噺宸插畬鎴愰噰璐叆搴擄紝鍘熷悎鏍兼暟閲忕户缁敱鍒拌揣鍗曞叆搴�");
+        return response;
+    }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcPurchaseReturnService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcPurchaseReturnService.java
new file mode 100644
index 0000000..1edbd1b
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcPurchaseReturnService.java
@@ -0,0 +1,74 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcPurchaseReturnDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr.MesQcPurchaseReturnMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr.MesQcPurchaseConcessionMapper;
+import jakarta.annotation.Resource;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import java.time.LocalDateTime;
+import java.util.Objects;
+import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
+
+@Service
+public class MesQcPurchaseReturnService {
+    @Resource private MesQcNcrPurchaseSourceValidator sourceValidator;
+    @Resource private MesQcPurchaseReturnMapper mapper;
+    @Resource private MesQcPurchaseConcessionMapper concessionMapper;
+    @Resource private MesQcArrivalDispositionService arrivalDispositionService;
+
+    /** 蹇呴』鐢卞凡閿佸畾 NCR 鐨勫缃簨鍔¤皟鐢ㄣ�� */
+    @Transactional(rollbackFor = Exception.class)
+    public MesQcPurchaseReturnDO createForNcr(MesQcNcrDO ncr) {
+        if (mapper.selectByNcrId(ncr.getId()) != null)
+            throw new ServiceException(400, "璇ヤ笉鍚堟牸鍗曞凡鐢熸垚閲囪喘閫�璐у崟");
+        var source = sourceValidator.validate(ncr);
+        if (concessionMapper.selectByIqcId(ncr.getQcId()) != null || mapper.selectByIqcId(ncr.getQcId()) != null)
+            throw new ServiceException(400, "璇ユ潵鏂欐楠屽凡鏈夐噰璐缃崟锛屼笉鑳介噸澶嶅缃�");
+        if (source.notice().getVendorId() == null || source.notice().getPurchaseOrderId() == null
+                || source.line().getPurchaseOrderItemId() == null)
+            throw new ServiceException(400, "鍒拌揣鍗曠己灏戜緵搴斿晢銆侀噰璐鍗曟垨閲囪喘鏄庣粏锛屾棤娉曠敓鎴愬彲杩芥函閫�璐у崟");
+        MesQcPurchaseReturnDO doc = new MesQcPurchaseReturnDO();
+        doc.setCode("NCR-RET-" + ncr.getId());
+        doc.setNcrId(ncr.getId());
+        doc.setIqcId(ncr.getQcId());
+        doc.setNoticeId(source.notice().getId());
+        doc.setNoticeLineId(source.line().getId());
+        doc.setPurchaseOrderId(source.notice().getPurchaseOrderId());
+        doc.setPurchaseOrderItemId(source.line().getPurchaseOrderItemId());
+        doc.setVendorId(source.notice().getVendorId());
+        doc.setItemId(ncr.getItemId());
+        doc.setVendorBatch(source.iqc().getVendorBatch());
+        doc.setQuantity(ncr.getUnqualifiedQuantity());
+        doc.setStatus(0);
+        mapper.insert(doc);
+        return doc;
+    }
+
+    public MesQcPurchaseReturnDO getByNcrId(Long ncrId) { return mapper.selectByNcrId(ncrId); }
+
+    public PageResult<MesQcPurchaseReturnDO> getPage(PageParam page, Integer status) {
+        if (status != null && status != 0 && status != 1) throw new ServiceException(400, "閲囪喘閫�璐х姸鎬佹棤鏁�");
+        return mapper.selectPage(page, status);
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public void confirm(Long id, String remark) {
+        MesQcPurchaseReturnDO doc = mapper.selectByIdForUpdate(id);
+        if (doc == null) throw new ServiceException(400, "閲囪喘閫�璐у崟涓嶅瓨鍦�");
+        if (!Objects.equals(doc.getStatus(), 0)) throw new ServiceException(400, "閲囪喘閫�璐у崟宸茬‘璁ら��璐�");
+        mapper.updateById(new MesQcPurchaseReturnDO().setId(id).setStatus(1)
+                .setConfirmedBy(getLoginUserId()).setConfirmedAt(LocalDateTime.now()).setConfirmationRemark(remark));
+        arrivalDispositionService.refresh(doc.getNoticeId());
+    }
+
+    public void validateConfirmed(Long ncrId) {
+        MesQcPurchaseReturnDO doc = mapper.selectByNcrId(ncrId);
+        if (doc == null || !Objects.equals(doc.getStatus(), 1))
+            throw new ServiceException(400, "璇峰厛鐢遍噰璐粨搴撶‘璁ら噰璐��璐у畬鎴愶紝鍐嶅叧闂笉鍚堟牸鍗�");
+    }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/listener/MesQcNcrStatusListener.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/listener/MesQcNcrStatusListener.java
index 4c0a651..bc10454 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/listener/MesQcNcrStatusListener.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ncr/listener/MesQcNcrStatusListener.java
@@ -66,7 +66,7 @@
         }
 
         // 4. 鏇存柊瀹℃壒鐘舵�侊紙Service 鍐呴儴浼氬啀娆℃牎楠屼粎瀹℃壒涓姸鎬佸彲鏇存柊锛�
-        ncrService.updateNcrAuditStatus(ncrId, event.getStatus());
+        ncrService.updateNcrAuditStatus(ncrId, event.getId(), event.getStatus());
         log.info("[onEvent] NCR({}) 瀹℃壒鐘舵�佹洿鏂板畬鎴愶紝BPM 鐘舵�侊細{}", ncrId, event.getStatus());
     }
 
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/rqc/MesQcRqcServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/rqc/MesQcRqcServiceImpl.java
index b807291..7dbb60e 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/rqc/MesQcRqcServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/rqc/MesQcRqcServiceImpl.java
@@ -212,6 +212,8 @@
                     rqc.getQualifiedQuantity(), rqc.getUnqualifiedQuantity());
         } else if (Objects.equals(rqc.getSourceDocType(), MesBizTypeConstants.WM_RETURN_SALES)) {
             // 鍥炲啓閿�鍞��璐у崟琛岋細鎷嗗垎琛� + 鏇存柊璐ㄩ噺鐘舵�� + 鑱斿姩涓诲崟鐘舵��
+            returnSalesLineService.bindRqcForFinish(rqc.getSourceLineId(), rqc.getSourceDocId(),
+                    rqc.getId(), rqc.getItemId(), rqc.getCheckQuantity());
             returnSalesLineService.updateReturnSalesLineWhenRqcFinish(
                     rqc.getSourceLineId(), rqc.getSourceDocId(), rqc.getCheckResult(),
                     rqc.getQualifiedQuantity(), rqc.getUnqualifiedQuantity());
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/arrivalnotice/MesWmArrivalNoticeServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/arrivalnotice/MesWmArrivalNoticeServiceImpl.java
index 50479f2..c5ac05f 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/arrivalnotice/MesWmArrivalNoticeServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/arrivalnotice/MesWmArrivalNoticeServiceImpl.java
@@ -48,6 +48,9 @@
 public class MesWmArrivalNoticeServiceImpl implements MesWmArrivalNoticeService {
 
     @Resource
+    private cn.iocoder.yudao.module.mes.service.qc.ncr.MesQcArrivalDispositionService arrivalDispositionService;
+
+    @Resource
     private MesWmArrivalNoticeMapper arrivalNoticeMapper;
 
     @Resource
@@ -201,27 +204,8 @@
         // 2. 鏇存柊鍒拌揣閫氱煡鍗曡锛氱粦瀹� iqcId + 璐ㄦ缁撴灉 + 鍚堟牸鏁伴噺
         arrivalNoticeLineService.updateArrivalNoticeLineWhenIqcFinish(lineId, iqcId, checkResult, qualifiedQuantity);
 
-        // 3.1 鍒ゆ柇鏄惁鎵�鏈夐渶妫�琛岄兘宸插畬鎴愯川妫�
-        List<MesWmArrivalNoticeLineDO> lines = arrivalNoticeLineService.getArrivalNoticeLineListByNoticeId(id);
-        boolean hasUnchecked = CollectionUtils.anyMatch(lines,
-                line -> Boolean.TRUE.equals(line.getIqcCheckFlag()) && line.getIqcCheckResult() == null);
-        if (hasUnchecked) {
-            log.info("[updateArrivalNoticeWhenIqcFinish][鍒拌揣閫氱煡鍗�({}) 杩樻湁鏈畬鎴愭楠岀殑琛岋紝鏆備笉鏇存柊鐘舵�乚", id);
-            return;
-        }
-
-        // 3.2 鍒ゆ柇鏄惁鎵�鏈夐渶妫�琛岄兘鍙互鍏ュ簱锛堝悎鏍兼垨鐗归噰锛�
-        boolean hasNonInbound = CollectionUtils.anyMatch(lines,
-                line -> Boolean.TRUE.equals(line.getIqcCheckFlag())
-                        && !MesQcCheckResultEnum.canInbound(line.getIqcCheckResult()));
-        if (hasNonInbound) {
-            log.info("[updateArrivalNoticeWhenIqcFinish][鍒拌揣閫氱煡鍗�({}) 瀛樺湪涓嶅彲鍏ュ簱鐨勮锛堥��璐�/鎶ュ簾锛夛紝鐘舵�佷繚鎸佸緟璐ㄦ]", id);
-            return;
-        }
-
-        // 3.3 鎵�鏈夎妫�楠屽畬鎴愪笖鍙叆搴擄紝鏇存柊涓昏〃鐘舵�� PENDING_QC 鈫� PENDING_RECEIPT
-        arrivalNoticeMapper.updateById(new MesWmArrivalNoticeDO()
-                .setId(id).setStatus(MesWmArrivalNoticeStatusEnum.PENDING_RECEIPT.getStatus()));
+        // 鍚屾椂璁ゅ彲浠撳簱宸茬‘璁ょ殑鏉ユ枡閫�璐э紱淇濈暀鍘熷涓嶅悎鏍肩粨璁恒��
+        arrivalDispositionService.refresh(id);
     }
 
     @Override
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/itemreceipt/MesWmItemReceiptLineServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/itemreceipt/MesWmItemReceiptLineServiceImpl.java
index 6450597..91b03fc 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/itemreceipt/MesWmItemReceiptLineServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/itemreceipt/MesWmItemReceiptLineServiceImpl.java
@@ -182,7 +182,8 @@
         MesWmBatchGenerateReqVO batchReqVO = new MesWmBatchGenerateReqVO();
         // 浠庡叆搴撳崟琛岃幏鍙�
         batchReqVO.setItemId(reqVO.getItemId()).setProduceDate(reqVO.getProductionDate())
-                .setExpireDate(reqVO.getExpireDate()).setLotNumber(reqVO.getLotNumber());
+                .setExpireDate(reqVO.getExpireDate()).setLotNumber(reqVO.getLotNumber())
+                .setBatchCode(reqVO.getBatchCode());
         // 浠庣埗鍗曟嵁鑾峰彇
         batchReqVO.setVendorId(receipt.getVendorId()).setReceiptDate(receipt.getReceiptDate())
                 .setPurchaseOrderCode(receipt.getPurchaseOrderCode());
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/itemreceipt/MesWmItemReceiptServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/itemreceipt/MesWmItemReceiptServiceImpl.java
index db3c34c..b2b7b01 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/itemreceipt/MesWmItemReceiptServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/itemreceipt/MesWmItemReceiptServiceImpl.java
@@ -433,13 +433,19 @@
 
         // 6. 閬嶅巻琛屽垱寤哄叆搴撳崟琛�
         for (MesWmArrivalNoticeLineDO noticeLine : lines) {
+            BigDecimal receivable = noticeLine.getQualifiedQuantity() != null
+                    ? noticeLine.getQualifiedQuantity() : noticeLine.getArrivalQuantity();
+            // 鏁磋宸查��渚涘簲鍟嗘椂涓嶇敓鎴愰浂鏁伴噺鍏ュ簱琛岋紱鍏朵綑琛屼粛姝e父鏀惰揣銆�
+            if (receivable == null || receivable.signum() <= 0) {
+                continue;
+            }
             MesWmItemReceiptLineDO receiptLine = new MesWmItemReceiptLineDO();
             receiptLine.setReceiptId(receipt.getId());
             receiptLine.setArrivalNoticeLineId(noticeLine.getId());
             receiptLine.setPurchaseOrderItemId(noticeLine.getPurchaseOrderItemId());
             receiptLine.setItemId(noticeLine.getItemId());
             // 浣跨敤鍚堟牸鏁伴噺锛堝鏋滄湁 IQC 鍒欐槸鍚堟牸鏁伴噺锛屽惁鍒欐槸鍒拌揣鏁伴噺锛�
-            receiptLine.setReceivedQuantity(noticeLine.getQualifiedQuantity() != null ? noticeLine.getQualifiedQuantity() : noticeLine.getArrivalQuantity());
+            receiptLine.setReceivedQuantity(receivable);
             // 鎸夐噰璐鍗曡鍗曚环蹇収閲戦锛屼緵鏉ョエ/瀵硅处浣跨敤
             fillReceiptLinePrice(receiptLine);
             itemReceiptLineService.createItemReceiptLineFromArrivalNoticeLine(receiptLine);
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/miscissue/MesWmMiscIssueServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/miscissue/MesWmMiscIssueServiceImpl.java
index 8861bc8..8f07b54 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/miscissue/MesWmMiscIssueServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/miscissue/MesWmMiscIssueServiceImpl.java
@@ -134,6 +134,7 @@
                 .setQuantity(line.getQuantity().negate()) // 鍑哄簱鏁伴噺涓鸿礋鏁�
                 .setBatchId(line.getBatchId()).setBatchCode(line.getBatchCode())
                 .setWarehouseId(line.getWarehouseId()).setLocationId(line.getLocationId()).setAreaId(line.getAreaId())
+                .setMaterialStockId(line.getMaterialStockId()) // 鎸囧畾搴撳瓨璁板綍ID锛岄伩鍏嶉噸鏂板尮閰嶆墸閿欏簱瀛�
                 .setBizType(MesBizTypeConstants.WM_MISC_ISSUE).setBizId(issue.getId()).setBizCode(issue.getCode()).setBizLineId(line.getId())));
     }
 
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmOqcConcessionGuard.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmOqcConcessionGuard.java
new file mode 100644
index 0000000..06e6fbd
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmOqcConcessionGuard.java
@@ -0,0 +1,69 @@
+package cn.iocoder.yudao.module.mes.service.wm.productsales;
+
+import cn.hutool.core.util.StrUtil;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.oqc.MesQcOqcDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.materialstock.MesWmMaterialStockDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesLineDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr.MesQcNcrMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.oqc.MesQcOqcMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.materialstock.MesWmMaterialStockMapper;
+import cn.iocoder.yudao.module.mes.enums.qc.MesNcrDispositionEnum;
+import cn.iocoder.yudao.module.mes.enums.qc.MesNcrStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmProductSalesStatusEnum;
+import jakarta.annotation.Resource;
+import org.springframework.stereotype.Component;
+import java.math.BigDecimal;
+import java.util.Objects;
+
+/** 宸茶姝ョ殑鍑鸿揣琛屽彧鑳戒粠鍘熸楠屾壒娆℃嫞璐у嚭搴撱�� */
+@Component
+public class MesWmOqcConcessionGuard {
+    @Resource private MesQcNcrMapper ncrMapper;
+    @Resource private MesQcOqcMapper oqcMapper;
+    @Resource private MesWmMaterialStockMapper stockMapper;
+
+    private MesQcOqcDO releasedQc(MesWmProductSalesLineDO line) {
+        if (line == null || line.getOqcId() == null) return null;
+        Long count = ncrMapper.selectCount(new LambdaQueryWrapperX<MesQcNcrDO>()
+                .eq(MesQcNcrDO::getQcType, MesQcTypeEnum.OQC.getType())
+                .eq(MesQcNcrDO::getQcId, line.getOqcId())
+                .eq(MesQcNcrDO::getDisposition, MesNcrDispositionEnum.CONCESSION.getType())
+                .in(MesQcNcrDO::getStatus, MesNcrStatusEnum.DISPOSED.getStatus(), MesNcrStatusEnum.CLOSED.getStatus()));
+        if (count == 0) return null;
+        MesQcOqcDO qc = oqcMapper.selectById(line.getOqcId());
+        if (qc == null || !Objects.equals(qc.getSourceLineId(), line.getId())
+                || !Objects.equals(qc.getItemId(), line.getItemId()) || StrUtil.isBlank(qc.getBatchCode())) {
+            throw new ServiceException(400, "璁╂鍑鸿揣鐨勫師妫�楠屻�佺墿鏂欐垨鎵规鏃犳硶鏍搁獙");
+        }
+        return qc;
+    }
+
+    public void validate(MesWmProductSalesLineDO line, Long stockId, String batchCode, BigDecimal quantity) {
+        MesQcOqcDO qc = releasedQc(line);
+        if (qc == null) return;
+        MesWmMaterialStockDO stock = stockId == null ? null : stockMapper.selectById(stockId);
+        if (quantity == null || quantity.signum() <= 0 || stock == null || !Objects.equals(stock.getItemId(), qc.getItemId())
+                || (line.getMaterialStockId() != null && !Objects.equals(line.getMaterialStockId(), stockId))
+                || !Objects.equals(stock.getBatchCode(), qc.getBatchCode())
+                || !Objects.equals(batchCode, qc.getBatchCode())) {
+            throw new ServiceException(400, "璁╂鍑鸿揣蹇呴』浣跨敤鍘熷嚭璐ф楠屽搴旂殑鐗╂枡鍜屾壒娆″簱瀛�");
+        }
+    }
+
+    public void validateQuantity(MesWmProductSalesLineDO line, BigDecimal picked) {
+        if (releasedQc(line) == null) return;
+        if (picked == null || line.getQuantity() == null || picked.compareTo(line.getQuantity()) != 0) {
+            throw new ServiceException(400, "璁╂鍑鸿揣鐨勬嫞璐ф暟閲忓繀椤荤瓑浜庡師妫�楠岃鏁伴噺");
+        }
+    }
+
+    public void validateEditable(MesWmProductSalesLineDO line, Integer salesStatus) {
+        if (releasedQc(line) != null && !Objects.equals(salesStatus, MesWmProductSalesStatusEnum.APPROVING.getStatus())) {
+            throw new ServiceException(400, "璁╂鍑鸿揣鏄庣粏浠呭彲鍦ㄥ緟鎷h揣鏃朵慨鏀癸紝搴撳瓨鍗犵敤鍚庝笉鍙彉鏇�");
+        }
+    }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesDetailServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesDetailServiceImpl.java
index d95f758..b5b34b0 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesDetailServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesDetailServiceImpl.java
@@ -6,12 +6,17 @@
 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesDetailDO;
 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesLineDO;
 import cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales.MesWmProductSalesDetailMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales.MesWmProductSalesMapper;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesDO;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
 import cn.iocoder.yudao.module.mes.service.mdm.MesMdmItemService;
 import cn.iocoder.yudao.module.mes.service.wm.materialstock.MesWmMaterialStockService;
 import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseAreaService;
 import jakarta.annotation.Resource;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
 
 import java.util.List;
@@ -42,9 +47,15 @@
     private MesWmWarehouseAreaService warehouseAreaService;
     @Resource
     private MesWmSalesReelGuard salesReelGuard;
+    @Resource
+    private MesWmOqcConcessionGuard oqcConcessionGuard;
+    @Resource
+    private MesWmProductSalesMapper salesMapper;
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Long createProductSalesDetail(MesWmProductSalesDetailSaveReqVO createReqVO) {
+        validateEditable(createReqVO.getSalesId(), createReqVO.getLineId());
         // 鏍¢獙鏁版嵁
         validateProductSalesDetailSaveData(createReqVO);
 
@@ -55,9 +66,14 @@
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void updateProductSalesDetail(MesWmProductSalesDetailSaveReqVO updateReqVO) {
         // 鏍¢獙瀛樺湪
-        validateProductSalesDetailExists(updateReqVO.getId());
+        MesWmProductSalesDetailDO existing = validateProductSalesDetailExists(updateReqVO.getId());
+        if (!ObjUtil.equal(existing.getSalesId(), updateReqVO.getSalesId()) || !ObjUtil.equal(existing.getLineId(), updateReqVO.getLineId())) {
+            throw new ServiceException(400, "涓嶅厑璁告洿鏀瑰嚭搴撴槑缁嗘墍灞炲崟鎹垨琛�");
+        }
+        validateEditable(existing.getSalesId(), existing.getLineId());
         // 鏍¢獙鏁版嵁
         validateProductSalesDetailSaveData(updateReqVO);
 
@@ -67,11 +83,23 @@
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void deleteProductSalesDetail(Long id) {
         // 鏍¢獙瀛樺湪
-        validateProductSalesDetailExists(id);
+        MesWmProductSalesDetailDO detail = validateProductSalesDetailExists(id);
+        validateEditable(detail.getSalesId(), detail.getLineId());
         // 鍒犻櫎
         productSalesDetailMapper.deleteById(id);
+    }
+
+    private void validateEditable(Long salesId, Long lineId) {
+        MesWmProductSalesDO sales = salesMapper.selectOne(new LambdaQueryWrapperX<MesWmProductSalesDO>()
+                .eq(MesWmProductSalesDO::getId, salesId).last("FOR UPDATE"));
+        MesWmProductSalesLineDO line = productSalesLineService.getProductSalesLine(lineId);
+        if (sales == null || line == null || !ObjUtil.equal(line.getSalesId(), salesId)) {
+            throw new ServiceException(400, "鍑哄簱鍗曟垨鍑哄簱琛屼笉瀛樺湪");
+        }
+        oqcConcessionGuard.validateEditable(line, sales.getStatus());
     }
 
     @Override
@@ -129,6 +157,7 @@
                 reqVO.getMaterialStockId(), reqVO.getItemId(), reqVO.getBatchId(), reqVO.getBatchCode(),
                 reqVO.getWarehouseId(), reqVO.getLocationId(), reqVO.getAreaId(), reqVO.getQuantity());
         salesReelGuard.validate(line, reqVO.getBatchId());
+        oqcConcessionGuard.validate(line, reqVO.getMaterialStockId(), reqVO.getBatchCode(), reqVO.getQuantity());
     }
 
 }
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesServiceImpl.java
index 0f1c14e..69d2d69 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesServiceImpl.java
@@ -2,6 +2,8 @@
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
@@ -9,11 +11,13 @@
 import cn.iocoder.yudao.module.mes.controller.admin.wm.productsales.vo.MesWmProductSalesPageReqVO;
 import cn.iocoder.yudao.module.mes.controller.admin.wm.productsales.vo.MesWmProductSalesSaveReqVO;
 import cn.iocoder.yudao.module.mes.controller.admin.wm.productsales.vo.MesWmProductSalesShippingReqVO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO;
 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeDO;
 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesDO;
 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesDetailDO;
 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesLineDO;
 import cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales.MesWmProductSalesMapper;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 import cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales.MesWmProductSalesLineMapper;
 import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants;
 import cn.iocoder.yudao.module.mes.enums.wm.MesWmProductSalesStatusEnum;
@@ -22,6 +26,7 @@
 import cn.iocoder.yudao.module.mes.enums.wm.MesWmStockReserveBizTypeEnum;
 import cn.iocoder.yudao.module.mes.enums.wm.MesWmTransactionTypeEnum;
 import cn.iocoder.yudao.module.crm.api.customer.CrmCustomerApi;
+import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService;
 import cn.iocoder.yudao.module.mes.service.wm.materialstock.MesWmMaterialStockService;
 import cn.iocoder.yudao.module.mes.service.wm.salesnotice.MesWmSalesNoticeService;
 import cn.iocoder.yudao.module.mes.service.wm.stockreserve.MesWmStockReserveService;
@@ -39,6 +44,7 @@
 
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Objects;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
@@ -64,6 +70,8 @@
     @Resource
     private MesWmProductSalesDetailService productSalesDetailService;
     @Resource
+    private MesWmOqcConcessionGuard oqcConcessionGuard;
+    @Resource
     private CrmCustomerApi customerApi;
     @Resource
     private MesWmSalesNoticeService salesNoticeService;
@@ -81,6 +89,8 @@
     private ErpSaleOrderApi saleOrderApi;
     @Resource
     private MesWmSalesReelGuard salesReelGuard;
+    @Resource
+    private MesMdItemService mdItemService;
 
     @Override
     public Long createProductSales(MesWmProductSalesSaveReqVO createReqVO) {
@@ -191,7 +201,10 @@
     @Transactional(rollbackFor = Exception.class)
     public void stockProductSales(Long id) {
         // 鏍¢獙瀛樺湪
-        MesWmProductSalesDO sales = validateProductSalesExists(id);
+        validateProductSalesExists(id);
+        MesWmProductSalesDO sales = productSalesMapper.selectOne(new LambdaQueryWrapperX<MesWmProductSalesDO>()
+                .eq(MesWmProductSalesDO::getId, id).last("FOR UPDATE"));
+        if (sales == null) throw exception(WM_PRODUCT_SALES_NOT_EXISTS);
         if (ObjUtil.notEqual(MesWmProductSalesStatusEnum.APPROVING.getStatus(), sales.getStatus())) {
             throw exception(WM_PRODUCT_SALES_CANNOT_PICK);
         }
@@ -202,9 +215,12 @@
             if (CollUtil.isEmpty(details)) {
                 throw exception(WM_PRODUCT_SALES_DETAILS_EMPTY);
             }
+            oqcConcessionGuard.validateQuantity(line, CollectionUtils.getSumValue(details,
+                    MesWmProductSalesDetailDO::getQuantity, BigDecimal::add, BigDecimal.ZERO));
             // 鏍¢獙搴撳瓨鍏呰冻骞跺垱寤哄崰鐢�
             for (MesWmProductSalesDetailDO detail : details) {
                 salesReelGuard.validate(line, detail.getBatchId());
+                oqcConcessionGuard.validate(line, detail.getMaterialStockId(), detail.getBatchCode(), detail.getQuantity());
                 materialStockService.validateSelectedStock(
                         detail.getMaterialStockId(),
                         detail.getItemId(),
@@ -334,12 +350,19 @@
 
     private void createTransactionList(MesWmProductSalesDO sales) {
         List<MesWmProductSalesDetailDO> details = productSalesDetailService.getProductSalesDetailListBySalesId(sales.getId());
+        for (MesWmProductSalesLineDO line : productSalesLineService.getProductSalesLineListBySalesId(sales.getId())) {
+            BigDecimal quantity = details.stream().filter(detail -> ObjUtil.equal(detail.getLineId(), line.getId()))
+                    .map(MesWmProductSalesDetailDO::getQuantity).filter(Objects::nonNull)
+                    .reduce(BigDecimal.ZERO, BigDecimal::add);
+            oqcConcessionGuard.validateQuantity(line, quantity);
+        }
         for (MesWmProductSalesDetailDO detail : details) {
             MesWmProductSalesLineDO line = productSalesLineService.getProductSalesLine(detail.getLineId());
             if (line == null || !ObjUtil.equal(line.getSalesId(), sales.getId())) {
                 throw exception(WM_PRODUCT_SALES_DETAIL_LINE_NOT_MATCH);
             }
             salesReelGuard.validate(line, detail.getBatchId());
+            oqcConcessionGuard.validate(line, detail.getMaterialStockId(), detail.getBatchCode(), detail.getQuantity());
         }
         wmTransactionService.createTransactionList(convertList(details, detail -> new MesWmTransactionSaveReqDTO()
                 .setType(MesWmTransactionTypeEnum.OUT.getType()).setItemId(detail.getItemId())
@@ -376,11 +399,36 @@
         if (ObjUtil.notEqual(MesWmProductSalesStatusEnum.CONFIRMED.getStatus(), sales.getStatus())) {
             throw exception(WM_PRODUCT_SALES_CANNOT_CONFIRM);
         }
+        // 鍑鸿揣妫�楠屼笉鍚堟牸鐨勫嚭搴撹蹇呴』鍏堝畬鎴愪笉鍚堟牸鍝佸缃紝绂佹鎵嬪伐纭缁曡繃杩斿伐/璁╂闂幆
+        List<MesWmProductSalesLineDO> lines = productSalesLineMapper.selectListBySalesId(id);
+        if (CollUtil.isNotEmpty(lines)) {
+            int rowNo = 0;
+            for (MesWmProductSalesLineDO line : lines) {
+                rowNo++;
+                if (Objects.equals(line.getQualityStatus(), MesWmQualityStatusEnum.FAIL.getStatus())
+                        || line.getNcrDispositionId() != null) {
+                    throw new ServiceException(400, String.format(
+                            "閿�鍞嚭搴撳崟[%s]绗琜%d]琛岀墿鏂橻%s]鍑鸿揣妫�楠屼笉鍚堟牸锛屽皻鏈畬鎴愪笉鍚堟牸鍝佸缃紱"
+                                    + "璇峰厛鍦ㄤ笉鍚堟牸鍝佸鐞嗗崟涓畬鎴愯繑宸�/杩斾慨/閲嶆柊鐢熶骇鎴栬姝ユ斁琛屽悗鍐嶇‘璁ゅ嚭搴�",
+                            sales.getCode(), rowNo, itemLabel(line.getItemId())));
+                }
+            }
+        }
         // OQC 妫�楠屽畬鎴愶紝娴佽浆鍒板緟鎷h揣
         productSalesMapper.updateById(new MesWmProductSalesDO()
                 .setId(id).setStatus(MesWmProductSalesStatusEnum.APPROVING.getStatus()));
     }
 
+    private String itemLabel(Long itemId) {
+        MesMdItemDO item = itemId == null ? null : mdItemService.getItem(itemId);
+        if (item == null) {
+            return "ID=" + itemId;
+        }
+        String label = (StrUtil.blankToDefault(item.getCode(), "") + " "
+                + StrUtil.blankToDefault(item.getName(), "")).trim();
+        return label.isEmpty() ? "ID=" + itemId : label;
+    }
+
     @Override
     public List<MesWmProductSalesDO> getProductSalesListByClientId(Long clientId) {
         return productSalesMapper.selectListByClientId(clientId);
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesLineService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesLineService.java
index 12e0520..149d6cb 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesLineService.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesLineService.java
@@ -85,6 +85,9 @@
      */
     void updateQualityStatusByReturnId(Long returnId, Integer qualityStatus);
 
+    /** 閿佸畾骞剁粦瀹氭潵婧愭楠岋紝纭繚鏁磋鏁伴噺涓庢楠岀粨鏋滃搴斻�� */
+    void bindRqcForFinish(Long lineId, Long returnId, Long rqcId, Long itemId, BigDecimal checkQuantity);
+
     /**
      * RQC 妫�楠屽畬鎴愬悗锛屾牴鎹悎鏍煎搧/涓嶅悎鏍煎搧鏁伴噺鏇存柊閿�鍞��璐у崟琛�
      *
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesLineServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesLineServiceImpl.java
index 3841671..e8663fc 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesLineServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesLineServiceImpl.java
@@ -7,6 +7,8 @@
 import cn.iocoder.yudao.module.aftersales.api.AfterSaleTicketApi;
 import cn.iocoder.yudao.module.aftersales.api.dto.AfterSaleWarehouseReturnStageReqDTO;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.line.MesWmReturnSalesLinePageReqVO;
 import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.line.MesWmReturnSalesLineSaveReqVO;
@@ -208,6 +210,21 @@
     }
 
     @Override
+    public void bindRqcForFinish(Long lineId, Long returnId, Long rqcId, Long itemId, BigDecimal checkQuantity) {
+        MesWmReturnSalesLineDO line = returnSalesLineMapper.selectOne(new LambdaQueryWrapperX<MesWmReturnSalesLineDO>()
+                .eq(MesWmReturnSalesLineDO::getId, lineId).last("FOR UPDATE"));
+        if (line == null || !Objects.equals(line.getReturnId(), returnId)
+                || !Objects.equals(line.getItemId(), itemId)
+                || !Objects.equals(line.getQualityStatus(), MesWmQualityStatusEnum.PENDING.getStatus())
+                || (line.getRqcId() != null && !Objects.equals(line.getRqcId(), rqcId))
+                || line.getQuantity() == null || checkQuantity == null
+                || line.getQuantity().compareTo(checkQuantity) != 0) {
+            throw new ServiceException(400, "閫�璐ф楠岄』瀵瑰簲鍞竴寰呮閫�璐ц锛岀墿鏂欏拰妫�楠屾暟閲忓繀椤讳笌閫�璐ц涓�鑷�");
+        }
+        returnSalesLineMapper.updateById(new MesWmReturnSalesLineDO().setId(lineId).setRqcId(rqcId));
+    }
+
+    @Override
     public void updateReturnSalesLineWhenRqcFinish(Long sourceLineId, Long sourceDocId, Integer checkResult,
                                                     BigDecimal qualifiedQuantity, BigDecimal unqualifiedQuantity) {
         MesWmReturnSalesLineDO sourceLine = validateReturnSalesLineExists(sourceLineId);
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesServiceImpl.java
index 41bd4b3..af8ffcd 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesServiceImpl.java
@@ -34,6 +34,7 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
@@ -166,7 +167,8 @@
     @Transactional(rollbackFor = Exception.class)
     public void stockReturnSales(Long id) {
         // 1.1 鏍¢獙瀛樺湪 + 寰呬笂鏋剁姸鎬�
-        MesWmReturnSalesDO returnSales = validateReturnSalesExists(id);
+        MesWmReturnSalesDO returnSales = returnSalesMapper.selectByIdForUpdate(id);
+        if (returnSales == null) throw exception(WM_RETURN_SALES_NOT_EXISTS);
         if (ObjUtil.notEqual(MesWmReturnSalesStatusEnum.APPROVED.getStatus(), returnSales.getStatus())) {
             throw exception(WM_RETURN_SALES_STATUS_NOT_APPROVED);
         }
@@ -182,6 +184,12 @@
                     allDetails, MesWmReturnSalesDetailDO::getLineId);
             // 妫�鏌ユ瘡琛岀殑鏄庣粏鏁伴噺
             for (MesWmReturnSalesLineDO line : lines) {
+                if (line.getNcrDispositionId() != null && Objects.equals(line.getQualityStatus(), MesWmQualityStatusEnum.FAIL.getStatus())) {
+                    if (!detailMap.getOrDefault(line.getId(), Collections.emptyList()).isEmpty()) {
+                        throw exception(WM_RETURN_SALES_LINE_NOT_QUALIFIED);
+                    }
+                    continue; // 涓嶅悎鏍兼暟閲忕敱 NCR 鐙珛澶勭悊锛屼笉鍦ㄥ師閫�璐у崟鍐嶆鍏ュ簱
+                }
                 if (ObjUtil.notEqual(line.getQualityStatus(), MesWmQualityStatusEnum.PASS.getStatus())) {
                     throw exception(WM_RETURN_SALES_LINE_NOT_QUALIFIED);
                 }
@@ -226,7 +234,8 @@
     @Transactional(rollbackFor = Exception.class)
     public void cancelReturnSales(Long id) {
         // 鏍¢獙瀛樺湪
-        MesWmReturnSalesDO returnSales = validateReturnSalesExists(id);
+        MesWmReturnSalesDO returnSales = returnSalesMapper.selectByIdForUpdate(id);
+        if (returnSales == null) throw exception(WM_RETURN_SALES_NOT_EXISTS);
         // 宸插畬鎴愬拰宸插彇娑堜笉鍏佽鍙栨秷
         if (ObjectUtils.equalsAny(returnSales.getStatus(),
                 MesWmReturnSalesStatusEnum.FINISHED.getStatus(),
@@ -243,6 +252,9 @@
     public Boolean checkReturnSalesQuantity(Long id) {
         List<MesWmReturnSalesLineDO> lines = returnSalesLineService.getReturnSalesLineListByReturnId(id);
         for (MesWmReturnSalesLineDO line : lines) {
+            if (line.getNcrDispositionId() != null && Objects.equals(line.getQualityStatus(), MesWmQualityStatusEnum.FAIL.getStatus())) {
+                continue;
+            }
             List<MesWmReturnSalesDetailDO> details = returnSalesDetailService.getReturnSalesDetailListByLineId(line.getId());
             BigDecimal totalDetailQty = CollectionUtils.getSumValue(details,
                     MesWmReturnSalesDetailDO::getQuantity, BigDecimal::add, BigDecimal.ZERO);
diff --git a/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcArrivalDispositionServiceTest.java b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcArrivalDispositionServiceTest.java
new file mode 100644
index 0000000..43077d9
--- /dev/null
+++ b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcArrivalDispositionServiceTest.java
@@ -0,0 +1,48 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcPurchaseReturnDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.arrivalnotice.MesWmArrivalNoticeDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.arrivalnotice.MesWmArrivalNoticeLineDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr.MesQcPurchaseReturnMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr.MesQcPurchaseConcessionMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.arrivalnotice.MesWmArrivalNoticeLineMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.arrivalnotice.MesWmArrivalNoticeMapper;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmArrivalNoticeStatusEnum;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+import org.springframework.test.util.ReflectionTestUtils;
+import java.math.BigDecimal;
+import java.util.List;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
+
+class MesQcArrivalDispositionServiceTest {
+    @Test void partialReturnEnablesOnlyQualifiedQuantityAndFullReturnFinishes() {
+        var service = new MesQcArrivalDispositionService();
+        var notices = mock(MesWmArrivalNoticeMapper.class);
+        var lines = mock(MesWmArrivalNoticeLineMapper.class);
+        var returns = mock(MesQcPurchaseReturnMapper.class);
+        ReflectionTestUtils.setField(service, "arrivalNoticeMapper", notices);
+        ReflectionTestUtils.setField(service, "lineMapper", lines);
+        ReflectionTestUtils.setField(service, "returnMapper", returns);
+        ReflectionTestUtils.setField(service, "concessionMapper", mock(MesQcPurchaseConcessionMapper.class));
+        when(notices.selectOne(any(Wrapper.class))).thenReturn(new MesWmArrivalNoticeDO().setId(1L)
+                .setStatus(MesWmArrivalNoticeStatusEnum.PENDING_QC.getStatus()));
+        var line = new MesWmArrivalNoticeLineDO().setId(2L).setIqcId(3L).setIqcCheckFlag(true)
+                .setIqcCheckResult(2).setArrivalQuantity(BigDecimal.TEN).setQualifiedQuantity(BigDecimal.valueOf(7));
+        when(lines.selectListByNoticeId(1L)).thenReturn(List.of(line));
+        service.refresh(1L);
+        verify(notices, never()).updateById(any(MesWmArrivalNoticeDO.class));
+        when(returns.selectConfirmedByIqcId(3L)).thenReturn(new MesQcPurchaseReturnDO().setNoticeLineId(2L));
+        service.refresh(1L);
+        var changed = ArgumentCaptor.forClass(MesWmArrivalNoticeDO.class);
+        verify(notices).updateById(changed.capture());
+        assertEquals(MesWmArrivalNoticeStatusEnum.PENDING_RECEIPT.getStatus(), changed.getValue().getStatus());
+        line.setQualifiedQuantity(BigDecimal.ZERO);
+        service.refresh(1L);
+        verify(notices, times(2)).updateById(changed.capture());
+        assertEquals(MesWmArrivalNoticeStatusEnum.FINISHED.getStatus(), changed.getValue().getStatus());
+    }
+}
diff --git a/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrGuardTest.java b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrGuardTest.java
new file mode 100644
index 0000000..e1394ae
--- /dev/null
+++ b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrGuardTest.java
@@ -0,0 +1,79 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.module.mdm.api.item.MdmItemApi;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.ncr.vo.MesQcNcrDisposeReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.ncr.vo.MesQcNcrSaveReqVO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr.MesQcNcrMapper;
+import cn.iocoder.yudao.module.mes.enums.qc.MesNcrStatusEnum;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.math.BigDecimal;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.*;
+
+@ExtendWith(MockitoExtension.class)
+class MesQcNcrGuardTest {
+    @Mock private MesQcNcrMapper mapper;
+    @Mock private MdmItemApi mdmItemApi;
+    @InjectMocks private MesQcNcrServiceImpl service;
+
+    private MesQcNcrDO sourceNcr() {
+        return new MesQcNcrDO().setId(1L).setCode("NCR-1").setQcId(2L)
+                .setItemId(3L).setUnqualifiedQuantity(new BigDecimal("10"))
+                .setStatus(MesNcrStatusEnum.PENDING_REVIEW.getStatus());
+    }
+
+    private MesQcNcrSaveReqVO request(Long itemId, String quantity) {
+        var req = new MesQcNcrSaveReqVO();
+        req.setId(1L);
+        req.setCode("NCR-1");
+        req.setItemId(itemId);
+        req.setUnqualifiedQuantity(new BigDecimal(quantity));
+        return req;
+    }
+
+    @Test
+    void rejectsChangingMaterialOrQuantityOfSourceInspection() {
+        when(mapper.selectByIdForUpdate(1L)).thenReturn(sourceNcr());
+        assertThrows(ServiceException.class, () -> service.updateNcr(request(4L, "10")));
+        assertThrows(ServiceException.class, () -> service.updateNcr(request(3L, "11")));
+        verify(mapper, times(2)).selectByIdForUpdate(1L);
+        verify(mapper, never()).updateById(any(MesQcNcrDO.class));
+    }
+
+    @Test
+    void rejectsDeletingSourceInspectionNcr() {
+        when(mapper.selectByIdForUpdate(1L)).thenReturn(sourceNcr());
+        assertThrows(ServiceException.class, () -> service.deleteNcr(1L));
+        verify(mapper, never()).deleteById(any(Long.class));
+    }
+
+    @Test
+    void acceptsEquivalentQuantityWithDifferentDecimalScale() {
+        when(mapper.selectByIdForUpdate(1L)).thenReturn(sourceNcr());
+        when(mdmItemApi.getItem(3L)).thenReturn(CommonResult.success(null));
+        service.updateNcr(request(3L, "10.00"));
+        verify(mapper).updateById(any(MesQcNcrDO.class));
+    }
+
+    @Test
+    void repeatedDispositionChecksLockedCurrentStatusBeforeCreatingDocuments() {
+        var disposed = sourceNcr().setStatus(MesNcrStatusEnum.DISPOSED.getStatus());
+        when(mapper.selectByIdForUpdate(1L)).thenReturn(disposed);
+        var req = new MesQcNcrDisposeReqVO();
+        req.setId(1L);
+        req.setDisposition(2);
+        assertThrows(ServiceException.class, () -> service.disposeNcr(req));
+        verify(mapper).selectByIdForUpdate(1L);
+        verify(mapper, never()).updateById(any(MesQcNcrDO.class));
+    }
+}
diff --git a/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcConcessionServiceTest.java b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcConcessionServiceTest.java
new file mode 100644
index 0000000..feeaafd
--- /dev/null
+++ b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcConcessionServiceTest.java
@@ -0,0 +1,83 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.oqc.MesQcOqcDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesLineDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.transaction.MesWmTransactionDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.oqc.MesQcOqcMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales.MesWmProductSalesMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales.MesWmProductSalesLineMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.transaction.MesWmTransactionMapper;
+import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmProductSalesStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmQualityStatusEnum;
+import cn.iocoder.yudao.module.mes.service.wm.productsales.MesWmProductSalesLineService;
+import cn.iocoder.yudao.module.mes.service.wm.productsales.MesWmProductSalesDetailService;
+import cn.iocoder.yudao.module.mes.service.wm.productsales.MesWmProductSalesService;
+import cn.iocoder.yudao.module.mes.service.wm.materialstock.MesWmMaterialStockService;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.materialstock.MesWmMaterialStockDO;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.ncr.vo.MesQcNcrDisposeReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.wm.productsales.vo.detail.MesWmProductSalesDetailSaveReqVO;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import org.junit.jupiter.api.Test;
+import org.springframework.test.util.ReflectionTestUtils;
+import java.math.BigDecimal;
+import java.util.List;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
+
+class MesQcNcrOqcConcessionServiceTest {
+    @Test void releaseAndCloseRequireMatchingOriginalLineAndShipment() {
+        var service = new MesQcNcrOqcConcessionService();
+        var oqcs = mock(MesQcOqcMapper.class);
+        var sales = mock(MesWmProductSalesMapper.class);
+        var lines = mock(MesWmProductSalesLineMapper.class);
+        var flows = mock(MesWmTransactionMapper.class);
+        var lineService = mock(MesWmProductSalesLineService.class);
+        var details = mock(MesWmProductSalesDetailService.class);
+        var salesService = mock(MesWmProductSalesService.class);
+        var stockService = mock(MesWmMaterialStockService.class);
+        ReflectionTestUtils.setField(service, "oqcMapper", oqcs);
+        ReflectionTestUtils.setField(service, "salesMapper", sales);
+        ReflectionTestUtils.setField(service, "lineMapper", lines);
+        ReflectionTestUtils.setField(service, "transactionMapper", flows);
+        ReflectionTestUtils.setField(service, "lineService", lineService);
+        ReflectionTestUtils.setField(service, "detailService", details);
+        ReflectionTestUtils.setField(service, "salesService", salesService);
+        ReflectionTestUtils.setField(service, "stockService", stockService);
+        var ncr = new MesQcNcrDO().setQcId(1L).setItemId(2L).setUnqualifiedQuantity(BigDecimal.valueOf(3));
+        var qc = new MesQcOqcDO().setId(1L).setSourceDocType(MesBizTypeConstants.WM_PRODUCT_SALES)
+                .setSourceDocId(4L).setSourceLineId(5L).setItemId(2L).setBatchCode("B1")
+                .setStatus(MesQcStatusEnum.FINISHED.getStatus()).setCheckResult(2)
+                .setCheckQuantity(BigDecimal.TEN).setQualifiedQuantity(BigDecimal.valueOf(7)).setUnqualifiedQuantity(BigDecimal.valueOf(3));
+        var sale = new MesWmProductSalesDO().setId(4L).setStatus(MesWmProductSalesStatusEnum.CONFIRMED.getStatus());
+        var line = new MesWmProductSalesLineDO().setId(5L).setSalesId(4L).setItemId(2L).setOqcId(1L)
+                .setQualityStatus(MesWmQualityStatusEnum.FAIL.getStatus()).setQuantity(BigDecimal.TEN);
+        when(oqcs.selectById(1L)).thenReturn(qc);
+        when(sales.selectOne(any(Wrapper.class))).thenReturn(sale);
+        when(lines.selectOne(any(Wrapper.class))).thenReturn(line);
+        when(stockService.getMaterialStock(8L)).thenReturn(new MesWmMaterialStockDO().setId(8L).setItemId(2L)
+                .setBatchCode("B1").setWarehouseId(11L).setLocationId(12L).setAreaId(13L));
+        when(details.getProductSalesDetailListByLineId(5L)).thenReturn(List.of());
+        when(lineService.getProductSalesLineListBySalesId(4L)).thenReturn(List.of(line));
+        when(salesService.checkProductSalesQuantity(4L)).thenReturn(true);
+        var req = new MesQcNcrDisposeReqVO(); req.setMaterialStockId(8L);
+        service.release(ncr, req);
+        verify(lineService).updateProductSalesLineWhenOqcFinish(5L, 1L, 1);
+        verify(details).createProductSalesDetail(any(MesWmProductSalesDetailSaveReqVO.class));
+        verify(salesService).stockProductSales(4L);
+        verify(salesService).finishProductSales(4L);
+        assertThrows(ServiceException.class, () -> service.validateBeforeClose(ncr));
+        sale.setStatus(MesWmProductSalesStatusEnum.FINISHED.getStatus());
+        when(flows.selectList(any(Wrapper.class))).thenReturn(List.of(new MesWmTransactionDO()
+                .setItemId(2L).setBatchCode("B2").setQuantity(BigDecimal.TEN.negate())));
+        assertThrows(ServiceException.class, () -> service.validateBeforeClose(ncr));
+        when(flows.selectList(any(Wrapper.class))).thenReturn(List.of(new MesWmTransactionDO()
+                .setItemId(2L).setBatchCode("B1").setQuantity(BigDecimal.TEN.negate())));
+        assertDoesNotThrow(() -> service.validateBeforeClose(ncr));
+    }
+}
diff --git a/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcReproductionServiceTest.java b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcReproductionServiceTest.java
new file mode 100644
index 0000000..bb585f8
--- /dev/null
+++ b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcReproductionServiceTest.java
@@ -0,0 +1,123 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.module.mes.controller.admin.pro.workorder.vo.process.MesProWorkOrderProcessSaveReqVO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderBomDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderProcessDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.oqc.MesQcOqcDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.batch.MesWmBatchDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesLineDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productproduce.MesWmProductProduceLineDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.md.item.MesMdItemMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.pro.workorder.MesProWorkOrderMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.pro.workorder.MesProWorkOrderBomMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.oqc.MesQcOqcMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.batch.MesWmBatchMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales.MesWmProductSalesLineMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales.MesWmProductSalesMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productproduce.MesWmProductProduceLineMapper;
+import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmQualityStatusEnum;
+import cn.iocoder.yudao.module.mes.service.md.autocode.MesMdAutoCodeRecordService;
+import cn.iocoder.yudao.module.mes.service.pro.workorder.MesProWorkOrderProcessService;
+import cn.iocoder.yudao.module.mes.service.pro.workorder.MesProWorkOrderService;
+import cn.iocoder.yudao.module.mes.service.pro.task.MesProTaskService;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import java.math.BigDecimal;
+import java.util.List;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
+
+@ExtendWith(MockitoExtension.class)
+class MesQcNcrOqcReproductionServiceTest {
+    @InjectMocks MesQcNcrOqcReproductionService service;
+    @Mock MesQcOqcMapper oqcMapper;
+    @Mock MesWmProductSalesLineMapper lineMapper;
+    @Mock MesWmProductSalesMapper salesMapper;
+    @Mock MesWmProductProduceLineMapper produceLineMapper;
+    @Mock MesQcNcrScrapService sourceService;
+    @Mock MesWmBatchMapper batchMapper;
+    @Mock MesProWorkOrderMapper orderMapper;
+    @Mock MesProWorkOrderBomMapper bomMapper;
+    @Mock MesMdItemMapper itemMapper;
+    @Mock MesProWorkOrderService orderService;
+    @Mock MesProWorkOrderProcessService processService;
+    @Mock MesProTaskService taskService;
+    @Mock MesMdAutoCodeRecordService autoCodeService;
+    private MesQcNcrDO ncr() { return new MesQcNcrDO().setId(1L).setCode("NCR1").setQcType(MesQcTypeEnum.OQC.getType()).setQcId(2L).setItemId(3L).setUnqualifiedQuantity(BigDecimal.ONE); }
+    private MesQcOqcDO qc() { return new MesQcOqcDO().setId(2L).setSourceDocType(MesBizTypeConstants.WM_PRODUCT_SALES)
+            .setSourceDocId(4L).setSourceLineId(5L).setStatus(MesQcStatusEnum.FINISHED.getStatus()).setItemId(3L)
+            .setClientId(8L).setBatchCode("B1").setOutQuantity(BigDecimal.TEN).setUnqualifiedQuantity(BigDecimal.ONE); }
+    private MesWmProductSalesLineDO line() { return new MesWmProductSalesLineDO().setId(5L).setSalesId(4L).setOqcId(2L).setItemId(3L)
+            .setBatchId(6L).setBatchCode("B1").setQuantity(BigDecimal.TEN).setQualityStatus(MesWmQualityStatusEnum.FAIL.getStatus()); }
+
+    @Test void refusesClientMismatchBeforeCreatingOrder() {
+        when(oqcMapper.selectById(2L)).thenReturn(qc());
+        when(lineMapper.selectById(5L)).thenReturn(line());
+        when(salesMapper.selectById(4L)).thenReturn(new MesWmProductSalesDO().setId(4L).setClientId(9L));
+        assertThrows(ServiceException.class, () -> service.reproduce(ncr(), 7));
+        verify(orderService, never()).createWorkOrder(any());
+    }
+
+    @Test void ipqcReproductionRequiresClaimedSourceAndCreatesTasks() {
+        var item = ncr().setQcType(MesQcTypeEnum.IPQC.getType());
+        var source = new MesQcNcrScrapService.IpqcSource(10L, "OLD", 12L, 6L, "B1");
+        when(sourceService.validateIpqcSource(item)).thenReturn(source);
+        var line = new MesWmProductProduceLineDO().setId(12L).setNcrDispositionId(99L);
+        when(produceLineMapper.selectById(12L)).thenReturn(line);
+        assertThrows(ServiceException.class, () -> service.reproduceIpqc(item, 7, source));
+        verify(orderService, never()).createWorkOrder(any());
+        line.setNcrDispositionId(1L);
+        when(orderMapper.selectById(10L)).thenReturn(new MesProWorkOrderDO().setId(10L).setCode("OLD")
+                .setProductId(11L).setRouteId(40L));
+        when(itemMapper.selectById(11L)).thenReturn(new MesMdItemDO().setId(11L).setMdmItemId(3L));
+        when(processService.getWorkOrderProcessListByWorkOrderId(10L)).thenReturn(List.of(
+                new MesProWorkOrderProcessDO().setProcessId(21L).setSort(1)));
+        when(bomMapper.selectListByWorkOrderId(10L)).thenReturn(List.of());
+        when(autoCodeService.generateAutoCode(anyString())).thenReturn("NEW");
+        when(orderService.createWorkOrder(any())).thenReturn(30L);
+        when(taskService.autoGenerateTasks(any())).thenReturn(List.of(50L));
+        assertEquals(30L, service.reproduceIpqc(item, 7, source).getDocId());
+        verify(taskService).autoGenerateTasks(argThat(r -> r.getWorkOrderId().equals(30L)));
+    }
+
+    @Test void copiesOrderProcessThenConfirms() {
+        when(oqcMapper.selectById(2L)).thenReturn(qc());
+        when(lineMapper.selectById(5L)).thenReturn(line());
+        when(salesMapper.selectById(4L)).thenReturn(new MesWmProductSalesDO().setId(4L).setClientId(8L));
+        when(batchMapper.selectById(6L)).thenReturn(new MesWmBatchDO().setId(6L).setCode("B1").setItemId(3L).setClientId(8L).setWorkOrderId(10L));
+        when(orderMapper.selectById(10L)).thenReturn(new MesProWorkOrderDO().setId(10L).setCode("OLD").setProductId(11L).setClientId(8L).setRouteId(40L));
+        when(itemMapper.selectById(11L)).thenReturn(new MesMdItemDO().setId(11L).setMdmItemId(3L));
+        when(processService.getWorkOrderProcessListByWorkOrderId(10L)).thenReturn(List.of(new MesProWorkOrderProcessDO().setId(20L)
+                .setProcessId(21L).setSort(1).setOutputItemId("3,4")));
+        when(bomMapper.selectListByWorkOrderId(10L)).thenReturn(List.of(new MesProWorkOrderBomDO()
+                .setProcessId(21L).setItemId(22L).setQuantity(new BigDecimal("1.25"))));
+        when(autoCodeService.generateAutoCode(anyString())).thenReturn("NEW");
+        when(orderService.createWorkOrder(any())).thenReturn(30L);
+        when(taskService.autoGenerateTasks(any())).thenReturn(List.of(50L));
+        var result = service.reproduce(ncr(), 7);
+        assertEquals(30L, result.getDocId());
+        verify(processService).createWorkOrderProcess(argThat(p -> p.getId() == null && p.getWorkOrderId().equals(30L)
+                && p.getProcessId().equals(21L) && p.getOutputItemIds().equals(List.of(3L, 4L))));
+        verify(bomMapper).deleteByWorkOrderId(30L);
+        verify(bomMapper).insert(argThat((MesProWorkOrderBomDO b) -> b.getWorkOrderId().equals(30L)
+                && b.getProcessId().equals(21L) && b.getQuantity().compareTo(new BigDecimal("1.25")) == 0));
+        var inOrder = inOrder(processService, orderService);
+        inOrder.verify(processService).getWorkOrderProcessListByWorkOrderId(10L);
+        inOrder.verify(orderService).createWorkOrder(any());
+        inOrder.verify(processService).createWorkOrderProcess(any(MesProWorkOrderProcessSaveReqVO.class));
+        inOrder.verify(orderService).confirmWorkOrder(30L);
+        verify(taskService).autoGenerateTasks(argThat(r -> r.getWorkOrderId().equals(30L) && r.getRouteId().equals(40L)));
+    }
+}
diff --git a/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcReworkServiceTest.java b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcReworkServiceTest.java
new file mode 100644
index 0000000..6a9f6b7
--- /dev/null
+++ b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrOqcReworkServiceTest.java
@@ -0,0 +1,250 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.ncr.vo.MesQcNcrDisposeReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.ncr.vo.MesQcNcrDisposeRespVO;
+import cn.iocoder.yudao.module.mes.controller.admin.wm.miscissue.vo.MesWmMiscIssueSaveReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.wm.miscissue.vo.line.MesWmMiscIssueLineSaveReqVO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.oqc.MesQcOqcDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.batch.MesWmBatchDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.materialstock.MesWmMaterialStockDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.miscissue.MesWmMiscIssueDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesLineDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.transaction.MesWmTransactionDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.pro.workorder.MesProWorkOrderMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.oqc.MesQcOqcMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.batch.MesWmBatchMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.materialstock.MesWmMaterialStockMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.miscissue.MesWmMiscIssueMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales.MesWmProductSalesMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.transaction.MesWmTransactionMapper;
+import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants;
+import cn.iocoder.yudao.module.mes.enums.qc.MesNcrDispositionEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmMiscIssueStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmMiscIssueTypeEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmProductSalesStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmQualityStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmTransactionTypeEnum;
+import cn.iocoder.yudao.module.mes.enums.pro.MesProWorkOrderStatusEnum;
+import cn.iocoder.yudao.module.mes.service.md.autocode.MesMdAutoCodeRecordService;
+import cn.iocoder.yudao.module.mes.service.wm.materialstock.MesWmMaterialStockService;
+import cn.iocoder.yudao.module.mes.service.wm.miscissue.MesWmMiscIssueLineService;
+import cn.iocoder.yudao.module.mes.service.wm.miscissue.MesWmMiscIssueService;
+import cn.iocoder.yudao.module.mes.service.wm.productsales.MesWmProductSalesService;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InOrder;
+import org.springframework.test.util.ReflectionTestUtils;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
+
+class MesQcNcrOqcReworkServiceTest {
+
+    private static final long NCR_ID = 100L;
+    private static final long QC_ID = 1L;
+    private static final long SALES_ID = 4L;
+    private static final long SALES_LINE_ID = 5L;
+    private static final long BATCH_ID = 6L;
+    private static final long ORDER_ID = 7L;
+    private static final long STOCK_ID = 9L;
+
+    private MesQcNcrOqcReworkService newService() {
+        var service = new MesQcNcrOqcReworkService();
+        ReflectionTestUtils.setField(service, "batchMapper", mock(MesWmBatchMapper.class));
+        ReflectionTestUtils.setField(service, "orderMapper", mock(MesProWorkOrderMapper.class));
+        ReflectionTestUtils.setField(service, "oqcMapper", mock(MesQcOqcMapper.class));
+        ReflectionTestUtils.setField(service, "stockMapper", mock(MesWmMaterialStockMapper.class));
+        ReflectionTestUtils.setField(service, "miscIssueMapper", mock(MesWmMiscIssueMapper.class));
+        ReflectionTestUtils.setField(service, "transactionMapper", mock(MesWmTransactionMapper.class));
+        ReflectionTestUtils.setField(service, "salesMapper", mock(MesWmProductSalesMapper.class));
+        ReflectionTestUtils.setField(service, "stockService", mock(MesWmMaterialStockService.class));
+        ReflectionTestUtils.setField(service, "salesService", mock(MesWmProductSalesService.class));
+        ReflectionTestUtils.setField(service, "miscIssueService", mock(MesWmMiscIssueService.class));
+        ReflectionTestUtils.setField(service, "miscIssueLineService", mock(MesWmMiscIssueLineService.class));
+        ReflectionTestUtils.setField(service, "autoCodeRecordService", mock(MesMdAutoCodeRecordService.class));
+        ReflectionTestUtils.setField(service, "itemService", mock(cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService.class));
+        ReflectionTestUtils.setField(service, "reproductionService", mock(MesQcNcrOqcReproductionService.class));
+        ReflectionTestUtils.setField(service, "warehouseService", mock(cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseService.class));
+        ReflectionTestUtils.setField(service, "warehouseLocationService", mock(cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseLocationService.class));
+        ReflectionTestUtils.setField(service, "warehouseAreaService", mock(cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseAreaService.class));
+        return service;
+    }
+
+    private static <T> T field(MesQcNcrOqcReworkService service, String name, Class<T> type) {
+        return type.cast(ReflectionTestUtils.getField(service, name));
+    }
+
+    private MesQcNcrDO ncr() {
+        return new MesQcNcrDO().setId(NCR_ID).setCode("NCR1").setQcId(QC_ID)
+                .setItemId(2L).setUnqualifiedQuantity(BigDecimal.valueOf(3));
+    }
+
+    private MesQcNcrOqcSourceClaim.OqcClaimedSource source() {
+        var qc = new MesQcOqcDO().setId(QC_ID).setSourceDocId(SALES_ID).setSourceLineId(SALES_LINE_ID);
+        var sales = new MesWmProductSalesDO().setId(SALES_ID).setCode("SALES1").setClientId(40L)
+                .setStatus(MesWmProductSalesStatusEnum.CONFIRMED.getStatus());
+        var line = new MesWmProductSalesLineDO().setId(SALES_LINE_ID).setSalesId(SALES_ID)
+                .setOqcId(QC_ID).setItemId(2L).setBatchId(BATCH_ID).setBatchCode("B1")
+                .setQualityStatus(MesWmQualityStatusEnum.FAIL.getStatus()).setQuantity(BigDecimal.TEN);
+        return new MesQcNcrOqcSourceClaim.OqcClaimedSource(qc, sales, line);
+    }
+
+    private static MesWmMaterialStockDO stock(BigDecimal quantity) {
+        return new MesWmMaterialStockDO().setId(STOCK_ID).setItemId(2L).setBatchId(BATCH_ID).setBatchCode("B1")
+                .setWarehouseId(11L).setLocationId(12L).setAreaId(13L).setQuantity(quantity)
+                .setFrozenQuantity(BigDecimal.ZERO).setReservedQuantity(BigDecimal.ZERO);
+    }
+
+    private void stubBatchAndOrder(MesQcNcrOqcReworkService service) {
+        when(field(service, "batchMapper", MesWmBatchMapper.class).selectById(BATCH_ID))
+                .thenReturn(new MesWmBatchDO().setId(BATCH_ID).setCode("B1").setItemId(2L)
+                        .setClientId(40L).setWorkOrderId(ORDER_ID));
+        when(field(service, "orderMapper", MesProWorkOrderMapper.class).selectById(ORDER_ID))
+                .thenReturn(new MesProWorkOrderDO().setId(ORDER_ID).setProductId(8L).setClientId(40L));
+    }
+
+    @Test
+    void disposeDeductsSelectedStockCancelsSalesAndCreatesReworkOrder() {
+        var service = newService();
+        var source = source();
+        stubBatchAndOrder(service);
+        var salesService = field(service, "salesService", MesWmProductSalesService.class);
+        var stockService = field(service, "stockService", MesWmMaterialStockService.class);
+        var stockMapper = field(service, "stockMapper", MesWmMaterialStockMapper.class);
+        var miscIssueService = field(service, "miscIssueService", MesWmMiscIssueService.class);
+        var miscLineService = field(service, "miscIssueLineService", MesWmMiscIssueLineService.class);
+        var autoCode = field(service, "autoCodeRecordService", MesMdAutoCodeRecordService.class);
+        var reproduction = field(service, "reproductionService", MesQcNcrOqcReproductionService.class);
+
+        when(stockService.getMaterialStock(STOCK_ID)).thenReturn(stock(BigDecimal.TEN));
+        when(stockMapper.lockById(STOCK_ID)).thenReturn(stock(BigDecimal.TEN));
+        when(autoCode.generateAutoCode(anyString())).thenReturn("MI1");
+        when(miscIssueService.createMiscIssue(any(MesWmMiscIssueSaveReqVO.class))).thenReturn(20L);
+        var result = new MesQcNcrDisposeRespVO();
+        result.setDocCode("WO1");
+        when(reproduction.createReworkFromOriginal(any(), anyInt(), any(), any(), any(), any())).thenReturn(result);
+
+        var req = new MesQcNcrDisposeReqVO();
+        req.setId(NCR_ID);
+        req.setDisposition(MesNcrDispositionEnum.REWORK.getType());
+        req.setMaterialStockId(STOCK_ID);
+
+        var resp = service.dispose(ncr(), source, req);
+
+        var issueCaptor = ArgumentCaptor.forClass(MesWmMiscIssueSaveReqVO.class);
+        verify(miscIssueService).createMiscIssue(issueCaptor.capture());
+        assertEquals(MesWmMiscIssueTypeEnum.REWORK.getType(), issueCaptor.getValue().getType());
+        assertEquals("QC_NCR", issueCaptor.getValue().getSourceDocType());
+        assertEquals(NCR_ID, issueCaptor.getValue().getSourceDocId().longValue());
+
+        var lineCaptor = ArgumentCaptor.forClass(MesWmMiscIssueLineSaveReqVO.class);
+        verify(miscLineService).createMiscIssueLine(lineCaptor.capture());
+        assertEquals(STOCK_ID, lineCaptor.getValue().getMaterialStockId().longValue());
+        assertEquals(BATCH_ID, lineCaptor.getValue().getBatchId().longValue());
+        assertEquals(0, BigDecimal.valueOf(3).compareTo(lineCaptor.getValue().getQuantity()));
+
+        InOrder order = inOrder(stockMapper, salesService, miscIssueService, reproduction);
+        order.verify(stockMapper).lockById(STOCK_ID);
+        order.verify(salesService).cancelProductSales(SALES_ID);
+        order.verify(miscIssueService).finishMiscIssue(20L);
+        order.verify(reproduction).createReworkFromOriginal(any(), anyInt(), any(), any(), any(), any());
+
+        assertNotNull(resp.getMessage());
+        assertTrue(resp.getMessage().contains("MI1"));
+        assertTrue(resp.getMessage().contains("SALES1"));
+        assertTrue(resp.getMessage().contains("WO1"));
+    }
+
+    @Test
+    void disposeRejectsWhenStockAvailableIsInsufficient() {
+        var service = newService();
+        stubBatchAndOrder(service);
+        var stockService = field(service, "stockService", MesWmMaterialStockService.class);
+        var stockMapper = field(service, "stockMapper", MesWmMaterialStockMapper.class);
+        when(stockService.getMaterialStock(STOCK_ID)).thenReturn(stock(BigDecimal.ONE));
+        when(stockMapper.lockById(STOCK_ID)).thenReturn(stock(BigDecimal.ONE));
+
+        var req = new MesQcNcrDisposeReqVO();
+        req.setDisposition(MesNcrDispositionEnum.REWORK.getType());
+        req.setMaterialStockId(STOCK_ID);
+
+        var ex = assertThrows(ServiceException.class, () -> service.dispose(ncr(), source(), req));
+        assertTrue(ex.getMessage().contains("鍙敤閲�"));
+        verify(field(service, "salesService", MesWmProductSalesService.class), never()).cancelProductSales(any());
+    }
+
+    @Test
+    void disposeRejectsAmbiguousStockWhenNoStockSelected() {
+        var service = newService();
+        stubBatchAndOrder(service);
+        var stockMapper = field(service, "stockMapper", MesWmMaterialStockMapper.class);
+        when(stockMapper.selectList(any(Wrapper.class))).thenReturn(List.of(
+                stock(BigDecimal.TEN).setId(9L).setWarehouseId(11L),
+                stock(BigDecimal.TEN).setId(10L).setWarehouseId(21L)));
+
+        var req = new MesQcNcrDisposeReqVO();
+        req.setDisposition(MesNcrDispositionEnum.REPAIR.getType());
+
+        var ex = assertThrows(ServiceException.class, () -> service.dispose(ncr(), source(), req));
+        assertTrue(ex.getMessage().contains("杩斿伐搴撳瓨"));
+        verify(field(service, "salesService", MesWmProductSalesService.class), never()).cancelProductSales(any());
+    }
+
+    @Test
+    void validateBeforeCloseRequiresFinishedOrderCancelledSalesAndMatchingIssue() {
+        var service = newService();
+        var ncr = ncr();
+        var orders = field(service, "orderMapper", MesProWorkOrderMapper.class);
+        var oqcs = field(service, "oqcMapper", MesQcOqcMapper.class);
+        var salesMapper = field(service, "salesMapper", MesWmProductSalesMapper.class);
+        var issues = field(service, "miscIssueMapper", MesWmMiscIssueMapper.class);
+        var flows = field(service, "transactionMapper", MesWmTransactionMapper.class);
+
+        // 1. 鎵句笉鍒拌繑宸ュ伐鍗�
+        when(orders.selectList(any(Wrapper.class))).thenReturn(List.of());
+        assertThrows(ServiceException.class, () -> service.validateBeforeClose(ncr));
+
+        // 2. 宸ュ崟鏈畬鎴�
+        var order = new MesProWorkOrderDO().setId(ORDER_ID).setCode("WO1");
+        when(orders.selectList(any(Wrapper.class))).thenReturn(List.of(order));
+        assertThrows(ServiceException.class, () -> service.validateBeforeClose(ncr));
+        order.setStatus(MesProWorkOrderStatusEnum.FINISHED.getStatus())
+                .setFinishDate(java.time.LocalDateTime.now());
+
+        // 3. 鍘熼攢鍞嚭搴撳崟鏈彇娑�
+        when(oqcs.selectById(QC_ID)).thenReturn(new MesQcOqcDO().setId(QC_ID).setSourceDocId(SALES_ID));
+        var sales = new MesWmProductSalesDO().setId(SALES_ID).setCode("SALES1")
+                .setStatus(MesWmProductSalesStatusEnum.CONFIRMED.getStatus());
+        when(salesMapper.selectById(SALES_ID)).thenReturn(sales);
+        assertThrows(ServiceException.class, () -> service.validateBeforeClose(ncr));
+        sales.setStatus(MesWmProductSalesStatusEnum.CANCELED.getStatus());
+
+        // 4. 杩斿伐棰嗙敤鍑哄簱鍗曠己澶�
+        when(issues.selectList(any(Wrapper.class))).thenReturn(List.of());
+        assertThrows(ServiceException.class, () -> service.validateBeforeClose(ncr));
+        var issue = new MesWmMiscIssueDO().setId(20L).setCode("MI1")
+                .setStatus(MesWmMiscIssueStatusEnum.FINISHED.getStatus());
+        when(issues.selectList(any(Wrapper.class))).thenReturn(List.of(issue));
+
+        // 5. 鍑哄簱娴佹按鏁伴噺涓嶇
+        when(flows.selectList(any(Wrapper.class))).thenReturn(List.of(new MesWmTransactionDO()
+                .setItemId(2L).setType(MesWmTransactionTypeEnum.OUT.getType())
+                .setQuantity(BigDecimal.valueOf(-2))));
+        assertThrows(ServiceException.class, () -> service.validateBeforeClose(ncr));
+
+        // 6. 鍏ㄩ儴婊¤冻
+        when(flows.selectList(any(Wrapper.class))).thenReturn(List.of(new MesWmTransactionDO()
+                .setItemId(2L).setType(MesWmTransactionTypeEnum.OUT.getType())
+                .setQuantity(BigDecimal.valueOf(-3))));
+        assertDoesNotThrow(() -> service.validateBeforeClose(ncr));
+    }
+}
diff --git a/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrPurchaseSourceValidatorTest.java b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrPurchaseSourceValidatorTest.java
new file mode 100644
index 0000000..fa30055
--- /dev/null
+++ b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrPurchaseSourceValidatorTest.java
@@ -0,0 +1,50 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.iqc.MesQcIqcDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.arrivalnotice.MesWmArrivalNoticeDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.arrivalnotice.MesWmArrivalNoticeLineDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.iqc.MesQcIqcMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.arrivalnotice.MesWmArrivalNoticeLineMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.arrivalnotice.MesWmArrivalNoticeMapper;
+import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmArrivalNoticeStatusEnum;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import org.junit.jupiter.api.Test;
+import org.springframework.test.util.ReflectionTestUtils;
+import java.math.BigDecimal;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
+
+class MesQcNcrPurchaseSourceValidatorTest {
+    @Test void verifiesAllSourceLinksAndQuantities() {
+        var validator = new MesQcNcrPurchaseSourceValidator();
+        var iqcs = mock(MesQcIqcMapper.class);
+        var notices = mock(MesWmArrivalNoticeMapper.class);
+        var lines = mock(MesWmArrivalNoticeLineMapper.class);
+        ReflectionTestUtils.setField(validator, "iqcMapper", iqcs);
+        ReflectionTestUtils.setField(validator, "arrivalNoticeMapper", notices);
+        ReflectionTestUtils.setField(validator, "lineMapper", lines);
+        var ncr = new MesQcNcrDO().setQcType(MesQcTypeEnum.IQC.getType()).setQcId(1L)
+                .setItemId(4L).setUnqualifiedQuantity(BigDecimal.TEN);
+        var iqc = new MesQcIqcDO().setId(1L).setSourceDocType(MesBizTypeConstants.WM_ARRIVAL_NOTICE)
+                .setSourceDocId(2L).setSourceLineId(3L).setItemId(4L)
+                .setUnqualifiedQuantity(BigDecimal.TEN).setCheckQuantity(BigDecimal.valueOf(100))
+                .setStatus(MesQcStatusEnum.FINISHED.getStatus());
+        var notice = new MesWmArrivalNoticeDO().setId(2L).setStatus(MesWmArrivalNoticeStatusEnum.PENDING_QC.getStatus());
+        var line = new MesWmArrivalNoticeLineDO().setId(3L).setNoticeId(2L).setIqcId(1L)
+                .setItemId(4L).setArrivalQuantity(BigDecimal.valueOf(100));
+        when(iqcs.selectOne(any(Wrapper.class))).thenReturn(iqc);
+        when(notices.selectOne(any(Wrapper.class))).thenReturn(notice);
+        when(lines.selectOne(any(Wrapper.class))).thenReturn(line);
+        assertDoesNotThrow(() -> validator.validate(ncr));
+        line.setIqcId(9L);
+        assertThrows(ServiceException.class, () -> validator.validate(ncr));
+        line.setIqcId(1L).setArrivalQuantity(BigDecimal.valueOf(101));
+        assertThrows(ServiceException.class, () -> validator.validate(ncr));
+    }
+}
diff --git a/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrReinspectionValidatorTest.java b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrReinspectionValidatorTest.java
new file mode 100644
index 0000000..784fcaf
--- /dev/null
+++ b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrReinspectionValidatorTest.java
@@ -0,0 +1,112 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ipqc.MesQcIpqcDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.md.item.MesMdItemMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.pro.workorder.MesProWorkOrderMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ipqc.MesQcIpqcMapper;
+import cn.iocoder.yudao.module.mes.enums.pro.MesProWorkOrderStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum;
+import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmQualityStatusEnum;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productproduce.MesWmProductProduceLineDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productproduce.MesWmProductProduceDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.transaction.MesWmTransactionDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productproduce.MesWmProductProduceLineMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productproduce.MesWmProductProduceMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.transaction.MesWmTransactionMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr.MesQcNcrMapper;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import org.junit.jupiter.api.Test;
+import org.springframework.test.util.ReflectionTestUtils;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.List;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
+
+class MesQcNcrReinspectionValidatorTest {
+    @Test void onlyExplicitPostCompletionWholeLotInspectionCanClose() {
+        var validator = new MesQcNcrReinspectionValidator();
+        var orders = mock(MesProWorkOrderMapper.class);
+        var items = mock(MesMdItemMapper.class);
+        var inspections = mock(MesQcIpqcMapper.class);
+        var lines = mock(MesWmProductProduceLineMapper.class);
+        var produces = mock(MesWmProductProduceMapper.class);
+        var transactions = mock(MesWmTransactionMapper.class);
+        var ncrs = mock(MesQcNcrMapper.class);
+        ReflectionTestUtils.setField(validator, "workOrderMapper", orders);
+        ReflectionTestUtils.setField(validator, "itemMapper", items);
+        ReflectionTestUtils.setField(validator, "ipqcMapper", inspections);
+        ReflectionTestUtils.setField(validator, "produceLineMapper", lines);
+        ReflectionTestUtils.setField(validator, "produceMapper", produces);
+        ReflectionTestUtils.setField(validator, "transactionMapper", transactions);
+        ReflectionTestUtils.setField(validator, "ncrMapper", ncrs);
+        var finishedAt = LocalDateTime.of(2026, 1, 1, 10, 0);
+        var order = new MesProWorkOrderDO().setId(1L).setProductId(2L)
+                .setStatus(MesProWorkOrderStatusEnum.FINISHED.getStatus()).setFinishDate(finishedAt);
+        var product = new MesMdItemDO().setId(2L).setMdmItemId(3L);
+        var ncr = new MesQcNcrDO().setCode("NCR1").setQcType(MesQcTypeEnum.IPQC.getType()).setItemId(3L).setUnqualifiedQuantity(BigDecimal.TEN)
+                .setHandleDate(finishedAt);
+        var qc = new MesQcIpqcDO().setId(4L).setWorkOrderId(1L).setItemId(2L)
+                .setSourceDocType(MesBizTypeConstants.PRO_FEEDBACK).setSourceDocId(7L).setSourceLineId(8L)
+                .setInspectDate(finishedAt.plusMinutes(1)).setStatus(MesQcStatusEnum.FINISHED.getStatus())
+                .setCheckResult(1).setCheckQuantity(BigDecimal.TEN).setQualifiedQuantity(BigDecimal.TEN)
+                .setUnqualifiedQuantity(BigDecimal.ZERO);
+        qc.setCreateTime(finishedAt.plusMinutes(1));
+        when(orders.selectList(any(Wrapper.class))).thenReturn(List.of(order));
+        when(items.selectById(2L)).thenReturn(product);
+        when(inspections.selectById(4L)).thenReturn(qc);
+        var line = new MesWmProductProduceLineDO().setId(8L).setProduceId(9L)
+                .setFeedbackId(7L).setItemId(2L).setQuantity(BigDecimal.TEN).setQualityStatus(MesWmQualityStatusEnum.PASS.getStatus());
+        when(lines.selectById(8L)).thenReturn(line);
+        when(produces.selectById(9L)).thenReturn(new MesWmProductProduceDO().setId(9L).setWorkOrderId(1L));
+        when(transactions.selectList(any(Wrapper.class))).thenReturn(List.of(new MesWmTransactionDO().setQuantity(BigDecimal.TEN)));
+        assertThrows(RuntimeException.class, () -> validator.validate(ncr, null));
+        assertDoesNotThrow(() -> validator.validate(ncr, 4L));
+        qc.setCheckResult(2).setQualifiedQuantity(BigDecimal.valueOf(6)).setUnqualifiedQuantity(BigDecimal.valueOf(4));
+        line.setQuantity(BigDecimal.valueOf(6));
+        when(transactions.selectList(any(Wrapper.class))).thenReturn(List.of(new MesWmTransactionDO().setQuantity(BigDecimal.valueOf(6))));
+        when(ncrs.selectList(any(Wrapper.class))).thenReturn(List.of());
+        assertThrows(RuntimeException.class, () -> validator.validate(ncr, 4L));
+        when(ncrs.selectList(any(Wrapper.class))).thenReturn(List.of(new MesQcNcrDO().setItemId(3L).setUnqualifiedQuantity(BigDecimal.valueOf(4))));
+        assertDoesNotThrow(() -> validator.validate(ncr, 4L));
+        qc.setQualifiedQuantity(BigDecimal.ZERO).setUnqualifiedQuantity(BigDecimal.TEN);
+        line.setQuantity(BigDecimal.ZERO);
+        when(transactions.selectList(any(Wrapper.class))).thenReturn(List.of());
+        when(ncrs.selectList(any(Wrapper.class))).thenReturn(List.of(new MesQcNcrDO().setItemId(3L).setUnqualifiedQuantity(BigDecimal.TEN)));
+        assertDoesNotThrow(() -> validator.validate(ncr, 4L));
+        qc.setCheckResult(1).setQualifiedQuantity(BigDecimal.TEN).setUnqualifiedQuantity(BigDecimal.ZERO);
+        line.setQuantity(BigDecimal.TEN);
+        when(transactions.selectList(any(Wrapper.class))).thenReturn(List.of());
+        assertThrows(RuntimeException.class, () -> validator.validate(ncr, 4L));
+        when(transactions.selectList(any(Wrapper.class))).thenReturn(List.of(new MesWmTransactionDO().setQuantity(BigDecimal.TEN)));
+        qc.setInspectDate(finishedAt.minusMinutes(1));
+        assertThrows(RuntimeException.class, () -> validator.validate(ncr, 4L));
+        qc.setInspectDate(finishedAt.plusMinutes(1)).setQualifiedQuantity(BigDecimal.ONE);
+        assertThrows(RuntimeException.class, () -> validator.validate(ncr, 4L));
+        qc.setQualifiedQuantity(BigDecimal.TEN).setCheckResult(2).setUnqualifiedQuantity(BigDecimal.ONE);
+        assertThrows(RuntimeException.class, () -> validator.validate(ncr, 4L));
+        qc.setCheckResult(1).setUnqualifiedQuantity(BigDecimal.ZERO);
+        qc.setQualifiedQuantity(BigDecimal.TEN).setWorkOrderId(5L);
+        assertThrows(RuntimeException.class, () -> validator.validate(ncr, 4L));
+        qc.setWorkOrderId(1L);
+        // 鍑鸿揣杩斿伐鍚屾牱璧版姤宸ヤ骇鍑哄妫�锛堜弗鏍煎垎鏀級锛屼笉鍐嶆斁琛岀嫭绔嬭繃绋嬫楠屽崟
+        ncr.setQcType(MesQcTypeEnum.OQC.getType());
+        qc.setSourceDocType(null).setSourceDocId(null).setSourceLineId(null);
+        assertThrows(RuntimeException.class, () -> validator.validate(ncr, 4L));
+        qc.setSourceDocType(MesBizTypeConstants.PRO_FEEDBACK).setSourceDocId(7L).setSourceLineId(8L);
+        assertDoesNotThrow(() -> validator.validate(ncr, 4L));
+        ncr.setQcType(MesQcTypeEnum.IPQC.getType());
+        qc.setSourceDocType(MesBizTypeConstants.PRO_FEEDBACK).setSourceDocId(7L).setSourceLineId(8L);
+        order.setFinishDate(null);
+        assertThrows(RuntimeException.class, () -> validator.validate(ncr, 4L));
+        order.setFinishDate(finishedAt);
+        when(orders.selectList(any(Wrapper.class))).thenReturn(List.of(order, order));
+        assertThrows(RuntimeException.class, () -> validator.validate(ncr, 4L));
+    }
+}
diff --git a/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrScrapServiceTest.java b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrScrapServiceTest.java
new file mode 100644
index 0000000..bd2fbe4
--- /dev/null
+++ b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrScrapServiceTest.java
@@ -0,0 +1,122 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.ncr.vo.MesQcNcrDisposeReqVO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.rqc.MesQcRqcDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ipqc.MesQcIpqcDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productproduce.MesWmProductProduceLineDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productproduce.MesWmProductProduceDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ipqc.MesQcIpqcMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.pro.workorder.MesProWorkOrderMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productproduce.MesWmProductProduceLineMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.productproduce.MesWmProductProduceMapper;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesLineDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.rqc.MesQcRqcMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.returnsales.MesWmReturnSalesLineMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.scrap.MesWmScrapReceiptMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.transaction.MesWmTransactionMapper;
+import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmQualityStatusEnum;
+import cn.iocoder.yudao.module.mes.service.wm.transaction.MesWmTransactionService;
+import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseAreaService;
+import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseService;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.BeforeAll;
+import com.baomidou.mybatisplus.core.MybatisConfiguration;
+import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
+import org.apache.ibatis.builder.MapperBuilderAssistant;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import java.math.BigDecimal;
+import java.util.List;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
+
+@ExtendWith(MockitoExtension.class)
+class MesQcNcrScrapServiceTest {
+    @BeforeAll static void initializeTableInfo() {
+        TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new MybatisConfiguration(), "test"),
+                MesWmProductProduceLineDO.class);
+    }
+    @InjectMocks MesQcNcrScrapService service;
+    @Mock MesQcRqcMapper rqc;
+    @Mock MesQcIpqcMapper ipqc;
+    @Mock MesProWorkOrderMapper orders;
+    @Mock MesWmProductProduceLineMapper outputs;
+    @Mock MesWmProductProduceMapper produces;
+    @Mock MesWmReturnSalesLineMapper lines;
+    @Mock MesWmScrapReceiptMapper receipts;
+    @Mock MesWmTransactionMapper transactions;
+    @Mock MesWmTransactionService transactionService;
+    @Mock MesWmWarehouseService warehouse;
+    @Mock MesWmWarehouseAreaService area;
+
+    private MesQcNcrDO ncr() { return new MesQcNcrDO().setId(1L).setCode("NCR1").setQcType(MesQcTypeEnum.RQC.getType())
+            .setQcId(2L).setItemId(3L).setUnqualifiedQuantity(BigDecimal.TEN); }
+    private MesQcRqcDO qc(int source) { return new MesQcRqcDO().setId(2L).setItemId(3L).setSourceDocType(source)
+            .setSourceDocId(4L).setSourceLineId(5L).setBatchCode("B1").setStatus(MesQcStatusEnum.FINISHED.getStatus())
+            .setUnqualifiedQuantity(BigDecimal.TEN); }
+    private MesQcNcrDisposeReqVO request() { var req = new MesQcNcrDisposeReqVO(); req.setWarehouseId(8L); req.setLocationId(9L); req.setAreaId(10L); return req; }
+
+    @Test void rejectsProductionReturn() {
+        when(rqc.selectById(2L)).thenReturn(qc(MesBizTypeConstants.WM_RETURN_ISSUE));
+        assertThrows(ServiceException.class, () -> service.receive(ncr(), request()));
+        verifyNoInteractions(receipts, transactionService);
+    }
+
+    @Test void validatesUnstockedIpqcOutputAndKeepsItsOriginalBatch() {
+        var item = ncr().setQcType(MesQcTypeEnum.IPQC.getType());
+        var qc = new MesQcIpqcDO().setId(2L).setItemId(3L).setSourceDocType(MesBizTypeConstants.PRO_FEEDBACK)
+                .setSourceDocId(11L).setSourceLineId(12L).setWorkOrderId(15L)
+                .setStatus(MesQcStatusEnum.FINISHED.getStatus()).setUnqualifiedQuantity(BigDecimal.TEN);
+        var original = new MesWmProductProduceLineDO().setId(12L).setFeedbackId(11L).setProduceId(13L)
+                .setBatchId(7L).setBatchCode("B1");
+        var failed = new MesWmProductProduceLineDO().setId(14L).setFeedbackId(11L).setProduceId(13L)
+                .setItemId(3L).setQuantity(BigDecimal.TEN).setBatchId(7L).setBatchCode("B1")
+                .setQualityStatus(MesWmQualityStatusEnum.FAIL.getStatus());
+        when(ipqc.selectById(2L)).thenReturn(qc);
+        when(outputs.selectById(12L)).thenReturn(original);
+        when(produces.selectById(13L)).thenReturn(new MesWmProductProduceDO().setId(13L).setFeedbackId(11L).setWorkOrderId(15L));
+        when(outputs.selectListByFeedbackId(11L)).thenReturn(List.of(failed));
+        when(orders.selectById(15L)).thenReturn(new MesProWorkOrderDO().setId(15L).setCode("WO1"));
+        var source = service.validateIpqcSource(item);
+        assertEquals(14L, source.sourceLineId());
+        assertEquals(7L, source.batchId());
+        assertEquals("B1", source.batchCode());
+        when(transactions.selectCount(any())).thenReturn(1L);
+        assertThrows(ServiceException.class, () -> service.validateIpqcSource(item));
+        failed.setBatchCode("other");
+        assertThrows(ServiceException.class, () -> service.validateIpqcSource(item));
+    }
+
+    @Test void onlyOneNcrCanClaimTheFailedOutput() {
+        var item = ncr().setQcType(MesQcTypeEnum.IPQC.getType());
+        var source = new MesQcNcrScrapService.IpqcSource(15L, "WO1", 14L, 7L, "B1");
+        when(outputs.update(isNull(), any(Wrapper.class))).thenReturn(1, 0);
+        assertDoesNotThrow(() -> service.claimIpqcSource(item, source));
+        assertThrows(ServiceException.class, () -> service.claimIpqcSource(item.setId(99L), source));
+        verify(outputs, times(2)).update(isNull(), any(Wrapper.class));
+    }
+
+    @Test void recordsCustomerReturnInScrapWarehouseWithOriginalBatch() {
+        when(rqc.selectById(2L)).thenReturn(qc(MesBizTypeConstants.WM_RETURN_SALES));
+        var line = new MesWmReturnSalesLineDO().setId(6L).setReturnId(4L).setRqcId(2L).setItemId(3L)
+                .setQuantity(BigDecimal.TEN).setBatchId(7L).setBatchCode("B1").setQualityStatus(MesWmQualityStatusEnum.FAIL.getStatus());
+        when(lines.selectListByReturnId(4L)).thenReturn(List.of(line));
+        when(warehouse.validateWarehouseExists(8L)).thenReturn(new MesWmWarehouseDO().setWarehouseType("搴熸枡浠�"));
+        var response = service.receive(ncr(), request());
+        assertEquals("SCRAP_RECEIPT", response.getDocType());
+        assertEquals("SCR-N" + MesQcTypeEnum.RQC.getType() + "-6", response.getDocCode());
+        verify(transactionService).createTransaction(argThat(tx -> tx.getItemId().equals(3L) && tx.getBatchId().equals(7L)
+                && tx.getQuantity().compareTo(BigDecimal.TEN) == 0 && tx.getWarehouseId().equals(8L)));
+    }
+}
diff --git a/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrStockClosureGuardTest.java b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrStockClosureGuardTest.java
new file mode 100644
index 0000000..1171e3c
--- /dev/null
+++ b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcNcrStockClosureGuardTest.java
@@ -0,0 +1,29 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.enums.qc.MesNcrDispositionEnum;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class MesQcNcrStockClosureGuardTest {
+    private final MesQcNcrStockClosureGuard guard = new MesQcNcrStockClosureGuard();
+
+    @Test
+    void blocksInventoryGeneratingDispositionsUntilSourceAndStockAreConnected() {
+        assertThrows(ServiceException.class, () -> guard.validateBeforeDispose(MesNcrDispositionEnum.SCRAP.getType()));
+        assertThrows(ServiceException.class, () -> guard.validateBeforeDispose(MesNcrDispositionEnum.CONCESSION.getType()));
+        assertDoesNotThrow(() -> guard.validateBeforeDispose(MesNcrDispositionEnum.REWORK.getType()));
+        assertDoesNotThrow(() -> guard.validateBeforeDispose(MesNcrDispositionEnum.REPAIR.getType()));
+    }
+
+    @Test
+    void blocksClosingLegacyScrapWithoutDestroyEvidence() {
+        MesQcNcrDO ncr = new MesQcNcrDO().setDisposition(MesNcrDispositionEnum.SCRAP.getType());
+        assertThrows(ServiceException.class, () -> guard.validateBeforeClose(ncr));
+        assertEquals(MesNcrDispositionEnum.SCRAP.getType(), ncr.getDisposition());
+        assertThrows(ServiceException.class, () -> guard.validateBeforeClose(new MesQcNcrDO().setDisposition(MesNcrDispositionEnum.CONCESSION.getType())));
+        assertDoesNotThrow(() -> guard.validateBeforeClose(new MesQcNcrDO().setDisposition(MesNcrDispositionEnum.REWORK.getType())));
+    }
+}
diff --git a/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcPurchaseConcessionServiceTest.java b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcPurchaseConcessionServiceTest.java
new file mode 100644
index 0000000..e56d3ae
--- /dev/null
+++ b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcPurchaseConcessionServiceTest.java
@@ -0,0 +1,63 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.ncr.vo.MesQcNcrDisposeReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.wm.itemreceipt.vo.line.MesWmItemReceiptLineSaveReqVO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.iqc.MesQcIqcDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcPurchaseReturnDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.arrivalnotice.MesWmArrivalNoticeDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.arrivalnotice.MesWmArrivalNoticeLineDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.itemreceipt.MesWmItemReceiptLineDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr.MesQcPurchaseConcessionMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr.MesQcPurchaseReturnMapper;
+import cn.iocoder.yudao.module.mes.service.wm.itemreceipt.MesWmItemReceiptService;
+import cn.iocoder.yudao.module.mes.service.wm.itemreceipt.MesWmItemReceiptLineService;
+import cn.iocoder.yudao.module.mes.service.wm.itemreceipt.MesWmItemReceiptDetailService;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+import org.springframework.test.util.ReflectionTestUtils;
+import java.math.BigDecimal;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
+
+class MesQcPurchaseConcessionServiceTest {
+    @Test void postsOnlyConcessionThroughPurchaseReceiptAndPreventsDuplicateReturn() {
+        var service = new MesQcPurchaseConcessionService();
+        var validator = mock(MesQcNcrPurchaseSourceValidator.class);
+        var concessions = mock(MesQcPurchaseConcessionMapper.class);
+        var returns = mock(MesQcPurchaseReturnMapper.class);
+        var receipts = mock(MesWmItemReceiptService.class);
+        var lines = mock(MesWmItemReceiptLineService.class);
+        var details = mock(MesWmItemReceiptDetailService.class);
+        var arrival = mock(MesQcArrivalDispositionService.class);
+        ReflectionTestUtils.setField(service, "validator", validator);
+        ReflectionTestUtils.setField(service, "concessionMapper", concessions);
+        ReflectionTestUtils.setField(service, "returnMapper", returns);
+        ReflectionTestUtils.setField(service, "receipts", receipts);
+        ReflectionTestUtils.setField(service, "lines", lines);
+        ReflectionTestUtils.setField(service, "details", details);
+        ReflectionTestUtils.setField(service, "arrivalDispositionService", arrival);
+        var ncr = new MesQcNcrDO().setId(1L).setCode("NCR1").setQcId(2L).setItemId(3L).setUnqualifiedQuantity(BigDecimal.TEN);
+        var notice = new MesWmArrivalNoticeDO().setId(4L).setVendorId(5L).setPurchaseOrderId(6L);
+        var line = new MesWmArrivalNoticeLineDO().setId(7L).setPurchaseOrderItemId(8L);
+        when(validator.validate(ncr)).thenReturn(new MesQcNcrPurchaseSourceValidator.Source(new MesQcIqcDO(), notice, line));
+        when(receipts.createItemReceipt(any())).thenReturn(9L);
+        when(lines.createItemReceiptLine(any())).thenReturn(10L);
+        when(lines.getItemReceiptLine(10L)).thenReturn(new MesWmItemReceiptLineDO().setId(10L));
+        var request = new MesQcNcrDisposeReqVO();
+        request.setDisposition(4); request.setWarehouseId(11L); request.setLocationId(12L); request.setAreaId(13L);
+        var result = service.dispose(ncr, request);
+        assertEquals(9L, result.getDocId());
+        var lineRequest = ArgumentCaptor.forClass(MesWmItemReceiptLineSaveReqVO.class);
+        verify(lines).createItemReceiptLine(lineRequest.capture());
+        assertEquals(BigDecimal.TEN, lineRequest.getValue().getReceivedQuantity());
+        assertNull(lineRequest.getValue().getArrivalNoticeLineId());
+        verify(receipts).finishItemReceipt(9L);
+        verify(arrival).refresh(4L);
+        when(returns.selectByIqcId(2L)).thenReturn(new MesQcPurchaseReturnDO());
+        assertThrows(ServiceException.class, () -> service.dispose(ncr, request));
+        verify(receipts, times(1)).createItemReceipt(any());
+    }
+}
diff --git a/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcPurchaseReturnServiceTest.java b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcPurchaseReturnServiceTest.java
new file mode 100644
index 0000000..b6808da
--- /dev/null
+++ b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/qc/ncr/MesQcPurchaseReturnServiceTest.java
@@ -0,0 +1,48 @@
+package cn.iocoder.yudao.module.mes.service.qc.ncr;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.iqc.MesQcIqcDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcNcrDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcPurchaseReturnDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ncr.MesQcPurchaseConcessionDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.arrivalnotice.MesWmArrivalNoticeDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.arrivalnotice.MesWmArrivalNoticeLineDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr.MesQcPurchaseReturnMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr.MesQcPurchaseConcessionMapper;
+import org.junit.jupiter.api.Test;
+import org.springframework.test.util.ReflectionTestUtils;
+import java.math.BigDecimal;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.*;
+
+class MesQcPurchaseReturnServiceTest {
+    @Test void createsTraceableWaitingDocumentAndRequiresWarehouseConfirmation() {
+        var service = new MesQcPurchaseReturnService();
+        var validator = mock(MesQcNcrPurchaseSourceValidator.class);
+        var mapper = mock(MesQcPurchaseReturnMapper.class);
+        var concessions = mock(MesQcPurchaseConcessionMapper.class);
+        ReflectionTestUtils.setField(service, "sourceValidator", validator);
+        ReflectionTestUtils.setField(service, "mapper", mapper);
+        ReflectionTestUtils.setField(service, "concessionMapper", concessions);
+        var ncr = new MesQcNcrDO().setId(1L).setQcId(2L).setItemId(3L).setUnqualifiedQuantity(BigDecimal.TEN);
+        var iqc = new MesQcIqcDO().setId(2L).setVendorBatch("B1");
+        var notice = new MesWmArrivalNoticeDO().setId(4L).setVendorId(5L).setPurchaseOrderId(6L);
+        var line = new MesWmArrivalNoticeLineDO().setId(7L).setPurchaseOrderItemId(8L);
+        when(validator.validate(ncr)).thenReturn(new MesQcNcrPurchaseSourceValidator.Source(iqc, notice, line));
+        var doc = service.createForNcr(ncr);
+        assertEquals(0, doc.getStatus());
+        assertEquals(8L, doc.getPurchaseOrderItemId());
+        assertEquals(BigDecimal.TEN, doc.getQuantity());
+        verify(mapper).insert(any(MesQcPurchaseReturnDO.class));
+        when(mapper.selectByNcrId(1L)).thenReturn(doc);
+        assertThrows(ServiceException.class, () -> service.createForNcr(ncr));
+        assertThrows(ServiceException.class, () -> service.validateConfirmed(1L));
+        doc.setStatus(1);
+        assertDoesNotThrow(() -> service.validateConfirmed(1L));
+        when(mapper.selectByNcrId(1L)).thenReturn(null);
+        when(concessions.selectByIqcId(2L)).thenReturn(new MesQcPurchaseConcessionDO());
+        assertThrows(ServiceException.class, () -> service.createForNcr(ncr));
+        verify(mapper, times(1)).insert(any(MesQcPurchaseReturnDO.class));
+    }
+}
diff --git a/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/wm/miscissue/MesWmMiscIssueServiceImplTest.java b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/wm/miscissue/MesWmMiscIssueServiceImplTest.java
new file mode 100644
index 0000000..ca5692e
--- /dev/null
+++ b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/wm/miscissue/MesWmMiscIssueServiceImplTest.java
@@ -0,0 +1,66 @@
+package cn.iocoder.yudao.module.mes.service.wm.miscissue;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.miscissue.MesWmMiscIssueDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.miscissue.MesWmMiscIssueLineDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.miscissue.MesWmMiscIssueMapper;
+import cn.iocoder.yudao.module.mes.enums.wm.MesWmMiscIssueStatusEnum;
+import cn.iocoder.yudao.module.mes.service.wm.transaction.MesWmTransactionService;
+import cn.iocoder.yudao.module.mes.service.wm.transaction.dto.MesWmTransactionSaveReqDTO;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+import org.springframework.test.util.ReflectionTestUtils;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
+
+class MesWmMiscIssueServiceImplTest {
+
+    @Test
+    void finishMiscIssuePassesSelectedMaterialStockIdToTransaction() {
+        var service = new MesWmMiscIssueServiceImpl();
+        var mapper = mock(MesWmMiscIssueMapper.class);
+        var lineService = mock(MesWmMiscIssueLineService.class);
+        var transactionService = mock(MesWmTransactionService.class);
+        ReflectionTestUtils.setField(service, "miscIssueMapper", mapper);
+        ReflectionTestUtils.setField(service, "miscIssueLineService", lineService);
+        ReflectionTestUtils.setField(service, "wmTransactionService", transactionService);
+
+        var issue = new MesWmMiscIssueDO().setId(1L).setCode("MI1")
+                .setStatus(MesWmMiscIssueStatusEnum.APPROVED.getStatus());
+        var line = new MesWmMiscIssueLineDO().setId(5L).setIssueId(1L).setItemId(2L)
+                .setQuantity(BigDecimal.valueOf(3)).setMaterialStockId(9L).setBatchId(6L)
+                .setBatchCode("B1").setWarehouseId(11L).setLocationId(12L).setAreaId(13L);
+        when(mapper.selectById(1L)).thenReturn(issue);
+        when(lineService.getMiscIssueLineListByIssueId(1L)).thenReturn(List.of(line));
+
+        service.finishMiscIssue(1L);
+
+        @SuppressWarnings("unchecked")
+        ArgumentCaptor<List<MesWmTransactionSaveReqDTO>> captor = ArgumentCaptor.forClass(List.class);
+        verify(transactionService).createTransactionList(captor.capture());
+        var dto = captor.getValue().get(0);
+        assertEquals(9L, dto.getMaterialStockId().longValue());
+        assertEquals(6L, dto.getBatchId().longValue());
+        assertEquals(0, BigDecimal.valueOf(-3).compareTo(dto.getQuantity()));
+    }
+
+    @Test
+    void finishMiscIssueRejectsNonApprovedStatus() {
+        var service = new MesWmMiscIssueServiceImpl();
+        var mapper = mock(MesWmMiscIssueMapper.class);
+        ReflectionTestUtils.setField(service, "miscIssueMapper", mapper);
+        ReflectionTestUtils.setField(service, "miscIssueLineService", mock(MesWmMiscIssueLineService.class));
+        ReflectionTestUtils.setField(service, "wmTransactionService", mock(MesWmTransactionService.class));
+
+        when(mapper.selectById(1L)).thenReturn(new MesWmMiscIssueDO().setId(1L).setCode("MI1")
+                .setStatus(MesWmMiscIssueStatusEnum.PREPARE.getStatus()));
+
+        assertThrows(ServiceException.class, () -> service.finishMiscIssue(1L));
+        verifyNoInteractions(ReflectionTestUtils.getField(service, "wmTransactionService"));
+    }
+}
diff --git a/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmOqcConcessionGuardTest.java b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmOqcConcessionGuardTest.java
new file mode 100644
index 0000000..edbfef1
--- /dev/null
+++ b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmOqcConcessionGuardTest.java
@@ -0,0 +1,40 @@
+package cn.iocoder.yudao.module.mes.service.wm.productsales;
+
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.oqc.MesQcOqcDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.materialstock.MesWmMaterialStockDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesLineDO;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.ncr.MesQcNcrMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.oqc.MesQcOqcMapper;
+import cn.iocoder.yudao.module.mes.dal.mysql.wm.materialstock.MesWmMaterialStockMapper;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import org.junit.jupiter.api.Test;
+import org.springframework.test.util.ReflectionTestUtils;
+import java.math.BigDecimal;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
+
+class MesWmOqcConcessionGuardTest {
+    @Test void enforcesInspectedBatchAndWholeLineQuantity() {
+        var guard = new MesWmOqcConcessionGuard();
+        var ncrs = mock(MesQcNcrMapper.class);
+        var oqcs = mock(MesQcOqcMapper.class);
+        var stocks = mock(MesWmMaterialStockMapper.class);
+        ReflectionTestUtils.setField(guard, "ncrMapper", ncrs);
+        ReflectionTestUtils.setField(guard, "oqcMapper", oqcs);
+        ReflectionTestUtils.setField(guard, "stockMapper", stocks);
+        var line = new MesWmProductSalesLineDO().setId(1L).setItemId(2L).setOqcId(3L).setQuantity(BigDecimal.TEN);
+        when(ncrs.selectCount(any(Wrapper.class))).thenReturn(1L);
+        when(oqcs.selectById(3L)).thenReturn(new MesQcOqcDO().setSourceLineId(1L).setItemId(2L).setBatchCode("B1"));
+        when(stocks.selectById(4L)).thenReturn(new MesWmMaterialStockDO().setItemId(2L).setBatchCode("B1"));
+        when(stocks.selectById(5L)).thenReturn(new MesWmMaterialStockDO().setItemId(2L).setBatchCode("B2"));
+        assertDoesNotThrow(() -> guard.validate(line, 4L, "B1", BigDecimal.TEN));
+        assertThrows(ServiceException.class, () -> guard.validate(line, 5L, "B1", BigDecimal.TEN));
+        assertThrows(ServiceException.class, () -> guard.validate(line, 4L, "B2", BigDecimal.TEN));
+        assertThrows(ServiceException.class, () -> guard.validate(line, null, "B1", BigDecimal.TEN));
+        assertThrows(ServiceException.class, () -> guard.validate(line, 4L, "B1", BigDecimal.ZERO));
+        assertDoesNotThrow(() -> guard.validateQuantity(line, BigDecimal.TEN));
+        assertThrows(ServiceException.class, () -> guard.validateQuantity(line, BigDecimal.ONE));
+    }
+}
diff --git a/yudao-module-mes/src/test/resources/sql/create_tables.sql b/yudao-module-mes/src/test/resources/sql/create_tables.sql
index 9cad6df..5dcf69b 100644
--- a/yudao-module-mes/src/test/resources/sql/create_tables.sql
+++ b/yudao-module-mes/src/test/resources/sql/create_tables.sql
@@ -353,6 +353,7 @@
     "expire_date" timestamp DEFAULT NULL,
     "lot_number" varchar(128) DEFAULT NULL,
     "quality_status" int DEFAULT NULL,
+    "ncr_disposition_id" bigint DEFAULT NULL,
     "remark" varchar(500) DEFAULT NULL,
     "creator" varchar(64) DEFAULT '',
     "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -485,6 +486,7 @@
     "oqc_check_flag" tinyint DEFAULT NULL,
     "oqc_id" bigint DEFAULT NULL,
     "quality_status" int DEFAULT NULL,
+    "ncr_disposition_id" bigint DEFAULT NULL,
     "remark" varchar(500) DEFAULT NULL,
     "creator" varchar(64) DEFAULT '',
     "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -509,6 +511,7 @@
     "rqc_id" bigint DEFAULT NULL,
     "rqc_check_flag" bit NOT NULL DEFAULT FALSE,
     "quality_status" int DEFAULT NULL,
+    "ncr_disposition_id" bigint DEFAULT NULL,
     "remark" varchar(500) DEFAULT '',
     "creator" varchar(64) DEFAULT '',
     "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,

--
Gitblit v1.9.3