From c974566c34ba679235140966c2addfd908a525dd Mon Sep 17 00:00:00 2001 From: caohuipeng Date: Mon, 8 Jun 2026 20:13:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(shipping-notice):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=8F=91=E8=B4=A7=E9=80=9A=E7=9F=A5Agent=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=B9=B6=E4=BF=AE=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/chat.py | 4 ---- backend/app/services/shipping_notice/openapi_spec.py | 1 + frontend/src/i18n.ts | 2 +- frontend/src/views/ChatView.vue | 8 ++++++++ frontend/src/views/ShippingNoticeView.vue | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/backend/app/api/chat.py b/backend/app/api/chat.py index 2528b49f..a421bd44 100644 --- a/backend/app/api/chat.py +++ b/backend/app/api/chat.py @@ -1103,7 +1103,6 @@ def chat_completions(): raise ValidationError('This route does not support attachments') generator = Text2SQLService.stream_chat(query, user_proxy.id, agent_proxy, external_conversation_id, session_id=session.session_id) else: -<<<<<<< HEAD from app.services.hr_leave_sqlserver import HRLeaveSQLServerService if HRLeaveSQLServerService.supports(query): if normalized_files: @@ -1124,9 +1123,6 @@ def chat_completions(): files=normalized_files, inputs=dify_inputs, ) -======= - generator = DifyService.stream_chat(query, user_proxy.id, agent_proxy, external_conversation_id, request_id=request_id, session_id=session.session_id, files=normalized_files) ->>>>>>> dev def relay_stream(): created_event = { diff --git a/backend/app/services/shipping_notice/openapi_spec.py b/backend/app/services/shipping_notice/openapi_spec.py index dd5500ec..600e20e0 100644 --- a/backend/app/services/shipping_notice/openapi_spec.py +++ b/backend/app/services/shipping_notice/openapi_spec.py @@ -78,6 +78,7 @@ def build_dify_openapi_spec(base_url: str) -> dict[str, Any]: "create_task", "创建发货任务 task", { + "task_id": _str_prop("已存在的发货任务编号(可选)。传入时将直接复用该任务,禁止重复创建。"), "user_id": _int_prop("Hxops 用户 ID(可选)"), "conversation_id": _str_prop("Dify 会话 ID,便于工作台关联"), "source_type": _str_prop("来源:manual|email|wecom|pdf", enum=["manual", "email", "wecom", "pdf"]), diff --git a/frontend/src/i18n.ts b/frontend/src/i18n.ts index 2e8ee7b5..2573e125 100644 --- a/frontend/src/i18n.ts +++ b/frontend/src/i18n.ts @@ -2823,7 +2823,7 @@ const messages = { thinking: '正在生成回答...', disclaimer: 'AI 可能会犯错,请核实重要信息。', createNewChat: '创建新对话', - shippingNoticeContinue: '请继续处理发货任务 {taskId},请先调用 get_task_status 查询当前状态并告知我下一步。', + shippingNoticeContinue: '请继续处理发货任务 {taskId}。该任务已存在,禁止调用 create_task。请先调用 get_task_status(task_id={taskId})查询当前状态并告知我下一步。', shippingNoticeActionsHint: '请选择操作:', shippingNoticeMissingTaskId: '未找到任务编号,请先完成发货通知解析。', shippingNoticeUploadDone: '库存文件已上传:{fileName}。', diff --git a/frontend/src/views/ChatView.vue b/frontend/src/views/ChatView.vue index 6c5d6f13..5c3ac05e 100644 --- a/frontend/src/views/ChatView.vue +++ b/frontend/src/views/ChatView.vue @@ -2403,11 +2403,14 @@ const findHistorySessionForShippingTask = (taskId: string) => { return history.value.find((item) => String(item.title || '').toUpperCase().includes(needle)) || null; }; +const autoResumedShippingTasks = ref>({}); + const resumeShippingTaskFromQuery = async () => { const taskId = shippingTaskIdFromQuery.value; if (!taskId || !isShippingNoticeAgent.value) return; if (route.query.conversation_id) return; if (presetQuestion.value) return; + if (autoResumedShippingTasks.value[taskId]) return; const existing = findHistorySessionForShippingTask(taskId); if (existing) { @@ -2415,6 +2418,7 @@ const resumeShippingTaskFromQuery = async () => { return; } + autoResumedShippingTasks.value[taskId] = true; input.value = t('chat.shippingNoticeContinue', { taskId }); await handleSend(); }; @@ -3925,6 +3929,10 @@ const loadConversation = async (id: string, options?: { force?: boolean }) => { loadConversationState(id, Array.isArray(loaded) ? loaded : []); if (!loaded?.length) { msg.warning(t('chat.historyEmpty')); + if (isShippingNoticeAgent.value && shippingTaskIdFromQuery.value && !isThinking.value) { + await router.replace({ path: route.path, query: { task_id: shippingTaskIdFromQuery.value } }); + return; + } } void refreshShippingActions(); } catch (e) { diff --git a/frontend/src/views/ShippingNoticeView.vue b/frontend/src/views/ShippingNoticeView.vue index d0ef19bb..75e4a67e 100644 --- a/frontend/src/views/ShippingNoticeView.vue +++ b/frontend/src/views/ShippingNoticeView.vue @@ -93,7 +93,7 @@ const openInChat = (taskNo: string, conversationId?: string | null) => { if (!chatAgentId.value) return; const query: Record = { task_id: taskNo }; const cid = String(conversationId || '').trim(); - if (cid) query.conversation_id = cid; + if (/^[0-9a-f]{32}$/i.test(cid)) query.conversation_id = cid; router.push({ path: `/chat/${chatAgentId.value}`, query }); };