Merge branch 'hugo-shipping-notice' into test
This commit is contained in:
commit
933ac8ebcc
18 files changed
+1050
-73
No files matched your search
@@ -2,7 +2,8 @@
|
||||
|
||||
依赖:受控 HTML 网格解析、冻结订单 Schema 表头契约、PO/Reservation 标准化。
|
||||
逻辑:订单字段表头只复用 Run/当前发布 Schema 的显式别名;邮件专属的分配事实
|
||||
仍使用受控固定列。表格歧义或缺 PO 保留原因,不将正文直接转成订单。
|
||||
仍使用受控固定列。表格歧义保留原因,不将正文直接转成订单。
|
||||
无 PO 表头时,若已映射料号或预约号仍解析行(供 merge mpn_fallback);二者皆无才整表跳过。
|
||||
非法非 PO 字段跳过本列并记 issue,避免可选列拖垮 Reservation/库存源线索。
|
||||
reservation_id 通过安全抽取后写入归一本体(含短数字行序后缀)。
|
||||
多表按文档顺序叠行:靠前为新,同行身份键先到为准;旧表仅补全新表未覆盖的行。
|
||||
@@ -58,14 +59,24 @@ def _supplement_row_identity(row: dict[str, Any]) -> tuple[str, str, str] | None
|
||||
return None
|
||||
|
||||
|
||||
_IDENTITY_FIELD_CODES = frozenset({
|
||||
'part_number', 'customer_part_number', 'reservation_id',
|
||||
})
|
||||
_PO_FIELD_CODES = frozenset({'customer_po_number', 'po_number'})
|
||||
|
||||
|
||||
def _mapping_has_identity(mapped_fields: set[str]) -> bool:
|
||||
"""表头或行是否具备可与 PDF 关联的身份列(料号或预约号)。"""
|
||||
return bool(mapped_fields & _IDENTITY_FIELD_CODES)
|
||||
|
||||
|
||||
def _normalize_schema_row(
|
||||
values: dict[str, str], *, schema_definition: dict[str, Any], issues: list[str],
|
||||
) -> dict[str, Any] | None:
|
||||
"""按冻结 Schema 规范化并校验 EML 单元格;非法非 PO 字段跳过,不拖垮整行。
|
||||
|
||||
核心逻辑:PO 仍是行身份门槛;其余字段解析/校验失败只记
|
||||
``email_supplement_field_invalid`` 并省略该字段,避免可选列(如 PO Date)
|
||||
非法时把 Reservation / 库存源线索一并丢掉。
|
||||
核心逻辑:有 PO 则写入 PO;无 PO 时须具备料号或合法预约号才成行,供 merge 兜底。
|
||||
其余字段解析/校验失败只记 ``email_supplement_field_invalid`` 并省略该字段。
|
||||
|
||||
Args:
|
||||
values: 表头映射后的 field_code → 原始单元格文本。
|
||||
@@ -73,7 +84,7 @@ def _normalize_schema_row(
|
||||
issues: 可追加的问题码列表(调用方持有,本函数原地写入)。
|
||||
|
||||
Returns:
|
||||
规范化后的补充行;缺有效 PO 时返回 None。
|
||||
规范化后的补充行;无 PO 且无料号/预约号时返回 None。
|
||||
"""
|
||||
configs = _schema_configs(schema_definition)
|
||||
normalized: dict[str, Any] = {}
|
||||
@@ -82,7 +93,7 @@ def _normalize_schema_row(
|
||||
if config is None:
|
||||
normalized[field_code] = raw_value
|
||||
continue
|
||||
# [STEP] 非 PO 字段失败只跳过本列;PO 失败则稍后由 po 门槛统一拒行。
|
||||
# [STEP] 非 PO 字段失败只跳过本列;PO 失败则稍后统一处理。
|
||||
try:
|
||||
value = normalize_order_field_value(raw_value, config)
|
||||
except Exception:
|
||||
@@ -101,11 +112,16 @@ def _normalize_schema_row(
|
||||
normalized[field_code] = value
|
||||
po_code = 'customer_po_number' if 'customer_po_number' in normalized else 'po_number'
|
||||
po_number = normalize_po_number(normalized.get(po_code))
|
||||
if not po_number:
|
||||
issues.append('email_supplement_row_po_missing')
|
||||
return None
|
||||
normalized[po_code] = po_number
|
||||
return normalized
|
||||
if po_number:
|
||||
normalized[po_code] = po_number
|
||||
return normalized
|
||||
# [STEP] 无 PO:有料号或合法预约号仍成行;否则丢弃。
|
||||
has_part = any(str(normalized.get(code) or '').strip() for code in ('part_number', 'customer_part_number'))
|
||||
has_reservation = bool(validated_reservation_id(normalized.get('reservation_id')))
|
||||
if has_part or has_reservation:
|
||||
return normalized
|
||||
issues.append('email_supplement_row_po_missing')
|
||||
return None
|
||||
|
||||
|
||||
def _field_map(grid: Any, *, schema_definition: dict[str, Any]) -> tuple[dict[int, str], list[str]]:
|
||||
@@ -136,11 +152,25 @@ def _field_map(grid: Any, *, schema_definition: dict[str, Any]) -> tuple[dict[in
|
||||
selected_by_field[field_code] = (priority, column)
|
||||
elif len(hits) > 1:
|
||||
issues.append('email_supplement_header_ambiguous')
|
||||
if not ({'customer_po_number', 'po_number'} & set(mapped.values())):
|
||||
mapped_fields = set(mapped.values())
|
||||
if not (mapped_fields & _PO_FIELD_CODES):
|
||||
# 无 PO:有料号/预约号时仅作可观测标记(不阻断解析);否则硬失败。
|
||||
issues.append('email_supplement_po_header_missing')
|
||||
return mapped, sorted(set(issues))
|
||||
|
||||
|
||||
def _blocking_table_issues(table_issues: list[str], *, mapped_fields: set[str]) -> list[str]:
|
||||
"""返回会跳过整表的 issue;无 PO 但已有身份列时,po_header_missing 不阻断。"""
|
||||
soft_po_missing = (
|
||||
'email_supplement_po_header_missing' in table_issues
|
||||
and _mapping_has_identity(mapped_fields)
|
||||
)
|
||||
return [
|
||||
code for code in table_issues
|
||||
if not (soft_po_missing and code == 'email_supplement_po_header_missing')
|
||||
]
|
||||
|
||||
|
||||
def _schema_header_priority(schema_definition: dict[str, Any], field_code: str, normalized_header: str) -> int:
|
||||
"""返回字段表头的 Schema 声明顺序,供同字段多别名确定性裁决。"""
|
||||
priorities: list[int] = []
|
||||
@@ -201,7 +231,7 @@ def parse_email_allocation_tables(*, html_tables: list[str], content_hash: str,
|
||||
continue
|
||||
mapping, table_issues = _field_map(grid, schema_definition=schema_definition)
|
||||
issues.extend(table_issues)
|
||||
if table_issues:
|
||||
if _blocking_table_issues(table_issues, mapped_fields=set(mapping.values())):
|
||||
continue
|
||||
for row_index in range(1, grid.row_count):
|
||||
values: dict[str, str] = {}
|
||||
@@ -259,7 +289,9 @@ def parse_email_allocation_text(*, body_text: str, content_hash: str, schema_def
|
||||
break
|
||||
expected.append(field)
|
||||
if not ({'customer_po_number', 'po_number'} & set(expected)):
|
||||
return result
|
||||
# 与 HTML 路径一致:无 PO 时须已识别料号或预约号表头,否则安全返回空。
|
||||
if not _mapping_has_identity(set(expected)):
|
||||
return result
|
||||
column_count = len(expected)
|
||||
rows: list[dict[str, Any]] = []
|
||||
seen_rows: set[tuple[str, ...]] = set()
|
||||
|
||||
@@ -10,6 +10,7 @@ services/shipping_notice/order_review_draft_service.py
|
||||
逻辑:只修改独立 Draft JSON;每次写入锁定 Case/Draft、校验草稿版本与 WorkflowItem 可写状态,
|
||||
追加 CaseEvent + ShippingAuditEvent,并镜像 review_field_changed 到订单抽取进度流;
|
||||
Item 已关闭/重识别中的冲突经 `_reject_draft_operation` 落 rejected 审计;
|
||||
STP 等待入队/排队/执行期间拒绝草稿内容写入(显式 validate 仍放行供自动协调器);
|
||||
整单校验汇总客户确认、有效 Reservation、行级库存源候选与自动建单资格;
|
||||
行级必填 reservation_id 空值时先回退表头(与建单资格 / Schema Runtime 一致),再报缺失;
|
||||
确认建单摘要同样回填行级 reservation_id,供物化 FieldValue / 冻结门禁消费;
|
||||
@@ -225,7 +226,7 @@ def _locked_case(*, user_id: int, case_no: str, action: str) -> ShippingOrderRev
|
||||
按 owner 分别锁定 Case 和当前 Draft;不可编辑时写拒绝审计。
|
||||
|
||||
核心逻辑:两段 FOR UPDATE 避免 joinedload+nullable 侧锁问题;Case 可识别后
|
||||
若状态不在可编辑集合,先落 rejected 审计再抛错。
|
||||
若状态不在可编辑集合,先落 rejected 审计再抛错;STP 已接手时拒绝内容写入。
|
||||
"""
|
||||
case = (
|
||||
ShippingOrderReviewCase.query
|
||||
@@ -248,9 +249,92 @@ def _locked_case(*, user_id: int, case_no: str, action: str) -> ShippingOrderRev
|
||||
action=action,
|
||||
error=ConflictError('Order review case is not editable', code='SHIPPING.REVIEW_CASE_NOT_EDITABLE'),
|
||||
)
|
||||
# draft_validated 放行:自动协调器在入队前仍需显式校验;内容写入一律拦截。
|
||||
if str(action or '').strip() != 'draft_validated' and _stp_automation_holds_draft(case):
|
||||
_reject_draft_operation(
|
||||
case,
|
||||
actor_id=int(user_id),
|
||||
action=action,
|
||||
error=ConflictError(
|
||||
'Draft is locked while system auto-create is in progress',
|
||||
code='SHIPPING.REVIEW_DRAFT_LOCKED_BY_AUTOMATION',
|
||||
),
|
||||
)
|
||||
return case
|
||||
|
||||
|
||||
def _stp_waiting_timeout_seconds() -> int:
|
||||
"""与 order_review_projection 同源的 STP waiting_to_start 超时秒数。"""
|
||||
try:
|
||||
from flask import current_app
|
||||
|
||||
return max(int(current_app.config.get('SHIPPING_NOTICE_STP_WAITING_TIMEOUT_SECONDS', 120) or 120), 15)
|
||||
except Exception: # noqa: BLE001
|
||||
return 120
|
||||
|
||||
|
||||
def _stp_automation_holds_draft(case: ShippingOrderReviewCase) -> bool:
|
||||
"""
|
||||
判断 STP 是否已接手草稿(等待入队 / 排队 / 执行),期间禁止人工改草稿。
|
||||
|
||||
核心逻辑:有活跃 Job → 锁定;无 Job 但 can_auto_create+can_build 且未超时 → 锁定。
|
||||
"""
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from app.jobs.types import JobType
|
||||
from app.models import Job
|
||||
from app.services.shipping_notice.order_stp_auto_create_service import build_stp_idempotency_key
|
||||
|
||||
if case.confirmed_task_id is not None:
|
||||
return False
|
||||
draft = case.current_draft
|
||||
if draft is None or case.document_id is None:
|
||||
return False
|
||||
run = case.run
|
||||
run_no = str(getattr(run, 'run_no', '') or '').strip()
|
||||
if run_no:
|
||||
business_ref = build_stp_idempotency_key(
|
||||
run_no=run_no,
|
||||
document_id=int(case.document_id),
|
||||
draft_version=int(draft.draft_version),
|
||||
)
|
||||
active = (
|
||||
Job.query.filter(
|
||||
Job.domain == 'shipping_notice',
|
||||
Job.job_type == JobType.SHIPPING_STP_AUTO_CREATE.value,
|
||||
Job.business_ref == business_ref,
|
||||
Job.status.in_(('queued', 'running')),
|
||||
)
|
||||
.order_by(Job.id.desc())
|
||||
.first()
|
||||
)
|
||||
if active is not None:
|
||||
return True
|
||||
|
||||
validation = draft.validation_result_json if isinstance(draft.validation_result_json, dict) else {}
|
||||
if not (bool(validation.get('can_auto_create')) and bool(validation.get('can_build'))):
|
||||
return False
|
||||
if str(case.status or '') in {'confirmed', 'non_order', 'quality_issue'}:
|
||||
return False
|
||||
|
||||
validated_at = None
|
||||
raw_validated = str(validation.get('validated_at') or '').strip()
|
||||
if raw_validated:
|
||||
try:
|
||||
text = raw_validated[:-1] + '+00:00' if raw_validated.endswith('Z') else raw_validated
|
||||
validated_at = datetime.fromisoformat(text)
|
||||
except ValueError:
|
||||
validated_at = None
|
||||
anchor = validated_at or getattr(case, 'updated_at', None) or getattr(draft, 'updated_at', None)
|
||||
if anchor is not None:
|
||||
if getattr(anchor, 'tzinfo', None) is None:
|
||||
anchor = anchor.replace(tzinfo=timezone.utc)
|
||||
age = (datetime.now(timezone.utc) - anchor).total_seconds()
|
||||
if age >= _stp_waiting_timeout_seconds():
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def _expected_version(value: Any) -> int:
|
||||
"""写入接口必须明确带版本号,避免缺省值退化为最后写入者获胜。"""
|
||||
if isinstance(value, bool):
|
||||
|
||||
@@ -16,6 +16,7 @@ backend/app/services/shipping_notice/reconciliation_projector.py
|
||||
② project_case_allowed_actions(case, automation, is_admin)
|
||||
完整复刻 order_review_projection._allowed_actions 核心路径,
|
||||
注入 reconcile_and_progress 作为统一对账恢复入口;
|
||||
STP waiting_to_start/queued/running 时剥离 edit_draft/validate;
|
||||
REMOVE_SET 白名单剔除 retry_stp_auto_create 等;
|
||||
裁决动作 derive_blocking_next_actions 一致注入。
|
||||
③ project_case_current_gate(case, automation, available_actions)
|
||||
@@ -420,6 +421,12 @@ def project_case_allowed_actions(
|
||||
actions.append('edit_draft')
|
||||
|
||||
auto_status = str((automation or {}).get('status') or '').strip().lower()
|
||||
# STP 已接手(等待入队/排队/执行)期间禁止草稿编辑与显式校验,避免误改后仍自动建单。
|
||||
if auto_status in {'waiting_to_start', 'queued', 'running'}:
|
||||
actions = [
|
||||
action for action in actions
|
||||
if action not in {'edit_draft', 'create_draft', 'validate', 'request_llm_suggestion'}
|
||||
]
|
||||
if isinstance(automation, dict) and auto_status in {
|
||||
'failed', 'manual_fallback',
|
||||
} and not case.confirmed_task_id:
|
||||
@@ -839,7 +846,7 @@ def project_case_primary_action(
|
||||
return {'code': 'edit_draft', 'variant': 'primary',
|
||||
'label_key': 'shipping.actions.edit_draft'}
|
||||
|
||||
# 1g: running/queued → 次优先 view(但 edit_draft 仍然允许)
|
||||
# 1g: running → 不展示草稿主 CTA(STP 活跃时 edit_draft 已从 available_actions 剥离)。
|
||||
if user_status == 'running' and 'edit_draft' in actions:
|
||||
return None
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ services/shipping_notice/shipping_processing_projection.py
|
||||
已建 Notice 时填 shipping_notice_no;work_items 构建后由
|
||||
_conversation_processing_from_work_items 构建正式 conversation_processing;
|
||||
首屏摘要在订单抽取失败且无 Case 时下发 reparse + 最新 run_no;
|
||||
摘要对开放 Case 批量预取活跃 STP Job,queued/running 映射为 running,
|
||||
禁止把建单队列中误判为待人工;
|
||||
不投影会话级批量恢复动作;失败必须由用户在当前 Gate 选择具体动作。
|
||||
"""
|
||||
|
||||
@@ -63,6 +65,7 @@ from app.services.shipping_notice.processing_ownership import (
|
||||
)
|
||||
from app.services.shipping_notice.reconciliation_projector import (
|
||||
project_case_primary_action,
|
||||
project_case_user_status,
|
||||
)
|
||||
from app.services.shipping_notice.lifecycle_projection import (
|
||||
LIFECYCLE_STAGE_CODES,
|
||||
@@ -4022,6 +4025,10 @@ def project_conversation_processing_summary(
|
||||
建单前五阶段权威与 order-review-queue 对齐:开放 Case 只认 Case.candidate_id
|
||||
绑定的可复核 Candidate;不得用「Case 存在」或「文档上另有未绑定 Candidate」
|
||||
抬升 candidate_count / waiting_review→order_review。
|
||||
|
||||
开放 Case 的用户态须先认活跃 STP Job(queued/running → running),再认草稿
|
||||
can_auto_create+can_build 未超时(waiting_to_start → running),与工作台
|
||||
project_case_user_status 同源;不得仅因 Case 未确认就判 waiting_human。
|
||||
"""
|
||||
del agent_id
|
||||
normalized = str(conversation_id or '').strip()
|
||||
@@ -4209,6 +4216,7 @@ def project_conversation_processing_summary(
|
||||
ShippingOrderReviewCase.current_draft_id,
|
||||
ShippingOrderReviewCase.confirmed_task_id,
|
||||
ShippingOrderReviewCase.candidate_id,
|
||||
ShippingOrderReviewCase.updated_at,
|
||||
)).filter(
|
||||
ShippingOrderReviewStream.document_id.in_(document_ids) if document_ids else False,
|
||||
).all()
|
||||
@@ -4267,6 +4275,121 @@ def project_conversation_processing_summary(
|
||||
)
|
||||
}
|
||||
|
||||
# [STEP] 开放 Case 批量预取活跃 STP Job(与 full 会话投影同构前缀),
|
||||
# 供摘要 _status 在判 waiting_human 前与工作台同源认「系统仍在建单」。
|
||||
_OPEN_CASE_STATUSES_FOR_STP = {
|
||||
'unreviewed', 'draft', 'ready', 'quality_issue', 'reparse_pending',
|
||||
}
|
||||
active_stp_status_by_document_id: dict[int, str] = {}
|
||||
open_case_stp_prefixes: dict[str, int] = {}
|
||||
for case in current_case_by_document_id.values():
|
||||
if case.confirmed_task_id is not None or case.document_id is None or case.run_id is None:
|
||||
continue
|
||||
if str(case.status or '').strip().lower() not in _OPEN_CASE_STATUSES_FOR_STP:
|
||||
continue
|
||||
run = runs_by_id.get(int(case.run_id))
|
||||
run_no = str(getattr(run, 'run_no', '') or '').strip()
|
||||
if not run_no:
|
||||
continue
|
||||
prefix = f'stp-auto:{run_no}:doc-{int(case.document_id)}:'
|
||||
open_case_stp_prefixes[prefix] = int(case.document_id)
|
||||
if open_case_stp_prefixes:
|
||||
from app.jobs.types import JobType
|
||||
|
||||
for job in (
|
||||
Job.query.filter(
|
||||
Job.domain == 'shipping_notice',
|
||||
Job.job_type == JobType.SHIPPING_STP_AUTO_CREATE.value,
|
||||
Job.status.in_(('queued', 'running')),
|
||||
or_(*(Job.business_ref.like(f'{prefix}%') for prefix in open_case_stp_prefixes)),
|
||||
)
|
||||
.order_by(Job.id.desc())
|
||||
.all()
|
||||
):
|
||||
ref = str(job.business_ref or '').strip()
|
||||
status = str(job.status or '').strip().lower()
|
||||
if status not in {'queued', 'running'}:
|
||||
continue
|
||||
for prefix, document_id in open_case_stp_prefixes.items():
|
||||
if not ref.startswith(prefix):
|
||||
continue
|
||||
# 同前缀取最新 Job(已按 id desc);已写入则跳过更旧记录。
|
||||
active_stp_status_by_document_id.setdefault(document_id, status)
|
||||
break
|
||||
|
||||
# [STEP] Phase 2:无活跃 Job 的开放 Case,批量读草稿 can_auto_create/can_build,
|
||||
# 未超时则视为 waiting_to_start(系统已接手),与工作台 F2 对齐。
|
||||
waiting_to_start_document_ids: set[int] = set()
|
||||
open_draft_ids = [
|
||||
int(case.current_draft_id)
|
||||
for case in current_case_by_document_id.values()
|
||||
if (
|
||||
case.confirmed_task_id is None
|
||||
and case.current_draft_id is not None
|
||||
and case.document_id is not None
|
||||
and str(case.status or '').strip().lower() in _OPEN_CASE_STATUSES_FOR_STP
|
||||
and int(case.document_id) not in active_stp_status_by_document_id
|
||||
)
|
||||
]
|
||||
drafts_by_id: dict[int, ShippingOrderReviewDraft] = {}
|
||||
if open_draft_ids:
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from app.services.shipping_notice.order_review_projection import (
|
||||
_stp_waiting_timeout_seconds as _summary_stp_waiting_timeout_seconds,
|
||||
)
|
||||
|
||||
for draft in ShippingOrderReviewDraft.query.options(load_only(
|
||||
ShippingOrderReviewDraft.id,
|
||||
ShippingOrderReviewDraft.validation_result_json,
|
||||
ShippingOrderReviewDraft.updated_at,
|
||||
)).filter(ShippingOrderReviewDraft.id.in_(open_draft_ids)).all():
|
||||
drafts_by_id[int(draft.id)] = draft
|
||||
|
||||
def _parse_validated_at(raw: Any):
|
||||
text = str(raw or '').strip()
|
||||
if not text:
|
||||
return None
|
||||
try:
|
||||
if text.endswith('Z'):
|
||||
text = text[:-1] + '+00:00'
|
||||
return datetime.fromisoformat(text)
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
timeout_sec = _summary_stp_waiting_timeout_seconds()
|
||||
for case in current_case_by_document_id.values():
|
||||
if case.confirmed_task_id is not None or case.document_id is None:
|
||||
continue
|
||||
doc_id = int(case.document_id)
|
||||
if doc_id in active_stp_status_by_document_id:
|
||||
continue
|
||||
if str(case.status or '').strip().lower() not in _OPEN_CASE_STATUSES_FOR_STP:
|
||||
continue
|
||||
draft = (
|
||||
drafts_by_id.get(int(case.current_draft_id))
|
||||
if case.current_draft_id is not None else None
|
||||
)
|
||||
if draft is None:
|
||||
continue
|
||||
validation = (
|
||||
draft.validation_result_json
|
||||
if isinstance(draft.validation_result_json, dict) else {}
|
||||
)
|
||||
if not (bool(validation.get('can_auto_create')) and bool(validation.get('can_build'))):
|
||||
continue
|
||||
anchor = (
|
||||
_parse_validated_at(validation.get('validated_at'))
|
||||
or getattr(case, 'updated_at', None)
|
||||
or getattr(draft, 'updated_at', None)
|
||||
)
|
||||
if anchor is not None:
|
||||
if getattr(anchor, 'tzinfo', None) is None:
|
||||
anchor = anchor.replace(tzinfo=timezone.utc)
|
||||
if (datetime.now(timezone.utc) - anchor).total_seconds() >= timeout_sec:
|
||||
continue
|
||||
waiting_to_start_document_ids.add(doc_id)
|
||||
|
||||
def _status(
|
||||
document: ShippingOrderDocument,
|
||||
task: ShippingOrderTask | None,
|
||||
@@ -4285,9 +4408,16 @@ def project_conversation_processing_summary(
|
||||
if gate_status == 'cancelled':
|
||||
return 'cancelled', gate_code, gate_reason
|
||||
case_status = str(getattr(case, 'status', None) or '').strip().lower()
|
||||
if case is not None and case.confirmed_task_id is None and case_status in {
|
||||
'unreviewed', 'draft', 'ready', 'quality_issue', 'reparse_pending',
|
||||
}:
|
||||
if case is not None and case.confirmed_task_id is None and case_status in _OPEN_CASE_STATUSES_FOR_STP:
|
||||
# 活跃 STP 或 waiting_to_start = 系统仍在建单;与 project_case_user_status 对齐。
|
||||
doc_id = int(case.document_id) if case.document_id is not None else int(document.id)
|
||||
stp_status = active_stp_status_by_document_id.get(doc_id)
|
||||
if stp_status in {'queued', 'running'}:
|
||||
mapped = project_case_user_status(case, {'status': stp_status})
|
||||
return mapped, 'waiting_review', None
|
||||
if doc_id in waiting_to_start_document_ids:
|
||||
mapped = project_case_user_status(case, {'status': 'waiting_to_start'})
|
||||
return mapped, 'waiting_review', None
|
||||
return 'waiting_human', 'waiting_review', f'review_case_{case_status}'
|
||||
raw = str(task.status if task is not None else document.order_extraction_status or '').strip().lower()
|
||||
stage = str(task.stage if task is not None else '').strip().lower() or (
|
||||
@@ -4378,13 +4508,18 @@ def project_conversation_processing_summary(
|
||||
if has_current_candidate:
|
||||
# Case 已绑定可复核 Candidate 后进入订单复核;仅用已批量读取的
|
||||
# current_draft_id 恢复权威业务动作,避免摘要路径逐文件加载 Case 详情。
|
||||
available_actions = ['edit_draft' if case.current_draft_id else 'create_draft']
|
||||
primary_action = project_case_primary_action(
|
||||
user_status,
|
||||
{'code': reason, 'i18n_key': None, 'details': None},
|
||||
available_actions,
|
||||
user_stage='order_review',
|
||||
)
|
||||
# STP 系统处理中禁止暴露 edit/create_draft,与 Case bundle 动作白名单一致。
|
||||
if user_status == 'running':
|
||||
available_actions = []
|
||||
primary_action = None
|
||||
else:
|
||||
available_actions = ['edit_draft' if case.current_draft_id else 'create_draft']
|
||||
primary_action = project_case_primary_action(
|
||||
user_status,
|
||||
{'code': reason, 'i18n_key': None, 'details': None},
|
||||
available_actions,
|
||||
user_stage='order_review',
|
||||
)
|
||||
else:
|
||||
# 无有效 Candidate 的 Case 仍在接收解析处置;阶段按钮只负责导航,
|
||||
# 文件主动作必须是服务端已经授权的重解析命令。
|
||||
|
||||
Reference in new issue
Block a user