云
2026-10-25 d54fbc9d4f8981fa0f7f613b33a28a8cd4f764ea
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/meteringcheck/MesDvMeteringCheckController.java
@@ -35,6 +35,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.meteringcheck.vo.MesDvMeteringCheckImportExcelVO;
import cn.iocoder.yudao.module.mes.controller.admin.dv.meteringcheck.vo.MesDvMeteringCheckImportRespVO;
@Tag(name = "管理后台 - MES 计量检测记录")
@RestController
@@ -127,4 +131,36 @@
        });
    }
    @GetMapping("/get-import-template")
    @Operation(summary = "获得计量检测记录导入模板")
    public void importTemplate(HttpServletResponse response) throws IOException {
        // 手动创建导出 demo
        List<MesDvMeteringCheckImportExcelVO> list = Collections.singletonList(
                MesDvMeteringCheckImportExcelVO.builder()
                        .checkCode("CK-001").meteringCode("MD-001")
                        .checkDate(java.time.LocalDate.of(2026, 12, 31))
                        .checkOrg("市计量院").checkResult(1).certNo("")
                        .checkUserId(1L).nextCheckDate(java.time.LocalDate.of(2027, 12, 31))
                        .remark("")
                        .build()
        );
        // 输出
        ExcelUtils.write(response, "计量检测记录导入模板.xls", "计量检测记录列表", MesDvMeteringCheckImportExcelVO.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-metering-check:import')")
    public CommonResult<MesDvMeteringCheckImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
                                                           @RequestParam(value = "updateSupport", required = false,
                                                                   defaultValue = "false") Boolean updateSupport) throws Exception {
        List<MesDvMeteringCheckImportExcelVO> list = ExcelUtils.read(file, MesDvMeteringCheckImportExcelVO.class);
        return success(meteringCheckService.importMeteringCheckList(list, updateSupport));
    }
}