feat(in-transit-transfer): 打通ERP 写路径按票执行与已执行调拨单卡片入口
- 新增 TransferDocument 按票执行模型与单据号序列生成(document_id 独立模块,迁移 tt0d/tt8b) - 发票行新增单位字段、matching_id 放宽可空,支持行与票两级执行口径(迁移 tt9c/tt1a) - capability_client 新增 create_transfer 写契约与六态结果裁决,执行链补写前复查门禁 - 抽取/匹配/执行 Job 按 run/item/match 拆分并入 jobs store 队列,transfer 队列单实例 worker 配套本地启动脚本 - 首页新增「已执行调拨单」四统计卡入口与明细列表子视图,重查/重试/关闭/重新触发与筛选分页齐全 - 行评估新鲜度 TTL 从 10 分钟放宽为当日有效(86400s),跨日由文件版本对账门禁兜底 - 同步 chat/errors 文案四语言、测试全家与两份实施计划文档
This commit is contained in:
1 parent
e750fa8602
commit
9f2b023a10
101 files changed
+11109
-2112
No files matched your search
@@ -8,9 +8,11 @@ import { requestBlob, requestJson } from '@/shared/api/client';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import type {
|
||||
TransferActionResult,
|
||||
TransferDocumentRetryResult,
|
||||
TransferBacklogItem,
|
||||
TransferBacklogSummary,
|
||||
TransferBatchResult,
|
||||
TransferExecutedOrdersPage,
|
||||
TransferExecuteResponse,
|
||||
TransferMatchingDetail,
|
||||
TransferMatchingItem,
|
||||
@@ -56,7 +58,12 @@ export const listExecutableTransferItems = () =>
|
||||
{ headers: getAuthHeaders() },
|
||||
);
|
||||
|
||||
/** 按明细行执行调拨(item-centric:body {item_ids};三层门禁在后端,失败抛 BusinessError) */
|
||||
/**
|
||||
* 按明细行执行调拨(item-centric:body {item_ids};三层门禁在后端,失败抛 BusinessError)。
|
||||
* D8 异步契约:后端只做门禁+建 Run+建单+入队,返回 202 envelope,
|
||||
* data = { run_no, status: 'queued' };202 在 requestJson 内按 2xx 与 200 同口径透传,
|
||||
* 本层零特判。进度/结果由 getTransferRun 轮询获取(D9 调拨单清单)。
|
||||
*/
|
||||
export const executeTransferItems = (itemIds: number[]) =>
|
||||
requestJson<TransferExecuteResponse>(`${BASE}/items/execute`, {
|
||||
method: 'POST',
|
||||
@@ -64,12 +71,77 @@ export const executeTransferItems = (itemIds: number[]) =>
|
||||
body: JSON.stringify({ item_ids: itemIds }),
|
||||
});
|
||||
|
||||
/** 恢复 Run 最终结果 */
|
||||
/**
|
||||
* 恢复 Run 结果与调拨单清单(D9 融合卡数据源:调拨单清单=进度=结果)。
|
||||
* 返回体 = result(单号聚合 + exceptions 既有口径)+ orders(TransferOrder[] 逐键,
|
||||
* 对应后端 serialize_run_orders);终态 Run 亦同口径投影,供刷新/重进页面恢复。
|
||||
*/
|
||||
export const getTransferRun = (runNo: string) =>
|
||||
requestJson<TransferRunResult>(`${BASE}/runs/${runNo}`, {
|
||||
headers: getAuthHeaders(),
|
||||
});
|
||||
|
||||
/**
|
||||
* 人工重新触发 result_unknown 单(D11 SOP 唯一出口,202 异步)。
|
||||
* 契约(计划 Task 10):POST /runs/{run_no}/documents/{doc_no}/retrigger → 202,
|
||||
* data = { run_no, doc_no, status: 'queued' };复用原单 doc_no/submit_timestamp,
|
||||
* 只触发末步(幂等,不重插)。非 result_unknown 单 → 400(TRANSFER.RETRIGGER_NOT_ALLOWED)。
|
||||
*/
|
||||
export const retriggerTransferDocument = (runNo: string, docNo: string) =>
|
||||
requestJson<{ run_no: string; doc_no: string; status: string }>(
|
||||
`${BASE}/runs/${encodeURIComponent(runNo)}/documents/${encodeURIComponent(docNo)}/retrigger`,
|
||||
{ method: 'POST', headers: jsonHeaders() },
|
||||
);
|
||||
|
||||
/**
|
||||
* 人工关闭失败单(D18:语义=A 废单不废行;契约取自计划 Task 17)。
|
||||
* POST /documents/{doc_no}/close,body { reason }(必填);仅 business_failed/
|
||||
* technical_failed 可关——单 cancelled、单内行脱离回 ready_to_execute(可重组新单);
|
||||
* result_unknown → 400(提示走重新触发,D11);pending/executing → 400(在飞)。
|
||||
*/
|
||||
export const closeTransferDocument = (docNo: string, reason: string) =>
|
||||
requestJson<TransferActionResult>(`${BASE}/documents/${encodeURIComponent(docNo)}/close`, {
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
body: JSON.stringify({ reason }),
|
||||
});
|
||||
|
||||
/**
|
||||
* 调拨单级重试(失败单一键恢复主路径):POST /documents/{doc_no}/retry。
|
||||
* 后端按单圈行逐行重查;全部 ready 自动建新 Run 重跑(复用原单号),
|
||||
* 任一行仍阻断则不重跑,返回 {doc_no, rerun, run_no, ready, blocked, total}。
|
||||
*/
|
||||
export const retryTransferOrder = (docNo: string) =>
|
||||
requestJson<TransferDocumentRetryResult>(`${BASE}/documents/${encodeURIComponent(docNo)}/retry`, {
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
});
|
||||
|
||||
/**
|
||||
* 已执行单分页查询(首页「已执行」区块数据源;计划 Task 17)。
|
||||
* GET /documents?status_group=&date_from=&date_to=&page=&page_size=;
|
||||
* 返回体 groups(计数恒全量,不受筛选影响)+ orders(TransferExecutedOrder 逐键)。
|
||||
* 缺省参数不下发(后端按缺省口径:全部分组、不限时间、page=1、page_size=20)。
|
||||
*/
|
||||
export const fetchExecutedOrders = (params: {
|
||||
statusGroup?: string;
|
||||
dateFrom?: string;
|
||||
dateTo?: string;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
}) => {
|
||||
const query = new URLSearchParams();
|
||||
if (params.statusGroup) query.set('status_group', params.statusGroup);
|
||||
if (params.dateFrom) query.set('date_from', params.dateFrom);
|
||||
if (params.dateTo) query.set('date_to', params.dateTo);
|
||||
if (params.page != null) query.set('page', String(params.page));
|
||||
if (params.pageSize != null) query.set('page_size', String(params.pageSize));
|
||||
const qs = query.toString();
|
||||
return requestJson<TransferExecutedOrdersPage>(`${BASE}/documents${qs ? `?${qs}` : ''}`, {
|
||||
headers: getAuthHeaders(),
|
||||
});
|
||||
};
|
||||
|
||||
/** 请求停止剩余任务 */
|
||||
export const cancelTransferRun = (runNo: string, reason: string) =>
|
||||
requestJson<TransferActionResult>(`${BASE}/runs/${runNo}/cancel`, {
|
||||
|
||||
Reference in new issue
Block a user