feat(xispeak): 新增Excel校验接口,只校验不保存到数据库

- JeecgController 新增 checkExcelByEasyExcel 基类方法,batchHandler 传 null 跳过入库
- ExcelImportListener 支持 batchHandler 为 null 时不攒 batch 内存
- BgXiSpeakController 新增 /checkExcelByEasyExcel 接口

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
wsm
2026-06-30 10:05:13 +08:00
co-authored by Claude Opus 4.7
parent d59adeeaf7
commit 16343d2e99
3 changed files with 51 additions and 7 deletions
@@ -47,7 +47,7 @@ public class ExcelImportListener<T> implements ReadListener<Map<Integer, String>
this.displayToCode = displayToCode;
this.batchHandler = batchHandler;
this.errorHandler = errorHandler;
this.batch = new ArrayList<>(batchSize);
this.batch = batchHandler != null ? new ArrayList<>(batchSize) : null;
this.errorBatch = new ArrayList<>(batchSize);
}
@@ -133,12 +133,14 @@ public class ExcelImportListener<T> implements ReadListener<Map<Integer, String>
return;
}
// 4. 成功加入批次
batch.add(obj);
// 4. 成功计数
successCount[0]++;
if (batch.size() >= batchSize) {
batchHandler.accept(new ArrayList<>(batch));
batch.clear();
if (batchHandler != null) {
batch.add(obj);
if (batch.size() >= batchSize) {
batchHandler.accept(new ArrayList<>(batch));
batch.clear();
}
}
} catch (Exception e) {
@@ -158,7 +160,7 @@ public class ExcelImportListener<T> implements ReadListener<Map<Integer, String>
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
if (!batch.isEmpty()) {
if (batchHandler != null && batch != null && !batch.isEmpty()) {
batchHandler.accept(new ArrayList<>(batch));
batch.clear();
}