| | |
| | | |
| | | 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.defect.vo.MesQcDefectImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.defect.vo.MesQcDefectImportRespVO; |
| | | |
| | | @Tag(name = "管理后台 - MES 缺陷类型") |
| | | @RestController |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得缺陷类型") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('mes:qc-defect:query')") |
| | | public CommonResult<MesQcDefectRespVO> getDefect(@RequestParam("id") Long id) { |
| | | MesQcDefectDO defect = defectService.getDefect(id); |
| | | return success(BeanUtils.toBean(defect, MesQcDefectRespVO.class)); |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得缺陷类型分页") |
| | | @PreAuthorize("@ss.hasPermission('mes:qc-defect:query')") |
| | | public CommonResult<PageResult<MesQcDefectRespVO>> getDefectPage(@Valid MesQcDefectPageReqVO pageReqVO) { |
| | | PageResult<MesQcDefectDO> pageResult = defectService.getDefectPage(pageReqVO); |
| | | return success(BeanUtils.toBean(pageResult, MesQcDefectRespVO.class)); |
| | |
| | | BeanUtils.toBean(list, MesQcDefectRespVO.class)); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得缺陷类型导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<MesQcDefectImportExcelVO> list = Collections.singletonList( |
| | | MesQcDefectImportExcelVO.builder() |
| | | .code("D-001").name("划伤").type(1).level(1) |
| | | .remark("") |
| | | .build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "缺陷类型导入模板.xls", "缺陷类型列表", MesQcDefectImportExcelVO.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-defect:import')") |
| | | public CommonResult<MesQcDefectImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesQcDefectImportExcelVO> list = ExcelUtils.read(file, MesQcDefectImportExcelVO.class); |
| | | return success(defectService.importDefectList(list, updateSupport)); |
| | | } |
| | | |
| | | } |