| | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.MesDvMaintenRecordImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.MesDvMaintenRecordImportRespVO; |
| | | |
| | | @Tag(name = "管理后台 - MES 设备保养记录") |
| | | @RestController |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得设备保养记录") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('mes:dv-mainten-record:query')") |
| | | public CommonResult<MesDvMaintenRecordRespVO> getMaintenRecord(@RequestParam("id") Long id) { |
| | | MesDvMaintenRecordDO maintenRecord = maintenRecordService.getMaintenRecord(id); |
| | | if (maintenRecord == null) { |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得设备保养记录分页") |
| | | @PreAuthorize("@ss.hasPermission('mes:dv-mainten-record:query')") |
| | | public CommonResult<PageResult<MesDvMaintenRecordRespVO>> getMaintenRecordPage(@Valid MesDvMaintenRecordPageReqVO pageReqVO) { |
| | | PageResult<MesDvMaintenRecordDO> pageResult = maintenRecordService.getMaintenRecordPage(pageReqVO); |
| | | return success(new PageResult<>(buildMaintenRecordRespVOList(pageResult.getList()), pageResult.getTotal())); |
| | |
| | | }); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得设备保养记录导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<MesDvMaintenRecordImportExcelVO> list = Collections.singletonList( |
| | | MesDvMaintenRecordImportExcelVO.builder() |
| | | .machineryCode("MC-001").planCode("CP-002") |
| | | .maintenTime(java.time.LocalDateTime.of(2026, 12, 31, 8, 0)) |
| | | .userId(1L).remark("") |
| | | .build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.writeTemplate(response, "设备保养记录导入模板.xls", "设备保养记录列表", MesDvMaintenRecordImportExcelVO.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-mainten-record:import')") |
| | | public CommonResult<MesDvMaintenRecordImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesDvMaintenRecordImportExcelVO> list = ExcelUtils.read(file, MesDvMaintenRecordImportExcelVO.class); |
| | | return success(maintenRecordService.importMaintenRecordList(list, updateSupport)); |
| | | } |
| | | |
| | | } |