fix(shipping-notice): 任务中心OT直链补case_no锚点并修复工作台装配期懒加载竞态
This commit is contained in:
1 parent
65f751daf4
commit
0333d713e0
6 files changed
+136
-26
No files matched your search
@@ -1468,8 +1468,8 @@ def _inject_unified_processing_fields(task: ShippingNotice, data: dict[str, Any]
|
||||
order_task_id → ShippingOrderTask。有 OT 时用领域事实映射为
|
||||
shipping_processing_status(与 shipping_processing_projection 同源),
|
||||
并注入 shipping_processing_stage / progress_version / order_task_no;
|
||||
另附带 review_run_no / owner_agent_id / conversation_id(经 OT.extraction_run),
|
||||
供任务中心「进入订单处理」深链。
|
||||
另附带 review_run_no / review_case_no / owner_agent_id / conversation_id(经 OT.extraction_run
|
||||
与 OT 反查确认 Case),供任务中心「进入订单处理」深链。
|
||||
|
||||
Args:
|
||||
task: ShippingNotice 或 ShippingOrderTask。
|
||||
@@ -1517,6 +1517,19 @@ def _inject_unified_processing_fields(task: ShippingNotice, data: dict[str, Any]
|
||||
data['conversation_id'] = cid
|
||||
if data.get('owner_agent_id') is None and getattr(run, 'owner_agent_id', None) is not None:
|
||||
data['owner_agent_id'] = int(run.owner_agent_id)
|
||||
# [STEP 3] 注入确认 Case 号:工作台以 case_no 绑定工作项,OT 直链缺失该字段时
|
||||
# 选法 2 不会拉 Case,任务详情身份链断裂、五阶段页签全锁(2026-09-17 工作台直链修复)。
|
||||
# confirmed_task_id 唯一约束保证 OT→Case 至多一条,点查代价可忽略。
|
||||
if order_task is not None and not str(data.get('review_case_no') or '').strip():
|
||||
confirmed_case = (
|
||||
ShippingOrderReviewCase.query
|
||||
.filter_by(confirmed_task_id=int(order_task.id))
|
||||
.first()
|
||||
)
|
||||
if confirmed_case is not None:
|
||||
case_no = str(confirmed_case.case_no or '').strip()
|
||||
if case_no:
|
||||
data['review_case_no'] = case_no
|
||||
|
||||
|
||||
def _enrich_task_center_fields(
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
"""
|
||||
backend/tests/test_shipping_task_center_review_run_deep_link.py
|
||||
|
||||
用途:验收任务中心 Notice/OT 摘要注入 review_run_no 与 order_task_no,供 UI-04 深链
|
||||
与工作台右卡 work-item 投影键。
|
||||
用途:验收任务中心 Notice/OT 摘要注入 review_run_no / order_task_no / review_case_no,
|
||||
供 UI-04 深链(run_no + case_no)与工作台右卡 work-item 投影键。
|
||||
依赖:query_service._inject_unified_processing_fields、ShippingOrderTask、pytest。
|
||||
逻辑:Notice 挂 OT 时 SUMMARY 必含 review_run_no;直接序列化 OT 时 order_task_no
|
||||
必须等于自身 task_no(禁止 enrich 冲成 null)。
|
||||
必须等于自身 task_no(禁止 enrich 冲成 null);OT 有确认 Case 时必须注入
|
||||
review_case_no(缺它工作台选法 2 不拉 Case、身份链断裂、五阶段页签全锁)。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -98,3 +99,50 @@ def test_serialize_order_task_keeps_self_order_task_no_after_enrich(app):
|
||||
assert detail['order_task_no'] == 'OT-TC-OT-SELF-1'
|
||||
assert detail['task_no'] == 'OT-TC-OT-SELF-1'
|
||||
assert detail['review_run_no'] == run.run_no
|
||||
|
||||
|
||||
def test_serialize_order_task_injects_confirmed_review_case_no_for_workbench_deeplink(app):
|
||||
"""
|
||||
OT 摘要/详情必须携带确认 Case 号,任务中心 OT 直链才能绑定工作台工作项。
|
||||
|
||||
关键断言:无 case_no 的 OT 直链下,工作台对正式下游阶段任务走选法 2 不拉 Case,
|
||||
activeCase/displayCase/confirmedNoticeTaskNo 全空、五阶段页签全锁;
|
||||
review_case_no 是 openOrderProcessing 追加 case_no 深链参数的唯一来源,
|
||||
SUMMARY 与 workbench DETAIL 都必须注入。
|
||||
"""
|
||||
with app.app_context():
|
||||
from app.models import ShippingOrderReviewCase
|
||||
from tests.test_shipping_order_extraction_runs import _seed_run_input
|
||||
from tests.test_shipping_order_review_service import _materialized_run
|
||||
|
||||
user, agent, session, intake, document = _seed_run_input(suffix='TC-CASE-LINK')
|
||||
run = _materialized_run(user=user, agent=agent, session=session, intake=intake)
|
||||
order_task = ShippingOrderTask(
|
||||
task_no='OT-TC-CASE-LINK-1',
|
||||
user_id=user.id,
|
||||
conversation_id=session.session_id,
|
||||
extraction_run_id=int(run.id),
|
||||
owner_agent_id=int(agent.id),
|
||||
status='blocked',
|
||||
stage='inventory_fetching',
|
||||
progress_version=2,
|
||||
)
|
||||
db.session.add(order_task)
|
||||
db.session.flush()
|
||||
# 模拟 RPA 超时阻断的正式下游 OT:存在一条已确认绑定该 OT 的复核 Case。
|
||||
case = ShippingOrderReviewCase(
|
||||
case_no='SNRC-TC-CASE-LINK', run_id=int(run.id),
|
||||
unit_id=int(run.extraction_plan.units[0].id),
|
||||
document_id=int(document.id), owner_user_id=user.id,
|
||||
status='confirmed', confirmed_task_id=int(order_task.id),
|
||||
)
|
||||
db.session.add(case)
|
||||
db.session.commit()
|
||||
|
||||
summary = serialize_task_summary(order_task, viewer_user_id=user.id)
|
||||
detail = serialize_task_detail(
|
||||
order_task, viewer_user_id=user.id, include_stage_context=True, view='workbench',
|
||||
)
|
||||
# 关键断言:SUMMARY / workbench DETAIL 均注入确认 Case 号(深链 case_no 锚点)。
|
||||
assert summary['review_case_no'] == 'SNRC-TC-CASE-LINK'
|
||||
assert detail['review_case_no'] == 'SNRC-TC-CASE-LINK'
|
||||
Reference in new issue
Block a user