feat(shipping-notice,receipt-report): 新增收料报表功能并优化发货通知流程

清理废弃的shipping xfa ocr automark相关代码和job配置
新增收料报表管理的前端页面、路由和侧边栏入口
新增后端收料报表配置接口、数据库模型和RPA脚本
优化发货通知流程的重试策略,将shipping相关job默认不自动重试
移除废弃的库存源确认相关逻辑,更新流程门禁规则
重构订单模板的值适配器模块,新增坐标OCR值适配器
清理前端shipping菜单和action的废弃选项
更新相关文档和测试用例,调整.gitignore忽略规则
This commit is contained in:
hugo committed 2026-08-20 20:23:10 +08:00
1 parent 260465b72d
commit 1b6483a4ea
466 files changed
+32115 -33796

No files matched your search

@@ -87,18 +87,35 @@ describe('resolveProcessingActionPresentation', () => {
availableActions: ['retry_parse', 'view_result'],
uiState: {
status: 'waiting_human', stage: 'fulfillment_prep', blocking_reason: null,
primary_action: { code: 'open_inventory_source_review', i18nKey: 'action.open_inventory_source_review', parameters: {} },
primary_action: { code: 'retry_inventory_preparation', i18nKey: 'action.retry_inventory_preparation', parameters: {} },
secondary_actions: [
{ code: 'view_details', enabled: true },
{ code: 'retry_parse', enabled: false },
],
},
}));
expect(result.primary?.actionCode).toBe('open_inventory_source_review');
expect(result.primary?.actionCode).toBe('retry_inventory_preparation');
expect(result.secondary?.actionCode).toBe('view_details');
expect(result.overflow).toEqual([]);
});
it('renders the backend-authorized extraction retry without consulting legacy actions', () => {
const result = resolveProcessingActionPresentation(projection({
availableActions: ['open_order_review'],
uiState: {
status: 'failed', stage: 'document_parsing', blocking_reason: {
code: 'SHIPPING_NOTICE.ORDER_EXTRACTION_RUN_SNAPSHOT_OBSOLETE', details: {},
},
primary_action: { code: 'retry_order_extraction', i18nKey: null, parameters: {} },
secondary_actions: [],
},
}), { surface: 'right' });
expect(result.primary).toMatchObject({
intent: 'retry', actionCode: 'retry_order_extraction',
});
});
it('uses the backend intake parse target for the navigation label', () => {
const result = resolveProcessingActionPresentation(projection({
uiState: {
@@ -167,11 +184,22 @@ describe('resolveProcessingActionPresentation', () => {
expect(result.primary).toMatchObject({
actionCode: 'retry_inventory_preparation',
labelKey: 'workspace.shippingNotice.processGate.actionCodes.retry_inventory_preparation',
labelKey: 'workspace.shippingNotice.processGate.inventoryActions.retryInventoryPreparation',
});
expect(result.secondary).toBeNull();
});
it('uses the shared inventory presentation for a rematch action', () => {
const result = resolveProcessingActionPresentation(projection({
availableActions: ['retry_inventory_matching'],
}), { surface: 'right' });
expect(result.primary).toMatchObject({
actionCode: 'retry_inventory_matching',
labelKey: 'workspace.shippingNotice.processGate.inventoryActions.retryInventoryMatching',
});
});
it('filters open_order_review and refresh on review surface', () => {
const result = resolveProcessingActionPresentation(projection({
availableActions: ['open_order_review', 'refresh', 'view_result'],
@@ -28,27 +28,22 @@ const ACTION_CODE_TO_INTENT: Record<string, ShippingProcessingActionIntent> = {
open_order_processing: 'open_order_review',
enter_manual_review: 'open_order_review',
edit_formal_task: 'edit_formal_task',
freeze_order: 'edit_formal_task',
open_profile_review: 'open_profile_review',
confirm_customer: 'confirm_customer',
resolve_field_conflicts: 'resolve_field_conflicts',
adjudicate_duplicate: 'adjudicate_duplicate',
open_inventory_source_review: 'open_inventory_source_review',
confirm_inventory_source: 'open_inventory_source_review',
retry_resolve_inventory_source: 'open_inventory_source_review',
open_inventory_match_review: 'open_inventory_match_review',
rematch: 'open_inventory_match_review',
match_inventory: 'open_inventory_match_review',
open_shortage_review: 'open_shortage_review',
upload_inventory_file: 'upload_inventory_file',
retry_inventory_preparation: 'retry',
retry_inventory_matching: 'open_inventory_match_review',
retry: 'retry',
reparse_batch: 'reparse_batch',
retry_parse: 'retry',
retry_failed_documents: 'retry',
retry_failed_attachments: 'retry',
retry_upload: 'retry',
retry_freight_upload_rpa: 'retry',
retry_order_extraction: 'retry',
retry_layout_parsing: 'retry',
// 订单识别复核卡后端动作码:统一复用右侧「进入订单处理/重试解析/查看结果」执行器。
edit_draft: 'open_order_review',
reconcile_and_progress: 'open_order_review',
@@ -57,8 +52,7 @@ const ACTION_CODE_TO_INTENT: Record<string, ShippingProcessingActionIntent> = {
reparse: 'retry',
view: 'view_result',
refresh: 'refresh',
regenerate_excel: 'regenerate_excel',
generate_excel: 'regenerate_excel',
regenerate_excel_artifact: 'regenerate_excel',
download_excel: 'download_excel',
open_manual_upload: 'open_manual_upload',
wait_manual_upload: 'open_manual_upload',
@@ -77,6 +71,48 @@ const ACTION_CODE_TO_INTENT: Record<string, ShippingProcessingActionIntent> = {
const AUTOMATING_STATUSES = new Set(['processing', 'automating', 'queued']);
/** 永不升为主 CTA 的动作码(仍可作次要/溢出)。 */
const NEVER_PRIMARY_CODES = new Set(['cancel_task', 'cancel_run', 'view_details']);
/**
* 仅供执行编排或历史审计使用的库存恢复动作;不得重新暴露为正式用户 CTA。
* 它们会绕过当前库存步骤的标准语义,用户入口必须使用 retry_inventory_preparation
* 或 retry_inventory_matching 等稳定动作码。
*/
const INTERNAL_INVENTORY_ACTION_CODES = new Set([
'retry_inventory_from_preparation',
'retry_inventory_from_matching',
'retry_inventory_field_mapping',
'retry_inventory_from_field_mapping',
'poll_inventory_preparation',
'refresh_inventory_candidate_projection',
'recheck_inventory_sufficiency',
]);
/**
* 返回库存业务动作的唯一展示文案键。
* 核心逻辑:所有 Surface 以 action_code 为准共享同一翻译,而不改变后端 Gate 的执行码。
* @param code - 后端下发的库存 Gate 动作码
* @returns 统一翻译键;非库存动作返回 null
*/
export function inventoryActionLabelKey(code: string | null | undefined): string | null {
const normalized = String(code || '').trim().toLowerCase();
const keyByCode: Record<string, string> = {
retry_inventory_preparation: 'workspace.shippingNotice.processGate.inventoryActions.retryInventoryPreparation',
retry_inventory_matching: 'workspace.shippingNotice.processGate.inventoryActions.retryInventoryMatching',
open_inventory_match_review: 'workspace.shippingNotice.processGate.inventoryActions.openInventoryMatchReview',
open_shortage_review: 'workspace.shippingNotice.processGate.inventoryActions.openShortageReview',
download_inventory_file: 'workspace.shippingNotice.processGate.inventoryActions.downloadInventoryFile',
release_inventory_shortage: 'workspace.shippingNotice.processGate.inventoryActions.releaseInventoryShortage',
};
return keyByCode[normalized] || null;
}
/**
* 判断动作是否只能留在内部恢复编排中。
* @param code - Gate / Projection 原始动作码
* @returns true 表示正式用户界面必须 fail-closed 隐藏
*/
export function isInternalInventoryAction(code: string | null | undefined): boolean {
return INTERNAL_INVENTORY_ACTION_CODES.has(String(code || '').trim().toLowerCase());
}
/**
* 将原始动作码映射为统一意图;未知码返回 null。
@@ -106,10 +142,12 @@ function toItem(
// 只读导航动作码而误显示为订单处理。该分支不改变权限或路由目标。
if (targetLifecycleStage === 'intake_parse') {
labelKey = 'chat.shippingProcessing.action.open_intake_parse';
} else if (normalized === 'retry_inventory_preparation') {
labelKey = 'workspace.shippingNotice.processGate.actionCodes.retry_inventory_preparation';
} else if (normalized === 'retry_freight_upload_rpa' || normalized === 'retry_upload') {
} else if (inventoryActionLabelKey(normalized)) {
labelKey = inventoryActionLabelKey(normalized)!;
} else if (normalized === 'retry_freight_upload_rpa') {
labelKey = 'chat.shippingNoticeRetryUploadAction';
} else if (normalized === 'reparse_batch') {
labelKey = 'chat.shippingProcessing.action.reparse_batch';
} else if (intent === 'retry' && chatOrRight) {
labelKey = 'chat.shippingProcessing.action.retry_parse';
} else if (normalized === 'focus_task' && chatOrRight) {
@@ -205,6 +243,7 @@ export function resolveProcessingActionPresentation(
const code = String(raw || '').trim();
if (!code) return;
const key = code.toLowerCase();
if (isInternalInventoryAction(key)) return;
// 仅用于管理员恢复缺失待办记录,不作为普通用户履约动作展示。
if (key === 'regenerate_manual_upload_todo') return;
if (seen.has(key)) return;
@@ -299,6 +338,7 @@ export function resolveConversationTaskActionPresentation(
const code = String(raw || '').trim();
if (!code) return;
const key = code.toLowerCase();
if (isInternalInventoryAction(key)) return;
if (seen.has(key)) return;
// 任务卡同样禁止通过“待处理 + view”补造订单生命周期权限。
const intent = mapActionCodeToIntent(code);
@@ -51,25 +51,23 @@ describe('workbenchActionRegistry', () => {
vi.restoreAllMocks();
});
it('registers fulfillment and focus actions used by Footer', () => {
it('registers Gate fulfillment actions and does not retain legacy aliases', () => {
for (const code of [
'confirm_inventory_source',
'match_inventory',
'retry_inventory_matching',
'generate_excel',
'mark_manual_uploaded',
'retry_upload',
'retry_freight_upload_rpa',
'regenerate_excel_artifact',
'view_result',
'view_record',
'confirm_customer',
'open_profile_review',
'open_inventory_source_review',
]) {
expect(lookupWorkbenchAction(code)).toBeTruthy();
}
expect(WORKBENCH_ACTION_REGISTRY.open_inventory_source_review.reviewBehavior).toBe('open_inventory_candidates');
expect(WORKBENCH_ACTION_REGISTRY.confirm_inventory_source.reviewBehavior).toBe('todo_panel');
expect(WORKBENCH_ACTION_REGISTRY.confirm_customer.reviewBehavior).toBe('open_customer_dialog');
for (const code of ['freeze_order', 'confirm_inventory_source', 'open_inventory_source_review', 'confirm_inventory_field_mapping', 'match_inventory', 'rematch', 'generate_excel', 'retry_upload']) {
expect(lookupWorkbenchAction(code)).toBeNull();
}
// 保存订单并校验只属于工作台底栏,不得注册为右栏当前任务动作。
expect(WORKBENCH_ACTION_REGISTRY.validate).toBeUndefined();
});
@@ -90,7 +88,7 @@ describe('workbenchActionRegistry', () => {
});
it('hides write actions when actionsExecutable=false but keeps view_result', () => {
expect(shouldRenderWorkbenchAction(WORKBENCH_ACTION_REGISTRY.match_inventory, {
expect(shouldRenderWorkbenchAction(WORKBENCH_ACTION_REGISTRY.retry_inventory_matching, {
actionsExecutable: false,
surface: 'review',
})).toBe(false);
@@ -111,23 +109,23 @@ describe('workbenchActionRegistry', () => {
expect(payload?.action_code).toBe('totally_unknown_action');
});
it('exposes match_inventory as primary for review Footer', () => {
it('exposes Gate retry_inventory_matching as primary for review Footer', () => {
const result = resolveProcessingActionPresentation(projection({
uiState: {
status: 'waiting_human', stage: 'inventory_matching', blocking_reason: null,
primary_action: { code: 'match_inventory', label_key: 'x' }, secondary_actions: [],
primary_action: { code: 'retry_inventory_matching', label_key: 'x' }, secondary_actions: [],
},
currentGate: {
gateCode: 'inventory_match',
status: 'blocked',
nextActionCode: 'match_inventory',
nextActionCode: 'retry_inventory_matching',
blockingReasonCode: 'inventory_shortage',
attemptNo: 1,
},
availableActions: ['refresh'],
}), { surface: 'review', actionsExecutable: true });
expect(result.primary?.intent).toBe('open_inventory_match_review');
expect(result.primary?.actionCode).toBe('match_inventory');
expect(result.primary?.actionCode).toBe('retry_inventory_matching');
expect(result.secondary).toBeNull();
});
@@ -204,21 +202,8 @@ describe('workbenchActionRegistry', () => {
expect(warn).toHaveBeenCalled();
});
it('routes aliased open_inventory_source_review to todo_panel after create', () => {
// 后端 normalize 后 Footer 只见 open_inventory_source_review;建单后须 Todo。
const pre = resolveWorkbenchActionItem({
intent: 'open_inventory_source_review',
actionCode: 'open_inventory_source_review',
labelKey: 'x',
}, { postCreate: false });
expect(pre?.reviewBehavior).toBe('open_inventory_candidates');
const post = resolveWorkbenchActionItem({
intent: 'open_inventory_source_review',
actionCode: 'open_inventory_source_review',
labelKey: 'x',
}, { postCreate: true });
expect(post?.reviewBehavior).toBe('todo_panel');
expect(post?.todoActionCode).toBe('confirm_inventory_source');
it('does not register inventory source selection or mapping confirmation', () => {
expect(lookupWorkbenchAction('open_inventory_source_review')).toBeNull();
expect(lookupWorkbenchAction('confirm_inventory_field_mapping')).toBeNull();
});
});
@@ -16,7 +16,6 @@ export type WorkbenchActionExecutorKind =
| 'focus_field_conflicts'
| 'focus_duplicate_panel'
| 'focus_profile_panel'
| 'open_inventory_candidates'
| 'focus_inventory_issues'
| 'download'
| 'retry'
@@ -31,7 +30,6 @@ export type WorkbenchPanelKey =
| 'hasFieldConflicts'
| 'hasDuplicateAdjudication'
| 'hasProfileMatch'
| 'hasInventoryCandidates'
| 'hasInventoryIssues';
/** 当前 Case 面板是否挂载/有内容,供 requiresPanel 过滤。 */
@@ -99,12 +97,6 @@ export const WORKBENCH_ACTION_REGISTRY: Record<string, WorkbenchActionRegistryEn
isWrite: false,
stageFamily: 'any',
},
freeze_order: {
intent: 'edit_formal_task',
reviewBehavior: 'hidden_on_review',
isWrite: true,
stageFamily: 'post_create',
},
open_profile_review: {
intent: 'open_profile_review',
reviewBehavior: 'focus_profile_panel',
@@ -137,55 +129,10 @@ export const WORKBENCH_ACTION_REGISTRY: Record<string, WorkbenchActionRegistryEn
isWrite: true,
stageFamily: 'pre_create',
},
// 建单前:打开库存候选面板(禁止 TaskTodoPanel);不依赖面板键(Gate 已授权)。
open_inventory_source_review: {
intent: 'open_inventory_source_review',
reviewBehavior: 'open_inventory_candidates',
scrollTestId: 'review-inventory-candidates-panel',
isWrite: true,
stageFamily: 'pre_create',
},
// 建单后:委托 TaskTodoPanel 确认库存源。
confirm_inventory_source: {
intent: 'open_inventory_source_review',
reviewBehavior: 'todo_panel',
todoActionCode: 'confirm_inventory_source',
requiresFormalTask: true,
isWrite: true,
stageFamily: 'post_create',
scrollTestId: 'review-formal-task-todo-panel',
},
retry_resolve_inventory_source: {
intent: 'open_inventory_source_review',
reviewBehavior: 'todo_panel',
todoActionCode: 'confirm_inventory_source',
requiresFormalTask: true,
isWrite: true,
stageFamily: 'post_create',
scrollTestId: 'review-formal-task-todo-panel',
},
open_inventory_match_review: {
intent: 'open_inventory_match_review',
reviewBehavior: 'todo_panel',
todoActionCode: 'match_inventory',
requiresFormalTask: true,
isWrite: true,
stageFamily: 'post_create',
scrollTestId: 'review-formal-task-todo-panel',
},
match_inventory: {
intent: 'open_inventory_match_review',
reviewBehavior: 'todo_panel',
todoActionCode: 'match_inventory',
requiresFormalTask: true,
isWrite: true,
stageFamily: 'post_create',
scrollTestId: 'review-formal-task-todo-panel',
},
rematch: {
intent: 'open_inventory_match_review',
reviewBehavior: 'todo_panel',
todoActionCode: 'rematch',
todoActionCode: 'open_inventory_match_review',
requiresFormalTask: true,
isWrite: true,
stageFamily: 'post_create',
@@ -200,6 +147,15 @@ export const WORKBENCH_ACTION_REGISTRY: Record<string, WorkbenchActionRegistryEn
stageFamily: 'post_create',
scrollTestId: 'review-formal-task-todo-panel',
},
retry_inventory_preparation: {
intent: 'retry',
reviewBehavior: 'todo_panel',
todoActionCode: 'retry_inventory_preparation',
requiresFormalTask: true,
isWrite: true,
stageFamily: 'post_create',
scrollTestId: 'review-formal-task-todo-panel',
},
open_shortage_review: {
intent: 'open_shortage_review',
reviewBehavior: 'focus_inventory_issues',
@@ -208,28 +164,10 @@ export const WORKBENCH_ACTION_REGISTRY: Record<string, WorkbenchActionRegistryEn
isWrite: true,
stageFamily: 'post_create',
},
upload_inventory_file: {
intent: 'upload_inventory_file',
reviewBehavior: 'todo_panel',
todoActionCode: 'upload_inventory_file',
requiresFormalTask: true,
isWrite: true,
stageFamily: 'post_create',
scrollTestId: 'review-formal-task-todo-panel',
},
regenerate_excel: {
regenerate_excel_artifact: {
intent: 'regenerate_excel',
reviewBehavior: 'todo_panel',
todoActionCode: 'generate_excel',
requiresFormalTask: true,
isWrite: true,
stageFamily: 'post_create',
scrollTestId: 'review-formal-task-todo-panel',
},
generate_excel: {
intent: 'regenerate_excel',
reviewBehavior: 'todo_panel',
todoActionCode: 'generate_excel',
todoActionCode: 'regenerate_excel_artifact',
requiresFormalTask: true,
isWrite: true,
stageFamily: 'post_create',
@@ -277,19 +215,10 @@ export const WORKBENCH_ACTION_REGISTRY: Record<string, WorkbenchActionRegistryEn
stageFamily: 'post_create',
scrollTestId: 'review-formal-task-todo-panel',
},
retry_upload: {
intent: 'retry',
reviewBehavior: 'todo_panel',
todoActionCode: 'retry_upload',
requiresFormalTask: true,
isWrite: true,
stageFamily: 'post_create',
scrollTestId: 'review-formal-task-todo-panel',
},
retry_freight_upload_rpa: {
intent: 'retry',
reviewBehavior: 'todo_panel',
todoActionCode: 'retry_upload',
todoActionCode: 'retry_freight_upload_rpa',
requiresFormalTask: true,
isWrite: true,
stageFamily: 'post_create',
@@ -301,6 +230,12 @@ export const WORKBENCH_ACTION_REGISTRY: Record<string, WorkbenchActionRegistryEn
isWrite: true,
stageFamily: 'any',
},
reparse_batch: {
intent: 'reparse_batch',
reviewBehavior: 'retry',
isWrite: true,
stageFamily: 'any',
},
retry_parse: {
intent: 'retry',
reviewBehavior: 'retry',
@@ -468,8 +403,7 @@ export function shouldRenderWorkbenchAction(
/**
* 从 ActionPresentationItem 解析注册条目;未登记返回 null。
*
* 核心逻辑:优先按原始 actionCode 查找;建单后若后端把 confirm_inventory_source
* 别名为 open_inventory_source_review,则改用 todo_panel 条目(禁止再开候选面板)。
* 核心逻辑:优先按原始 actionCode 查找;后端 Gate code 是唯一执行标识。
*
* @param item - 统一动作项
* @param options.postCreate - 正式 Notice 已建单时为 true
@@ -483,18 +417,6 @@ export function resolveWorkbenchActionItem(
const entry = byCode || byIntent;
if (!entry) return null;
// [STEP] 建单后库存源确认:契约意图仍是 open_inventory_source_review,执行器须走 Todo。
const code = String(item.actionCode || '').trim().toLowerCase();
const inventorySourceCodes = new Set([
'open_inventory_source_review',
'confirm_inventory_source',
'retry_resolve_inventory_source',
]);
if (
options?.postCreate
&& (entry.intent === 'open_inventory_source_review' || inventorySourceCodes.has(code))
) {
return lookupWorkbenchAction('confirm_inventory_source') || entry;
}
void options;
return entry;
}