feat(shipping-notice): 增强发货通知候选管理功能,支持候选选择、重复检测与业务摘要修订
This commit is contained in:
1 parent
70f684b94a
commit
b595e157e9
83 files changed
+5857
-200
No files matched your search
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* features/chat/shipping/useChatShippingSendHandler.ts
|
||||
* 用途:在聊天发送前拦截发货通知专属意图,如切票、决策文本、列映射和附件自动流程。
|
||||
* 用途:在聊天发送前拦截发货通知专属意图,如订单抽取、切票、决策文本、列映射和附件自动流程。
|
||||
* 依赖:shipping.api、shippingIntents、shippingMenu、shippingMapping、shippingDownload、chat.types。
|
||||
* 逻辑:业务动作经 Chat Turn / handleShippingMenuAction;纯 UI(下载/选文件/映射卡片)保留本地或客户端行为。
|
||||
* 逻辑:已预处理 Intake 通过普通聊天接口进入现有 Dify Chatflow;其他业务动作经 Chat Turn / handleShippingMenuAction。
|
||||
*/
|
||||
import {
|
||||
getWorkspaceShippingBatch,
|
||||
@@ -50,6 +50,8 @@ export interface ShippingSendHandlerContext {
|
||||
agentId: number,
|
||||
kb: string,
|
||||
files: ChatUploadFileSpec[],
|
||||
context?: { task_id?: string; batch_no?: string; shipping_intake_nos?: string[]; display_query?: string },
|
||||
hooks?: { onAssistantMessageFinished?: (message: ChatMessage, runMessages: ChatMessage[]) => void | Promise<void> },
|
||||
) => Promise<void>;
|
||||
buildFileSpecsForSend: () => Promise<ChatUploadFileSpec[]>;
|
||||
loadHistory: () => Promise<void>;
|
||||
@@ -65,8 +67,12 @@ export interface ShippingSendHandlerContext {
|
||||
hasBlockingNoticeIntake?: () => boolean;
|
||||
hasNoticeIntakeFailures?: () => boolean;
|
||||
hasBlockingNoticeDuplicates?: () => boolean;
|
||||
hasCandidateReviewIssues?: () => boolean;
|
||||
hasSelectedNoticeCandidates?: () => boolean;
|
||||
openShippingDuplicateDialog?: (attachmentId?: string) => void;
|
||||
getParsedIntakeNos?: () => string[];
|
||||
refreshNoticeIntakeStatuses?: () => Promise<void>;
|
||||
clearConsumedNoticeAttachments?: () => void;
|
||||
refreshShippingActions: () => Promise<void>;
|
||||
shippingSuggestedPrompt: ComputedRef<string>;
|
||||
isShippingShortageQueryIntent: (text: string) => boolean;
|
||||
@@ -78,7 +84,7 @@ export interface ShippingSendHandlerContext {
|
||||
/**
|
||||
* 创建发货通知发送拦截器。
|
||||
*
|
||||
* 核心逻辑:识别切换任务、数字菜单、决策文本、映射文本、上传/导出意图,并在命中时直接走本地前后端流程。
|
||||
* 核心逻辑:已预处理邮件固定 Intake 上下文后调用普通聊天;其余识别切换任务、数字菜单、决策文本、映射文本、上传/导出意图。
|
||||
* @param ctx - 发送拦截上下文
|
||||
* @returns 发送前文本与附件自动流程处理函数;返回 true 表示已消费本次发送
|
||||
*/
|
||||
@@ -203,17 +209,30 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeParseFailedHint'));
|
||||
return true;
|
||||
}
|
||||
if (ctx.hasBlockingNoticeDuplicates?.()) {
|
||||
ctx.openShippingDuplicateDialog?.();
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeDuplicateNeedsResolution'));
|
||||
return true;
|
||||
}
|
||||
const intakeNos = ctx.getParsedIntakeNos?.() || [];
|
||||
if (intakeNos.length && (!trimmed || ctx.shippingAutoFlowRequested.value)) {
|
||||
if (intakeNos.length) {
|
||||
const query = trimmed || ctx.t('chat.shippingOrderExtractionDefaultPrompt');
|
||||
ctx.shippingAutoFlowRequested.value = false;
|
||||
if (typeof textOrEvent !== 'string') ctx.input.value = '';
|
||||
try {
|
||||
await ctx.handleShippingAutoUploadNoticeBatch([]);
|
||||
await ctx.sendMessage(
|
||||
query,
|
||||
ctx.currentAgentId.value,
|
||||
ctx.selectedKb.value,
|
||||
[],
|
||||
{
|
||||
shipping_intake_nos: intakeNos,
|
||||
display_query: query,
|
||||
},
|
||||
{
|
||||
onAssistantMessageFinished: async () => {
|
||||
await ctx.refreshNoticeIntakeStatuses?.();
|
||||
ctx.clearConsumedNoticeAttachments?.();
|
||||
await ctx.refreshShippingActions();
|
||||
},
|
||||
},
|
||||
);
|
||||
await ctx.loadHistory();
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : '文件处理失败';
|
||||
ctx.msg.warning(errorMessage);
|
||||
|
||||
Reference in new issue
Block a user