feat(shipping_notice): 添加重新上传发货通知功能
- 新增接口支持覆盖当前任务的发货通知 - 重新解析时重置任务状态,避免重复任务 - 增加库存 RPA 等待时间的复查逻辑 - 更新状态机以处理文本抽取失败的情况 - 增强测试用例以覆盖新功能
This commit is contained in:
1 parent
f434402530
commit
7f1d5dfbcd
20 files changed
+691
-26
No files matched your search
@@ -8,6 +8,7 @@ import { computed } from 'vue';
|
||||
import {
|
||||
createWorkspaceShippingBatchFromNotices,
|
||||
createWorkspaceShippingTask,
|
||||
replaceWorkspaceShippingTaskNotice,
|
||||
uploadWorkspaceShippingInventory,
|
||||
type ShippingTaskSummary,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
@@ -133,6 +134,26 @@ export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext)
|
||||
}
|
||||
};
|
||||
|
||||
const handleReplaceNoticeForCurrentTask = async (taskId: string, file: File) => {
|
||||
const result = await replaceWorkspaceShippingTaskNotice(taskId, file);
|
||||
syncBatchContextFromNoticeResponse(result as unknown as Record<string, unknown>);
|
||||
ctx.resolvedShippingTaskId.value = taskId;
|
||||
const hint = String(result.message || '').trim();
|
||||
const status = String((result as { status?: string }).status || '').trim();
|
||||
const orchestratorStarted = Boolean(
|
||||
(result.data as { orchestrator_started?: boolean } | undefined)?.orchestrator_started,
|
||||
);
|
||||
await ctx.pushShippingLocalAssistantMessage(
|
||||
[
|
||||
hint || `已重新上传发货通知并覆盖当前任务 ${taskId}`,
|
||||
`任务编号:${taskId}`,
|
||||
orchestratorStarted ? '后台已开始重新解析当前任务,请稍后查看进度自动刷新。' : '',
|
||||
status === 'needs_human' ? '请根据提示重新上传清晰文件,或粘贴通知正文。' : '',
|
||||
].filter(Boolean).join('\n'),
|
||||
);
|
||||
void ctx.refreshShippingActions();
|
||||
};
|
||||
|
||||
const handleShippingAutoUploadFile = async (file: File) => {
|
||||
const kind = classifyShippingUploadFile(file, extractExt);
|
||||
if (kind === 'inventory') {
|
||||
@@ -152,6 +173,11 @@ export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext)
|
||||
await uploadInventoryForTask(taskId, file);
|
||||
return;
|
||||
}
|
||||
const activeTaskId = String(ctx.getActiveShippingTaskId() || '').trim().toUpperCase();
|
||||
if (activeTaskId) {
|
||||
await handleReplaceNoticeForCurrentTask(activeTaskId, file);
|
||||
return;
|
||||
}
|
||||
const result = await createWorkspaceShippingBatchFromNotices(
|
||||
[file],
|
||||
String(ctx.conversationId.value || '').trim() || undefined,
|
||||
@@ -188,6 +214,12 @@ export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext)
|
||||
const handleShippingAutoUploadNoticeBatch = async (files: File[]) => {
|
||||
const noticeFiles = files.filter(Boolean);
|
||||
if (!noticeFiles.length) return;
|
||||
const activeTaskId = String(ctx.getActiveShippingTaskId() || '').trim().toUpperCase();
|
||||
const singleNoticeFile = noticeFiles[0];
|
||||
if (noticeFiles.length === 1 && activeTaskId && singleNoticeFile) {
|
||||
await handleReplaceNoticeForCurrentTask(activeTaskId, singleNoticeFile);
|
||||
return;
|
||||
}
|
||||
const result = await createWorkspaceShippingBatchFromNotices(
|
||||
noticeFiles,
|
||||
String(ctx.conversationId.value || '').trim() || undefined,
|
||||
|
||||
Reference in new issue
Block a user