feat(shipping_notice): 新增货代订单全流程业务模块及配套基建
本次提交新增货代订单处理全流程的完整业务能力、数据库迁移与测试用例: 1. 统一追加式审计事件体系,支持全链路不可篡改的业务追溯 2. 货代任务撤销、版本替代管控逻辑,规范已上传订单的合规版本更替 3. 订单抽取路由审计、模板自动冻结资格、路由计数等核心业务基建 4. EML订单补充表解析契约与合并逻辑,完善订单补全能力 5. Chatflow只读能力令牌校验机制,保障工具调用安全 6. 人工复核证据校验服务,规范人工审核的证据留存 所有变更均配套完整的单元测试与迁移契约测试,支持受控回退
This commit is contained in:
1 parent
90f77634d6
commit
1f3ecb87b7
128 files changed
+3635
-2074
No files matched your search
@@ -24,7 +24,9 @@ class ProfileMatchCandidate(BaseModel):
|
||||
version: int = Field(ge=1)
|
||||
score: float = Field(ge=0, le=1)
|
||||
hard_match: bool
|
||||
reasons: list[str] = Field(default_factory=list)
|
||||
reason_codes: list[str] = Field(default_factory=list)
|
||||
# Anchor IDs are template configuration identifiers, never document text.
|
||||
missing_required_anchor_ids: list[str] = Field(default_factory=list)
|
||||
|
||||
|
||||
class ProfileMatchResult(BaseModel):
|
||||
@@ -62,25 +64,29 @@ def match_frozen_coordinate_profiles(*, profiles: list[dict[str, Any]], layout:
|
||||
)
|
||||
except (TypeError, ValueError):
|
||||
continue
|
||||
reasons: list[str] = []
|
||||
reason_codes: list[str] = []
|
||||
if len(tables) < len(profile.table_regions):
|
||||
reasons.append('table_region_count_insufficient')
|
||||
reason_codes.append('table_region_count_insufficient')
|
||||
required = profile.document_match.required_anchors
|
||||
required_hits = [_anchor_present(
|
||||
anchor.model_dump(), tables=tables, glyph_tables=glyph_tables, page_glyphs=page_glyphs, pages=pages,
|
||||
) for anchor in required]
|
||||
if not all(required_hits):
|
||||
reasons.append('required_anchor_missing')
|
||||
missing_required_anchor_ids = [
|
||||
anchor.anchor_id for anchor, present in zip(required, required_hits) if not present
|
||||
]
|
||||
if missing_required_anchor_ids:
|
||||
reason_codes.append('required_anchor_missing')
|
||||
optional = profile.document_match.optional_anchors
|
||||
optional_hits = sum(_anchor_present(
|
||||
anchor.model_dump(), tables=tables, glyph_tables=glyph_tables, page_glyphs=page_glyphs, pages=pages,
|
||||
) for anchor in optional)
|
||||
hard_match = not reasons
|
||||
hard_match = not reason_codes
|
||||
# Required evidence is mandatory rather than a soft score. Optional evidence only separates already valid templates.
|
||||
score = 1.0 if not optional else 0.8 + 0.2 * optional_hits / len(optional)
|
||||
candidates.append((raw, profile, ProfileMatchCandidate(
|
||||
profile_code=profile.profile_code, version=profile.version, score=score if hard_match else 0.0,
|
||||
hard_match=hard_match, reasons=reasons,
|
||||
hard_match=hard_match, reason_codes=reason_codes,
|
||||
missing_required_anchor_ids=missing_required_anchor_ids,
|
||||
)))
|
||||
rendered = sorted((item[2] for item in candidates), key=lambda item: (-item.score, item.profile_code, item.version))
|
||||
valid = sorted((item for item in candidates if item[2].hard_match), key=lambda item: (-item[2].score, item[1].profile_code, item[1].version))
|
||||
|
||||
Reference in new issue
Block a user