按 common/connectors/inventory/receipt 分层并重命名
- common/: rpa_common, rpa_heartbeat, download_artifact_fallback,
new_rpa_worker_secret
- connectors/dsv|crane/: 登录网站连接器,库存与收料共用
- inventory/: inventory_rpa_worker, run_inventory_batch_trigger,
start_inventory_worker, register_inventory_worker_tasks
- receipt/: receipt_rpa_worker, receipt_crane/dbs_export,
start_receipt_worker
保留裸 import + sys.path 引导;修正懒加载路径;
按范围命名 register_rpa_background_tasks -> register_inventory_worker_tasks;
同步 backend 测试、start_local.ps1、.env 注释、docs 与 README 路径。
(cherry picked from commit f3050164d0)
43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
"""DBS 收料报表导出适配器。"""
|
|
|
|
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
|
|
|
|
import dsv_report_export
|
|
|
|
|
|
def export_receipt_report(page: Any, unit: dict[str, Any], *, entry_url: str, first_in_profile: bool) -> Any:
|
|
"""在既有 DBS 登录态内执行收料路径、Warehouse 与受控非日期条件。"""
|
|
source = {
|
|
'entry_url': entry_url,
|
|
'report_path_json': dict(unit.get('report_path_json') or {}),
|
|
'parameters': list(unit.get('query_parameters_json') or []),
|
|
'__download_dir': str(unit.get('__download_dir') or ''),
|
|
}
|
|
warehouse_id = str(unit.get('warehouse_id') or '').strip()
|
|
if not warehouse_id:
|
|
raise RuntimeError('DBS receipt unit requires warehouse_id')
|
|
source['parameters'].append({
|
|
'name': 'Warehouse', 'mode': 'single', 'values': [warehouse_id],
|
|
'required': True, 'select_all': False,
|
|
})
|
|
if first_in_profile:
|
|
dsv_report_export.ensure_dsv_session(page, entry_url)
|
|
return dsv_report_export.export_dsv_inventory_source(page, {'action': 'receipt_export_batch'}, source)
|