| | |
| | | |
| | | 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 |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得质检方案") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('mes:qc-template:query')") |
| | | public CommonResult<MesQcTemplateRespVO> getTemplate(@RequestParam("id") Long id) { |
| | | MesQcTemplateDO template = templateService.getTemplate(id); |
| | | return success(BeanUtils.toBean(template, MesQcTemplateRespVO.class)); |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得质检方案分页") |
| | | @PreAuthorize("@ss.hasPermission('mes:qc-template:query')") |
| | | public CommonResult<PageResult<MesQcTemplateRespVO>> getTemplatePage(@Valid MesQcTemplatePageReqVO pageReqVO) { |
| | | PageResult<MesQcTemplateDO> pageResult = templateService.getTemplatePage(pageReqVO); |
| | | return success(BeanUtils.toBean(pageResult, MesQcTemplateRespVO.class)); |
| | |
| | | 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)); |
| | | } |
| | | |
| | | } |