From c47c8647f514eaa8c6a7624185b55738e8625c2c Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期四, 05 十一月 2026 13:37:31 +0800
Subject: [PATCH] feat(product-issue): 支持按任务工序校验和选择领料物料

---
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pd/ctc/ProductCtcController.java |   37 ++++++++++++++++++++++++++++++++-----
 1 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pd/ctc/ProductCtcController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pd/ctc/ProductCtcController.java
index 7b32418..6bf5518 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pd/ctc/ProductCtcController.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pd/ctc/ProductCtcController.java
@@ -15,6 +15,7 @@
 import cn.iocoder.yudao.module.mes.service.pd.ctc.ProductCtcService;
 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;
@@ -22,6 +23,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;
@@ -71,7 +73,6 @@
     @GetMapping("/get")
     @Operation(summary = "鑾峰緱鎹綅瀵肩嚎浜у搧鎶�鏈弬鏁�")
     @Parameter(name = "id", description = "缂栧彿", required = true, example = "1024")
-    @PreAuthorize("@ss.hasPermission('mes:pd-ctc:query')")
     public CommonResult<ProductCtcRespVO> getCtc(@RequestParam("id") Long id) {
         ProductCtcDO ctc = ctcService.getCtc(id);
         if (ctc == null) {
@@ -82,7 +83,6 @@
 
     @GetMapping("/page")
     @Operation(summary = "鑾峰緱鎹綅瀵肩嚎浜у搧鎶�鏈弬鏁板垎椤�")
-    @PreAuthorize("@ss.hasPermission('mes:pd-ctc:query')")
     public CommonResult<PageResult<ProductCtcRespVO>> getCtcPage(@Valid ProductCtcPageReqVO pageReqVO) {
         PageResult<ProductCtcDO> pageResult = ctcService.getCtcPage(pageReqVO);
         return success(new PageResult<>(buildCtcRespVOList(pageResult.getList()), pageResult.getTotal()));
@@ -102,25 +102,52 @@
 
     @PostMapping("/calc-angle")
     @Operation(summary = "缁曞寘瑙掑害璁$畻锛堝凡鐭ョ焊甯﹀搴︼級")
-    @PreAuthorize("@ss.hasPermission('mes:pd-ctc:query')")
     public CommonResult<ProductCtcAngleCalcRespVO> calcAngle(@Valid @RequestBody ProductCtcAngleCalcReqVO reqVO) {
         return success(ctcService.calcAngle(reqVO));
     }
 
     @PostMapping("/calc-resistance")
     @Operation(summary = "鐩存祦鐢甸樆璁$畻锛堟寜娓╁害鎹㈢畻锛�")
-    @PreAuthorize("@ss.hasPermission('mes:pd-ctc:query')")
     public CommonResult<ProductCtcResistanceCalcRespVO> calcResistance(@Valid @RequestBody ProductCtcResistanceCalcReqVO reqVO) {
         return success(ctcService.calcResistance(reqVO));
     }
 
     @PostMapping("/calc-reel")
     @Operation(summary = "鐩樺叿瀹归噺璁$畻锛堟瘡鐩樻渶澶ч暱搴︼級")
-    @PreAuthorize("@ss.hasPermission('mes:pd-ctc:query')")
     public CommonResult<ProductCtcReelCalcRespVO> calcReelCapacity(@Valid @RequestBody ProductCtcReelCalcReqVO reqVO) {
         return success(ctcService.calcReelCapacity(reqVO));
     }
 
+    @GetMapping("/get-import-template")
+    @Operation(summary = "鑾峰緱鎹綅瀵肩嚎浜у搧鎶�鏈弬鏁板鍏ユā鏉�")
+    public void importTemplate(HttpServletResponse response) throws IOException {
+        List<ProductCtcImportExcelVO> list = Collections.singletonList(
+                ProductCtcImportExcelVO.builder()
+                        .itemCode("").orderSpec("QQNB-2/120").bareConductorSpec("1.27脳5.7")
+                        .enameledSpec("0.11脳5.7").transpositionSpec("19.08脳12.6").conductorType("copper")
+                        .crossSection(new java.math.BigDecimal("120")).outerDiameter(new java.math.BigDecimal("19.08"))
+                        .resistance20c(new java.math.BigDecimal("0.002937")).wrappingAngle(new java.math.BigDecimal("18.02"))
+                        .insulationThickness(new java.math.BigDecimal("0.75")).ratedVoltage("110").testVoltage("230")
+                        .minBendingRadius(new java.math.BigDecimal("500")).weightPerKm(new java.math.BigDecimal("1200"))
+                        .standardCode("GB/T 7095-2008").remark("").build()
+        );
+        ExcelUtils.write(response, "鎹綅瀵肩嚎浜у搧鎶�鏈弬鏁板鍏ユā鏉�.xls", "鎹綅瀵肩嚎浜у搧鎶�鏈弬鏁板垪琛�", ProductCtcImportExcelVO.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:pd-ctc:import')")
+    public CommonResult<ProductCtcImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
+                                                            @RequestParam(value = "updateSupport", required = false,
+                                                                    defaultValue = "false") Boolean updateSupport) throws Exception {
+        List<ProductCtcImportExcelVO> list = ExcelUtils.read(file, ProductCtcImportExcelVO.class);
+        return success(ctcService.importCtcList(list, updateSupport));
+    }
+
     // ==================== 鎷兼帴 VO ====================
 
     private List<ProductCtcRespVO> buildCtcRespVOList(List<ProductCtcDO> list) {

--
Gitblit v1.9.3