feat(in-transit-transfer): 落地证据流重解析并纳入货代与排程配套改动
外部单号进入异动档自然键,圈档按 T-2 成熟封顶,当前归档可单独重解析。同批带上 Crane 禁整页刷新、ODM 白名单降级、排程抽屉与执行记录日期窗,以及 YAML 库存源下线。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
911afa0f73
commit
4c2a7e2a23
145 files changed
+11695
-4214
No files matched your search
@@ -1,8 +1,12 @@
|
||||
"""
|
||||
Freight RPA worker (PoC).
|
||||
scripts/freight_rpa/onhand/onhand_rpa_worker.py
|
||||
|
||||
轮询 trigger JSON → 按 connector_type 调用 DSV/Crane driver → 回调 hxops Tool API。
|
||||
DSV 逻辑见 dsv_driver / dsv_session / dsv_navigation / dsv_report_export;Crane 见 crane_*。
|
||||
用途:货代库存(onhand)RPA Worker——轮询 onhand trigger → 按 connector/profile 分组导出 →
|
||||
批末 ONHAND_BATCH_READY 回调 hxops。
|
||||
依赖:rpa_callbacks、dsv_report_export / dsv_session、crane_*、rpa_common。
|
||||
逻辑:同 Profile 组内单次登录串行导出;批级/Profile 打开失败时须为组内尚未入 results
|
||||
的源补 failed(error_code=rpa_profile_failed),再继续其他组并批末回调——与
|
||||
inbound/outbound「剩余单元补 failed」同契约,禁止静默丢源导致 awaiting 永挂。
|
||||
|
||||
Usage:
|
||||
python scripts/freight_rpa/onhand/onhand_rpa_worker.py
|
||||
@@ -1571,8 +1575,42 @@ def _handle_onhand_batch_trigger(trigger_path: Path, drop_dir: Path, processed_d
|
||||
record_result({"source_code": code, "warehouse_id": wh, "status": "failed", "success": False, "error_code": error_code, "error_message": str(exc), "worker_attempt": attempt, "validation_run_no": source.get("validation_run_no")})
|
||||
print(f"[onhand-batch] {site} export failed {code}/{wh}: {exc}", file=sys.stderr)
|
||||
except Exception as exc:
|
||||
for source in site_sources:
|
||||
record_result({"source_code": source.get("source_code"), "warehouse_id": source.get("warehouse_id"), "status": "failed", "success": False, "error_code": "rpa_profile_failed", "error_message": str(exc), "validation_run_no": source.get("validation_run_no")})
|
||||
# [STEP] 批级/Profile 组失败(含 launch_persistent_context 浏览器已关):
|
||||
# 只给尚未写入 results 的源补 failed;已 success/skipped/failed 的源不得二次追加
|
||||
# (否则批末 summary 重复计失败)。与 inbound/outbound 的「剩余单元补 failed 回调」
|
||||
# 同契约——onhand 走 results 数组 + 批末 ONHAND_BATCH_READY,不逐源 HTTP 终态。
|
||||
recorded_keys = {
|
||||
(
|
||||
str(item.get("source_code") or "").strip().upper(),
|
||||
str(item.get("warehouse_id") or item.get("expected_warehouse_id") or "").strip().upper(),
|
||||
)
|
||||
for item in results
|
||||
if isinstance(item, dict)
|
||||
}
|
||||
remaining = [
|
||||
source for source in site_sources
|
||||
if isinstance(source, dict)
|
||||
and (
|
||||
str(source.get("source_code") or "").strip().upper(),
|
||||
str(source.get("warehouse_id") or source.get("expected_warehouse_id") or "").strip().upper(),
|
||||
) not in recorded_keys
|
||||
]
|
||||
if remaining:
|
||||
print(
|
||||
f"[onhand-batch] open/group failed; recording {len(remaining)} source failure(s): "
|
||||
f"{str(exc)[:200]}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
for source in remaining:
|
||||
record_result({
|
||||
"source_code": source.get("source_code"),
|
||||
"warehouse_id": source.get("warehouse_id"),
|
||||
"status": "failed",
|
||||
"success": False,
|
||||
"error_code": "rpa_profile_failed",
|
||||
"error_message": str(exc),
|
||||
"validation_run_no": source.get("validation_run_no"),
|
||||
})
|
||||
finally:
|
||||
_close_batch_browser_resources(context, playwright, runtime_profile_dir)
|
||||
|
||||
|
||||
Reference in new issue
Block a user