Merge branch 'dev' into runny827

feat(training): 新增精益培训视频与周任务管理

# Conflicts:
#	backend/app/models/__init__.py
This commit is contained in:
runny committed 2026-09-08 18:30:09 +08:00
1 parent 85d27e9ffa
commit 91b7233872
812 files changed
+73763 -18908

No files matched your search

@@ -34,6 +34,7 @@ from app.jobs.types import JobType
from app.models import (
Job,
ShippingNotice,
ShippingOrderTask,
ShippingOrderCandidate,
ShippingOrderReviewCase,
ShippingOrderReviewCaseEvent,
@@ -326,14 +327,15 @@ def _write_reconcile_audit_and_event(
def _write_back_case_task_binding(
*,
case: ShippingOrderReviewCase,
task: ShippingNotice,
task: ShippingOrderTask,
actor_type: str,
) -> None:
"""
Q2:L2 命中后必须写回正式关联,避免下次恢复仍撞重复检查。
1. Case.confirmed_task_id / confirmed_task_no
2. Candidate.fulfilled_task_id(若存在当前 Candidate)
3. Document → Task 外键(ShippingNotice.source_document_id 如空则补)
3. 来源文档继续由 Case.document_id / Candidate.primary_document_id 承载;
OT 只保存 intake/candidate 指针,不写入已移除的 source_document_id 投影。
"""
case.confirmed_task_id = int(task.id)
# confirmed_task_no 通常为 property,但实际存字段若可写则同步
@@ -350,12 +352,6 @@ def _write_back_case_task_binding(
cand.fulfilled_task_id = int(task.id)
except Exception: # noqa: BLE001 — 模型无列则降级
pass
# Document → Task 外键
if not getattr(task, 'source_document_id', None) and getattr(case, 'document_id', None):
try:
task.source_document_id = int(case.document_id)
except Exception: # noqa: BLE001
pass
# ============================================================
@@ -537,8 +533,8 @@ def reconcile_and_progress(
mlvl: str = match_result['match_level']
confidence: str = match_result['confidence']
matched_task_no: str | None = match_result.get('task_no')
matched_task: ShippingNotice | None = (
ShippingNotice.query.filter_by(task_no=matched_task_no).first()
matched_task: ShippingOrderTask | None = (
ShippingOrderTask.query.filter_by(task_no=matched_task_no).first()
if matched_task_no else None
)
@@ -775,12 +771,23 @@ def assert_case_not_blocked_manual(*, case_no: str, case: ShippingOrderReviewCas
return
rj = latest.result_json if isinstance(latest.result_json, dict) else {}
retryable_flag = bool(rj.get('retryable', True))
error_code = str(rj.get('error_code') or '').strip()
blocking_reason_raw = rj.get('blocking_reason')
blocking_reason = (
{'code': str(blocking_reason_raw)}
if isinstance(blocking_reason_raw, str) and blocking_reason_raw
else blocking_reason_raw if isinstance(blocking_reason_raw, dict) else None
)
# 兼容修复前已落库的技术异常:旧结果被错误写成 retryable=false,
# 但 SHIPPING.STP_AUTO_CREATE_UNEXPECTED 本身不是业务裁决原因,普通
# retry 应创建新的 Job,而不是强制用户走 reconcile-and-progress。
effective_error_code = error_code or (
blocking_reason.get('code')
if isinstance(blocking_reason, dict)
else str(blocking_reason or '').strip()
)
if not retryable_flag and effective_error_code == 'SHIPPING.STP_AUTO_CREATE_UNEXPECTED':
return
if should_general_retry_be_removed(retryable_flag=retryable_flag, blocking_reason=blocking_reason):
raise ConflictError(
'Case blocked on manual adjudication; use reconcile-and-progress instead of retry-stp-auto-create',