From a1a94ab39a3ac9cc28601e3381b3b4fbc0cda02a Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期四, 29 十月 2026 12:20:31 +0800
Subject: [PATCH] fix(mes): 解决产品收货批次信息传递和销售订单校验问题

---
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesLineServiceImpl.java |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesLineServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesLineServiceImpl.java
index 92444cb..d1460c8 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesLineServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesLineServiceImpl.java
@@ -1,6 +1,7 @@
 package cn.iocoder.yudao.module.mes.service.wm.productsales;
 
 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
+import cn.iocoder.yudao.module.erp.api.sale.ErpSaleOrderApi;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.ObjUtil;
@@ -60,6 +61,8 @@
     @Resource
     @Lazy
     private MesQcOqcService oqcService;
+    @Resource
+    private ErpSaleOrderApi saleOrderApi;
 
     @Override
     public Long createProductSalesLine(MesWmProductSalesLineSaveReqVO createReqVO) {
@@ -196,6 +199,16 @@
         mdmItemService.validateItemExistsAndEnable(reqVO.getItemId());
         // 鏍¢獙鍏宠仈鍙戣揣閫氱煡鍗曡锛堝瓨鍦ㄦ�� + 褰掑睘 + 瀛楁涓�鑷存�э級
         MesWmSalesNoticeLineDO noticeLine = validateSalesNoticeLine(sales, reqVO);
+        if (noticeLine == null && sales.getSaleOrderId() != null) {
+            if (reqVO.getSaleOrderItemId() == null) {
+                throw exception(WM_SALES_NOTICE_SALE_ORDER_ITEM_EMPTY);
+            }
+            var item = saleOrderApi.getSaleOrderItem(reqVO.getSaleOrderItemId()).getCheckedData();
+            if (item == null || !Objects.equals(item.getOrderId(), sales.getSaleOrderId())
+                    || !Objects.equals(item.getProductId(), reqVO.getItemId())) {
+                throw exception(WM_SALES_NOTICE_LINE_SALE_ITEM_MISMATCH);
+            }
+        }
         // 鏍规嵁 batchCode 瑙f瀽 batchId
         fillBatchId(reqVO);
         return noticeLine;

--
Gitblit v1.9.3