From 87733eb3623593da247c051593d64b8ff9e1d3a4 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 06 十一月 2026 19:00:39 +0800
Subject: [PATCH] feat(crm,mes): 扩展客户字段与重构批次号生成逻辑

---
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/productsales/MesWmProductSalesDetailMapper.java |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/productsales/MesWmProductSalesDetailMapper.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/productsales/MesWmProductSalesDetailMapper.java
index dc477d3..575bfa5 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/productsales/MesWmProductSalesDetailMapper.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/productsales/MesWmProductSalesDetailMapper.java
@@ -5,6 +5,7 @@
 import org.apache.ibatis.annotations.Mapper;
 
 import java.util.List;
+import java.util.Collection;
 
 /**
  * MES 閿�鍞嚭搴撴槑缁� Mapper
@@ -14,11 +15,26 @@
 @Mapper
 public interface MesWmProductSalesDetailMapper extends BaseMapperX<MesWmProductSalesDetailDO> {
 
+    default List<MesWmProductSalesDetailDO> selectBySalesIdsAndBagIds(Collection<Long> salesIds, Collection<Long> bagIds) {
+        if (salesIds.isEmpty() || bagIds.isEmpty()) return List.of();
+        return selectList(new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<MesWmProductSalesDetailDO>()
+                .in(MesWmProductSalesDetailDO::getSalesId, salesIds)
+                .in(MesWmProductSalesDetailDO::getBagCodeId, bagIds));
+    }
+
+    default List<MesWmProductSalesDetailDO> selectByBagIds(Collection<Long> bagIds) {
+        if (bagIds.isEmpty()) return List.of();
+        return selectList(new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<MesWmProductSalesDetailDO>()
+                .in(MesWmProductSalesDetailDO::getBagCodeId, bagIds));
+    }
+
     // 浠呮湭鍙栨秷涓斿皻鏈畬鎴愮殑鍑哄簱鍗曞崰鐢ㄨ鐮併�傛棫鏁存墭鏄庣粏涔熷弬涓庨噸鍙犲垽鏂��
     @org.apache.ibatis.annotations.Select("""
         SELECT d.* FROM mes_wm_product_sales_detail d
         JOIN mes_wm_product_sales s ON s.id = d.sales_id
+        LEFT JOIN mes_wm_product_sales_shipment sh ON sh.id = d.shipment_id AND sh.deleted = 0
         WHERE d.deleted = 0 AND s.deleted = 0 AND s.status IN (2, 10, 3)
+          AND (d.shipment_id IS NULL OR sh.status IN (10, 20))
           AND d.batch_code = #{batchCode}
         """)
     List<MesWmProductSalesDetailDO> selectPickingByBatchCode(String batchCode);
@@ -26,7 +42,9 @@
     @org.apache.ibatis.annotations.Select("""
         SELECT d.* FROM mes_wm_product_sales_detail d
         JOIN mes_wm_product_sales s ON s.id = d.sales_id
+        LEFT JOIN mes_wm_product_sales_shipment sh ON sh.id = d.shipment_id AND sh.deleted = 0
         WHERE d.deleted = 0 AND s.deleted = 0 AND s.status IN (2, 10, 3)
+          AND (d.shipment_id IS NULL OR sh.status IN (10, 20))
           AND d.batch_code = #{batchCode} FOR UPDATE
         """)
     List<MesWmProductSalesDetailDO> selectPickingByBatchCodeForUpdate(String batchCode);
@@ -35,6 +53,12 @@
         return selectList(MesWmProductSalesDetailDO::getLineId, lineId);
     }
 
+    default void unassignShipment(Long shipmentId) {
+        update(null, new com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper<MesWmProductSalesDetailDO>()
+                .eq(MesWmProductSalesDetailDO::getShipmentId, shipmentId)
+                .set(MesWmProductSalesDetailDO::getShipmentId, null));
+    }
+
     default List<MesWmProductSalesDetailDO> selectListBySalesId(Long salesId) {
         return selectList(MesWmProductSalesDetailDO::getSalesId, salesId);
     }

--
Gitblit v1.9.3