feat(shipping-notice): 新增库存确认来源接口及相关逻辑
This commit is contained in:
1 parent
a31735b689
commit
0a9bd6415d
69 files changed
+8442
-775
No files matched your search
@@ -218,7 +218,7 @@ watch(
|
||||
:ref="bindShippingPickerRef"
|
||||
type="file"
|
||||
class="hidden"
|
||||
accept=".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv"
|
||||
accept=".xlsx,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,text/csv"
|
||||
@change="emit('shipping-inventory-selected', $event)"
|
||||
/>
|
||||
|
||||
|
||||
@@ -324,6 +324,21 @@ const resolveTaskDiagnosis = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
advice: t('chat.shippingNoticeUi.diagnosisReservationRequiredAdvice'),
|
||||
};
|
||||
}
|
||||
if (reason === 'inventory_source_unresolved') {
|
||||
const resolution = (task as ShippingTaskDetail).inventory_source_resolution;
|
||||
const status = resolution && typeof resolution === 'object'
|
||||
? String((resolution as { status?: unknown }).status || '').trim()
|
||||
: '';
|
||||
const isAmbiguous = status === 'ambiguous';
|
||||
return {
|
||||
title: t(isAmbiguous
|
||||
? 'chat.shippingNoticeUi.diagnosisInventorySourceAmbiguousTitle'
|
||||
: 'chat.shippingNoticeUi.diagnosisInventorySourceTitle'),
|
||||
advice: t(isAmbiguous
|
||||
? 'chat.shippingNoticeUi.diagnosisInventorySourceAmbiguousAdvice'
|
||||
: 'chat.shippingNoticeUi.diagnosisInventorySourceAdvice'),
|
||||
};
|
||||
}
|
||||
if (reason === 'map_infer' || processStatus === 'waiting_inventory') {
|
||||
return {
|
||||
title: t('chat.shippingNoticeUi.diagnosisInventoryWaitingTitle'),
|
||||
@@ -352,6 +367,9 @@ const resolveSuggestedAction = (task: ShippingTaskSummary | ShippingTaskDetail)
|
||||
if (reason === 'low_confidence' || reviewStatus === 'parse_review') {
|
||||
return t('chat.shippingNoticeUi.suggestReviewParse');
|
||||
}
|
||||
if (reason === 'inventory_source_unresolved') {
|
||||
return t('chat.shippingNoticeUi.suggestConfirmInventorySource');
|
||||
}
|
||||
if (isFailedTask(task)) {
|
||||
return t('chat.shippingNoticeUi.suggestRetryStep');
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@ function deriveCurrentIndex(task: ShippingTaskStepperSource | null | undefined):
|
||||
|| reviewStatus === 'rsv_required'
|
||||
|| pendingReason === 'low_confidence'
|
||||
|| pendingReason === 'rsv_required'
|
||||
|| pendingReason === 'inventory_source_unresolved'
|
||||
) {
|
||||
return 1;
|
||||
}
|
||||
@@ -159,7 +160,12 @@ export function buildShippingWorkflowSteps(
|
||||
}
|
||||
|
||||
if (
|
||||
(index === 1 && (reviewStatus === 'parse_review' || pendingReason === 'low_confidence' || pendingReason === 'rsv_required'))
|
||||
(index === 1 && (
|
||||
reviewStatus === 'parse_review'
|
||||
|| pendingReason === 'low_confidence'
|
||||
|| pendingReason === 'rsv_required'
|
||||
|| pendingReason === 'inventory_source_unresolved'
|
||||
))
|
||||
|| (index === 2 && (pendingReason === 'inv_unavail' || pendingReason === 'rpa_exhausted'))
|
||||
|| (index === 3 && (reviewStatus === 'align_review' || pendingReason === 'align_review'))
|
||||
|| (index === 4 && (reviewStatus === 'shortage_review' || pendingReason === 'shortage_review' || pendingReason === 'shortage'))
|
||||
|
||||
@@ -32,7 +32,7 @@ export interface ShippingMenuHandlerContext {
|
||||
refreshShippingActions: () => Promise<void>;
|
||||
startChatTurn: (options: StartChatTurnOptions) => Promise<boolean>;
|
||||
msg: { warning: (text: string) => void; info: (text: string) => void };
|
||||
t: (key: string) => string;
|
||||
t: (key: string, ...args: unknown[]) => string;
|
||||
}
|
||||
|
||||
export interface HandleShippingMenuActionOptions {
|
||||
@@ -97,8 +97,8 @@ export function createShippingMenuHandlers(ctx: ShippingMenuHandlerContext) {
|
||||
if (!turnSpec) return false;
|
||||
const displayBase = String(action.message || actionId || '操作').trim();
|
||||
const displayText = actionId === 'confirm_inventory_source'
|
||||
? `${displayBase}\n任务编号:${taskId}`
|
||||
: `${displayBase}(任务编号:${taskId})`;
|
||||
? ctx.t('chat.shippingNoticeUi.inventorySource.confirmWithTask', { taskId })
|
||||
: ctx.t('chat.shippingNoticeUi.inventorySource.actionWithTask', { message: displayBase, taskId });
|
||||
await ctx.startChatTurn({
|
||||
agentId: ctx.currentAgentId.value,
|
||||
inputType: 'action',
|
||||
@@ -168,7 +168,7 @@ export function createShippingMenuHandlers(ctx: ShippingMenuHandlerContext) {
|
||||
sourceCode = await resolveInventorySourceCodeFromContext(taskId);
|
||||
}
|
||||
if (!sourceCode) {
|
||||
ctx.msg.warning('请直接输入要使用的库存源线索,例如 AWSDU、Dublin 或 Singapore。');
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeUi.inventorySource.inputHint'));
|
||||
if (chatMsg) chatMsg.shipping_actions_used = false;
|
||||
return;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ export function createShippingMenuHandlers(ctx: ShippingMenuHandlerContext) {
|
||||
}
|
||||
const label = String(('label' in action ? action.label : '') || sourceCode).trim();
|
||||
const displayMessage = action.id === 'confirm_inventory_source'
|
||||
? `确认库存查询来源:${label || sourceCode}`
|
||||
? ctx.t('chat.shippingNoticeUi.inventorySource.confirmDisplay', { label: label || sourceCode })
|
||||
: action.message;
|
||||
await runShippingActionTurn(
|
||||
{ ...action, message: displayMessage },
|
||||
@@ -195,7 +195,7 @@ export function createShippingMenuHandlers(ctx: ShippingMenuHandlerContext) {
|
||||
|
||||
if (action.id === 'retry_resolve_inventory_source') {
|
||||
await ctx.refreshShippingActions();
|
||||
ctx.msg.info('已重新刷新库存源状态');
|
||||
ctx.msg.info(ctx.t('chat.shippingNoticeUi.inventorySource.retryResolveDone'));
|
||||
return;
|
||||
}
|
||||
if (action.id === 'edit_inventory_mapping') {
|
||||
|
||||
@@ -66,7 +66,7 @@ export interface ShippingSendHandlerContext {
|
||||
isShippingShortageQueryIntent: (text: string) => boolean;
|
||||
queryShippingShortageDetails: (taskNo?: string, displayText?: string) => Promise<boolean>;
|
||||
msg: { warning: (text: string) => void; info: (text: string) => void };
|
||||
t: (key: string) => string;
|
||||
t: (key: string, ...args: unknown[]) => string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,13 +114,13 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
const label = String(hit?.display_name || sourceCode).trim();
|
||||
await ctx.handleShippingMenuAction({
|
||||
id: 'confirm_inventory_source',
|
||||
message: `确认库存查询来源:${label}`,
|
||||
message: ctx.t('chat.shippingNoticeUi.inventorySource.confirmDisplay', { label }),
|
||||
label,
|
||||
source_code: sourceCode,
|
||||
});
|
||||
return true;
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : '确认库存源失败';
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.shippingNoticeUi.inventorySource.confirmFailed');
|
||||
ctx.msg.warning(errorMessage);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,42 @@
|
||||
* 依赖:无(纯类型模块)。
|
||||
* 逻辑:shipping.api.ts 与 Chat/工作台组件统一引用本文件 DTO 类型。
|
||||
*/
|
||||
export type InventorySourceStatus =
|
||||
| 'unresolved'
|
||||
| 'ambiguous'
|
||||
| 'resolved'
|
||||
| 'user_confirmed'
|
||||
| 'invalid'
|
||||
| 'conflicted';
|
||||
|
||||
export type InventorySourceMethod =
|
||||
| 'rule_exact'
|
||||
| 'rule_combined'
|
||||
| 'user_confirmed'
|
||||
| 'legacy_migrated';
|
||||
|
||||
export interface ShippingInventorySourceCandidate {
|
||||
source_code: string;
|
||||
display_name?: string | null;
|
||||
site_id?: string | null;
|
||||
warehouse_id?: string | null;
|
||||
source_type?: string | null;
|
||||
match_score?: number | null;
|
||||
matched_by?: string | null;
|
||||
}
|
||||
|
||||
export interface ShippingInventorySourceResolution {
|
||||
status?: InventorySourceStatus | null;
|
||||
method?: InventorySourceMethod | null;
|
||||
reason?: string | null;
|
||||
candidates?: ShippingInventorySourceCandidate[];
|
||||
destination_candidates?: string[];
|
||||
evidence?: Record<string, unknown>[];
|
||||
conflicts?: string[];
|
||||
config_version?: string | null;
|
||||
routing_fingerprint?: string | null;
|
||||
}
|
||||
|
||||
export interface ShippingInventorySnapshot {
|
||||
inventory_file_no?: string | null;
|
||||
source_code?: string | null;
|
||||
@@ -48,7 +84,21 @@ export interface ShippingTaskSummary {
|
||||
};
|
||||
rpa_runtime?: ShippingRpaRuntime | null;
|
||||
rpa_inventory_source?: Record<string, unknown> | null;
|
||||
inventory_source_resolution?: Record<string, unknown> | null;
|
||||
inventory_source_resolution?: ShippingInventorySourceResolution | null;
|
||||
destination_code?: string | null;
|
||||
destination_city?: string | null;
|
||||
destination_country?: string | null;
|
||||
warehouse_hint?: string | null;
|
||||
inventory_source_code?: string | null;
|
||||
inventory_source_type?: string | null;
|
||||
inventory_site_id?: string | null;
|
||||
inventory_warehouse_id?: string | null;
|
||||
inventory_source_status?: InventorySourceStatus | null;
|
||||
inventory_source_method?: InventorySourceMethod | null;
|
||||
inventory_source_config_version?: string | null;
|
||||
inventory_routing_fingerprint?: string | null;
|
||||
inventory_source_confirmed_at?: string | null;
|
||||
inventory_source_confirmed_by?: number | null;
|
||||
inventory_snapshot?: ShippingInventorySnapshot | null;
|
||||
created_at?: string | null;
|
||||
updated_at?: string | null;
|
||||
|
||||
Reference in new issue
Block a user