77 lines
2.9 KiB
Markdown
77 lines
2.9 KiB
Markdown
"""
|
||
docs/features/shipping-notice/order-profile-layout-signature.md
|
||
|
||
用途:订单文档模板版面签名与模板匹配分阶段实施方案的落地说明与切换清单。
|
||
依赖:阶段一至五代码实现、ValidationRun、PublishCheckPage、重建脚本。
|
||
逻辑:开发与运维按本文件执行迁移、重签、发布门禁与生产切换;详细产品方案见对话定稿。
|
||
"""
|
||
|
||
# 订单模板版面签名与匹配落地说明
|
||
|
||
## 边界
|
||
|
||
- 完整签名存 `shipping_order_document_profile_validation_runs.result_snapshot_json`(`run_type=layout_signature`)
|
||
- Profile 主表仅存签名运行引用、checksum 与稳定签名类型;签名类型不使用版本化命名
|
||
- 不新增签名表、不新增一级菜单;仅扩展现有发布检查页
|
||
- 直接替换旧七维 Matcher;历史 Run/Route/审计只读保留
|
||
- 运行时无法唯一匹配继续 fail-closed
|
||
|
||
## 迁移
|
||
|
||
```bash
|
||
cd backend
|
||
flask db upgrade
|
||
# head 应包含 cm7a8b9c0d1e
|
||
```
|
||
|
||
## 重建签名(不自动发布)
|
||
|
||
```bash
|
||
cd backend
|
||
python scripts/rebuild_order_profile_matching_signatures.py --dry-run
|
||
python scripts/rebuild_order_profile_matching_signatures.py
|
||
```
|
||
|
||
草稿模板会生成新的 `layout_signature` ValidationRun。已发布模板需管理员克隆为草稿后重签、交叉验证、再发布。
|
||
|
||
## 发布检查
|
||
|
||
1. 保存草稿后旧签名失效
|
||
2. 进入发布检查页 → 自动/手动生成签名与跨模板重叠验证
|
||
3. 自身样本唯一命中、跨模板误命中=0、ambiguous=0、coverage/margin 达标才可发布
|
||
4. 阻断不可人工绕过;后端二次校验
|
||
|
||
## 生产切换开关
|
||
|
||
`.env.shared` / 环境覆盖:
|
||
|
||
```text
|
||
SHIPPING_NOTICE_PROFILE_LAYOUT_SIGNATURE_REQUIRED=false
|
||
```
|
||
|
||
全部目标模板重签并重新发布后改为 `true`,无有效签名的模板将不再进入新 Run 候选。
|
||
|
||
回滚:仅关闭自动选择 / 将上述开关改回 `false`;**不得删除**签名 ValidationRun 与审计记录。
|
||
|
||
## 真实样本验收(阶段五)
|
||
|
||
仓库外受控保存用户提供的 PDF:
|
||
|
||
- `1000050815.pdf` → ZT
|
||
- `1000050215.pdf` → ZT
|
||
- `1078376132.PDF` → Quanta
|
||
|
||
验收目标:唯一命中正确模板、ZT/Quanta 互相误命中率 0、未知版式不落入已知模板。
|
||
|
||
## 关键文件
|
||
|
||
| 模块 | 路径 |
|
||
|---|---|
|
||
| 签名生成 | `backend/app/services/shipping_notice/document_layout/order_profile_signature.py` |
|
||
| Matcher | `backend/app/services/shipping_notice/document_layout/order_profile_matcher.py` |
|
||
| 解析验证 | `backend/app/services/shipping_notice/document_layout/order_profile_parse_validation.py` |
|
||
| 验证/重叠 | `backend/app/services/shipping_notice/order_document_profile_validation_service.py` |
|
||
| 发布门禁 | `backend/app/services/shipping_notice/order_document_profile_publish_check_service.py` |
|
||
| 发布检查页 | `frontend/.../OrderProfilePublishCheckPage.vue` |
|
||
| 重建脚本 | `backend/scripts/rebuild_order_profile_matching_signatures.py` |
|