refactor(in-transit-transfer): 行归属解耦、按行执行三层门禁并重构术语为匹配
- 行不迁移:匹配记录降级为评估留痕(scope/counts/hash 留痕不拦执行), 匹配/重查原地刷新行并续行级新鲜度(updated_at) - 执行改按行:POST /items/execute 三层门禁(行级新鲜度 TTL/文件版本对账/写前复查), Run 留痕不绑匹配记录;消失行 blocked_file_removed fail-closed 入异常池 - 恢复处理收敛为行级重查(batch-resume 删除);待处理池补齐匹配窗口字段, 排序改业务稳定键(收料日期→Invoice→created_at,操作不再引起跳位) - 首页待办看板四队列:可调拨明细/待恢复异常/已人工关闭/结果未知;「最近预检」移除; 收料日期默认 T-1 并加输入期限制;「重新查询 ERP」更名「重查」 - 术语重构 precheck→match:表 transfer_matchings、列 matching_id/matching_no/matching_hash、 API /matchings、单号前缀 MTG、状态值 prechecking→matching(迁移 rn1a2b3c4d5e6,模块未上线无兼容层) - 修复 integration_connector mapping 扇出嵌套丢行缺陷;对账结论:0 vs 30/40/36 系收料仓库映射曾指向错误账套 TGHX(已改 TGHX1),探针留档 backend/tmp - 测试:后端 in_transit_transfer+api+connector 393 passed;前端 chat 713 passed;build ✓
This commit is contained in:
1 parent
f9f5053f0b
commit
0cf3c24119
108 files changed
+3660
-2356
No files matched your search
@@ -1,27 +1,28 @@
|
||||
/**
|
||||
* features/chat/composables/useChatTransfer.ts
|
||||
* 用途:在途仓自动调拨聊天编排入口——预检创建/恢复、选择范围、直接生成执行 Run、
|
||||
* Run 进度与结果恢复、人工重试/关闭、下载。
|
||||
* 用途:在途仓自动调拨聊天编排入口——匹配创建/恢复、选择范围(按明细 item_id)、
|
||||
* 按行直接生成执行 Run、Run 进度与结果恢复、人工重试/关闭、恢复处理(重查)、下载。
|
||||
* 依赖:transfer.api、transfer.types、useMessage、Vue refs/computed。
|
||||
* 逻辑:前端只消费稳定 DTO;Run 是异步真相源,刷新/重进由 GET 恢复;
|
||||
* 勾选集合以明细行 item_id 为键(历史回放行无 item_id 不可选);
|
||||
* 恢复处理 = 按明细 id 重查库存(batch-requery 是唯一后端);
|
||||
* 防重复点击(busy);错误统一 useMessage 展示 BusinessError。
|
||||
*/
|
||||
import { computed, ref, type Ref } from 'vue';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
batchManualCloseTransferItems,
|
||||
batchResumeTransferItems,
|
||||
batchRequeryTransferItems,
|
||||
cancelTransferRun,
|
||||
createTransferPrecheck,
|
||||
createTransferMatching,
|
||||
downloadTransferErpInventory,
|
||||
downloadTransferExceptions,
|
||||
downloadTransferReceiptFiles,
|
||||
executeTransferPrecheck,
|
||||
executeTransferItems,
|
||||
getTransferBacklogSummary,
|
||||
getTransferPrecheck,
|
||||
getTransferMatching,
|
||||
getTransferRun,
|
||||
listRecentTransferPrechecks,
|
||||
listExecutableTransferItems,
|
||||
listTransferBacklog,
|
||||
listTransferSources,
|
||||
manualCloseTransferItem,
|
||||
@@ -31,12 +32,10 @@ import {
|
||||
import type {
|
||||
TransferBacklogItem,
|
||||
TransferBacklogSummary,
|
||||
TransferBatchResumeResponse,
|
||||
TransferBatchResult,
|
||||
TransferPrecheckDetail,
|
||||
TransferPrecheckItem,
|
||||
TransferPrecheckSummary,
|
||||
TransferRecentPrecheck,
|
||||
TransferMatchingDetail,
|
||||
TransferMatchingItem,
|
||||
TransferMatchingSummary,
|
||||
TransferRunResult,
|
||||
TransferSourceOption,
|
||||
TransferSourceProgress,
|
||||
@@ -46,30 +45,32 @@ import type {
|
||||
export function useChatTransfer() {
|
||||
const { error: notifyError } = useMessage();
|
||||
|
||||
const precheckId = ref<string | null>(null);
|
||||
const precheck = ref<TransferPrecheckSummary | null>(null);
|
||||
const items = ref<TransferPrecheckItem[]>([]);
|
||||
const matchingId = ref<string | null>(null);
|
||||
const matching = ref<TransferMatchingSummary | null>(null);
|
||||
const items = ref<TransferMatchingItem[]>([]);
|
||||
const sources = ref<TransferSourceProgress[]>([]);
|
||||
const runNo = ref<string | null>(null);
|
||||
const run = ref<TransferRunResult | null>(null);
|
||||
const backlog = ref<TransferBacklogItem[]>([]);
|
||||
const backlogSummary = ref<TransferBacklogSummary | null>(null);
|
||||
const recentPrechecks = ref<TransferRecentPrecheck[]>([]);
|
||||
const executableItems = ref<TransferMatchingItem[]>([]);
|
||||
const sourceOptions = ref<TransferSourceOption[]>([]);
|
||||
const selected = ref<Set<string>>(new Set());
|
||||
const selected = ref<Set<number>>(new Set());
|
||||
const busy = ref(false);
|
||||
const error = ref('');
|
||||
|
||||
/** 全部可执行 Invoice(阻断/未成熟不可勾选) */
|
||||
const executableInvoices = computed(() =>
|
||||
items.value.filter((item) => item.result === 'executable').map((item) => item.invoice_no),
|
||||
/** 全部可执行明细行 id(阻断/未成熟/无 item_id 的历史行不可勾选) */
|
||||
const executableItemIds = computed(() =>
|
||||
items.value
|
||||
.filter((item) => item.result === 'executable' && item.item_id != null)
|
||||
.map((item) => item.item_id as number),
|
||||
);
|
||||
|
||||
const selectedCount = computed(() => selected.value.size);
|
||||
const estimatedQuantity = computed(() => precheck.value?.estimated_transfer_quantity ?? '0');
|
||||
const estimatedQuantity = computed(() => matching.value?.estimated_transfer_quantity ?? '0');
|
||||
|
||||
/** 创建预检(缺文件时来源级阶段展示等待/失败);transferType 决定收料数据范围,缺省在途仓至HUB仓 */
|
||||
async function createPrecheck(
|
||||
/** 创建匹配(缺文件时来源级阶段展示等待/失败);transferType 决定收料数据范围,缺省在途仓至HUB仓 */
|
||||
async function createMatching(
|
||||
sourceCodes: string[],
|
||||
businessDate?: string,
|
||||
dateRange?: { from?: string; to?: string },
|
||||
@@ -78,15 +79,15 @@ export function useChatTransfer() {
|
||||
busy.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const summary = await createTransferPrecheck({
|
||||
const summary = await createTransferMatching({
|
||||
source_codes: sourceCodes,
|
||||
business_date: businessDate,
|
||||
receipt_date_from: dateRange?.from,
|
||||
receipt_date_to: dateRange?.to,
|
||||
transfer_type: transferType,
|
||||
});
|
||||
precheckId.value = summary.precheck_id;
|
||||
await refreshPrecheck();
|
||||
matchingId.value = summary.matching_id;
|
||||
await refreshMatching();
|
||||
return summary;
|
||||
} catch (e) {
|
||||
error.value = String(e);
|
||||
@@ -96,42 +97,43 @@ export function useChatTransfer() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 恢复预检进度(页面刷新/会话恢复) */
|
||||
async function refreshPrecheck() {
|
||||
if (!precheckId.value) return null;
|
||||
const detail = await getTransferPrecheck(precheckId.value);
|
||||
/** 恢复匹配进度(页面刷新/会话恢复) */
|
||||
async function refreshMatching() {
|
||||
if (!matchingId.value) return null;
|
||||
const detail = await getTransferMatching(matchingId.value);
|
||||
applyDetail(detail);
|
||||
return detail;
|
||||
}
|
||||
|
||||
function applyDetail(detail: TransferPrecheckDetail) {
|
||||
precheck.value = detail.summary;
|
||||
function applyDetail(detail: TransferMatchingDetail) {
|
||||
matching.value = detail.summary;
|
||||
items.value = detail.items;
|
||||
sources.value = detail.sources;
|
||||
// 默认勾选全部可执行项;阻断/未成熟不可选
|
||||
// 默认勾选全部可执行明细行(按 item_id);阻断/未成熟/无 item_id 不可选
|
||||
selected.value = new Set(
|
||||
detail.items.filter((item) => item.result === 'executable').map((item) => item.invoice_no),
|
||||
detail.items
|
||||
.filter((item) => item.result === 'executable' && item.item_id != null)
|
||||
.map((item) => item.item_id as number),
|
||||
);
|
||||
}
|
||||
|
||||
function toggleSelect(invoiceNo: string, checked: boolean) {
|
||||
function toggleSelect(itemId: number, checked: boolean) {
|
||||
const next = new Set(selected.value);
|
||||
if (checked) next.add(invoiceNo);
|
||||
else next.delete(invoiceNo);
|
||||
if (checked) next.add(itemId);
|
||||
else next.delete(itemId);
|
||||
selected.value = next;
|
||||
}
|
||||
|
||||
/** 直接生成调拨单(决策 4/5:无独立确认页) */
|
||||
/** 按勾选明细行直接生成调拨单(item-centric:门禁在后端,失败抛 BusinessError) */
|
||||
async function execute() {
|
||||
if (!precheckId.value) throw new Error('precheck not created');
|
||||
if (selected.value.size === 0) {
|
||||
notifyError('请至少选择一个可执行 Invoice');
|
||||
notifyError('请至少选择一个可执行明细行');
|
||||
return null;
|
||||
}
|
||||
busy.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const result = await executeTransferPrecheck(precheckId.value, [...selected.value]);
|
||||
const result = await executeTransferItems([...selected.value]);
|
||||
runNo.value = result.run_no;
|
||||
await refreshRun();
|
||||
return result;
|
||||
@@ -162,14 +164,14 @@ export function useChatTransfer() {
|
||||
/** 人工重试异常项 */
|
||||
async function retry(itemId: number) {
|
||||
const result = await retryTransferItem(itemId);
|
||||
await refreshPrecheck();
|
||||
await refreshMatching();
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 人工关闭异常项 */
|
||||
async function manualClose(itemId: number, reason: string) {
|
||||
const result = await manualCloseTransferItem(itemId, reason);
|
||||
await refreshPrecheck();
|
||||
await refreshMatching();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -181,7 +183,7 @@ export function useChatTransfer() {
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 下载预检冻结的 ERP 库存表(csv) */
|
||||
/** 下载匹配冻结的 ERP 库存表(csv) */
|
||||
async function downloadErpInventory() {
|
||||
if (!runNo.value) return null;
|
||||
const result = await downloadTransferErpInventory(runNo.value);
|
||||
@@ -218,18 +220,11 @@ export function useChatTransfer() {
|
||||
return { items, summary };
|
||||
}
|
||||
|
||||
/** 加载最近预检(未执行、未过期、仍拥有归属行;供一键恢复预检卡) */
|
||||
async function loadRecentPrechecks() {
|
||||
recentPrechecks.value = await listRecentTransferPrechecks();
|
||||
return recentPrechecks.value;
|
||||
}
|
||||
|
||||
/** 按预检号恢复预检进度(最近预检入口 → 预检卡) */
|
||||
async function restorePrecheckById(id: string) {
|
||||
const detail = await getTransferPrecheck(id);
|
||||
precheckId.value = detail.summary.precheck_id;
|
||||
applyDetail(detail);
|
||||
return detail;
|
||||
/** 加载可调拨明细(全局可执行行队列;恢复后的行会出现在这里) */
|
||||
async function loadExecutableItems() {
|
||||
const payload = await listExecutableTransferItems();
|
||||
executableItems.value = payload.items;
|
||||
return executableItems.value;
|
||||
}
|
||||
|
||||
/** 批量重查库存(单行隔离,结果由调用方刷新列表后展示) */
|
||||
@@ -237,9 +232,10 @@ export function useChatTransfer() {
|
||||
return batchRequeryTransferItems(itemIds);
|
||||
}
|
||||
|
||||
/** 批量恢复处理:按(来源, 收料日期)分组重建预检,返回预检/重抓/跳过明细 */
|
||||
async function batchResume(itemIds: number[]): Promise<TransferBatchResumeResponse> {
|
||||
return batchResumeTransferItems(itemIds);
|
||||
/** 恢复处理(行级/多选):恢复语义 = 按明细 id 重查库存(batch-requery 唯一后端);
|
||||
* 返回批量结果,由视图统计 recovered(status=ready_to_execute)与仍阻断数。 */
|
||||
async function resume(itemIds: number[]): Promise<TransferBatchResult> {
|
||||
return batchRequeryTransferItems(itemIds);
|
||||
}
|
||||
|
||||
/** 批量人工关闭(原因整批共用;单行隔离) */
|
||||
@@ -257,39 +253,39 @@ export function useChatTransfer() {
|
||||
}
|
||||
|
||||
function reset() {
|
||||
precheckId.value = null;
|
||||
precheck.value = null;
|
||||
matchingId.value = null;
|
||||
matching.value = null;
|
||||
items.value = [];
|
||||
sources.value = [];
|
||||
runNo.value = null;
|
||||
run.value = null;
|
||||
backlog.value = [];
|
||||
backlogSummary.value = null;
|
||||
recentPrechecks.value = [];
|
||||
executableItems.value = [];
|
||||
sourceOptions.value = [];
|
||||
selected.value = new Set();
|
||||
error.value = '';
|
||||
}
|
||||
|
||||
return {
|
||||
precheckId,
|
||||
precheck,
|
||||
matchingId,
|
||||
matching,
|
||||
items,
|
||||
sources,
|
||||
runNo,
|
||||
run,
|
||||
backlog,
|
||||
backlogSummary,
|
||||
recentPrechecks,
|
||||
executableItems,
|
||||
sourceOptions,
|
||||
selected,
|
||||
selectedCount,
|
||||
executableInvoices,
|
||||
executableItemIds,
|
||||
estimatedQuantity,
|
||||
busy,
|
||||
error,
|
||||
createPrecheck,
|
||||
refreshPrecheck,
|
||||
createMatching,
|
||||
refreshMatching,
|
||||
toggleSelect,
|
||||
execute,
|
||||
refreshRun,
|
||||
@@ -299,10 +295,9 @@ export function useChatTransfer() {
|
||||
loadSources,
|
||||
retrySourceRpa,
|
||||
loadBacklog,
|
||||
loadRecentPrechecks,
|
||||
restorePrecheckById,
|
||||
loadExecutableItems,
|
||||
batchRequery,
|
||||
batchResume,
|
||||
resume,
|
||||
batchManualClose,
|
||||
downloadReceiptFiles,
|
||||
downloadErpInventory,
|
||||
|
||||
Reference in new issue
Block a user