feat(in-transit-transfer): inbound/outbound 幂等重命名与解析用途分层

- receipt→inbound 三件套改名(回调桥/文件门禁/触发服务),回调链幂等去重,迁移 tt14 同步台账键与测试基建
- 库存解析用途分层 onhand/inbound/outbound(迁移 tt15):解析档案、文件存储与下载名按用途隔离,管理端表单同步
- 「成熟」概念退役(迁移 tt16):数据无成熟属性,日期边界由调用方入参严格判定
- backlog 新增重解析服务,在途重识别投影 processing,EML 父项不再停留处理中
- 收料 RPA 回调/归档/排程链路同步改名挂点,运维脚本复位假完成状态
- 文档随批:ADR 0003 模块边界决策、10-15/10-16 计划与设计、调拨文档族与 demand/tec/funclist
- 同步 chat/errors 文案四语言、调拨前端卡片与 e2e、测试全家
This commit is contained in:
hugo committed 2026-10-16 19:43:49 +08:00
1 parent 43dceaf027
commit 8102a1fe44
151 files changed
+8057 -2382

No files matched your search

@@ -9,6 +9,7 @@
*/
import { afterEach, describe, expect, it, vi, beforeEach } from 'vitest';
import { effectScope } from 'vue';
import { BusinessError } from '@/shared/api/client';
const api = vi.hoisted(() => ({
createTransferMatching: vi.fn(),
@@ -19,16 +20,18 @@ const api = vi.hoisted(() => ({
retryTransferItem: vi.fn(),
manualCloseTransferItem: vi.fn(),
batchRequeryTransferItems: vi.fn(),
downloadTransferReceiptFiles: vi.fn(),
downloadTransferInboundFiles: vi.fn(),
downloadTransferErpInventory: vi.fn(),
downloadTransferExceptions: vi.fn(),
listTransferSources: vi.fn(),
fetchTransferTypes: vi.fn(),
retryTransferSourceRpa: vi.fn(),
listTransferBacklog: vi.fn(),
listTransferBacklogPage: vi.fn(),
getTransferBacklogSummary: vi.fn(),
listExecutableTransferItems: vi.fn(),
listPendingMatchRecords: vi.fn(),
listPendingMatchRecordsPage: vi.fn(),
fetchPendingMatchReparsePreview: vi.fn(),
reparsePendingMatch: vi.fn(),
}));
vi.mock('../api/transfer.api', () => api);
@@ -39,9 +42,8 @@ const summary = {
matching_id: 'MTG-20260806-001',
status: 'ready_to_execute',
business_date: '2026-08-06',
eligible_receipt_date_to: '2026-08-05',
expires_at: '',
counts: { file_invoice_count: 2, not_matured_count: 0, matched_count: 2, executable_count: 2, blocked_count: 0 },
counts: { file_invoice_count: 2, matched_count: 2, executable_count: 2, blocked_count: 0 },
estimated_transfer_quantity: '2400',
estimated_external_write_count: 2,
matching_hash: 'sha256:abc',
@@ -53,7 +55,7 @@ const detail = {
items: [
{ item_id: 11, source_code: 'DBS-AWSBI', material_no: 'MAT-1', material_name: 'x', specification: 'y', invoice_no: 'INV-001', from_warehouse: 'DBS-TRANSIT', from_quantity: '1200', to_warehouse: 'HUB-CN01', to_quantity: '1200', result: 'executable' },
{ item_id: 12, source_code: 'DBS-AWSBI', material_no: 'MAT-2', material_name: 'x', specification: 'y', invoice_no: 'INV-002', from_warehouse: 'DBS-TRANSIT', from_quantity: '1200', to_warehouse: 'HUB-CN01', to_quantity: '1200', result: 'executable' },
{ item_id: 13, source_code: 'DBS-AWSBI', material_no: 'MAT-3', material_name: 'x', specification: 'y', invoice_no: 'INV-041', from_warehouse: '', from_quantity: null, to_warehouse: '', to_quantity: '400', result: 'not_matured' },
{ item_id: 13, source_code: 'DBS-AWSBI', material_no: 'MAT-3', material_name: 'x', specification: 'y', invoice_no: 'INV-041', from_warehouse: '', from_quantity: null, to_warehouse: '', to_quantity: '400', result: 'blocked_quantity_mismatch' },
],
};
@@ -70,7 +72,7 @@ describe('useChatTransfer', () => {
});
});
it('创建匹配后默认按 item_id 勾选全部可执行行,未成熟项不可勾选', async () => {
it('创建匹配后默认按 item_id 勾选全部可执行行,阻断项不可勾选', async () => {
const transfer = useChatTransfer();
await transfer.createMatching(['DBS-AWSBI'], '2026-08-06');
expect(transfer.matchingId.value).toBe('MTG-20260806-001');
@@ -79,6 +81,30 @@ describe('useChatTransfer', () => {
expect(transfer.selected.value.has(13)).toBe(false);
});
it('创建匹配携带异动日期范围:参数名 movement_date_from/to(Task 3 契约更名)', async () => {
// [断言意图] 匹配查询范围参数对齐后端 /matchings 新契约(Task 3 更名):
// 参数名为 movement_date_from/to;日期值透传来源选择卡的 D+1 规则区间。
const transfer = useChatTransfer();
await transfer.createMatching(['DBS-AWSBI'], undefined, { from: '2026-09-26', to: '2026-09-26' });
expect(api.createTransferMatching).toHaveBeenCalledWith(
expect.objectContaining({ movement_date_from: '2026-09-26', movement_date_to: '2026-09-26' }),
);
});
it('downloadInboundFiles 按 run_no 调下载 API,文件名缺省回退 inbound-files-<run_no>.zip', async () => {
// [断言意图] 下载出入站来源文件走 /runs/{run_no}/inbound-files(Task 3 路由更名):
// 组合式函数按 run_no 调 API;后端未回 filename 时前端回退 inbound-files- 前缀命名。
api.downloadTransferInboundFiles.mockResolvedValue({ blob: new Blob(['zip']), filename: 'inbound-files.zip' });
const transfer = useChatTransfer();
transfer.runNo.value = 'RUN-20260806-001';
await transfer.downloadInboundFiles();
expect(api.downloadTransferInboundFiles).toHaveBeenCalledWith('RUN-20260806-001');
api.downloadTransferInboundFiles.mockResolvedValue({ blob: new Blob(['zip']), filename: null });
await transfer.downloadInboundFiles();
expect(api.downloadTransferInboundFiles).toHaveBeenCalledTimes(2);
});
it('执行时按明细行 id 提交勾选范围并恢复 Run', async () => {
const transfer = useChatTransfer();
await transfer.createMatching(['DBS-AWSBI']);
@@ -286,7 +312,7 @@ describe('useChatTransfer Run 轮询(D8 异步 202 / D9 融合卡数据源)'
});
});
describe('useChatTransfer 来源状态轮询(收料 RPA 202 异步收口)', () => {
describe('useChatTransfer 来源状态轮询(入站 RPA 202 异步收口)', () => {
/** 来源选择卡轮询用例的标准来源载荷(file_status 可变,驱动 fetching→终态分支) */
const sourceOptionsWith = (file_status: string) => [
{
@@ -308,7 +334,7 @@ describe('useChatTransfer 来源状态轮询(收料 RPA 202 异步收口)',
vi.useRealTimers();
});
it('重试收料 RPA 后来源处于抓取中即自动轮询,收口(ready)后停止', async () => {
it('重试入站 RPA 后来源处于抓取中即自动轮询,收口(ready)后停止', async () => {
// [断言意图] 重试 202 返回后 loadSources 首帧仍是 fetching(RPA 回调未到),
// 轮询必须自动接管:收口帧把 抓取中→ready 投影进 sourceOptions(修复状态卡死),
// 全部来源脱离 fetching 即停——再推进 20s 也不产生新请求。
@@ -435,6 +461,50 @@ describe('useChatTransfer 调拨类型加载(Task 7 接口化,模块级单
});
});
describe('useChatTransfer 待匹配清空重解析(Task 8 维护链路)', () => {
/** POST /backlog/pending-match/reparse data 形状(后端 Task 7 ReparseOutcome 序列化) */
const reparsePayload = {
source_code: 'DBS-AWSBI',
cleared: 12,
reinserted: 10,
date_skipped: 0,
kept_unrebuildable: 4,
unlinked_items: 2,
files: [{ file_id: 5, sha256: 'sha-aaa', archived_at: '2026-08-03T10:00:00', inserted: 10 }],
};
beforeEach(() => {
vi.clearAllMocks();
api.listPendingMatchRecordsPage.mockResolvedValue({ records: [], total: 0, page: 1, page_size: 20 });
});
it('reparsePendingMatch 调 POST reparse 并在成功后刷新待匹配清单', async () => {
// [断言意图] 维护链路唯一编排点:按来源调执行端点,成功即重拉待匹配清单
// (桶内容已被清空重建,宿主面板经 emit refresh 再拉一次,组合式函数自身
// 状态也必须同步,保证 reset/恢复路径拿到新桶)。
api.reparsePendingMatch.mockResolvedValue(reparsePayload);
const transfer = useChatTransfer();
await transfer.loadPendingMatchRecords();
const result = await transfer.reparsePendingMatch('DBS-AWSBI');
expect(api.reparsePendingMatch).toHaveBeenCalledWith('DBS-AWSBI');
expect(api.listPendingMatchRecordsPage).toHaveBeenCalledTimes(2); // 初始 1 + 重建后刷新 1
expect(result.cleared).toBe(12);
expect(transfer.pendingMatchRecords.value).toEqual([]);
});
it('执行失败原样上抛(TRANSFER.REPARSE_PARSE_FAILED 中止未删语义由调用方展示)', async () => {
// [断言意图] 失败不吞错、不刷新:BusinessError 透传给调用方(弹窗内展示
// 「中止未删」),且失败路径不产生待匹配清单重拉。
api.reparsePendingMatch.mockRejectedValue(
new BusinessError({ message: '归档解析失败', code: 'TRANSFER.REPARSE_PARSE_FAILED' }),
);
const transfer = useChatTransfer();
await expect(transfer.reparsePendingMatch('DBS-AWSBI'))
.rejects.toMatchObject({ code: 'TRANSFER.REPARSE_PARSE_FAILED' });
expect(api.listPendingMatchRecordsPage).not.toHaveBeenCalled();
});
});
describe('useChatTransfer 首页看板预取(会话引导期单飞)', () => {
/** 标准看板载荷(供预取槽位消费;单飞槽位是模块级状态,用例结束前必须双槽消费完) */
const backlogSummaryPayload = {