| | |
| | | |
| | | 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.checkplan.vo.MesDvCheckPlanImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.MesDvCheckPlanImportRespVO; |
| | | |
| | | @Tag(name = "管理后台 - MES 点检保养方案") |
| | | @RestController |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得点检保养方案") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('mes:dv-check-plan:query')") |
| | | public CommonResult<MesDvCheckPlanRespVO> getCheckPlan(@RequestParam("id") Long id) { |
| | | MesDvCheckPlanDO checkPlan = checkPlanService.getCheckPlan(id); |
| | | return success(BeanUtils.toBean(checkPlan, MesDvCheckPlanRespVO.class)); |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得点检保养方案分页") |
| | | @PreAuthorize("@ss.hasPermission('mes:dv-check-plan:query')") |
| | | public CommonResult<PageResult<MesDvCheckPlanRespVO>> getCheckPlanPage(@Valid MesDvCheckPlanPageReqVO pageReqVO) { |
| | | PageResult<MesDvCheckPlanDO> pageResult = checkPlanService.getCheckPlanPage(pageReqVO); |
| | | return success(BeanUtils.toBean(pageResult, MesDvCheckPlanRespVO.class)); |
| | |
| | | BeanUtils.toBean(list, MesDvCheckPlanRespVO.class)); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得点检保养方案导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<MesDvCheckPlanImportExcelVO> list = Collections.singletonList( |
| | | MesDvCheckPlanImportExcelVO.builder() |
| | | .code("CP-001").name("注塑机日检方案").type(1) |
| | | .startDate(java.time.LocalDateTime.of(2026, 1, 1, 0, 0)) |
| | | .endDate(java.time.LocalDateTime.of(2026, 12, 31, 0, 0)) |
| | | .cycleType(1).cycleCount(1).remark("") |
| | | .build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.writeTemplate(response, "点检保养方案导入模板.xls", "点检保养方案列表", MesDvCheckPlanImportExcelVO.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-check-plan:import')") |
| | | public CommonResult<MesDvCheckPlanImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesDvCheckPlanImportExcelVO> list = ExcelUtils.read(file, MesDvCheckPlanImportExcelVO.class); |
| | | return success(checkPlanService.importCheckPlanList(list, updateSupport)); |
| | | } |
| | | |
| | | } |