feat(shipping-notice): 落地字段资产治理与唯一 Schema,自动建单随版本冻结
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b7307fc573
commit
3a1dbf7ce5
144 files changed
+15167
-4480
No files matched your search
@@ -2,7 +2,7 @@
|
||||
* features/chat/shipping/useShippingOrderExtractionRuns.ts
|
||||
* 用途:把货代订单抽取作为独立 Run 启动、轮询并投影到聊天状态消息。
|
||||
* 依赖:shipping.api Run 接口、chat.types、Vue refs。
|
||||
* 逻辑:发送处理器调用 startRun;本模块持久化本地消息并轮询 Run,终态后刷新 Intake、批次工作台与动作。
|
||||
* 逻辑:发送处理器调用 startRun;本模块持久化本地消息并轮询 Run;终态后仍保留 run_no 供右侧「本次处理」面板。
|
||||
*/
|
||||
import { getCurrentInstance, onBeforeUnmount, type ComputedRef, type Ref } from 'vue';
|
||||
import {
|
||||
@@ -48,6 +48,11 @@ export function mapOrderExtractionRunToMessageState(run: ShippingOrderExtraction
|
||||
reviewRequiredDocuments: Number(run.summary?.review_required_documents || 0),
|
||||
failedDocuments: Number(run.summary?.failed_documents || 0),
|
||||
candidateCount: Number(run.summary?.candidate_count || 0),
|
||||
openedExistingCount: Number(
|
||||
run.summary?.opened_existing_documents
|
||||
|| run.result?.opened_existing_count
|
||||
|| 0,
|
||||
),
|
||||
},
|
||||
currentActivity: run.current_activity
|
||||
? {
|
||||
@@ -119,15 +124,21 @@ export function useShippingOrderExtractionRuns(options: UseShippingOrderExtracti
|
||||
let pollGeneration = 0;
|
||||
const persistedSignatures = new Map<string, string>();
|
||||
|
||||
/** 停止当前 Run 短轮询;终态、切会话和组件卸载都会调用。 */
|
||||
/** 停止当前 Run 短轮询;切会话和组件卸载时再清空 activeRunNo。 */
|
||||
const stopPolling = () => {
|
||||
if (pollTimer) clearTimeout(pollTimer);
|
||||
requestController?.abort();
|
||||
requestController = null;
|
||||
pollTimer = null;
|
||||
activeRunNo = '';
|
||||
pollFailureCount = 0;
|
||||
pollGeneration += 1;
|
||||
// 注意:终态(含需复核)后仍保留 activeRunNo,供右侧「本次处理」面板继续展示。
|
||||
};
|
||||
|
||||
/** 切会话时清空活动 Run,避免串会话。 */
|
||||
const clearActiveRun = () => {
|
||||
stopPolling();
|
||||
activeRunNo = '';
|
||||
};
|
||||
|
||||
/** 网络轮询失败只更新本地提示,不得把后台业务 Run 误判为失败。 */
|
||||
@@ -421,9 +432,9 @@ export function useShippingOrderExtractionRuns(options: UseShippingOrderExtracti
|
||||
}));
|
||||
};
|
||||
|
||||
/** 刷新或进入既有会话时恢复最新 Run;活动 Run 继续轮询,终态只恢复状态卡。 */
|
||||
/** 刷新或进入既有会话时恢复最新 Run;活动 Run 继续轮询,终态只恢复状态卡并保留 run_no 供右侧面板。 */
|
||||
const restoreForConversation = async (conversationId: string): Promise<void> => {
|
||||
stopPolling();
|
||||
clearActiveRun();
|
||||
try {
|
||||
const generation = pollGeneration;
|
||||
const request = createRequestController(generation);
|
||||
@@ -431,6 +442,7 @@ export function useShippingOrderExtractionRuns(options: UseShippingOrderExtracti
|
||||
if (options.conversationId.value !== conversationId) return;
|
||||
const latest = items[0];
|
||||
if (!latest) return;
|
||||
activeRunNo = latest.run_no;
|
||||
const reviewAttachments = ACTIVE_RUN_STATUSES.has(latest.status)
|
||||
? undefined
|
||||
: await refreshTerminalFacts(latest);
|
||||
@@ -446,6 +458,15 @@ export function useShippingOrderExtractionRuns(options: UseShippingOrderExtracti
|
||||
}
|
||||
};
|
||||
|
||||
if (getCurrentInstance()) onBeforeUnmount(stopPolling);
|
||||
return { startRun, retryRun, reparseRun, restoreForConversation, stopPolling, updateCandidateReviewSnapshot, getActiveRunNo: () => activeRunNo };
|
||||
if (getCurrentInstance()) onBeforeUnmount(clearActiveRun);
|
||||
return {
|
||||
startRun,
|
||||
retryRun,
|
||||
reparseRun,
|
||||
restoreForConversation,
|
||||
stopPolling,
|
||||
clearActiveRun,
|
||||
updateCandidateReviewSnapshot,
|
||||
getActiveRunNo: () => activeRunNo,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user