feat(freight-rpa): 增加出站报表配置与回调支持,重构相关服务

- 将 RPA 管理 API 扩展至出站报表配置,新增出站相关的回调接口。
- 重构 freight_rpa_report_config_service,支持入站与出站报表配置的管理。
- 更新 ORM 模型,增加出站报表相关的持久化模型。
- 统一命名规范,确保在手、入站与出站的概念一致性。
This commit is contained in:
hugo committed 2026-10-19 18:45:16 +08:00
1 parent 39fe3c05f2
commit 911afa0f73
152 files changed
+9861 -2984

No files matched your search

@@ -3,8 +3,8 @@ scripts/freight_rpa/dsv_report_export.py
用途:DSV 360 填参、View Report、Excel 导出与 batch 编排。
依赖:rpa_common、dsv_debug、dsv_navigation、dsv_session、dsv_report_parameters。
逻辑:worker connector_type=dsv360 / 收料 DBS 时委托本模块;按 export_kind 分流
库存/收料的结果就绪正文标记与明细行探针(结构可参考,字段不复用);
逻辑:worker connector_type=dsv360 / 入站或出站 DBS 时委托本模块;按 export_kind 分流
库存/入站/出站的结果就绪正文标记与明细行探针(结构可参考,字段不复用);
DOM 明细行探测仅作加速,无行时重试 View Report 一次后仍导出,真空由落盘 Excel 判定。
"""
@@ -114,29 +114,48 @@ _DSV_INBOUND_BODY_MARKERS: tuple[str, ...] = (
"whole page",
)
# 出站报表正文标记(Task 12 占位:未拿到实机列头前用通用 shipped/outbound 词 + SSRS UI 词)。
_DSV_OUTBOUND_BODY_MARKERS: tuple[str, ...] = (
"outbound detail",
"outbound details",
"ship qty",
"qty shipped",
"date shipped",
"shipment",
"dispatch",
"page width",
"whole page",
)
def _dsv_export_kind(source: dict[str, Any] | None = None, *, kind: str | None = None) -> str:
"""
解析导出语义:inventory(onhand)| inbound(原 receipt)。
解析导出语义:inventory(onhand)| inbound(原 receipt)| outbound。
核心逻辑:显式 kind / source.__export_kind__ 优先;否则按报表名含 receipt detail 推断。
核心逻辑:显式 kind / source.__export_kind__ 优先;否则按报表名含 receipt/outbound 推断。
"""
explicit = str(kind or "").strip().lower()
if explicit in {"inventory", "inbound"}:
if explicit in {"inventory", "inbound", "outbound"}:
return explicit
if isinstance(source, dict):
flagged = str(source.get("__export_kind__") or "").strip().lower()
if flagged in {"inventory", "inbound"}:
if flagged in {"inventory", "inbound", "outbound"}:
return flagged
report = _dsv_report_name(source).casefold()
if "receipt detail" in report:
return "inbound"
if "outbound" in report:
return "outbound"
return "inventory"
def _dsv_body_markers_for_kind(kind: str) -> tuple[str, ...]:
"""按 export_kind 返回结果正文标记;收料与库存字段列表分离。"""
return _DSV_INBOUND_BODY_MARKERS if kind == "inbound" else _DSV_INVENTORY_BODY_MARKERS
"""按 export_kind 返回结果正文标记;入站/出站/库存字段列表分离。"""
if kind == "inbound":
return _DSV_INBOUND_BODY_MARKERS
if kind == "outbound":
return _DSV_OUTBOUND_BODY_MARKERS
return _DSV_INVENTORY_BODY_MARKERS
def _click_dsv_export_excel(page: Any, *, kind: str = "inventory") -> None:
@@ -746,8 +765,8 @@ def _wait_for_dsv_report_result_ready(page: Any, timeout_ms: int, *, kind: str =
f"frameIndex={frame_index}"
)
ready = bool(state["bodyReady"] and not state["asyncWait"])
if export_kind == "inbound":
# 收料:Export 工具栏或 Receipt Detail 正文均可作为就绪信号。
if export_kind in {"inbound", "outbound"}:
# 入站/出站:Export 工具栏或报表正文均可作为就绪信号(避免库存标记永远等不到)。
ready = (not state["asyncWait"]) and (state["bodyReady"] or state["exportReady"])
if ready:
# #region debug-point H2:wait-report-ready
@@ -1730,6 +1749,9 @@ def _run_dsv_inventory_export_from_form(page: Any, source: dict[str, Any]) -> An
# 真空由落盘 Excel 判定(避免慢渲染假空 skip)。收料用 Receipt Detail 行探针。
if export_kind == "inbound":
_ensure_dsv_inbound_rows_or_export_fallback(page, report_name=report_name)
elif export_kind == "outbound":
# 出站 DOM 列头未用实机确认:不走库存/收料行探针,真空由落盘 Excel 判定。
pass
else:
_ensure_dsv_inventory_rows_or_export_fallback(page, report_name=report_name)
except Exception as exc: