refactor(shipping-notice): 重构货代发货通知状态管理,移除废弃的process_status字段
统一货代发货通知的业务阶段为四个标准阶段:接收解析、订单复核、发货准备、上传完成 设置 ui_state 为前端唯一状态数据源,不再依赖 process_status 驱动业务流程 删除 shipping_notices 表的废弃 process_status 列及对应复合索引,新增数据库迁移脚本 替换全栈代码中所有对 process_status 的引用为生命周期、上传状态等领域字段 更新相关文档、测试用例与前端展示逻辑适配新的状态管理规则
This commit is contained in:
1 parent
6684e7181a
commit
5ef8329bd8
178 files changed
+5091
-1734
No files matched your search
@@ -2,7 +2,7 @@
|
||||
* features/shipping-progress/actionPresentation.ts
|
||||
* 用途:从统一投影 / 会话 OT 任务解析四页面共用的 ActionPresentation(主/次/溢出)。
|
||||
* 依赖:ShippingProcessingProjection、ConversationProcessingUserTask、workbenchActionRegistry、types。
|
||||
* 逻辑:优先级 Gate.nextActionCode → availableActions → 终态查看 → none;
|
||||
* 逻辑:新版优先 ui_state.primary_action / secondary_actions;旧响应才兼容 primaryAction / availableActions;
|
||||
* cancel_* 与 view_details 永不作主 CTA;无业务入口时 focus_task 兜底并映射「查看进度」;
|
||||
* 自动处理中(processing/automating)主按钮为空;review 面经注册表 fail-closed 过滤。
|
||||
*/
|
||||
@@ -41,6 +41,7 @@ const ACTION_CODE_TO_INTENT: Record<string, ShippingProcessingActionIntent> = {
|
||||
match_inventory: 'open_inventory_match_review',
|
||||
open_shortage_review: 'open_shortage_review',
|
||||
upload_inventory_file: 'upload_inventory_file',
|
||||
retry_inventory_preparation: 'retry',
|
||||
retry: 'retry',
|
||||
retry_parse: 'retry',
|
||||
retry_failed_documents: 'retry',
|
||||
@@ -105,6 +106,8 @@ function toItem(
|
||||
const chatOrRight = surface === 'chat' || surface === 'right';
|
||||
if (intent === 'open_order_review' && chatOrRight) {
|
||||
labelKey = 'chat.shippingProcessing.action.open_order_processing';
|
||||
} else if (normalized === 'retry_inventory_preparation') {
|
||||
labelKey = 'workspace.shippingNotice.processGate.actionCodes.retry_inventory_preparation';
|
||||
} else if (normalized === 'retry_freight_upload_rpa' || normalized === 'retry_upload') {
|
||||
labelKey = 'chat.shippingNoticeRetryUploadAction';
|
||||
} else if (intent === 'retry' && chatOrRight) {
|
||||
@@ -160,9 +163,9 @@ export interface ResolveProcessingActionPresentationOptions {
|
||||
* 解析统一动作投影。
|
||||
*
|
||||
* 核心逻辑:
|
||||
* 1. processing/automating/queued → 主按钮为空(自动推进中);
|
||||
* 2. currentGate.nextActionCode 优先;
|
||||
* 3. availableActions 依次填主/次/溢出;
|
||||
* 1. 有 ui_state 时只渲染其已授权主/次动作;
|
||||
* 2. 旧响应 processing/automating/queued → 主按钮为空(自动推进中);
|
||||
* 3. 旧响应由 primaryAction / availableActions 填主/次/溢出;
|
||||
* 4. completed/failed/cancelled → view_result / view_record 兜底;
|
||||
* 5. surface=review 时经注册表 fail-closed(未知隐藏 + 告警;隐藏 refresh/自跳转);
|
||||
* 6. cancel / view_details 强制降为次要或溢出。
|
||||
@@ -180,8 +183,9 @@ export function resolveProcessingActionPresentation(
|
||||
const surface = options?.surface;
|
||||
const actionsExecutable = options?.actionsExecutable !== false;
|
||||
const panels = options?.panels ?? null;
|
||||
const status = String(projection.status || '').trim().toLowerCase();
|
||||
if (AUTOMATING_STATUSES.has(status) && !projection.currentGate?.nextActionCode) {
|
||||
const authoritativeUiState = projection.uiState;
|
||||
const status = String(authoritativeUiState?.status || projection.userStatus || projection.status || '').trim().toLowerCase();
|
||||
if (!authoritativeUiState && AUTOMATING_STATUSES.has(status) && !projection.currentGate?.nextActionCode) {
|
||||
return empty;
|
||||
}
|
||||
|
||||
@@ -231,41 +235,18 @@ export function resolveProcessingActionPresentation(
|
||||
items.push(toItem(code, intent, surface));
|
||||
};
|
||||
|
||||
pushCode(projection.primaryAction?.code || projection.currentGate?.nextActionCode);
|
||||
// Gate 20 同时保留两条用户路径:主动重试 RPA 与人工上传登记。
|
||||
// 该动作由正式任务面板打开登记弹窗,不走 Gate API。
|
||||
if (
|
||||
String(projection.currentGate?.gateCode || '').trim().toLowerCase() === 'manual_upload_handoff'
|
||||
&& items.some((item) => String(item.actionCode).toLowerCase() === 'retry_freight_upload_rpa')
|
||||
) {
|
||||
pushCode('mark_manual_uploaded');
|
||||
}
|
||||
// [ORDER-STABLE] 对 availableActions 标准化(去重 + 字典序排序),确保后端返回顺序不影响前端按钮顺序。
|
||||
const normalizedAvailableActions = normalizeActionCodes(projection.availableActions || []);
|
||||
for (const action of normalizedAvailableActions) {
|
||||
// [AUTHORITY] 新版只消费同一份 ui_state;currentGate 只保留诊断,禁止产生或替换按钮。
|
||||
// 旧服务端未下发 ui_state 时才兼容 primaryAction / availableActions。
|
||||
pushCode(authoritativeUiState
|
||||
? authoritativeUiState.primary_action?.code
|
||||
: projection.primaryAction?.code);
|
||||
const actionCodes = authoritativeUiState
|
||||
? authoritativeUiState.secondary_actions.filter((action) => action.enabled).map((action) => action.code)
|
||||
: normalizeActionCodes(projection.availableActions || []);
|
||||
for (const action of actionCodes) {
|
||||
pushCode(action);
|
||||
}
|
||||
// Gate 19 RPA 失败时,人工登记作为任务级替代路径展示,避免与 RPA 重试并列。
|
||||
if (
|
||||
String(projection.currentGate?.gateCode || '').trim().toLowerCase() === 'freight_upload_rpa'
|
||||
&& items.some((item) => String(item.actionCode).toLowerCase() === 'retry_freight_upload_rpa')
|
||||
) {
|
||||
for (let index = items.length - 1; index >= 0; index -= 1) {
|
||||
const code = String(items[index]?.actionCode || '').toLowerCase();
|
||||
if (code === 'mark_manual_uploaded' || code === 'open_manual_upload' || code === 'wait_manual_upload') {
|
||||
items.splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (items.length === 0 && (status === 'completed' || status === 'failed' || status === 'cancelled')) {
|
||||
pushCode('view_result');
|
||||
}
|
||||
|
||||
if (AUTOMATING_STATUSES.has(status) && items.length === 0) {
|
||||
return empty;
|
||||
}
|
||||
|
||||
return partitionActionItems(items);
|
||||
}
|
||||
|
||||
@@ -284,7 +265,7 @@ export function resolveConversationTaskActionPresentation(
|
||||
if (!task) return empty;
|
||||
|
||||
const surface = options?.surface || 'right';
|
||||
const userStatus = String(task.userStatus ?? '').trim().toLowerCase();
|
||||
const userStatus = String(task.uiState?.status ?? task.userStatus ?? '').trim().toLowerCase();
|
||||
const legacyStatus = String(task.status_label ?? '').trim().toLowerCase();
|
||||
const status = userStatus || legacyStatus;
|
||||
const isNeedsAction = task.group === 'needs_action' || NEEDS_ACTION_STATUSES.has(status);
|
||||
@@ -308,19 +289,19 @@ export function resolveConversationTaskActionPresentation(
|
||||
items.push(toItem(code, intent, surface));
|
||||
};
|
||||
|
||||
pushCode(task.primaryAction?.code || task.primary_action);
|
||||
pushCode(task.uiState
|
||||
? task.uiState.primary_action?.code
|
||||
: (task.primaryAction?.code || task.primary_action));
|
||||
// [ORDER-STABLE] 对 available_actions 标准化排序,确保后端顺序变化不影响按钮渲染顺序。
|
||||
const normalizedTaskActions = normalizeActionCodes(task.available_actions || []);
|
||||
const normalizedTaskActions = normalizeActionCodes(
|
||||
task.uiState?.secondary_actions?.filter((item) => item.enabled).map((item) => item.code)
|
||||
|| task.available_actions
|
||||
|| [],
|
||||
);
|
||||
for (const action of normalizedTaskActions) {
|
||||
pushCode(action);
|
||||
}
|
||||
|
||||
// 人工待办禁止伪造查看进度;无明确动作时进入订单处理作为安全兜底。
|
||||
if (isNeedsAction && !items.some((item) => !NEVER_PRIMARY_CODES.has(String(item.actionCode || '').trim().toLowerCase()))) {
|
||||
pushCode('open_order_processing');
|
||||
}
|
||||
// 只有系统处理中才允许显示查看进度,且只能作为次要文字链。
|
||||
if (isProcessing && !items.length) pushCode('focus_task');
|
||||
const hasPrimaryCandidate = items.some(
|
||||
(item) => !NEVER_PRIMARY_CODES.has(String(item.actionCode || '').trim().toLowerCase()),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user