45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
"""
|
|
scripts/rpa/dsv_driver.py
|
|
|
|
用途:DSV 360 库存 RPA 对外编排入口(session → 导航 → 导出)。
|
|
依赖:dsv_report_export。
|
|
逻辑:freight_rpa_worker 在 connector_type=dsv360 时仅调用本模块公开函数。
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys as _sys
|
|
from pathlib import Path as _Path
|
|
|
|
_RPA_ROOT = next(
|
|
(_c for _c in _Path(__file__).resolve().parents
|
|
if (_c / "connectors").is_dir() and (_c / "common").is_dir()
|
|
and (_c / "inventory").is_dir() and (_c / "receipt").is_dir()),
|
|
None,
|
|
)
|
|
if _RPA_ROOT is not None:
|
|
for _rel in ("", "common", "connectors", "connectors/dsv", "connectors/crane", "inventory", "receipt"):
|
|
_dir = str(_RPA_ROOT) if not _rel else str(_RPA_ROOT / _rel)
|
|
if _dir not in _sys.path:
|
|
_sys.path.insert(0, _dir)
|
|
|
|
from typing import Any
|
|
|
|
from dsv_report_export import (
|
|
ensure_dsv_session,
|
|
export_dsv_inventory_source,
|
|
prepare_dsv_batch_export_step,
|
|
)
|
|
|
|
|
|
def download_dsv360_inventory(page: Any, trigger: dict[str, Any], source: dict[str, Any]) -> Any:
|
|
"""
|
|
单票 trigger 的 DSV 360 导出。
|
|
核心逻辑:ensure session → 导航至参数页 → 填参并导出 Excel。
|
|
"""
|
|
entry_url = str(source.get("entry_url") or "").strip()
|
|
if not entry_url:
|
|
raise RuntimeError("DSV360 inventory source missing entry_url")
|
|
ensure_dsv_session(page, entry_url)
|
|
return export_dsv_inventory_source(page, trigger, source)
|