feat(shipping-notice): 增强订单抽取功能,添加进度事件和诊断运行管理,优化数据模型和访问控制
This commit is contained in:
1 parent
ce26d6d0c4
commit
c4095b08da
175 files changed
+13064
-1814
No files matched your search
@@ -582,6 +582,25 @@ def _group_batch_sources_by_profile(sources: list[Any]) -> dict[tuple[str, str],
|
||||
return grouped
|
||||
|
||||
|
||||
def _open_clean_batch_page(context: Any, current_page: Any | None) -> Any:
|
||||
"""在同一登录上下文中切换到干净页面,隔离上一站的 DSV 报表状态。
|
||||
|
||||
Args:
|
||||
context: 已建立登录态的 Playwright browser context,Cookie 会继续复用。
|
||||
current_page: 上一站使用的页面;关闭它避免报表 iframe 和下载菜单残留。
|
||||
|
||||
Returns:
|
||||
Any: 可重新进入库存报表的空白页面,不会触发新的浏览器登录。
|
||||
"""
|
||||
next_page = context.new_page()
|
||||
if current_page is not None:
|
||||
try:
|
||||
current_page.close()
|
||||
except Exception as exc:
|
||||
print(f"[inventory-batch] close previous page failed: {exc}", file=sys.stderr)
|
||||
return next_page
|
||||
|
||||
|
||||
@contextmanager
|
||||
def _profile_credentials(source: dict[str, Any]):
|
||||
"""仅在单 Profile 执行范围内解密凭据并暂存环境变量,退出时恢复原值。"""
|
||||
@@ -1008,7 +1027,11 @@ def _handle_inventory_batch_trigger(trigger_path: Path, drop_dir: Path, processe
|
||||
_validate_inventory_source_for_rpa(source)
|
||||
skip_navigation = False
|
||||
if site == "dsv360":
|
||||
skip_navigation = _prepare_dsv_batch_export_step(page, entry_url, site_sources[index - 1] if index > 0 else None, source, index=index)
|
||||
# DSV 报表页会保留 iframe、导出菜单与下载等待状态;同一 tab
|
||||
# 串行切换站点会让下一站误用上一站页面。复用 context 登录态,但每站新开页面。
|
||||
if index > 0:
|
||||
page = _open_clean_batch_page(context, page)
|
||||
_prepare_dsv_batch_export_step(page, entry_url, None, source, index=0)
|
||||
elif index == 0:
|
||||
_ensure_crane_session(page, entry_url)
|
||||
else:
|
||||
|
||||
Reference in new issue
Block a user