diff --git a/inbound_verify/sites/shunxin.py b/inbound_verify/sites/shunxin.py index bca5418..89e6cab 100644 --- a/inbound_verify/sites/shunxin.py +++ b/inbound_verify/sites/shunxin.py @@ -149,7 +149,7 @@ def shunxin_merge_final(kind, tags): pass -def shunxin_expected_download(pages, foreground=True, force=False): +def shunxin_expected_download(pages, foreground=True, force=False, date=None): """顺心:应到货物数据下载(双账号/双归属地,内部含异常兜底重试与数据融合)。 pages 为该站点的 page 列表(双账号在同一窗口的各一个标签页)。 @@ -175,8 +175,8 @@ def shunxin_expected_download(pages, foreground=True, force=False): ok = with_retry( f"顺心-{tag}", "应到", - lambda p=pg, t=tag, f=force: shunxin_expected_download_impl( - p, out_tag=t, force=f + lambda p=pg, t=tag, f=force, d=date: shunxin_expected_download_impl( + p, out_tag=t, force=f, date=d ), lambda p=pg: shunxin_reset(p), ) @@ -187,7 +187,7 @@ def shunxin_expected_download(pages, foreground=True, force=False): return True -def shunxin_expected_download_impl(page, out_tag="", force=False): +def shunxin_expected_download_impl(page, out_tag="", force=False, date=None): """顺心:应到货物数据下载(单次执行,无重试;供自动化测试探测原始结果用)。 out_tag 为归属地标签时,合并产物命名为「顺心-{out_tag}-应到货物数据.xlsx」, @@ -224,11 +224,15 @@ def shunxin_expected_download_impl(page, out_tag="", force=False): # 2. 读取服务端日期偏移(0=今天,1=昨天…),单日范围:起止同日 offset = state_store.get_offset("顺心") today = datetime.now() - target = today - timedelta(days=offset) + if date: + target = datetime.strptime(date, "%Y-%m-%d") + else: + target = today - timedelta(days=offset) target_str = target.strftime("%Y-%m-%d") start_date_str = target_str today_str = target_str - print(f">> 正在设置查询日期: [{target_str}](偏移 {offset},0=今天)...") + src = f"指定 {date}" if date else f"偏移 {offset},0=今天" + print(f">> 正在设置查询日期: [{target_str}]({src})...") # 分两步精准呼出和点击时间控件 print(" >> 设置起始时间...") @@ -516,7 +520,7 @@ def shunxin_expected_download_impl(page, out_tag="", force=False): return False -def shunxin_actual_download(pages, foreground=True, force=False): +def shunxin_actual_download(pages, foreground=True, force=False, date=None): """顺心:实到货物数据下载(双账号/双归属地,内部含异常兜底重试与数据融合)。 与 shunxin_expected_download 同构:读归属地 → 去重校验 → 顺序各账号下载 → @@ -540,7 +544,9 @@ def shunxin_actual_download(pages, foreground=True, force=False): ok = with_retry( f"顺心-{tag}", "实到", - lambda p=pg, t=tag: shunxin_actual_download_impl(p, out_tag=t), + lambda p=pg, t=tag, d=date: shunxin_actual_download_impl( + p, out_tag=t, date=d + ), lambda p=pg: shunxin_reset(p), ) if not ok: @@ -550,7 +556,7 @@ def shunxin_actual_download(pages, foreground=True, force=False): return True -def shunxin_actual_download_impl(page, out_tag=""): +def shunxin_actual_download_impl(page, out_tag="", date=None): """顺心:实到货物数据下载(单次执行,无重试;供自动化测试探测原始结果用)。 out_tag 为归属地标签时,合并产物命名为「顺心-{out_tag}-实到货物数据.xlsx」, @@ -583,11 +589,15 @@ def shunxin_actual_download_impl(page, out_tag=""): # 2. 读取服务端日期偏移(0=今天,1=昨天…),单日范围:起止同日 offset = state_store.get_offset("顺心", "actual") today = datetime.now() - target = today - timedelta(days=offset) + if date: + target = datetime.strptime(date, "%Y-%m-%d") + else: + target = today - timedelta(days=offset) target_str = target.strftime("%Y-%m-%d") start_date_str = target_str today_str = target_str - print(f">> 正在设置查询日期: [{target_str}](偏移 {offset},0=今天)...") + src = f"指定 {date}" if date else f"偏移 {offset},0=今天" + print(f">> 正在设置查询日期: [{target_str}]({src})...") # 分两步精准呼出和点击时间控件 print(" >> 设置起始时间...")