From e40743871c45ecac6605a9a4c05ce70698ad7177 Mon Sep 17 00:00:00 2001 From: caohuipeng Date: Mon, 7 Sep 2026 18:29:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(rpa):=20=E5=B0=86=20Crane=20=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E7=AD=89=E5=BE=85=E9=BB=98=E8=AE=A4=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E5=BB=B6=E9=95=BF=E8=87=B3=2010=20=E5=88=86=E9=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 应对 Scheduled Reports 排队超过 5 分钟导致导出失败。 Co-authored-by: Cursor --- scripts/rpa/README.md | 2 +- scripts/rpa/connectors/crane/crane_report_export.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/rpa/README.md b/scripts/rpa/README.md index 99ff11e4..6d5f444b 100644 --- a/scripts/rpa/README.md +++ b/scripts/rpa/README.md @@ -1691,7 +1691,7 @@ Worker 按 `worker_connector_type + rpa_profile_code` 分组,确保同一 conn | `SHIPPING_NOTICE_RPA_WORKER_CRANE_SUBMISSION_COMPLETE_WAIT_MS` | 等待 Report Submitted 提示消失的最长时间(默认 120000) | | `SHIPPING_NOTICE_RPA_WORKER_CRANE_SCHEDULED_TABLE_SELECTOR` | Scheduled Reports 表格行选择器 | | `SHIPPING_NOTICE_RPA_WORKER_CRANE_SCHEDULED_REPORT_NAME` | Scheduled Reports 目标文件名(Name 列,默认 `OnHandDetails.xlsx`) | -| `SHIPPING_NOTICE_RPA_WORKER_CRANE_SCHEDULED_REPORT_WAIT_MS` | 等待列表行 Submitted→Download 的最长时间(默认 300000) | +| `SHIPPING_NOTICE_RPA_WORKER_CRANE_SCHEDULED_REPORT_WAIT_MS` | 等待列表行 Submitted→Download 的最长时间(默认 **600000**=10 分钟) | | `SHIPPING_NOTICE_RPA_WORKER_CRANE_SCHEDULED_REPORT_POLL_SECONDS` | 轮询 Scheduled Reports 间隔秒数(默认 3) | | `SHIPPING_NOTICE_RPA_WORKER_CRANE_SCHEDULED_REPORTS_URL` | Scheduled Reports 页面 URL(默认由当前站点 hash 推导) | | `SHIPPING_NOTICE_RPA_WORKER_CRANE_OWNER_SELECTOR` | Crane Owner 下拉/输入(可选) | diff --git a/scripts/rpa/connectors/crane/crane_report_export.py b/scripts/rpa/connectors/crane/crane_report_export.py index 99bbaab5..b9bca63c 100644 --- a/scripts/rpa/connectors/crane/crane_report_export.py +++ b/scripts/rpa/connectors/crane/crane_report_export.py @@ -962,10 +962,11 @@ def _wait_and_click_scheduled_download( 轮询 Scheduled Reports 直至目标行 Download 列由 Submitted 变为 Download 并点击。 核心逻辑:每 2s 探测一次状态;每 10s goto 刷新列表;表格可见时不重登,避免闪回登录页; expect_download 超时且已配置 download_dir 时,短窗口扫描目录新文件兜底。 + 等待上限由 SHIPPING_NOTICE_RPA_WORKER_CRANE_SCHEDULED_REPORT_WAIT_MS 控制(默认 600000=10 分钟)。 Args: page: Playwright 页面。 - env: 环境变量读取函数。 + env: 环境变量读取函数(Windows RPA Worker 进程环境)。 browser_timeout_ms: 浏览器操作超时(亦用于 expect_download)。 description: Schedule 时写入的 Description,用于定位行。 expected_report_name: 期望的 Name 列文件名。 @@ -976,7 +977,8 @@ def _wait_and_click_scheduled_download( Playwright Download 或 FilesystemDownloadArtifact。 """ entry = entry_url or _default_crane_entry_url(None) - wait_ms = int(env("SHIPPING_NOTICE_RPA_WORKER_CRANE_SCHEDULED_REPORT_WAIT_MS", "300000") or "300000") + # 默认 10 分钟:Crane 偶发 Submitted 排队 >5 分钟(见 2026-09-03 ~262s / 2026-09-07 满 300s 失败) + wait_ms = int(env("SHIPPING_NOTICE_RPA_WORKER_CRANE_SCHEDULED_REPORT_WAIT_MS", "600000") or "600000") deadline = time.monotonic() + (wait_ms / 1000) poll_seconds = float(env("SHIPPING_NOTICE_RPA_WORKER_CRANE_SCHEDULED_REPORT_POLL_SECONDS", "2") or "2") list_refresh_seconds = float(