| | |
| | | |
| | | 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.dv.subject.vo.MesDvSubjectImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.subject.vo.MesDvSubjectImportRespVO; |
| | | |
| | | @Tag(name = "管理后台 - MES 点检保养项目") |
| | | @RestController |
| | |
| | | BeanUtils.toBean(list, MesDvSubjectRespVO.class)); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得点检保养项目导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<MesDvSubjectImportExcelVO> list = Collections.singletonList( |
| | | MesDvSubjectImportExcelVO.builder() |
| | | .code("SUB-001").name("外观检查").type(1) |
| | | .content("检查外壳是否有裂纹").standard("外观完好") |
| | | .status(0).remark("") |
| | | .build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "点检保养项目导入模板.xls", "点检保养项目列表", MesDvSubjectImportExcelVO.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:dv-subject:import')") |
| | | public CommonResult<MesDvSubjectImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesDvSubjectImportExcelVO> list = ExcelUtils.read(file, MesDvSubjectImportExcelVO.class); |
| | | return success(subjectService.importSubjectList(list, updateSupport)); |
| | | } |
| | | |
| | | } |