feat: dedup expected data by handover_no before export submit
- store.get_existing_handover_nos: query PG expected_record.handover_no - inject dedup skip before submitting export in zto/yunda/anneng/shunxin - shunxin reads RTS handover_no from waybill-list view (method 1) - force-redownload switch threaded via task_spec -> dispatch -> impl - schema: add idx_expected_handover index Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -169,18 +169,18 @@ def yunda_smart_menu_click(page, menu_path):
|
||||
page.wait_for_timeout(1000)
|
||||
|
||||
|
||||
def yunda_expected_download(page):
|
||||
def yunda_expected_download(page, force=False):
|
||||
"""韵达:应到货物数据下载(内部含异常兜底重试,路由层无感)。"""
|
||||
|
||||
return with_retry(
|
||||
"韵达",
|
||||
"应到",
|
||||
lambda: yunda_expected_download_impl(page),
|
||||
lambda: yunda_expected_download_impl(page, force=force),
|
||||
lambda: yunda_reset(page),
|
||||
)
|
||||
|
||||
|
||||
def yunda_expected_download_impl(page):
|
||||
def yunda_expected_download_impl(page, force=False):
|
||||
"""韵达:应到货物数据下载(单次执行,无重试;供自动化测试探测原始结果用)。"""
|
||||
print("\n▶ 开始执行【韵达 - 应到货物数据下载】任务...")
|
||||
|
||||
@@ -283,6 +283,19 @@ def yunda_expected_download_impl(page):
|
||||
row_count = main_rows.count()
|
||||
print(f">> 当前视窗共捕获到活跃交接单记录: {row_count} 条")
|
||||
|
||||
# 【去重】加载本站已落库交接单号;force=True 或查询失败时 existing=空集(不去重)
|
||||
if force:
|
||||
existing = set()
|
||||
print(">> [去重] 强制重下,跳过去重。")
|
||||
else:
|
||||
try:
|
||||
from inbound_verify import store
|
||||
|
||||
existing = store.get_existing_handover_nos("韵达")
|
||||
except Exception as _e:
|
||||
existing = set()
|
||||
print(f">> [去重] 加载已落库交接单号失败,本次不去重: {_e}")
|
||||
|
||||
# 5. 逐行双击并提交导出
|
||||
for i in range(row_count):
|
||||
print(f" ⏳ 正在处理第 {i+1}/{row_count} 个交接单模块...")
|
||||
@@ -290,6 +303,11 @@ def yunda_expected_download_impl(page):
|
||||
|
||||
raw_no = current_row.locator("td").nth(1).inner_text().strip()
|
||||
|
||||
# 【去重】已落库的交接单号不再提交导出任务
|
||||
if raw_no in existing:
|
||||
print(f" ⏭️ 交接单号 {raw_no} 已落库,跳过提交导出。")
|
||||
continue
|
||||
|
||||
# 跳过已绑定的交接单
|
||||
bind_status = current_row.locator("td").nth(2).inner_text().strip()
|
||||
print(f" -> 交接单号: {raw_no} [绑定状态: {bind_status}]")
|
||||
@@ -404,7 +422,7 @@ def yunda_expected_download_impl(page):
|
||||
return False
|
||||
|
||||
|
||||
def yunda_actual_download(page):
|
||||
def yunda_actual_download(page, force=False):
|
||||
"""韵达:实到货物数据下载(内部含异常兜底重试,路由层无感)。"""
|
||||
|
||||
return with_retry(
|
||||
|
||||
Reference in New Issue
Block a user