Unify export-task matching to time tolerance only (≤40s)
去掉顺心/中通/韵达/安能(应到) 导出任务认领时的标题/模块名校验, 统一改为仅按提交时间容差 ≤40 秒匹配本批任务。 理由:单账号无并发,时间窗内的任务必为本批所建;而站点可能调整 任务标题名,写死标题会导致匹配失败、任务已创建却一直查不到。 同步清理因此变成死代码的局部变量与函数形参。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -52,8 +52,6 @@ def set_cdp_port(port):
|
||||
CDP_PORT = int(port)
|
||||
|
||||
|
||||
# 导出下载页里,本批任务的“导出功能名称”固定为“交接单明细”。
|
||||
TARGET_EXPORT_FUNC = "交接单明细"
|
||||
FINAL_FILENAME = "安能-应到货物数据.xlsx"
|
||||
|
||||
# 进站交接单查询页 / 导出下载页的 URL 特征(用于在 /json 里定位/复用 tab 目标)。
|
||||
@@ -651,18 +649,20 @@ def _click_export_query(export_cdp):
|
||||
|
||||
|
||||
def _match_our_tasks(rows, export_times):
|
||||
"""从行里挑出本批任务(导出功能名称=交接单明细 且 导出时间接近某次导出时刻)。"""
|
||||
"""从行里挑出本批任务:仅按导出时间容差(40s)匹配,不校验导出功能名称。
|
||||
|
||||
单账号无并发,本批提交的任务必为我们创建;而站点可能调整导出功能名称,
|
||||
写死名称反而会导致匹配失败、任务一直查不到。
|
||||
"""
|
||||
matched = []
|
||||
for row in rows:
|
||||
cell = row.get("cellMap", {})
|
||||
if cell.get("导出功能名称") != TARGET_EXPORT_FUNC:
|
||||
continue
|
||||
time_str = cell.get("导出时间", "")
|
||||
try:
|
||||
row_time = datetime.strptime(time_str.strip(), "%Y-%m-%d %H:%M:%S")
|
||||
except ValueError:
|
||||
continue
|
||||
if any(abs((row_time - et).total_seconds()) <= 120 for et in export_times):
|
||||
if any(abs((row_time - et).total_seconds()) <= 40 for et in export_times):
|
||||
row["_time"] = row_time
|
||||
matched.append(row)
|
||||
return matched
|
||||
@@ -672,7 +672,7 @@ def poll_and_download_tasks(export_cdp, export_times, download_dir):
|
||||
"""轮询导出下载页直到本批任务齐全且全部“导出完成”,再逐个免对话框下载。"""
|
||||
total_expected = len(export_times)
|
||||
|
||||
print(f">> 轮询导出下载任务(期望 {total_expected} 个“{TARGET_EXPORT_FUNC}”)...")
|
||||
print(f">> 轮询导出下载任务(期望 {total_expected} 个)...")
|
||||
while True:
|
||||
wait_until(
|
||||
export_cdp,
|
||||
|
||||
Reference in New Issue
Block a user