feat(shipping-notice,receipt-report): 新增收料报表功能并优化发货通知流程
清理废弃的shipping xfa ocr automark相关代码和job配置 新增收料报表管理的前端页面、路由和侧边栏入口 新增后端收料报表配置接口、数据库模型和RPA脚本 优化发货通知流程的重试策略,将shipping相关job默认不自动重试 移除废弃的库存源确认相关逻辑,更新流程门禁规则 重构订单模板的值适配器模块,新增坐标OCR值适配器 清理前端shipping菜单和action的废弃选项 更新相关文档和测试用例,调整.gitignore忽略规则
This commit is contained in:
1 parent
260465b72d
commit
1b6483a4ea
466 files changed
+32115
-33796
No files matched your search
@@ -4,9 +4,8 @@ services/shipping_notice/recovery_contract.py
|
||||
用途:STP / 发货通知 恢复裁决 契约层(Phase 1)。
|
||||
依赖:无外部 IO(纯函数 + 枚举 + dataclass);error_explainability_contract(顶层原因码交叉校验)、process_gate_contract。
|
||||
逻辑:
|
||||
T1 — 错误码 → is_tech_retryable_error(白名单制,fail-closed);
|
||||
T2 — build_stp_job_blocked_manual_result / build_stp_job_failed_transient_result
|
||||
输出严格结构契约的 Job.result;
|
||||
T1 — 失败统一停止并由用户选择明确恢复动作;
|
||||
T2 — build_stp_job_blocked_manual_result 输出严格结构契约的 Job.result;
|
||||
T3 — should_general_retry_be_removed + derive_blocking_next_actions
|
||||
决定是否删除 UI 侧的 "retry" 按钮并注入阻塞裁决动作;
|
||||
T4 — reconcile_queries 所用到的 ReconcileMatchResult / ReconcileMatchLevel
|
||||
@@ -26,30 +25,6 @@ from typing import Any
|
||||
|
||||
RECOVERY_CONTRACT_VERSION: str = "shipping-recovery-v1-phase1"
|
||||
|
||||
# T1:技术重试白名单前缀(优先命中 prefix;category_hint 其次)
|
||||
_TECH_RETRYABLE_PREFIXES: tuple[str, ...] = (
|
||||
"SHIPPING.TRANSIENT_",
|
||||
"SHIPPING.WORKER_TIMEOUT_",
|
||||
)
|
||||
|
||||
_TECH_RETRYABLE_CATEGORY_HINTS: frozenset[str] = frozenset({
|
||||
"worker_timeout",
|
||||
"queue_unavailable",
|
||||
"temporary_network_error",
|
||||
"temporary_storage_error",
|
||||
"external_service_5xx",
|
||||
"lease_expired",
|
||||
})
|
||||
|
||||
# 库存 RPA Trigger 投递/领取失败属于技术暂态;不能被当作业务人工阻断,
|
||||
# 否则正式 OT 的 retryable 投影会变成 false,conversation retry 不会重新建 Trigger。
|
||||
_TECH_RETRYABLE_ERROR_CODES: frozenset[str] = frozenset({
|
||||
"trigger_not_claimed_missing",
|
||||
"trigger_not_claimed_timeout",
|
||||
"inventory_trigger_missing",
|
||||
"inventory_trigger_write_failed",
|
||||
})
|
||||
|
||||
# T3:业务阻断 → 推荐 UI 动作映射;未命中时 fallback 为 "open_order_review"
|
||||
BLOCKING_REASON_TO_ACTION_CODES: dict[str, str] = {
|
||||
"duplicate_decision_required": "adjudicate_duplicate",
|
||||
@@ -75,50 +50,6 @@ REMOVE_ACTIONS_WHEN_BLOCKED: frozenset[str] = frozenset({
|
||||
# T1 — 错误重试白名单分类
|
||||
# ============================================================
|
||||
|
||||
def is_tech_retryable_error(
|
||||
error_code: str | None,
|
||||
*,
|
||||
category_hint: str | None = None,
|
||||
) -> bool:
|
||||
"""
|
||||
判断错误码是否属于「技术临时失败」,允许自动/手动技术重试。
|
||||
|
||||
【AI 触发时机】:
|
||||
- Worker 领取 Job 失败后分类 retryable 标志;
|
||||
- 工作台 / 对话侧投影 available_actions 时决定是否显示 retry;
|
||||
- 对账链路 error_code 分类。
|
||||
|
||||
核心逻辑(fail-closed):
|
||||
[STEP 1] error_code 为空/None → 直接 False,禁止空码回退到可重试;
|
||||
[STEP 2] 前缀 _TECH_RETRYABLE_PREFIXES 命中 → True;
|
||||
[STEP 3] category_hint 在 _TECH_RETRYABLE_CATEGORY_HINTS → True;
|
||||
[STEP 4] 其他全部 False(业务阻断、未知错误都不得自动重试)。
|
||||
|
||||
Args:
|
||||
error_code: 业务/AppError.code;前缀优先。
|
||||
category_hint: 上游 catch 时给出的原因分类(如 "external_service_5xx")。
|
||||
|
||||
Returns:
|
||||
True → 技术临时失败,允许 retryable=true;False → 业务阻断或未知,必须人工接管。
|
||||
"""
|
||||
normalized = str(error_code or "").strip()
|
||||
if not normalized:
|
||||
return False
|
||||
|
||||
for prefix in _TECH_RETRYABLE_PREFIXES:
|
||||
if normalized.startswith(prefix):
|
||||
return True
|
||||
|
||||
if normalized.lower() in _TECH_RETRYABLE_ERROR_CODES:
|
||||
return True
|
||||
|
||||
hint = str(category_hint or "").strip()
|
||||
if hint and hint in _TECH_RETRYABLE_CATEGORY_HINTS:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
# ============================================================
|
||||
# T2 — STP Job Result 结构契约
|
||||
# ============================================================
|
||||
@@ -149,8 +80,7 @@ def build_stp_job_blocked_manual_result(
|
||||
构建「业务阻断 → 人工接管」的 STP Job.result。
|
||||
|
||||
【AI 触发时机】:
|
||||
Handler 收到业务拒绝 ok=False / AppError 为阻断码 / 非预期 Exception 兜底且
|
||||
is_tech_retryable_error 返回 False 时,统一输出这个结构(禁止各 handler 手写散 schema)。
|
||||
Handler 收到任意失败时统一输出这个结构(禁止各 handler 手写散 schema)。
|
||||
|
||||
保证字段:status=failed / retryable=false / blocking_reason=error_code /
|
||||
blocking_reason_details=details / next_action=next_action(default derive)/
|
||||
@@ -178,38 +108,6 @@ def build_stp_job_blocked_manual_result(
|
||||
}
|
||||
|
||||
|
||||
def build_stp_job_failed_transient_result(
|
||||
*,
|
||||
error_code: str,
|
||||
message: str,
|
||||
category_hint: str | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""
|
||||
构建「技术临时失败 → 可重试」的 STP Job.result。
|
||||
|
||||
【AI 触发时机】:
|
||||
is_tech_retryable_error 返回 True 时调用;blocking_reason/next_action 置空,
|
||||
由上游 worker 根据 retryable=true 自动重试或保留 retry 按钮。
|
||||
"""
|
||||
code = str(error_code or "").strip()
|
||||
return {
|
||||
"status": "failed",
|
||||
"retryable": True,
|
||||
"blocking_reason": None,
|
||||
"next_action": None,
|
||||
"error_code": code,
|
||||
"message": str(message or ""),
|
||||
"category_hint": category_hint,
|
||||
"contract_version": RECOVERY_CONTRACT_VERSION,
|
||||
"decision_trace": _build_decision_trace(
|
||||
contract_version=RECOVERY_CONTRACT_VERSION,
|
||||
stage="failed_transient",
|
||||
retryable=True,
|
||||
matched_rule="tech_retry_whitelist",
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
# ============================================================
|
||||
# T3 — UI 动作注入 / 删除
|
||||
# ============================================================
|
||||
|
||||
Reference in new issue
Block a user