| | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.ipqc.vo.MesQcIpqcImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.ipqc.vo.MesQcIpqcImportRespVO; |
| | | |
| | | @Tag(name = "管理后台 - MES 过程检验单(IPQC)") |
| | | @RestController |
| | |
| | | }); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得过程检验单导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<MesQcIpqcImportExcelVO> list = Collections.singletonList( |
| | | MesQcIpqcImportExcelVO.builder() |
| | | .workOrderCode("WO-001").workstationCode("WS-001").name("过程检验单").type(1) |
| | | .checkQuantity(new java.math.BigDecimal("100")) |
| | | .qualifiedQuantity(new java.math.BigDecimal("98")) |
| | | .unqualifiedQuantity(new java.math.BigDecimal("2")) |
| | | .laborScrapQuantity(new java.math.BigDecimal("0")) |
| | | .materialScrapQuantity(new java.math.BigDecimal("0")) |
| | | .otherScrapQuantity(new java.math.BigDecimal("0")) |
| | | .checkResult(1).inspectDate(java.time.LocalDateTime.of(2026, 12, 31, 8, 0)) |
| | | .inspectorUserId(1L).remark("") |
| | | .build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "过程检验单导入模板.xls", "过程检验单列表", MesQcIpqcImportExcelVO.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:qc-ipqc:import')") |
| | | public CommonResult<MesQcIpqcImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesQcIpqcImportExcelVO> list = ExcelUtils.read(file, MesQcIpqcImportExcelVO.class); |
| | | return success(ipqcService.importIpqcList(list, updateSupport)); |
| | | } |
| | | |
| | | } |