feat(in-transit-transfer): 自动调拨联动收料就绪并分层来源错误
- 调度整合:退役 in_transit_receipt_file_job,收料归档收敛 shipping_receipt_rpa_archive,排程注册表统一 - 自动调拨 Job:调拨前确保各来源当日收料文件就绪(缺失自动触发收料 RPA),严格等量匹配后生成 ERP 调拨单 - worker 手动唤醒:排程工作台支持手动唤醒与 runs 透视,heartbeat 协议同步 - 收料缺失幸存 T2:parse_failed 状态落库(迁移 q4c5) - 来源错误分层与 stale 时钟换源:改挂 inventory_checked_at 库存查得时刻,展示阈值与执行门禁解耦(迁移 t5a6) - 新增 wecom_sender 企微通知:每非空 Run 汇总一条,通知失败不影响 ERP 结果 - 同步排程工作台/调拨卡片前端、chat/admin 文案四语言、RPA 脚本与测试全家
This commit is contained in:
1 parent
993e581135
commit
abf3d48927
144 files changed
+10161
-2132
No files matched your search
@@ -66,7 +66,17 @@ def _env(name: str, default: str = "") -> str:
|
||||
|
||||
|
||||
def _browser_timeout_ms() -> int:
|
||||
return max(5_000, int(_env("FREIGHT_RPA_WORKER_BROWSER_TIMEOUT_MS", "60000") or "60000"))
|
||||
"""
|
||||
读取 Playwright/DSV 操作默认超时(毫秒)。
|
||||
|
||||
核心逻辑:环境变量 ``FREIGHT_RPA_WORKER_BROWSER_TIMEOUT_MS``,未设置时默认
|
||||
120000(2 分钟)。下限钳制为 5000,避免误配成过短值。库存与收料共用:
|
||||
含 View Report 后的 result_ready 轮询、page.goto、元素点击等。
|
||||
|
||||
Returns:
|
||||
int: 超时毫秒数,至少 5000。
|
||||
"""
|
||||
return max(5_000, int(_env("FREIGHT_RPA_WORKER_BROWSER_TIMEOUT_MS", "120000") or "120000"))
|
||||
|
||||
def _click_text(page: Any, text: str, *, exact: bool = True, timeout_ms: int | None = None) -> None:
|
||||
timeout = timeout_ms if timeout_ms is not None else _browser_timeout_ms()
|
||||
|
||||
@@ -3,7 +3,8 @@ scripts/freight_rpa/common/rpa_heartbeat.py
|
||||
|
||||
用途:货代 RPA Worker 向后端上报心跳(POST /api/shipping-notice/rpa/heartbeat)。
|
||||
依赖:rpa_common.env、urllib、socket。
|
||||
逻辑:由 freight_rpa_worker 主循环按 FREIGHT_RPA_WORKER_HEARTBEAT_SECONDS 周期调用;同步写入共享目录哨兵文件。
|
||||
逻辑:由库存/收料 Worker 主循环或守护线程按 FREIGHT_RPA_WORKER_HEARTBEAT_SECONDS 周期调用;
|
||||
库存声明 inventory_export,收料声明 receipt_export;库存侧可写共享目录哨兵。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -134,18 +135,22 @@ def build_heartbeat_payload(
|
||||
) -> dict[str, Any]:
|
||||
"""
|
||||
组装心跳 payload。
|
||||
核心逻辑:capabilities 含 inventory_export;Worker 开启上传时附加 freight_upload;
|
||||
shared_scope_id 用于跨平台路径对齐与环境隔离。
|
||||
|
||||
核心逻辑:库存 Worker 声明 inventory_export;收料 Worker(worker_id 以 -receipt
|
||||
结尾,或 trigger_dir 路径含 /receipt/)声明 receipt_export;开启上传时附加 freight_upload。
|
||||
"""
|
||||
hostname = socket.gethostname()
|
||||
capabilities = ["inventory_export"]
|
||||
worker_id = _resolve_worker_id(hostname)
|
||||
trigger_norm = str(trigger_dir or "").replace("\\", "/").lower()
|
||||
is_receipt = str(worker_id).lower().endswith("-receipt") or "/receipt/" in f"/{trigger_norm}/"
|
||||
capabilities = ["receipt_export" if is_receipt else "inventory_export"]
|
||||
upload_enabled = str(_env("FREIGHT_RPA_WORKER_UPLOAD_ENABLED", "false") or "false").strip().lower() in {
|
||||
"1", "true", "yes", "on",
|
||||
}
|
||||
if upload_enabled:
|
||||
capabilities.append("freight_upload")
|
||||
return {
|
||||
"worker_id": _resolve_worker_id(hostname),
|
||||
"worker_id": worker_id,
|
||||
"hostname": hostname,
|
||||
"environment": _resolve_worker_environment(),
|
||||
"capabilities": capabilities,
|
||||
|
||||
Reference in new issue
Block a user