refactor(in-transit-transfer): 行归属解耦、按行执行三层门禁并重构术语为匹配

- 行不迁移:匹配记录降级为评估留痕(scope/counts/hash 留痕不拦执行),
  匹配/重查原地刷新行并续行级新鲜度(updated_at)
- 执行改按行:POST /items/execute 三层门禁(行级新鲜度 TTL/文件版本对账/写前复查),
  Run 留痕不绑匹配记录;消失行 blocked_file_removed fail-closed 入异常池
- 恢复处理收敛为行级重查(batch-resume 删除);待处理池补齐匹配窗口字段,
  排序改业务稳定键(收料日期→Invoice→created_at,操作不再引起跳位)
- 首页待办看板四队列:可调拨明细/待恢复异常/已人工关闭/结果未知;「最近预检」移除;
  收料日期默认 T-1 并加输入期限制;「重新查询 ERP」更名「重查」
- 术语重构 precheck→match:表 transfer_matchings、列 matching_id/matching_no/matching_hash、
  API /matchings、单号前缀 MTG、状态值 prechecking→matching(迁移 rn1a2b3c4d5e6,模块未上线无兼容层)
- 修复 integration_connector mapping 扇出嵌套丢行缺陷;对账结论:0 vs 30/40/36
  系收料仓库映射曾指向错误账套 TGHX(已改 TGHX1),探针留档 backend/tmp
- 测试:后端 in_transit_transfer+api+connector 393 passed;前端 chat 713 passed;build ✓
This commit is contained in:
hugo committed 2026-09-24 00:24:03 +08:00
1 parent f9f5053f0b
commit 0cf3c24119
108 files changed
+3660 -2356

No files matched your search

@@ -1,6 +1,6 @@
"""在途调拨 DTO 序列化(API 与 Chat Action 共用)。
用途:将领域 DTO 转为前端稳定 JSON(预检摘要/明细/来源进度/执行结果)。
用途:将领域 DTO 转为前端稳定 JSON(匹配摘要/明细/来源进度/执行结果)。
依赖:contracts、execution_service。
逻辑:单一序列化来源,避免 API 与 Chat Action 各自实现导致契约漂移。
"""
@@ -13,9 +13,9 @@ from app.services.in_transit_transfer.execution_service import serialize_run_res
def serialize_summary(summary) -> dict[str, Any]:
"""预检摘要序列化。"""
"""匹配摘要序列化。"""
return {
"precheck_id": summary.precheck_id,
"matching_id": summary.matching_id,
"status": summary.status,
"business_date": summary.business_date,
"eligible_receipt_date_to": summary.eligible_receipt_date_to,
@@ -23,18 +23,23 @@ def serialize_summary(summary) -> dict[str, Any]:
"counts": {
"file_invoice_count": summary.counts.file_invoice_count,
"not_matured_count": summary.counts.not_matured_count,
"prechecked_count": summary.counts.prechecked_count,
"matched_count": summary.counts.matched_count,
"executable_count": summary.counts.executable_count,
"blocked_count": summary.counts.blocked_count,
},
"estimated_transfer_quantity": summary.estimated_transfer_quantity,
"estimated_external_write_count": summary.estimated_external_write_count,
"precheck_hash": summary.precheck_hash,
"matching_hash": summary.matching_hash,
}
def serialize_item(item) -> dict[str, Any]:
"""明细项序列化(决策 6 十列字段)。"""
"""明细项序列化(决策 6 十列字段 + 行装饰字段)。
行装饰字段(item_id/checked_at/stale/file_current)由 restore 按 scope
实时视图路径在 DTO 上填齐;匹配快照路径(run_matching)为缺省值
(0/None/False/False),前端按存在性展示。
"""
return {
"source_code": item.source_code,
"material_no": item.material_no,
@@ -53,6 +58,10 @@ def serialize_item(item) -> dict[str, Any]:
{"sheet": line.sheet, "row_no": line.row_no, "file_version": line.file_version}
for line in item.raw_lines
],
"item_id": item.item_id,
"checked_at": item.checked_at,
"stale": item.stale,
"file_current": item.file_current,
}
@@ -69,8 +78,8 @@ def serialize_source(source) -> dict[str, Any]:
}
def serialize_precheck_detail(detail: dict[str, Any]) -> dict[str, Any]:
"""预检恢复详情(summary + items + sources)。"""
def serialize_matching_detail(detail: dict[str, Any]) -> dict[str, Any]:
"""匹配恢复详情(summary + items + sources)。"""
return {
"summary": serialize_summary(detail["summary"]),
"items": [serialize_item(item) for item in detail["items"]],