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/qc/ipqc/MesQcIpqcController.java |   42 ++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ipqc/MesQcIpqcController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ipqc/MesQcIpqcController.java
index 3e1c52b..a809691 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ipqc/MesQcIpqcController.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ipqc/MesQcIpqcController.java
@@ -43,6 +43,10 @@
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
 import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
+import org.springframework.web.multipart.MultipartFile;
+import io.swagger.v3.oas.annotations.Parameters;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.ipqc.vo.MesQcIpqcImportExcelVO;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.ipqc.vo.MesQcIpqcImportRespVO;
 
 @Tag(name = "绠$悊鍚庡彴 - MES 杩囩▼妫�楠屽崟锛圛PQC锛�")
 @RestController
@@ -102,7 +106,6 @@
     @GetMapping("/get")
     @Operation(summary = "鑾峰緱杩囩▼妫�楠屽崟")
     @Parameter(name = "id", description = "缂栧彿", required = true, example = "1024")
-    @PreAuthorize("@ss.hasPermission('mes:qc-ipqc:query')")
     public CommonResult<MesQcIpqcRespVO> getIpqc(@RequestParam("id") Long id) {
         MesQcIpqcDO ipqc = ipqcService.getIpqc(id);
         return success(buildIpqcRespVOList(Collections.singletonList(ipqc)).get(0));
@@ -110,7 +113,6 @@
 
     @GetMapping("/page")
     @Operation(summary = "鑾峰緱杩囩▼妫�楠屽崟鍒嗛〉")
-    @PreAuthorize("@ss.hasPermission('mes:qc-ipqc:query')")
     public CommonResult<PageResult<MesQcIpqcRespVO>> getIpqcPage(@Valid MesQcIpqcPageReqVO pageReqVO) {
         PageResult<MesQcIpqcDO> pageResult = ipqcService.getIpqcPage(pageReqVO);
         return success(new PageResult<>(buildIpqcRespVOList(pageResult.getList()), pageResult.getTotal()));
@@ -170,4 +172,40 @@
         });
     }
 
+
+    @GetMapping("/get-import-template")
+    @Operation(summary = "鑾峰緱杩囩▼妫�楠屽崟瀵煎叆妯℃澘")
+    public void importTemplate(HttpServletResponse response) throws IOException {
+        // 鎵嬪姩鍒涘缓瀵煎嚭 demo
+        List<MesQcIpqcImportExcelVO> list = Collections.singletonList(
+                MesQcIpqcImportExcelVO.builder()
+                        .workOrderCode("WO-001").workstationCode("WS-001").name("杩囩▼妫�楠屽崟").type(1)
+                        .checkQuantity(new java.math.BigDecimal("100"))
+                        .qualifiedQuantity(new java.math.BigDecimal("98"))
+                        .unqualifiedQuantity(new java.math.BigDecimal("2"))
+                        .laborScrapQuantity(new java.math.BigDecimal("0"))
+                        .materialScrapQuantity(new java.math.BigDecimal("0"))
+                        .otherScrapQuantity(new java.math.BigDecimal("0"))
+                        .checkResult(1).inspectDate(java.time.LocalDateTime.of(2026, 12, 31, 8, 0))
+                        .inspectorUserId(1L).remark("")
+                        .build()
+        );
+        // 杈撳嚭
+        ExcelUtils.writeTemplate(response, "杩囩▼妫�楠屽崟瀵煎叆妯℃澘.xls", "杩囩▼妫�楠屽崟鍒楄〃", MesQcIpqcImportExcelVO.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:qc-ipqc:import')")
+    public CommonResult<MesQcIpqcImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
+                                                           @RequestParam(value = "updateSupport", required = false,
+                                                                   defaultValue = "false") Boolean updateSupport) throws Exception {
+        List<MesQcIpqcImportExcelVO> list = ExcelUtils.read(file, MesQcIpqcImportExcelVO.class);
+        return success(ipqcService.importIpqcList(list, updateSupport));
+    }
+
 }

--
Gitblit v1.9.3