| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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) { |