From b0978a62cf2050170793e87fbd01db1760808043 Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期三, 04 十一月 2026 09:50:30 +0800
Subject: [PATCH] feat: 从长辉移植新高缺失的六个业务模块(安全生产/能耗/数采/备件/质检台账/售后问题回访)

---
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productsales/MesWmProductSalesController.java |   47 ++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 38 insertions(+), 9 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..6222b81 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,18 +8,21 @@
 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.mes.controller.admin.wm.productsales.vo.MesWmProductSalesImportExcelVO;
+import cn.iocoder.yudao.module.mes.controller.admin.wm.productsales.vo.MesWmProductSalesImportRespVO;
 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.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;
 import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Parameters;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import jakarta.annotation.Resource;
 import jakarta.servlet.http.HttpServletResponse;
@@ -27,6 +30,7 @@
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
 import java.util.*;
@@ -44,7 +48,7 @@
     @Resource
     private MesWmProductSalesService productSalesService;
     @Resource
-    private MesMdClientService clientService;
+    private CrmCustomerApi crmCustomerApi;
     @Resource
     private MesWmSalesNoticeService salesNoticeService;
 
@@ -75,7 +79,6 @@
     @GetMapping("/get")
     @Operation(summary = "鑾峰緱閿�鍞嚭搴撳崟")
     @Parameter(name = "id", description = "缂栧彿", required = true, example = "1024")
-    @PreAuthorize("@ss.hasPermission('mes:wm-product-sales:query')")
     public CommonResult<MesWmProductSalesRespVO> getProductSales(@RequestParam("id") Long id) {
         MesWmProductSalesDO sales = productSalesService.getProductSales(id);
         if (sales == null) {
@@ -86,7 +89,6 @@
 
     @GetMapping("/page")
     @Operation(summary = "鑾峰緱閿�鍞嚭搴撳崟鍒嗛〉")
-    @PreAuthorize("@ss.hasPermission('mes:wm-product-sales:query')")
     public CommonResult<PageResult<MesWmProductSalesRespVO>> getProductSalesPage(
             @Valid MesWmProductSalesPageReqVO pageReqVO) {
         PageResult<MesWmProductSalesDO> pageResult = productSalesService.getProductSalesPage(pageReqVO);
@@ -117,7 +119,6 @@
     @GetMapping("/check-quantity")
     @Operation(summary = "鏍¢獙閿�鍞嚭搴撳崟鏁伴噺")
     @Parameter(name = "id", description = "缂栧彿", required = true)
-    @PreAuthorize("@ss.hasPermission('mes:wm-product-sales:query')")
     public CommonResult<Boolean> checkProductSalesQuantity(@RequestParam("id") Long id) {
         return success(productSalesService.checkProductSalesQuantity(id));
     }
@@ -157,6 +158,34 @@
         return success(true);
     }
 
+    @GetMapping("/get-import-template")
+    @Operation(summary = "鑾峰緱閿�鍞嚭搴撳崟瀵煎叆妯℃澘")
+    public void importTemplate(HttpServletResponse response) throws IOException {
+        // 鎵嬪姩鍒涘缓瀵煎嚭 demo
+        List<MesWmProductSalesImportExcelVO> list = Collections.singletonList(
+                MesWmProductSalesImportExcelVO.builder()
+                        .code("XS001").name("绀轰緥閿�鍞嚭搴撳崟")
+                        .salesDate(java.time.LocalDateTime.now()).salesOrderCode("SO001")
+                        .contactName("寮犱笁").remark("").build()
+        );
+        // 杈撳嚭
+        ExcelUtils.writeTemplate(response, "閿�鍞嚭搴撳崟瀵煎叆妯℃澘.xls", "閿�鍞嚭搴撳崟鍒楄〃", MesWmProductSalesImportExcelVO.class, list);
+    }
+
+    @PostMapping("/import")
+    @Operation(summary = "瀵煎叆閿�鍞嚭搴撳崟")
+    @Parameters({
+            @Parameter(name = "file", description = "Excel 鏂囦欢", required = true),
+            @Parameter(name = "updateSupport", description = "鏄惁鏀寔鏇存柊锛岄粯璁や负 false", example = "true")
+    })
+    @PreAuthorize("@ss.hasPermission('mes:wm-product-sales:import')")
+    public CommonResult<MesWmProductSalesImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
+                                                                   @RequestParam(value = "updateSupport", required = false,
+                                                                           defaultValue = "false") Boolean updateSupport) throws Exception {
+        List<MesWmProductSalesImportExcelVO> list = ExcelUtils.read(file, MesWmProductSalesImportExcelVO.class);
+        return success(productSalesService.importProductSalesList(list, updateSupport));
+    }
+
     // ==================== 鎷兼帴 VO ====================
 
     private List<MesWmProductSalesRespVO> buildRespVOList(List<MesWmProductSalesDO> list) {
@@ -164,14 +193,14 @@
             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));
         // 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()));
             MapUtils.findAndThen(noticeMap, vo.getNoticeId(),
                     notice -> vo.setNoticeCode(notice.getCode()));
         });

--
Gitblit v1.9.3