1
This commit is contained in:
@@ -110,17 +110,17 @@ public class TencentDocConfigController extends BaseController {
|
||||
if (currentProgress <= (startRow + 49)) {
|
||||
// 进度较小,下次从配置起始行开始
|
||||
nextStartRow = startRow;
|
||||
progressHint = String.format("已同步到第 %d 行,下次将从第 %d 行重新开始(进度较小)",
|
||||
progressHint = String.format("已读取到第 %d 行,下次将从第 %d 行重新开始(进度较小)",
|
||||
currentProgress, nextStartRow);
|
||||
} else if (currentProgress > threshold) {
|
||||
// 进度较大,下次回溯100行
|
||||
nextStartRow = currentProgress - 100;
|
||||
progressHint = String.format("已同步到第 %d 行,下次将从第 %d 行开始(回溯100行,防止遗漏)",
|
||||
// 进度较大,下次回溯100行(但不能小于起始行)
|
||||
nextStartRow = Math.max(startRow, currentProgress - 100);
|
||||
progressHint = String.format("已读取到第 %d 行,下次将从第 %d 行开始(回溯100行,防止遗漏)",
|
||||
currentProgress, nextStartRow);
|
||||
} else {
|
||||
// 进度在阈值范围内,下次从配置起始行开始
|
||||
nextStartRow = startRow;
|
||||
progressHint = String.format("已同步到第 %d 行,下次将从第 %d 行重新开始",
|
||||
progressHint = String.format("已读取到第 %d 行,下次将从第 %d 行重新开始",
|
||||
currentProgress, nextStartRow);
|
||||
}
|
||||
|
||||
|
||||
@@ -724,9 +724,10 @@ public class TencentDocController extends BaseController {
|
||||
lastMaxRow, effectiveStartRow + 49, startRow);
|
||||
} else if (lastMaxRow > threshold) {
|
||||
// 进度较大(超过阈值),往回退100行,防止遗漏
|
||||
startRow = lastMaxRow - 100;
|
||||
log.info("上次进度 {} 较大(>{}),回溯100行,从第 {} 行开始(防止遗漏)",
|
||||
lastMaxRow, threshold, startRow);
|
||||
// 但不能小于配置的起始行(避免读取表头行)
|
||||
startRow = Math.max(effectiveStartRow, lastMaxRow - 100);
|
||||
log.info("上次进度 {} 较大(>{}),回溯100行,从第 {} 行开始(防止遗漏,最小为{})",
|
||||
lastMaxRow, threshold, startRow, effectiveStartRow);
|
||||
} else {
|
||||
// 进度在阈值范围内,重新从配置起始行开始
|
||||
startRow = effectiveStartRow;
|
||||
@@ -885,7 +886,6 @@ public class TencentDocController extends BaseController {
|
||||
int filledCount = 0;
|
||||
int skippedCount = 0;
|
||||
int errorCount = 0;
|
||||
int currentMaxRow = startRow - 1; // 记录当前处理的最大行号(Excel行号,从1开始)
|
||||
|
||||
JSONArray updates = new JSONArray(); // 存储需要更新的行和值
|
||||
|
||||
@@ -897,7 +897,6 @@ public class TencentDocController extends BaseController {
|
||||
|
||||
// 计算实际的行号(Excel行号,从1开始)
|
||||
int excelRow = startRow + i;
|
||||
currentMaxRow = Math.max(currentMaxRow, excelRow);
|
||||
|
||||
// 获取单号
|
||||
String orderNo = row.getString(orderNoColumn);
|
||||
@@ -1006,11 +1005,11 @@ public class TencentDocController extends BaseController {
|
||||
log.info("批量填充物流链接完成 - 成功: {}, 跳过: {}, 错误: {}", successUpdates, skippedCount, errorCount);
|
||||
}
|
||||
|
||||
// 更新Redis中记录的最大行数(如果本次处理了数据)
|
||||
if (currentMaxRow >= startRow) {
|
||||
redisCache.setCacheObject(redisKey, currentMaxRow, 30, TimeUnit.DAYS);
|
||||
log.info("更新上次处理的最大行数 - 文件ID: {}, 工作表ID: {}, 最大行: {}", fileId, sheetId, currentMaxRow);
|
||||
}
|
||||
// 记录本次读取的最大行号(无论是否处理,都记录读取范围,确保不会漏掉中间空行后的数据)
|
||||
int currentMaxRow = endRow;
|
||||
redisCache.setCacheObject(redisKey, currentMaxRow, 30, TimeUnit.DAYS);
|
||||
log.info("更新上次读取的最大行数 - 文件ID: {}, 工作表ID: {}, 本次读取范围: {}-{}, 记录最大行: {}",
|
||||
fileId, sheetId, startRow, endRow, currentMaxRow);
|
||||
|
||||
// 计算下次同步的起始行(根据回溯机制)
|
||||
int threshold = effectiveStartRow + 100;
|
||||
@@ -1022,8 +1021,8 @@ public class TencentDocController extends BaseController {
|
||||
nextStartRow = effectiveStartRow;
|
||||
nextSyncHint = String.format("下次将从第 %d 行重新开始(进度较小)", nextStartRow);
|
||||
} else if (currentMaxRow > threshold) {
|
||||
// 进度较大,下次回溯100行
|
||||
nextStartRow = currentMaxRow - 100;
|
||||
// 进度较大,下次回溯100行(但不能小于配置的起始行)
|
||||
nextStartRow = Math.max(effectiveStartRow, currentMaxRow - 100);
|
||||
nextSyncHint = String.format("下次将从第 %d 行开始(回溯100行,防止遗漏)", nextStartRow);
|
||||
} else {
|
||||
// 进度在阈值范围内,下次从配置起始行开始
|
||||
|
||||
Reference in New Issue
Block a user