feat(shipping-notice): 新增通用解析能力,优化性能并清理遗留废弃代码
This commit is contained in:
1 parent
935bf26fa6
commit
7cfd5d167e
230 files changed
+9337
-10989
No files matched your search
@@ -4,7 +4,7 @@
|
||||
* 依赖:shipping.api getWorkspaceShippingProcessing / focus·viewed、Vue 响应式、BusinessError。
|
||||
* 逻辑:由 ChatViewContent / ShippingWorkflowTimeline 消费;仅读 shipping-processing;
|
||||
* focus/viewed 写路径优先应用响应中的 work_items;
|
||||
* 前台 2s / 后台 8s;请求 10s AbortController 超时;失败指数退避至 8s;
|
||||
* 前台 2s / 后台 8s;共享请求的超时由 API 层统一管理;会话切换/卸载才取消当前消费者;失败指数退避至 8s;
|
||||
* 分层轮询:仅系统处理中 2s 轮询;外部 Run 轮询不会在待人工处理时反复唤醒本读接口;
|
||||
* 区分 initialLoading / manualRefreshing / polling 三种 loading 态;
|
||||
* 语义签名比较:业务状态未变化时不替换投影对象,防止按钮闪烁与 DOM 重建。
|
||||
@@ -40,7 +40,6 @@ const FIRST_ACTIVE_POLL_MS = 2000;
|
||||
const MID_ACTIVE_POLL_MS = 5000;
|
||||
const LONG_ACTIVE_POLL_MS = 10000;
|
||||
const BACKGROUND_POLL_MS = 30000;
|
||||
const REQUEST_TIMEOUT_MS = 10000;
|
||||
const MAX_BACKOFF_MS = 30000;
|
||||
const SNAPSHOT_CACHE_LIMIT = 20;
|
||||
|
||||
@@ -137,7 +136,7 @@ export function shouldContinueProcessingPolling(
|
||||
processing?: ConversationProcessingProjection | null,
|
||||
): boolean {
|
||||
const processingCount = Number(
|
||||
processing?.summary?.processing || processing?.processing?.length || 0,
|
||||
processing?.summary?.processing ?? processing?.status_groups?.processing.length ?? 0,
|
||||
);
|
||||
return processingCount > 0;
|
||||
}
|
||||
@@ -200,10 +199,22 @@ export function useShippingNoticeWorkflow(
|
||||
return JSON.stringify(items.map((item) => ({
|
||||
no: item.workItemNo,
|
||||
type: item.workItemType,
|
||||
status: item.uiState?.status ?? item.userStatus ?? item.status,
|
||||
stage: item.uiState?.stage ?? item.userStage ?? item.stage,
|
||||
gate: item.uiState?.blocking_reason?.code ?? item.blockingReason?.code ?? null,
|
||||
action: item.uiState?.primary_action?.code ?? item.primaryAction?.code ?? null,
|
||||
status: item.uiState?.status ?? null,
|
||||
stage: item.uiState?.stage ?? null,
|
||||
runNo: item.runNo ?? null,
|
||||
caseNo: item.caseNo ?? null,
|
||||
gate: item.uiState?.blocking_reason?.code ?? null,
|
||||
action: (() => {
|
||||
const action = item.uiState?.primary_action ?? null;
|
||||
return action
|
||||
? {
|
||||
code: action.code,
|
||||
executionMode: action.executionMode ?? null,
|
||||
targetSurface: action.targetSurface ?? null,
|
||||
targetLifecycleStage: action.targetLifecycleStage ?? null,
|
||||
}
|
||||
: null;
|
||||
})(),
|
||||
lifecycleEntries: item.uiState?.lifecycleEntries?.map((entry) => ({
|
||||
code: entry.code,
|
||||
state: entry.state,
|
||||
@@ -215,6 +226,16 @@ export function useShippingNoticeWorkflow(
|
||||
no: child.workItemNo,
|
||||
status: child.uiState?.status ?? child.userStatus ?? child.status,
|
||||
stage: child.uiState?.stage ?? child.userStage ?? child.stage,
|
||||
runNo: child.runNo ?? null,
|
||||
caseNo: child.caseNo ?? null,
|
||||
primaryAction: child.uiState?.primary_action
|
||||
? {
|
||||
code: child.uiState.primary_action.code,
|
||||
executionMode: child.uiState.primary_action.executionMode ?? null,
|
||||
targetSurface: child.uiState.primary_action.targetSurface ?? null,
|
||||
targetLifecycleStage: child.uiState.primary_action.targetLifecycleStage ?? null,
|
||||
}
|
||||
: null,
|
||||
lifecycleEntries: child.uiState?.lifecycleEntries?.map((entry) => ({
|
||||
code: entry.code,
|
||||
state: entry.state,
|
||||
@@ -292,20 +313,22 @@ export function useShippingNoticeWorkflow(
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建带超时的 AbortController。
|
||||
* 创建当前会话代际的 AbortController。
|
||||
*
|
||||
* 共享 API 请求自行持有 30 秒超时,不能在此再设更短的消费者超时:
|
||||
* 否则底层请求虽仍可成功返回,当前代际会因 signal 已 aborted 而丢弃响应,
|
||||
* 导致首屏永久停留在权威投影骨架。这里仅用于会话切换或组件卸载的真实取消。
|
||||
*/
|
||||
function createRequestController(): AbortController {
|
||||
requestController?.abort();
|
||||
const controller = new AbortController();
|
||||
requestController = controller;
|
||||
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
||||
controller.signal.addEventListener('abort', () => clearTimeout(timeout), { once: true });
|
||||
return controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅拉取统一 shipping-processing 投影。
|
||||
* 核心逻辑:后端 status_groups 存在时直接使用;仅旧响应缺状态组才由 work_items 合成;
|
||||
* 核心逻辑:只消费后端 status_groups;
|
||||
* 同会话在途请求合并;跨会话请求中止,且只有最新一代可回写页面数据;
|
||||
* 语义签名相同则不替换 projection 对象,避免 DOM 重建与按钮闪烁。
|
||||
*
|
||||
@@ -450,7 +473,7 @@ export function useShippingNoticeWorkflow(
|
||||
|
||||
/**
|
||||
* 将 focus/viewed/submit 写路径响应应用到本地 processing 与 work_items。
|
||||
* 核心逻辑:有 work_items 时用统一合成;否则仅回写 processing 兼容块;
|
||||
* 核心逻辑:只回写后端返回的 status_groups;work_items 仅提供最小附件叶子。
|
||||
* 每次回写后更新语义签名,避免下一轮轮询误判为「无变化」。
|
||||
*/
|
||||
function applyMutationProcessingResponse(response: {
|
||||
@@ -458,12 +481,12 @@ export function useShippingNoticeWorkflow(
|
||||
work_items?: unknown[];
|
||||
}): void {
|
||||
const workItems = Array.isArray(response.work_items) ? response.work_items : [];
|
||||
if (workItems.length > 0) {
|
||||
const nextProjection = resolveConversationProcessingFromUnified(
|
||||
workItems as typeof processingWorkItems.value,
|
||||
response.processing ?? null,
|
||||
processing.value,
|
||||
);
|
||||
const nextProjection = resolveConversationProcessingFromUnified(
|
||||
workItems as typeof processingWorkItems.value,
|
||||
response.processing ?? null,
|
||||
processing.value,
|
||||
);
|
||||
if (nextProjection) {
|
||||
processingWorkItems.value = resolveStableWorkItems(
|
||||
workItems as typeof processingWorkItems.value,
|
||||
processing.value,
|
||||
@@ -476,13 +499,6 @@ export function useShippingNoticeWorkflow(
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (response.processing) {
|
||||
const nextKey = buildProcessingSemanticKey(response.processing);
|
||||
if (nextKey !== lastSemanticKey) {
|
||||
processing.value = response.processing;
|
||||
lastSemanticKey = nextKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user