From b29d86d9ed34fd890eb14cb7a75f6ae4f7148865 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 01 九月 2026 13:58:03 +0800
Subject: [PATCH] feat(mes): 新增防伪防窜货功能模块

---
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productsales/MesWmProductSalesController.java |   35 ++++++++++++++++++++++++++++-------
 1 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productsales/MesWmProductSalesController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productsales/MesWmProductSalesController.java
index cdd84a8..675e6af 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productsales/MesWmProductSalesController.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productsales/MesWmProductSalesController.java
@@ -8,14 +8,18 @@
 import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+import cn.iocoder.yudao.module.crm.api.customer.CrmCustomerApi;
+import cn.iocoder.yudao.module.crm.api.customer.dto.CrmCustomerRespDTO;
+import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
+import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
 import cn.iocoder.yudao.module.mes.controller.admin.wm.productsales.vo.MesWmProductSalesPageReqVO;
 import cn.iocoder.yudao.module.mes.controller.admin.wm.productsales.vo.MesWmProductSalesRespVO;
 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.client.MesMdClientDO;
+import cn.iocoder.yudao.module.mes.controller.admin.wm.productsales.vo.MesWmProductSalesScanReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.wm.productsales.vo.MesWmProductSalesScanRespVO;
 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesDO;
 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeDO;
-import cn.iocoder.yudao.module.mes.service.md.client.MesMdClientService;
 import cn.iocoder.yudao.module.mes.service.wm.productsales.MesWmProductSalesService;
 import cn.iocoder.yudao.module.mes.service.wm.salesnotice.MesWmSalesNoticeService;
 import io.swagger.v3.oas.annotations.Operation;
@@ -44,7 +48,9 @@
     @Resource
     private MesWmProductSalesService productSalesService;
     @Resource
-    private MesMdClientService clientService;
+    private CrmCustomerApi crmCustomerApi;
+    @Resource
+    private AdminUserApi adminUserApi;
     @Resource
     private MesWmSalesNoticeService salesNoticeService;
 
@@ -122,6 +128,14 @@
         return success(productSalesService.checkProductSalesQuantity(id));
     }
 
+    @PostMapping("/scan")
+    @Operation(summary = "鎵爜鎷h揣")
+    @PreAuthorize("@ss.hasPermission('mes:wm-product-sales:stock')")
+    public CommonResult<MesWmProductSalesScanRespVO> scanProductSales(
+            @Valid @RequestBody MesWmProductSalesScanReqVO reqVO) {
+        return success(productSalesService.scanProductSales(reqVO));
+    }
+
     @PutMapping("/stock")
     @Operation(summary = "鎵ц鎷h揣")
     @Parameter(name = "id", description = "缂栧彿", required = true)
@@ -164,17 +178,24 @@
             return Collections.emptyList();
         }
         // 1. 鑾峰緱鍏宠仈鏁版嵁
-        Map<Long, MesMdClientDO> clientMap = clientService.getClientMap(
+        Map<Long, CrmCustomerRespDTO> customerMap = crmCustomerApi.getCustomerMap(
                 convertSet(list, MesWmProductSalesDO::getClientId));
         Map<Long, MesWmSalesNoticeDO> noticeMap = salesNoticeService.getSalesNoticeMap(
                 convertSet(list, MesWmProductSalesDO::getNoticeId));
+        Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
+                convertSet(list, MesWmProductSalesDO::getOutboundUserId));
         // 2. 鏋勫缓缁撴灉
         return BeanUtils.toBean(list, MesWmProductSalesRespVO.class, vo -> {
-            MapUtils.findAndThen(clientMap, vo.getClientId(), client ->
-                    vo.setClientName(client.getName()).setClientCode(client.getCode()));
+            MapUtils.findAndThen(customerMap, vo.getClientId(), customer ->
+                    vo.setClientName(customer.getName()));
+            if (vo.getClientName() == null) {
+                MapUtils.findAndThen(customerMap, vo.getClientId(), customer -> vo.setClientName(customer.getName()));
+            }
             MapUtils.findAndThen(noticeMap, vo.getNoticeId(),
                     notice -> vo.setNoticeCode(notice.getCode()));
+            MapUtils.findAndThen(userMap, vo.getOutboundUserId(),
+                    user -> vo.setOutboundUserName(user.getNickname()));
         });
     }
 
-}
+}
\ No newline at end of file

--
Gitblit v1.9.3