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)
|