Unify export-task matching to time tolerance only (≤40s)
去掉顺心/中通/韵达/安能(应到) 导出任务认领时的标题/模块名校验, 统一改为仅按提交时间容差 ≤40 秒匹配本批任务。 理由:单账号无并发,时间窗内的任务必为本批所建;而站点可能调整 任务标题名,写死标题会导致匹配失败、任务已创建却一直查不到。 同步清理因此变成死代码的局部变量与函数形参。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -206,37 +206,35 @@ def shunxin_expected_download(page):
|
||||
pending_tasks = 0
|
||||
current_ready_timestamps = []
|
||||
|
||||
# 单账号无并发:仅按提交时间容差(40s)认领本批任务,不再校验任务标题
|
||||
# (站点可能调整标题名,写死标题会导致匹配失败、任务一直查不到)。
|
||||
for i in range(row_count):
|
||||
tds = rows.nth(i).locator("td")
|
||||
if tds.count() < 9:
|
||||
continue
|
||||
|
||||
submit_time_str = tds.nth(2).inner_text().strip()
|
||||
title_str = tds.nth(5).inner_text().strip()
|
||||
status_str = tds.nth(6).inner_text().strip()
|
||||
|
||||
if title_str == "发车管理运单列表":
|
||||
try:
|
||||
row_time = datetime.strptime(
|
||||
submit_time_str, "%Y-%m-%d %H:%M:%S"
|
||||
)
|
||||
matched = any(
|
||||
abs((row_time - et).total_seconds()) <= 60
|
||||
for et in export_times
|
||||
)
|
||||
try:
|
||||
row_time = datetime.strptime(submit_time_str, "%Y-%m-%d %H:%M:%S")
|
||||
matched = any(
|
||||
abs((row_time - et).total_seconds()) <= 40
|
||||
for et in export_times
|
||||
)
|
||||
|
||||
if matched:
|
||||
if status_str != "执行完成":
|
||||
pending_tasks += 1
|
||||
if submit_time_str not in current_ready_timestamps:
|
||||
print(
|
||||
f" ⏳ 任务 [{submit_time_str}] 状态为【{status_str}】,数据生成中..."
|
||||
)
|
||||
else:
|
||||
if submit_time_str not in current_ready_timestamps:
|
||||
current_ready_timestamps.append(submit_time_str)
|
||||
except Exception as e:
|
||||
print(f" ⚠️ 解析时间时出错: {e}")
|
||||
if matched:
|
||||
if status_str != "执行完成":
|
||||
pending_tasks += 1
|
||||
if submit_time_str not in current_ready_timestamps:
|
||||
print(
|
||||
f" ⏳ 任务 [{submit_time_str}] 状态为【{status_str}】,数据生成中..."
|
||||
)
|
||||
else:
|
||||
if submit_time_str not in current_ready_timestamps:
|
||||
current_ready_timestamps.append(submit_time_str)
|
||||
except Exception as e:
|
||||
print(f" ⚠️ 解析时间时出错: {e}")
|
||||
|
||||
if pending_tasks > 0:
|
||||
print(
|
||||
@@ -454,37 +452,35 @@ def shunxin_actual_download(page):
|
||||
pending_tasks = 0
|
||||
current_ready_timestamps = []
|
||||
|
||||
# 单账号无并发:仅按提交时间容差(40s)认领本批任务,不再校验任务标题
|
||||
# (站点可能调整标题名,写死标题会导致匹配失败、任务一直查不到)。
|
||||
for i in range(row_count):
|
||||
tds = rows.nth(i).locator("td")
|
||||
if tds.count() < 9:
|
||||
continue
|
||||
|
||||
submit_time_str = tds.nth(2).inner_text().strip()
|
||||
title_str = tds.nth(5).inner_text().strip()
|
||||
status_str = tds.nth(6).inner_text().strip()
|
||||
|
||||
if title_str.startswith("卸车扫描记录"):
|
||||
try:
|
||||
row_time = datetime.strptime(
|
||||
submit_time_str, "%Y-%m-%d %H:%M:%S"
|
||||
)
|
||||
matched = any(
|
||||
abs((row_time - et).total_seconds()) <= 60
|
||||
for et in export_times
|
||||
)
|
||||
try:
|
||||
row_time = datetime.strptime(submit_time_str, "%Y-%m-%d %H:%M:%S")
|
||||
matched = any(
|
||||
abs((row_time - et).total_seconds()) <= 40
|
||||
for et in export_times
|
||||
)
|
||||
|
||||
if matched:
|
||||
if status_str != "执行完成":
|
||||
pending_tasks += 1
|
||||
if submit_time_str not in current_ready_timestamps:
|
||||
print(
|
||||
f" ⏳ 任务 [{submit_time_str}] 状态为【{status_str}】,数据生成中..."
|
||||
)
|
||||
else:
|
||||
if submit_time_str not in current_ready_timestamps:
|
||||
current_ready_timestamps.append(submit_time_str)
|
||||
except Exception as e:
|
||||
print(f" ⚠️ 解析时间时出错: {e}")
|
||||
if matched:
|
||||
if status_str != "执行完成":
|
||||
pending_tasks += 1
|
||||
if submit_time_str not in current_ready_timestamps:
|
||||
print(
|
||||
f" ⏳ 任务 [{submit_time_str}] 状态为【{status_str}】,数据生成中..."
|
||||
)
|
||||
else:
|
||||
if submit_time_str not in current_ready_timestamps:
|
||||
current_ready_timestamps.append(submit_time_str)
|
||||
except Exception as e:
|
||||
print(f" ⚠️ 解析时间时出错: {e}")
|
||||
|
||||
if pending_tasks > 0:
|
||||
print(
|
||||
|
||||
Reference in New Issue
Block a user