This commit is contained in:
2025-11-06 16:34:22 +08:00
parent 5f25910a4b
commit 3970cbbbe6

View File

@@ -463,22 +463,46 @@ public class TencentDocController extends BaseController {
}
}
// 从参数或配置中获取文档信息
String fileId = (String) params.get("fileId");
String sheetId = (String) params.get("sheetId");
// 可选参数:表头行号
Integer headerRow = params.get("headerRow") != null ?
Integer.valueOf(params.get("headerRow").toString()) : 1; // 表头所在行默认第1行从1开始
// 如果前端没有传fileId/sheetId则从配置中读取
final String CONFIG_KEY_PREFIX = "tencent:doc:auto:config:";
if (fileId == null || fileId.isEmpty()) {
fileId = redisCache.getCacheObject(CONFIG_KEY_PREFIX + "fileId");
if (fileId == null || fileId.isEmpty()) {
fileId = tencentDocConfig.getFileId();
}
}
if (sheetId == null || sheetId.isEmpty()) {
sheetId = redisCache.getCacheObject(CONFIG_KEY_PREFIX + "sheetId");
if (sheetId == null || sheetId.isEmpty()) {
sheetId = tencentDocConfig.getSheetId();
}
}
// 从配置中读取startRow数据起始行号
Integer configStartRow = redisCache.getCacheObject(CONFIG_KEY_PREFIX + "startRow");
if (configStartRow == null) {
configStartRow = tencentDocConfig.getStartRow();
}
// 表头行号 = 数据起始行 - 1例如数据从第3行开始表头在第2行
Integer headerRow = configStartRow != null ? configStartRow - 1 : 2;
// 可选参数是否强制从指定行开始如果为true则忽略Redis记录的最大行数
Boolean forceStart = params.get("forceStart") != null ?
Boolean.valueOf(params.get("forceStart").toString()) : false;
Integer forceStartRow = params.get("forceStartRow") != null ?
Integer.valueOf(params.get("forceStartRow").toString()) : null;
Integer.valueOf(params.get("forceStartRow").toString()) : configStartRow;
if (accessToken == null || fileId == null || sheetId == null) {
return AjaxResult.error("accessToken、fileIdsheetId不能为空");
return AjaxResult.error("文档配置不完整,请先配置 fileIdsheetId");
}
log.info("同步物流配置 - fileId: {}, sheetId: {}, 数据起始行: {}, 表头行: {}",
fileId, sheetId, configStartRow, headerRow);
// 生成Redis key用于存储该文件的工作表的上次处理最大行数
String redisKey = LAST_PROCESSED_ROW_KEY_PREFIX + fileId + ":" + sheetId;