"""DBS 收料报表导出适配器。""" from __future__ import annotations 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)