feat(shipping-notice): 完善订单解析、模板管理与库存 RPA 流程
- 优化订单文档解析、补充合并与坐标重建 - 完善订单模板校验、发布及前端管理界面 - 改进库存 RPA 下载回退与工作流处理 - 补充后端、前端及 RPA 自动化测试 - 更新 Shipping Notice 技术文档与四语言文案
This commit is contained in:
1 parent
c4a27324c8
commit
8f2f568f92
46 files changed
+1745
-265
No files matched your search
@@ -1068,29 +1068,54 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
build_eligibility: { can_build: true, status: 'ready', line_projections: [] },
|
||||
},
|
||||
});
|
||||
api.getCase.mockResolvedValue(readyCase);
|
||||
const confirmedCase = {
|
||||
...readyCase,
|
||||
status: 'confirmed',
|
||||
confirmed_task_no: 'OT-1',
|
||||
order_task_no: 'OT-1',
|
||||
has_formal_ot: true,
|
||||
};
|
||||
api.getCase.mockResolvedValue(confirmedCase);
|
||||
api.getRun.mockResolvedValue({
|
||||
run_no: 'RUN-1', summary: {},
|
||||
items: [{ case_no: 'CASE-1', document_id: 1, status: 'ready', available_actions: ['confirm'] }],
|
||||
});
|
||||
api.getQueue.mockResolvedValue({
|
||||
summary: { total: 1, needs_action: 1, processing: 0, completed: 0 },
|
||||
items: [{
|
||||
case_no: 'CASE-1', document_id: 1, source_run_no: 'RUN-1', status: 'confirmed',
|
||||
lifecycle_stage: 'fulfillment_prep',
|
||||
lifecycle_entries: [{ code: 'fulfillment_prep', state: 'current' }],
|
||||
}],
|
||||
});
|
||||
api.getEvidence.mockResolvedValue({ items: [] });
|
||||
api.getPreview.mockResolvedValue({ preview_url: '' });
|
||||
api.getProcessingWorkItem.mockResolvedValue({
|
||||
work_item_no: 'OT-1', status: 'blocked', user_status: 'waiting_human',
|
||||
workItemNo: 'OT-1',
|
||||
status: 'waiting_human',
|
||||
userStatus: 'waiting_human',
|
||||
stage: 'inventory_matching',
|
||||
currentGate: { gateCode: 'inventory_matching', status: 'blocked_manual' },
|
||||
uiState: {
|
||||
status: 'waiting_human',
|
||||
lifecycleStage: 'fulfillment_prep',
|
||||
lifecycleEntries: [{ code: 'fulfillment_prep', state: 'current' }],
|
||||
},
|
||||
});
|
||||
api.confirmCase.mockResolvedValue({
|
||||
task_no: 'SN-1', order_task_no: 'OT-1', shipping_notice_no: 'SN-1', idempotent_replay: false,
|
||||
case: { ...readyCase, status: 'confirmed', order_task_no: 'OT-1' }, auto_progress_started: true,
|
||||
case: confirmedCase, auto_progress_started: true,
|
||||
});
|
||||
|
||||
const review = useShippingOrderReview();
|
||||
await review.load('RUN-1', 'CASE-1', { conversationId: 'conv-1', itemNo: 'WFI-1' });
|
||||
const queueCallsBeforeConfirm = api.getQueue.mock.calls.length;
|
||||
await review.confirm();
|
||||
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
await vi.advanceTimersByTimeAsync(PROGRESS_POLL_MS + 100);
|
||||
await Promise.resolve();
|
||||
// 中断(waiting_human,即“等待人工处理”)视为线性终态:结果不会自行变化,必须停止轮询。
|
||||
// 中断(waiting_human)停轮询前须刷新 Case/Queue,否则自动跳阶段拿不到 lifecycle。
|
||||
expect(api.getQueue.mock.calls.length).toBeGreaterThan(queueCallsBeforeConfirm);
|
||||
expect(review.workflowProgressPolling.value).toBe(false);
|
||||
|
||||
review.stopWorkflowProgressPolling();
|
||||
|
||||
@@ -621,9 +621,12 @@ export function useShippingOrderReview(options: {
|
||||
};
|
||||
|
||||
/**
|
||||
* 轮询正式 OT / Extraction Run 的处理投影,驱动工作流进度与阶段条。
|
||||
*
|
||||
* OT ShippingProcessing Extraction Run
|
||||
* WorkflowItem OT Run
|
||||
* 核心逻辑:有权威 OT 时刷 shipping processing;投影进入 waiting_human/failed 等
|
||||
* 终态前先 await refreshActiveAutomationLifecycle,保证五阶段条能跟随跳转后再停轮询。
|
||||
*
|
||||
* @param itemNo - 可选工作流/OT 编号覆盖
|
||||
*/
|
||||
const startWorkflowProgressPolling = (itemNo?: string | null) => {
|
||||
stopWorkflowProgressPolling();
|
||||
@@ -658,12 +661,8 @@ export function useShippingOrderReview(options: {
|
||||
lastUnifiedStatus = unifiedStatus;
|
||||
options.onWorkflowRefresh?.();
|
||||
}
|
||||
if (UNIFIED_TERMINAL.has(unifiedStatus)) {
|
||||
stopWorkflowProgressPolling();
|
||||
return;
|
||||
}
|
||||
// 顶部五阶段取 Case/Queue 的 lifecycle_entries。仅当 OT 投影的阶段/门禁发生变化
|
||||
// 时刷新一次,避免每 2.5 秒重复读取队列;不等待该读取,保证终态轮询及时停止。
|
||||
// 时刷新一次,避免每 2.5 秒重复读取队列。
|
||||
const lifecycleFingerprint = [
|
||||
unifiedStatus,
|
||||
String(shippingProcessingProjection.value?.stage || ''),
|
||||
@@ -672,7 +671,13 @@ export function useShippingOrderReview(options: {
|
||||
].join('|');
|
||||
if (lifecycleFingerprint !== lastLifecycleFingerprint) {
|
||||
lastLifecycleFingerprint = lifecycleFingerprint;
|
||||
void refreshActiveAutomationLifecycle();
|
||||
// [STEP] waiting_human/failed 也会停轮询,但停前必须落地一次阶段投影,
|
||||
// 否则提交订单后秒级阻断时五阶段条卡在订单复核、自动跳转永不触发。
|
||||
await refreshActiveAutomationLifecycle();
|
||||
}
|
||||
if (UNIFIED_TERMINAL.has(unifiedStatus)) {
|
||||
stopWorkflowProgressPolling();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1999,6 +1999,47 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('follows the backend stage advance when the route has no lifecycle_stage deep link', async () => {
|
||||
// 无 lifecycle_stage = 尚未钉工作面,应跟随系统 current,不能因空深链永久停在订单复核。
|
||||
const originalQueue = reviewQueue.value;
|
||||
try {
|
||||
reviewQueue.value = {
|
||||
...reviewQueue.value,
|
||||
items: [{
|
||||
...reviewQueue.value.items[0],
|
||||
lifecycle_stage: 'order_review',
|
||||
lifecycle_entries: [
|
||||
{ code: 'order_review', state: 'current', targetSurface: 'order_lifecycle_workbench' },
|
||||
{ code: 'fulfillment_prep', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
|
||||
],
|
||||
}],
|
||||
};
|
||||
const wrapper = await mountView({});
|
||||
expect((wrapper.vm as { $route: { query: Record<string, string> } }).$route.query.lifecycle_stage)
|
||||
.toBeUndefined();
|
||||
|
||||
reviewQueue.value = {
|
||||
...reviewQueue.value,
|
||||
items: [{
|
||||
...reviewQueue.value.items[0],
|
||||
lifecycle_stage: 'fulfillment_prep',
|
||||
lifecycle_entries: [
|
||||
{ code: 'order_review', state: 'available', targetSurface: 'order_lifecycle_workbench' },
|
||||
{ code: 'fulfillment_prep', state: 'current', targetSurface: 'order_lifecycle_workbench' },
|
||||
],
|
||||
}],
|
||||
};
|
||||
await nextTick();
|
||||
await flushPromises();
|
||||
|
||||
expect((wrapper.vm as { $route: { query: Record<string, string> } }).$route.query.lifecycle_stage)
|
||||
.toBe('fulfillment_prep');
|
||||
expect(messageMocks.success).toHaveBeenCalledWith('已自动推进到通知准备');
|
||||
} finally {
|
||||
reviewQueue.value = originalQueue;
|
||||
}
|
||||
});
|
||||
|
||||
it('keeps a manually revisited earlier lifecycle stage when the backend advances', async () => {
|
||||
const originalQueue = reviewQueue.value;
|
||||
try {
|
||||
|
||||
@@ -4451,8 +4451,10 @@ watch(
|
||||
) return;
|
||||
// 只响应后端 current 阶段的真实推进:用户点击已完成阶段只会改路由,
|
||||
// 绝不能触发自动跳转而被带回当前阶段。
|
||||
// 无 lifecycle_stage 深链 = 尚未钉工作面,视为仍跟随系统(与「仍停在旧 current」同权)。
|
||||
const requested = String(route.query.lifecycle_stage || '').trim();
|
||||
if (requested !== previousStage) return;
|
||||
const followingSystem = !requested || requested === previousStage;
|
||||
if (!followingSystem) return;
|
||||
if (lifecycleStagePinnedByUserForCase.value === String(activeCase.value?.case_no || '').trim()) return;
|
||||
const previousIndex = LIFECYCLE_STAGE_CODES.indexOf(previousStage);
|
||||
const currentIndex = LIFECYCLE_STAGE_CODES.indexOf(currentStage);
|
||||
|
||||
Reference in new issue
Block a user