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,8 +1,8 @@
"""在途调拨性能与规模测试(Phase 4,L6 子集)。
用途:验证大批量 Invoice 预检可完成且不退化(O(n) 汇总),投影读取正常。
依赖:transfer_db、precheck_service、repo_fakes。
逻辑:300 行收料文件 → 预检 300 个 Invoice;仅断言正确性,耗时打印参考。
用途:验证大批量 Invoice 匹配可完成且不退化(O(n) 汇总),投影读取正常。
依赖:transfer_db、matching_service、repo_fakes。
逻辑:300 行收料文件 → 匹配 300 个 Invoice;仅断言正确性,耗时打印参考。
"""
from __future__ import annotations
@@ -11,7 +11,7 @@ import time
import pytest
from app.services.in_transit_transfer.precheck_service import create_precheck, restore_precheck
from app.services.in_transit_transfer.matching_service import create_matching, restore_matching
from tests.services.in_transit_transfer.repo_fakes import make_transfer_deps
@@ -38,18 +38,18 @@ def _bulk_file(count: int) -> dict:
}
def test_bulk_precheck_300_invoices(transfer_db):
"""300 Invoice 预检完成且数量正确;耗时打印参考(不设脆断言)。"""
def test_bulk_matching_300_invoices(transfer_db):
"""300 Invoice 匹配完成且数量正确;耗时打印参考(不设脆断言)。"""
deps, erp, _ = make_transfer_deps(_bulk_file(300))
for index in range(1, 301):
# 库存种子按 (料号, 拨出库位, 拨出批号) 三元组与文件行一一对应。
erp.seed_stock(f"MAT-{index:04d}", "DBS-TRANSIT", f"LOT-BULK-{index:04d}", "100")
started = time.perf_counter()
summary = create_precheck(source_codes=["DBS-AWSBI"], business_date="2026-08-06", deps=deps)
summary = create_matching(source_codes=["DBS-AWSBI"], business_date="2026-08-06", deps=deps)
elapsed = time.perf_counter() - started
assert summary.counts.executable_count == 300
assert summary.counts.file_invoice_count == 300
restored = restore_precheck(summary.precheck_id)
restored = restore_matching(summary.matching_id)
assert len(restored["items"]) == 300
print(f"\n[perf] bulk precheck 300 invoices: {elapsed:.3f}s")
print(f"\n[perf] bulk matching 300 invoices: {elapsed:.3f}s")