feat(shipping-notice,receipt-report): 新增收料报表功能并优化发货通知流程
清理废弃的shipping xfa ocr automark相关代码和job配置 新增收料报表管理的前端页面、路由和侧边栏入口 新增后端收料报表配置接口、数据库模型和RPA脚本 优化发货通知流程的重试策略,将shipping相关job默认不自动重试 移除废弃的库存源确认相关逻辑,更新流程门禁规则 重构订单模板的值适配器模块,新增坐标OCR值适配器 清理前端shipping菜单和action的废弃选项 更新相关文档和测试用例,调整.gitignore忽略规则
This commit is contained in:
1 parent
260465b72d
commit
1b6483a4ea
466 files changed
+32115
-33796
No files matched your search
@@ -1,28 +1,13 @@
|
||||
/**
|
||||
* features/chat/shipping/useChatShippingDecision.ts
|
||||
* 用途:封装人工决策提交与手工上传标记逻辑,统一走 Chat Turn SSE。
|
||||
* 依赖:shippingTurnActions、chat-turn.types、chat.types。
|
||||
* 逻辑:由 useChatShipping 调用;所有决策/手工上传经 startChatTurn,不再 push 本地消息或直调 workspace API。
|
||||
* 用途:阻止 Chat 提交已迁入正式 OT Gate 的履约写操作。
|
||||
* 依赖:chat.types。
|
||||
* 逻辑:历史聊天指令只刷新权威投影并提示进入任务处理页;不再构造 Chat Turn 或上传凭据。
|
||||
*/
|
||||
import { buildShippingSubmitDecisionTurn, buildShippingTurnRefs } from './shippingTurnActions';
|
||||
import { reportShippingDebugEvent } from './shippingDebugReporter';
|
||||
import { uploadFileAsset } from '@/shared/api/file-assets.api';
|
||||
import type { StartChatTurnOptions } from '../types/chat-turn.types';
|
||||
import type { ChatMessage, ChatSessionItem } from '../types/chat.types';
|
||||
import type { ComputedRef, Ref } from 'vue';
|
||||
|
||||
export interface ShippingDecisionContext {
|
||||
messages: Ref<ChatMessage[]>;
|
||||
conversationId: Ref<string | null>;
|
||||
history: Ref<ChatSessionItem[]>;
|
||||
isShippingNoticeAgent: ComputedRef<boolean>;
|
||||
currentAgentId: ComputedRef<number>;
|
||||
getActiveShippingTaskId: () => string;
|
||||
getActiveShippingBatchNo: () => string;
|
||||
loadHistory: () => Promise<void>;
|
||||
refreshShippingActions: () => Promise<void>;
|
||||
startChatTurn: (options: StartChatTurnOptions) => Promise<boolean>;
|
||||
msg: { warning: (text: string) => void; success: (text: string) => void };
|
||||
msg: { warning: (text: string) => void };
|
||||
t: (key: string, params?: Record<string, unknown>) => string;
|
||||
}
|
||||
|
||||
@@ -34,139 +19,36 @@ export interface ExecuteShippingDecisionOptions {
|
||||
/**
|
||||
* 创建发货通知决策处理器。
|
||||
*
|
||||
* 核心逻辑:构造 shipping.submit_decision Chat Turn,由平台 SSE 统一渲染 user/assistant 与 ChatLog。
|
||||
* 核心逻辑:Chat 不再有履约写执行权,只刷新后端 Gate 投影。
|
||||
* @param ctx - 决策处理上下文
|
||||
* @returns 人工决策与手工上传确认处理函数
|
||||
*/
|
||||
export function createShippingDecisionHandlers(ctx: ShippingDecisionContext) {
|
||||
const manualUploadInFlightTaskIds = new Set<string>();
|
||||
|
||||
const reportRetryRpaDebug = (hypothesisId: string, msg: string, data: Record<string, unknown>) =>
|
||||
reportShippingDebugEvent('useChatShippingDecision.ts', hypothesisId, msg, data);
|
||||
|
||||
const syncHistoryIfNeeded = async () => {
|
||||
if (!ctx.conversationId.value && ctx.history.value.length === 0) {
|
||||
await ctx.loadHistory();
|
||||
} else if (ctx.conversationId.value) {
|
||||
const exists = ctx.history.value.some((h) => h.conversation_id === ctx.conversationId.value);
|
||||
if (!exists) await ctx.loadHistory();
|
||||
}
|
||||
};
|
||||
|
||||
const afterDecisionTurn = async () => {
|
||||
await syncHistoryIfNeeded();
|
||||
void ctx.refreshShippingActions();
|
||||
};
|
||||
|
||||
/**
|
||||
* 在 Chat 操作中选择并上传人工货代回执,返回当前用户私有的 FileAsset 编号。
|
||||
* 取消选择不会提交“已手工上传”动作,确保后端的证据门禁没有绕过路径。
|
||||
*/
|
||||
const selectManualUploadEvidence = () => new Promise<File | null>((resolve) => {
|
||||
const picker = document.createElement('input');
|
||||
picker.type = 'file';
|
||||
picker.accept = 'image/*,.pdf';
|
||||
picker.style.display = 'none';
|
||||
document.body.appendChild(picker);
|
||||
let settled = false;
|
||||
const finish = (file: File | null) => {
|
||||
if (settled) return;
|
||||
settled = true;
|
||||
picker.remove();
|
||||
resolve(file);
|
||||
};
|
||||
picker.addEventListener('change', () => finish(picker.files?.[0] || null), { once: true });
|
||||
picker.addEventListener('cancel', () => finish(null), { once: true });
|
||||
// 部分浏览器不会触发 cancel;窗口重新获得焦点后仍未选择文件即视为取消。
|
||||
window.addEventListener('focus', () => setTimeout(() => finish(picker.files?.[0] || null), 0), { once: true });
|
||||
picker.click();
|
||||
});
|
||||
|
||||
/**
|
||||
* 提交发货人工决策,经 Chat Turn 统一 SSE 返回。
|
||||
*/
|
||||
/** 历史 Chat 决策只刷新 Gate 投影,禁止绕过正式 OT。 */
|
||||
const executeShippingDecision = async (
|
||||
decision: string,
|
||||
displayText?: string,
|
||||
options?: ExecuteShippingDecisionOptions,
|
||||
) => {
|
||||
const taskId = String(options?.taskId || ctx.getActiveShippingTaskId() || '').trim().toUpperCase();
|
||||
void reportRetryRpaDebug('D', 'executeShippingDecision entry', {
|
||||
decision,
|
||||
taskId,
|
||||
conversationId: ctx.conversationId.value,
|
||||
silent: Boolean(options?.silent),
|
||||
});
|
||||
void decision;
|
||||
void displayText;
|
||||
void options;
|
||||
if (!taskId) {
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeMissingTaskId'));
|
||||
return false;
|
||||
}
|
||||
const userText = (displayText || decision).trim();
|
||||
const turnSpec = buildShippingSubmitDecisionTurn(taskId, decision);
|
||||
try {
|
||||
const ok = await ctx.startChatTurn({
|
||||
agentId: ctx.currentAgentId.value,
|
||||
inputType: 'action',
|
||||
displayText: options?.silent ? userText : `${userText}\n任务编号:${taskId}`,
|
||||
actionType: turnSpec.actionType,
|
||||
payload: turnSpec.payload,
|
||||
refs: buildShippingTurnRefs(taskId, ctx.getActiveShippingBatchNo()),
|
||||
silent: options?.silent,
|
||||
hooks: {
|
||||
onAssistantMessageFinished: async (assistantMsg) => {
|
||||
void assistantMsg;
|
||||
await afterDecisionTurn();
|
||||
},
|
||||
},
|
||||
});
|
||||
return ok;
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.streamError.generic');
|
||||
ctx.msg.warning(errorMessage);
|
||||
return false;
|
||||
}
|
||||
await ctx.refreshShippingActions();
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeUi.manualUpload.openTaskWorkbench'));
|
||||
return false;
|
||||
};
|
||||
|
||||
const executeShippingManualUpload = async (taskId: string, displayText?: string) => {
|
||||
const normalizedTaskId = String(taskId || '').trim().toUpperCase();
|
||||
if (!normalizedTaskId || manualUploadInFlightTaskIds.has(normalizedTaskId)) return false;
|
||||
manualUploadInFlightTaskIds.add(normalizedTaskId);
|
||||
const userText = (displayText || '我已在货代系统完成上传').trim();
|
||||
try {
|
||||
const evidenceFile = await selectManualUploadEvidence();
|
||||
if (!evidenceFile) {
|
||||
ctx.msg.warning('请先选择货代上传截图或回执文件');
|
||||
return false;
|
||||
}
|
||||
const evidence = await uploadFileAsset(evidenceFile);
|
||||
const ok = await ctx.startChatTurn({
|
||||
agentId: ctx.currentAgentId.value,
|
||||
inputType: 'action',
|
||||
displayText: userText,
|
||||
actionType: 'shipping.mark_manual_uploaded',
|
||||
payload: { task_no: normalizedTaskId, evidence_asset_no: evidence.asset_no },
|
||||
refs: buildShippingTurnRefs(normalizedTaskId, ctx.getActiveShippingBatchNo()),
|
||||
hooks: {
|
||||
onAssistantMessageFinished: async (assistantMsg) => {
|
||||
assistantMsg.shipping_actions_used = true;
|
||||
assistantMsg.shipping_actions = undefined;
|
||||
ctx.messages.value.forEach((rawMsg) => {
|
||||
if (rawMsg.role === 'assistant') {
|
||||
rawMsg.shipping_actions = undefined;
|
||||
}
|
||||
});
|
||||
void ctx.refreshShippingActions();
|
||||
},
|
||||
},
|
||||
});
|
||||
return ok;
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : '标记手工上传失败';
|
||||
ctx.msg.warning(errorMessage);
|
||||
return false;
|
||||
} finally {
|
||||
manualUploadInFlightTaskIds.delete(normalizedTaskId);
|
||||
}
|
||||
void taskId;
|
||||
void displayText;
|
||||
await ctx.refreshShippingActions();
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeUi.manualUpload.openTaskWorkbench'));
|
||||
return false;
|
||||
};
|
||||
|
||||
return { executeShippingDecision, executeShippingManualUpload };
|
||||
|
||||
Reference in new issue
Block a user