feat(anneng): support date arg (date takes precedence over offset)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -855,15 +855,18 @@ def _load_query_days():
|
|||||||
return max(1, days)
|
return max(1, days)
|
||||||
|
|
||||||
|
|
||||||
def anneng_expected_download(force=False):
|
def anneng_expected_download(force=False, date=None):
|
||||||
"""安能:应到货物数据下载(内部含异常兜底重试,路由层无感)。"""
|
"""安能:应到货物数据下载(内部含异常兜底重试,路由层无感)。"""
|
||||||
|
|
||||||
return with_retry(
|
return with_retry(
|
||||||
"安能", "应到", lambda: anneng_expected_download_impl(force=force), anneng_reset
|
"安能",
|
||||||
|
"应到",
|
||||||
|
lambda: anneng_expected_download_impl(force=force, date=date),
|
||||||
|
anneng_reset,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def anneng_expected_download_impl(force=False):
|
def anneng_expected_download_impl(force=False, date=None):
|
||||||
"""安能:应到货物数据(运单信息)下载,完整流程(单次执行,无重试;供自动化测试用)。"""
|
"""安能:应到货物数据(运单信息)下载,完整流程(单次执行,无重试;供自动化测试用)。"""
|
||||||
print("\n▶ 开始执行【安能 - 应到货物数据下载】任务 ...")
|
print("\n▶ 开始执行【安能 - 应到货物数据下载】任务 ...")
|
||||||
download_dir = DOWNLOAD_DIR
|
download_dir = DOWNLOAD_DIR
|
||||||
@@ -874,11 +877,15 @@ def anneng_expected_download_impl(force=False):
|
|||||||
|
|
||||||
offset = state_store.get_offset("安能")
|
offset = state_store.get_offset("安能")
|
||||||
today = datetime.now()
|
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 = f"{target.year}-{target.month:02d}-{target.day:02d}"
|
target_str = f"{target.year}-{target.month:02d}-{target.day:02d}"
|
||||||
start_str = target_str
|
start_str = target_str
|
||||||
today_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})")
|
||||||
|
|
||||||
main_cdp = find_main_page_cdp()
|
main_cdp = find_main_page_cdp()
|
||||||
export_times = []
|
export_times = []
|
||||||
@@ -1258,13 +1265,15 @@ def _save_actual(rows, download_dir):
|
|||||||
print("====================================================")
|
print("====================================================")
|
||||||
|
|
||||||
|
|
||||||
def anneng_actual_download(force=False):
|
def anneng_actual_download(force=False, date=None):
|
||||||
"""安能:实到数据下载(内部含异常兜底重试,路由层无感)。"""
|
"""安能:实到数据下载(内部含异常兜底重试,路由层无感)。"""
|
||||||
|
|
||||||
return with_retry("安能", "实到", anneng_actual_download_impl, anneng_reset)
|
return with_retry(
|
||||||
|
"安能", "实到", lambda: anneng_actual_download_impl(date=date), anneng_reset
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def anneng_actual_download_impl():
|
def anneng_actual_download_impl(date=None):
|
||||||
"""安能:实到数据(网点到件扫描,子单)下载,完整流程(单次执行,无重试;供自动化测试用)。"""
|
"""安能:实到数据(网点到件扫描,子单)下载,完整流程(单次执行,无重试;供自动化测试用)。"""
|
||||||
print("\n▶ 开始执行【安能 - 实到货物数据下载】任务 ...")
|
print("\n▶ 开始执行【安能 - 实到货物数据下载】任务 ...")
|
||||||
download_dir = DOWNLOAD_DIR
|
download_dir = DOWNLOAD_DIR
|
||||||
@@ -1275,10 +1284,14 @@ def anneng_actual_download_impl():
|
|||||||
|
|
||||||
offset = state_store.get_offset("安能", "actual")
|
offset = state_store.get_offset("安能", "actual")
|
||||||
today = datetime.now()
|
today = datetime.now()
|
||||||
target = today - timedelta(days=offset)
|
if date:
|
||||||
|
target = datetime.strptime(date, "%Y-%m-%d")
|
||||||
|
else:
|
||||||
|
target = today - timedelta(days=offset)
|
||||||
start_str = f"{target.year}/{target.month:02d}/{target.day:02d} 00:00:00"
|
start_str = f"{target.year}/{target.month:02d}/{target.day:02d} 00:00:00"
|
||||||
end_str = f"{target.year}/{target.month:02d}/{target.day:02d} 23:59:59"
|
end_str = f"{target.year}/{target.month:02d}/{target.day:02d} 23:59:59"
|
||||||
print(f">> 扫描日期: [{start_str} 至 {end_str}](偏移 {offset},0=今天)")
|
src = f"指定 {date}" if date else f"偏移 {offset},0=今天"
|
||||||
|
print(f">> 扫描日期: [{start_str} 至 {end_str}]({src})")
|
||||||
|
|
||||||
main_cdp = find_main_page_cdp()
|
main_cdp = find_main_page_cdp()
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user