This commit is contained in:
2025-03-24 18:25:05 +08:00
parent 98c5f0f154
commit f41a6b6e5b
2 changed files with 549 additions and 154 deletions

View File

@@ -479,8 +479,23 @@ export async function main(
.toArray();
if (records.length === 0) {
logWithTimestamp(`${page+1} 批次没有找到数据,结束处理`);
break;
logWithTimestamp(`${page+1} 批次没有找到数据,但将继续尝试后续批次...`);
// 更新查询条件,以确保能找到后续数据
// 更新查询时间,增加一定的时间窗口以尝试找到后续数据
const timeGap = 3600 * 1000; // 1小时的毫秒数
lastCreateTime += timeGap;
query.createTime = { $gt: lastCreateTime };
if (lastId) {
// 移除ID条件因为我们已经跳过了时间
delete query._id;
}
logWithTimestamp(`调整查询条件向前搜索: 创建时间 > ${new Date(lastCreateTime).toISOString()}`);
// 继续下一批次,不中断循环
continue;
}
logWithTimestamp(`获取到 ${records.length} 条记录,开始处理...`);