From 381e02b9eccbe953b31d09f2af1c2ce77c816140 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期六, 07 十一月 2026 14:51:05 +0800
Subject: [PATCH] fix(mes): 隔离设备物料并支持销售产品映射

---
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/card/MesProCardController.java |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/card/MesProCardController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/card/MesProCardController.java
index 288f36b..b63f78c 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/card/MesProCardController.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/card/MesProCardController.java
@@ -9,6 +9,8 @@
 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.mes.controller.admin.pro.card.vo.MesProCardImportExcelVO;
+import cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.MesProCardImportRespVO;
 import cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.MesProCardPageReqVO;
 import cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.MesProCardRespVO;
 import cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.MesProCardSaveReqVO;
@@ -22,6 +24,7 @@
 import cn.iocoder.yudao.module.mes.service.pro.workorder.MesProWorkOrderService;
 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;
@@ -29,6 +32,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.Collections;
@@ -108,7 +112,6 @@
     @GetMapping("/get")
     @Operation(summary = "鑾峰緱鐢熶骇娴佽浆鍗�")
     @Parameter(name = "id", description = "缂栧彿", required = true, example = "1024")
-    @PreAuthorize("@ss.hasPermission('mes:pro-card:query')")
     public CommonResult<MesProCardRespVO> getCard(@RequestParam("id") Long id) {
         MesProCardDO card = cardService.getCard(id);
         if (card == null) {
@@ -119,7 +122,6 @@
 
     @GetMapping("/page")
     @Operation(summary = "鑾峰緱鐢熶骇娴佽浆鍗″垎椤�")
-    @PreAuthorize("@ss.hasPermission('mes:pro-card:query')")
     public CommonResult<PageResult<MesProCardRespVO>> getCardPage(@Valid MesProCardPageReqVO pageReqVO) {
         PageResult<MesProCardDO> pageResult = cardService.getCardPage(pageReqVO);
         return success(new PageResult<>(buildCardRespVOList(pageResult.getList()), pageResult.getTotal()));
@@ -138,6 +140,31 @@
         ExcelUtils.write(response, "鐢熶骇娴佽浆鍗�.xls", "鏁版嵁", MesProCardRespVO.class, voList);
     }
 
+    @GetMapping("/get-import-template")
+    @Operation(summary = "鑾峰緱鐢熶骇娴佽浆鍗″鍏ユā鏉�")
+    public void importTemplate(HttpServletResponse response) throws IOException {
+        List<MesProCardImportExcelVO> list = Collections.singletonList(
+                MesProCardImportExcelVO.builder()
+                        .code("CARD-001").workOrderCode("").itemCode("").batchCode("")
+                        .transferedQuantity(new java.math.BigDecimal("100")).remark("").build()
+        );
+        ExcelUtils.write(response, "鐢熶骇娴佽浆鍗″鍏ユā鏉�.xls", "鐢熶骇娴佽浆鍗″垪琛�", MesProCardImportExcelVO.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:pro-card:import')")
+    public CommonResult<MesProCardImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
+                                                            @RequestParam(value = "updateSupport", required = false,
+                                                                    defaultValue = "false") Boolean updateSupport) throws Exception {
+        List<MesProCardImportExcelVO> list = ExcelUtils.read(file, MesProCardImportExcelVO.class);
+        return success(cardService.importCardList(list, updateSupport));
+    }
+
     // ==================== 鎷兼帴 VO ====================
 
     private List<MesProCardRespVO> buildCardRespVOList(List<MesProCardDO> list) {

--
Gitblit v1.9.3