feat(chat): 优化发货相关消息处理逻辑
- 在列出聊天消息时,过滤掉类型为'shipping-parse-review'的消息 - 移除不再使用的shippingConversationTaskIdCache - 更新发货决策处理逻辑,简化保存消息的参数 - 添加发货动作按钮刷新时的任务定位优先级逻辑 - 移除解析复核消息的展示逻辑,统一处理到轻量工作台 - 增加单元测试,验证发货动作按钮刷新时的任务定位优先级
This commit is contained in:
1 parent
9f5493185d
commit
6a0a51313f
18 files changed
+1230
-199
No files matched your search
@@ -37,17 +37,12 @@ def _latest_batch_for_conversation(conversation_id: str) -> ShippingBatch | None
|
||||
)
|
||||
|
||||
|
||||
def _latest_task_for_conversation(conversation_id: str) -> ShippingTask | None:
|
||||
"""按会话号获取最近一个未拒绝任务,用于恢复当前任务焦点。"""
|
||||
conv_id = str(conversation_id or "").strip()
|
||||
if not conv_id:
|
||||
def _task_by_task_no(task_id: str) -> ShippingTask | None:
|
||||
"""按显式 task_id 获取任务;仅用于补齐批次 ref,禁止按会话号猜测当前任务。"""
|
||||
normalized = str(task_id or "").strip().upper()
|
||||
if not normalized:
|
||||
return None
|
||||
return (
|
||||
ShippingTask.query.filter_by(conversation_id=conv_id)
|
||||
.filter(ShippingTask.process_status.notin_(["rejected"]))
|
||||
.order_by(ShippingTask.id.desc())
|
||||
.first()
|
||||
)
|
||||
return ShippingTask.query.filter_by(task_no=normalized).first()
|
||||
|
||||
|
||||
def _build_hxops_refs(*, task: str, batch: str) -> list[dict[str, str]]:
|
||||
@@ -81,24 +76,22 @@ def build_dify_chat_inputs(
|
||||
explicit_batch = str(batch_no or "").strip().upper()
|
||||
|
||||
batch = _latest_batch_for_conversation(conv_id)
|
||||
task = _latest_task_for_conversation(conv_id)
|
||||
explicit_task_row = _task_by_task_no(explicit_task)
|
||||
|
||||
focus_task = explicit_task
|
||||
if not focus_task and batch and batch.current_focus_task_no:
|
||||
focus_task = str(batch.current_focus_task_no or "").strip().upper()
|
||||
elif not focus_task and task and task.task_no:
|
||||
focus_task = str(task.task_no or "").strip().upper()
|
||||
|
||||
focus_batch = explicit_batch
|
||||
if not focus_batch and batch and batch.batch_no:
|
||||
focus_batch = str(batch.batch_no or "").strip().upper()
|
||||
elif (
|
||||
not focus_batch
|
||||
and task
|
||||
and getattr(task, "batch", None) is not None
|
||||
and getattr(task.batch, "batch_no", None)
|
||||
and explicit_task_row
|
||||
and getattr(explicit_task_row, "batch", None) is not None
|
||||
and getattr(explicit_task_row.batch, "batch_no", None)
|
||||
):
|
||||
focus_batch = str(task.batch.batch_no or "").strip().upper()
|
||||
focus_batch = str(explicit_task_row.batch.batch_no or "").strip().upper()
|
||||
|
||||
hxops_context = build_hxops_context(
|
||||
session_id=conv_id,
|
||||
|
||||
Reference in new issue
Block a user