| | |
| | | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import java.util.Collections; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.MesQcTemplateImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.MesQcTemplateImportRespVO; |
| | | |
| | | @Tag(name = "管理后台 - MES 质检方案") |
| | | @RestController |
| | |
| | | BeanUtils.toBean(list, MesQcTemplateRespVO.class)); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得质检方案导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<MesQcTemplateImportExcelVO> list = Collections.singletonList( |
| | | MesQcTemplateImportExcelVO.builder() |
| | | .code("TP-001").name("外观检验方案").types("1,2") |
| | | .status(0).remark("") |
| | | .build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "质检方案导入模板.xls", "质检方案列表", MesQcTemplateImportExcelVO.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-template:import')") |
| | | public CommonResult<MesQcTemplateImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesQcTemplateImportExcelVO> list = ExcelUtils.read(file, MesQcTemplateImportExcelVO.class); |
| | | return success(templateService.importTemplateList(list, updateSupport)); |
| | | } |
| | | |
| | | } |