gaoluyang
2026-10-18 6e3d8e950e7dec3551bee3512673e1fc2d384d2b
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkrecord/MesDvCheckRecordController.java
@@ -37,6 +37,10 @@
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.checkrecord.vo.MesDvCheckRecordImportExcelVO;
import cn.iocoder.yudao.module.mes.controller.admin.dv.checkrecord.vo.MesDvCheckRecordImportRespVO;
@Tag(name = "管理后台 - MES 设备点检记录")
@RestController
@@ -147,4 +151,34 @@
        });
    }
    @GetMapping("/get-import-template")
    @Operation(summary = "获得设备点检记录导入模板")
    public void importTemplate(HttpServletResponse response) throws IOException {
        // 手动创建导出 demo
        List<MesDvCheckRecordImportExcelVO> list = Collections.singletonList(
                MesDvCheckRecordImportExcelVO.builder()
                        .machineryCode("MC-001").planCode("CP-001")
                        .checkTime(java.time.LocalDateTime.of(2026, 12, 31, 8, 0))
                        .userId(1L).remark("")
                        .build()
        );
        // 输出
        ExcelUtils.write(response, "设备点检记录导入模板.xls", "设备点检记录列表", MesDvCheckRecordImportExcelVO.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-record:import')")
    public CommonResult<MesDvCheckRecordImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
                                                           @RequestParam(value = "updateSupport", required = false,
                                                                   defaultValue = "false") Boolean updateSupport) throws Exception {
        List<MesDvCheckRecordImportExcelVO> list = ExcelUtils.read(file, MesDvCheckRecordImportExcelVO.class);
        return success(checkRecordService.importCheckRecordList(list, updateSupport));
    }
}