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