Merge branch 'hugo-auto-transfer' into dev
This commit is contained in:
commit
ffbcb93b2e
2 files changed
+23
-6
No files matched your search
@@ -151,7 +151,10 @@ SHIPPING_NOTICE_LAYOUT_OCR_CROP_ENABLED=true
|
|||||||
SHIPPING_NOTICE_INVENTORY_SNAPSHOT_TTL_HOURS=24
|
SHIPPING_NOTICE_INVENTORY_SNAPSHOT_TTL_HOURS=24
|
||||||
# 共享目录逻辑标识(Ubuntu 后端与 Windows RPA 必须一致,用于哨兵校验与跨平台路径对齐)
|
# 共享目录逻辑标识(Ubuntu 后端与 Windows RPA 必须一致,用于哨兵校验与跨平台路径对齐)
|
||||||
FREIGHT_RPA_SHARED_SCOPE_ID=hxops-rpa-test-data
|
FREIGHT_RPA_SHARED_SCOPE_ID=hxops-rpa-test-data
|
||||||
FREIGHT_RPA_INVENTORY_TIMEOUT_SECONDS=900
|
# 两域超时须覆盖最坏批次总时长(10 站串行 + 单站失败重试可达 30 分钟+),
|
||||||
|
# 否则每轮对账会把仍在飞的健康批次误回收(2026-10-08 RUN20261008003113B726 实测教训)
|
||||||
|
FREIGHT_RPA_INVENTORY_TIMEOUT_SECONDS=3600
|
||||||
|
FREIGHT_RPA_RECEIPT_TIMEOUT_SECONDS=3600
|
||||||
FREIGHT_RPA_UPLOAD_MAX_ATTEMPTS=3
|
FREIGHT_RPA_UPLOAD_MAX_ATTEMPTS=3
|
||||||
FREIGHT_RPA_UPLOAD_TIMEOUT_SECONDS=30
|
FREIGHT_RPA_UPLOAD_TIMEOUT_SECONDS=30
|
||||||
FREIGHT_RPA_WORKER_HEARTBEAT_TTL_SECONDS=90
|
FREIGHT_RPA_WORKER_HEARTBEAT_TTL_SECONDS=90
|
||||||
|
|||||||
@@ -490,17 +490,25 @@ def _export_unit_download(
|
|||||||
page: Any,
|
page: Any,
|
||||||
context: Any,
|
context: Any,
|
||||||
drop_dir: Path,
|
drop_dir: Path,
|
||||||
|
attempt: int = 1,
|
||||||
) -> tuple[Any, Any]:
|
) -> tuple[Any, Any]:
|
||||||
"""
|
"""
|
||||||
导出单个收料单元的 Playwright Download;必要时干净页重试会话。
|
导出单个收料单元的 Playwright Download;必要时干净页重试会话。
|
||||||
|
|
||||||
|
Args:
|
||||||
|
attempt: 第几次尝试(1 起)。>1 时强制完整重导航(对齐库存 2026-09-20 AWSRTM
|
||||||
|
兜底:报表页导出菜单缺失属瞬态故障,绝不在错误页上直接重试,须回入口页
|
||||||
|
重选菜单进报表),且 prepare 的导航/会话类异常一并走干净页安全网
|
||||||
|
(凭据校验类 invalid/verification 为确定性失败,不重试)。
|
||||||
Returns:
|
Returns:
|
||||||
(download, page):download 为 Playwright Download;page 可能已切换为干净页。
|
(download, page):download 为 Playwright Download;page 可能已切换为干净页。
|
||||||
"""
|
"""
|
||||||
unit['__download_dir'] = str(drop_dir)
|
unit['__download_dir'] = str(drop_dir)
|
||||||
if connector == 'dbs':
|
if connector == 'dbs':
|
||||||
source = receipt_dbs_export.build_receipt_dsv_source(unit, entry_url=login_url)
|
source = receipt_dbs_export.build_receipt_dsv_source(unit, entry_url=login_url)
|
||||||
previous_unit = group[index - 1] if index > 0 else None
|
# 重试尝试强制完整重导航:不携带前一单元上下文,prepare 从入口页重选菜单进报表。
|
||||||
|
force_full_navigation = attempt > 1
|
||||||
|
previous_unit = group[index - 1] if (index > 0 and not force_full_navigation) else None
|
||||||
previous_source = (
|
previous_source = (
|
||||||
receipt_dbs_export.build_receipt_dsv_source(previous_unit, entry_url=login_url)
|
receipt_dbs_export.build_receipt_dsv_source(previous_unit, entry_url=login_url)
|
||||||
if previous_unit is not None else None
|
if previous_unit is not None else None
|
||||||
@@ -509,14 +517,18 @@ def _export_unit_download(
|
|||||||
try:
|
try:
|
||||||
skip_navigation = bool(
|
skip_navigation = bool(
|
||||||
dsv_report_export.prepare_dsv_batch_export_step(
|
dsv_report_export.prepare_dsv_batch_export_step(
|
||||||
page, login_url, previous_source, source, index=index,
|
page, login_url, previous_source, source,
|
||||||
|
index=0 if force_full_navigation else index,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
if not _is_login_session_error(exc):
|
# 安全网:登录/会话与导航类瞬态异常均新开干净页重跑完整准备;
|
||||||
|
# 仅凭据校验类(invalid/verification)确定性失败不重试(对齐库存)。
|
||||||
|
message = str(exc).lower()
|
||||||
|
if any(token in message for token in ('invalid', 'verification')):
|
||||||
raise
|
raise
|
||||||
print(
|
print(
|
||||||
f'[receipt-batch] dbs session prepare failed for {unit.get("source_code")}, '
|
f'[receipt-batch] dbs prepare failed for {unit.get("source_code")}, '
|
||||||
f'retry with clean page: {exc}',
|
f'retry with clean page: {exc}',
|
||||||
file=_sys.stderr,
|
file=_sys.stderr,
|
||||||
)
|
)
|
||||||
@@ -531,7 +543,8 @@ def _export_unit_download(
|
|||||||
)
|
)
|
||||||
return download, page
|
return download, page
|
||||||
|
|
||||||
first_in_profile = index == 0
|
# Crane 重试尝试同样强制完整重登导航(first_in_profile=True 走首源完整登录)。
|
||||||
|
first_in_profile = index == 0 or attempt > 1
|
||||||
try:
|
try:
|
||||||
download = receipt_crane_export.export_receipt_report(
|
download = receipt_crane_export.export_receipt_report(
|
||||||
page, unit, env=env, browser_timeout_ms=browser_timeout_ms(),
|
page, unit, env=env, browser_timeout_ms=browser_timeout_ms(),
|
||||||
@@ -643,6 +656,7 @@ def _process_units(body: dict[str, Any], drop_dir: Path) -> None:
|
|||||||
page=page,
|
page=page,
|
||||||
context=context,
|
context=context,
|
||||||
drop_dir=drop_dir,
|
drop_dir=drop_dir,
|
||||||
|
attempt=attempt,
|
||||||
)
|
)
|
||||||
output = _save_download(
|
output = _save_download(
|
||||||
download, drop_dir, unit, batch_run_no=batch_run_no,
|
download, drop_dir, unit, batch_run_no=batch_run_no,
|
||||||
|
|||||||
Reference in new issue
Block a user