| | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.reel.vo.ProductCtcReelImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.reel.vo.ProductCtcReelImportRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.reel.vo.ProductCtcReelPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.reel.vo.ProductCtcReelRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.reel.vo.ProductCtcReelSaveReqVO; |
| | |
| | | import cn.iocoder.yudao.module.mes.service.pd.reel.ProductCtcReelService; |
| | | 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 jakarta.validation.Valid; |
| | | 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; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得盘具计算记录") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('mes:pd-ctc-reel:query')") |
| | | public CommonResult<ProductCtcReelRespVO> getReel(@RequestParam("id") Long id) { |
| | | ProductCtcReelDO reel = reelService.getReel(id); |
| | | if (reel == null) { |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得盘具计算记录分页") |
| | | @PreAuthorize("@ss.hasPermission('mes:pd-ctc-reel:query')") |
| | | public CommonResult<PageResult<ProductCtcReelRespVO>> getReelPage(@Valid ProductCtcReelPageReqVO pageReqVO) { |
| | | PageResult<ProductCtcReelDO> pageResult = reelService.getReelPage(pageReqVO); |
| | | return success(new PageResult<>(buildReelRespVOList(pageResult.getList()), pageResult.getTotal())); |
| | |
| | | @GetMapping("/list-by-ctc") |
| | | @Operation(summary = "获得指定换位导线产品的盘具计算记录列表") |
| | | @Parameter(name = "ctcId", description = "换位导线产品ID", required = true) |
| | | @PreAuthorize("@ss.hasPermission('mes:pd-ctc-reel:query')") |
| | | public CommonResult<List<ProductCtcReelRespVO>> getReelListByCtcId(@RequestParam("ctcId") Long ctcId) { |
| | | List<ProductCtcReelDO> list = reelService.getReelListByCtcId(ctcId); |
| | | return success(buildReelRespVOList(list)); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得盘具计算记录导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | List<ProductCtcReelImportExcelVO> list = Collections.singletonList( |
| | | ProductCtcReelImportExcelVO.builder() |
| | | .ctcOrderSpec("QQNB-2/120").reelType("木盘") |
| | | .reelOuterDiameter(new java.math.BigDecimal("1200")).reelInnerDiameter(new java.math.BigDecimal("630")) |
| | | .reelWidth(new java.math.BigDecimal("850")).maxCapacity(new java.math.BigDecimal("3")) |
| | | .recommendedLength(new java.math.BigDecimal("2.5")).netWeight(new java.math.BigDecimal("180")) |
| | | .grossWeight(new java.math.BigDecimal("200")).calcFormula("").remark("").build() |
| | | ); |
| | | ExcelUtils.write(response, "盘具计算记录导入模板.xls", "盘具计算记录列表", ProductCtcReelImportExcelVO.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-reel:import')") |
| | | public CommonResult<ProductCtcReelImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<ProductCtcReelImportExcelVO> list = ExcelUtils.read(file, ProductCtcReelImportExcelVO.class); |
| | | return success(reelService.importReelList(list, updateSupport)); |
| | | } |
| | | |
| | | // ==================== 拼接 VO ==================== |
| | | |
| | | private List<ProductCtcReelRespVO> buildReelRespVOList(List<ProductCtcReelDO> list) { |