清理废弃的shipping xfa ocr automark相关代码和job配置 新增收料报表管理的前端页面、路由和侧边栏入口 新增后端收料报表配置接口、数据库模型和RPA脚本 优化发货通知流程的重试策略,将shipping相关job默认不自动重试 移除废弃的库存源确认相关逻辑,更新流程门禁规则 重构订单模板的值适配器模块,新增坐标OCR值适配器 清理前端shipping菜单和action的废弃选项 更新相关文档和测试用例,调整.gitignore忽略规则
43 lines
2.1 KiB
Python
43 lines
2.1 KiB
Python
"""Crane 收料报表导出适配器。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Callable
|
|
from urllib.parse import urlsplit, urlunsplit
|
|
|
|
import crane_report_export
|
|
import crane_session
|
|
|
|
|
|
def _inbound_details_entry_url(login_url: str) -> str:
|
|
"""将复用的 Crane Profile 登录地址固定到收料 Inbound Details 路由。"""
|
|
parsed = urlsplit(str(login_url or '').strip())
|
|
if not parsed.scheme or not parsed.netloc:
|
|
raise RuntimeError('Crane receipt unit requires an absolute login_url')
|
|
return urlunsplit((parsed.scheme, parsed.netloc, parsed.path or '/', parsed.query, '/inbound-details-query'))
|
|
|
|
|
|
def export_receipt_report(
|
|
page: Any, unit: dict[str, Any], *, env: Callable[[str, str], str], browser_timeout_ms: int,
|
|
select_or_fill: Callable[..., None], click_text: Callable[..., None], first_in_profile: bool,
|
|
) -> Any:
|
|
"""创建并下载唯一 Description 对应的 Crane Inbound Details 文件,禁止按最新历史文件选择。"""
|
|
report_path = dict(unit.get('report_path_json') or {})
|
|
if str(report_path.get('report_name') or '').strip() != 'Inbound Details':
|
|
raise RuntimeError('Crane receipt report must be Inbound Details')
|
|
entry_url = _inbound_details_entry_url(str(unit.get('login_url') or '').strip())
|
|
if first_in_profile:
|
|
page.goto(entry_url, wait_until='domcontentloaded', timeout=browser_timeout_ms)
|
|
crane_session.maybe_auto_login_crane(page, env=env, browser_timeout_ms=browser_timeout_ms)
|
|
crane_session.wait_for_crane_app_ready(page, entry_url, env=env, browser_timeout_ms=browser_timeout_ms)
|
|
# 旧 Crane driver 的 Scheduled Reports 匹配名来自 source;收料固定为
|
|
# Inbound Details,不能沿用库存的 OnHandDetails.xlsx 默认值。
|
|
source = {
|
|
'entry_url': entry_url,
|
|
'scheduled_report_name': 'Inbound Details',
|
|
}
|
|
return crane_report_export.export_crane_inventory_report(
|
|
page, source, trigger={'callback_id': unit.get('callback_id')}, env=env,
|
|
browser_timeout_ms=browser_timeout_ms, select_or_fill=select_or_fill, click_text=click_text,
|
|
)
|