From 1ab2b329a40decba8ff7eefbeb158ff259aceb6d Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期二, 14 七月 2026 15:23:34 +0800
Subject: [PATCH] 追溯+分类接口

---
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesServiceImpl.java |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

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 baec481..7309606 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
@@ -251,9 +251,9 @@
         productSalesMapper.updateById(new MesWmProductSalesDO()
                 .setId(id).setStatus(MesWmProductSalesStatusEnum.FINISHED.getStatus()));
 
-        // 5. 鏇存柊鍏宠仈鐨勫彂璐ч�氱煡鍗曠姸鎬�
+        // 5. 鏇存柊鍏宠仈鐨勫彂璐ч�氱煡鍗曞嚭搴撴暟閲忓拰鐘舵��
         if (sales.getNoticeId() != null) {
-            salesNoticeService.finishSalesNotice(sales.getNoticeId());
+            updateSalesNoticeOutCount(sales);
         }
 
         // 6. 鍥炲啓 ERP 閿�鍞鍗曠殑鍑哄簱鏁伴噺鍜岀姸鎬�
@@ -261,6 +261,23 @@
     }
 
     /**
+     * 鏇存柊鍙戣揣閫氱煡鍗曠殑鍑哄簱鏁伴噺鍜岀姸鎬�
+     */
+    private void updateSalesNoticeOutCount(MesWmProductSalesDO sales) {
+        // 鑾峰彇鍑哄簱鍗曡
+        List<MesWmProductSalesLineDO> lines = productSalesLineService.getProductSalesLineListBySalesId(sales.getId());
+        if (CollUtil.isEmpty(lines)) {
+            return;
+        }
+        // 閬嶅巻琛岋紝鎸� noticeLineId 鏇存柊鍑哄簱鏁伴噺
+        for (MesWmProductSalesLineDO line : lines) {
+            if (line.getNoticeLineId() != null && line.getQuantity() != null) {
+                salesNoticeService.updateSalesNoticeLineOutCount(line.getNoticeLineId(), line.getQuantity());
+            }
+        }
+    }
+
+    /**
      * 鍥炲啓 ERP 閿�鍞鍗曠殑鍑哄簱鏁伴噺鍜岀姸鎬�
      */
     private void updateErpSaleOrderOutCount(MesWmProductSalesDO sales) {

--
Gitblit v1.9.3