From 481d8165f26fc7e37f0e87f6444ac0340bb563a3 Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期二, 03 十一月 2026 18:53:22 +0800
Subject: [PATCH] fix: 移植长辉已验证的四类接口 500/体验问题(不含物料颜色字段)

---
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/machinery/MesDvMachineryTypeController.java |   39 +++++++++++++++++++++++++++++++++++++--
 1 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/machinery/MesDvMachineryTypeController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/machinery/MesDvMachineryTypeController.java
index e534d76..bb9f597 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/machinery/MesDvMachineryTypeController.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/machinery/MesDvMachineryTypeController.java
@@ -1,4 +1,7 @@
 package cn.iocoder.yudao.module.mes.controller.admin.dv.machinery;
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+import jakarta.servlet.http.HttpServletResponse;
+import java.io.IOException;
 
 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
@@ -21,6 +24,11 @@
 
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
+import org.springframework.web.multipart.MultipartFile;
+import io.swagger.v3.oas.annotations.Parameters;
+import java.util.Collections;
+import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.type.MesDvMachineryTypeImportExcelVO;
+import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.type.MesDvMachineryTypeImportRespVO;
 
 @Tag(name = "绠$悊鍚庡彴 - MES 璁惧绫诲瀷")
 @RestController
@@ -58,7 +66,6 @@
     @GetMapping("/get")
     @Operation(summary = "鑾峰緱璁惧绫诲瀷")
     @Parameter(name = "id", description = "缂栧彿", required = true, example = "1024")
-    @PreAuthorize("@ss.hasPermission('mes:dv-machinery-type:query')")
     public CommonResult<MesDvMachineryTypeRespVO> getMachineryType(@RequestParam("id") Long id) {
         MesDvMachineryTypeDO machineryType = machineryTypeService.getMachineryType(id);
         return success(BeanUtils.toBean(machineryType, MesDvMachineryTypeRespVO.class));
@@ -66,7 +73,6 @@
 
     @GetMapping("/list")
     @Operation(summary = "鑾峰緱璁惧绫诲瀷鍒楄〃")
-    @PreAuthorize("@ss.hasPermission('mes:dv-machinery-type:query')")
     public CommonResult<List<MesDvMachineryTypeRespVO>> getMachineryTypeList(@Valid MesDvMachineryTypeListReqVO listReqVO) {
         List<MesDvMachineryTypeDO> list = machineryTypeService.getMachineryTypeList(listReqVO);
         return success(BeanUtils.toBean(list, MesDvMachineryTypeRespVO.class));
@@ -82,4 +88,33 @@
                 .setCode(machineryType.getCode()).setRemark(machineryType.getRemark())));
     }
 
+
+    @GetMapping("/get-import-template")
+    @Operation(summary = "鑾峰緱璁惧绫诲瀷瀵煎叆妯℃澘")
+    public void importTemplate(HttpServletResponse response) throws IOException {
+        // 鎵嬪姩鍒涘缓瀵煎嚭 demo
+        List<MesDvMachineryTypeImportExcelVO> list = Collections.singletonList(
+                MesDvMachineryTypeImportExcelVO.builder()
+                        .code("MT-001").name("鏁版帶鏈哄簥").parentCode("")
+                        .status(0).sort(0).remark("")
+                        .build()
+        );
+        // 杈撳嚭
+        ExcelUtils.write(response, "璁惧绫诲瀷瀵煎叆妯℃澘.xls", "璁惧绫诲瀷鍒楄〃", MesDvMachineryTypeImportExcelVO.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:dv-machinery-type:import')")
+    public CommonResult<MesDvMachineryTypeImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
+                                                           @RequestParam(value = "updateSupport", required = false,
+                                                                   defaultValue = "false") Boolean updateSupport) throws Exception {
+        List<MesDvMachineryTypeImportExcelVO> list = ExcelUtils.read(file, MesDvMachineryTypeImportExcelVO.class);
+        return success(machineryTypeService.importMachineryTypeList(list, updateSupport));
+    }
+
 }

--
Gitblit v1.9.3