feat(shipping-notice): 新增临时库存管理功能,支持创建会话、获取分析结果及字段映射建议
This commit is contained in:
1 parent
46eb63f5bb
commit
e9bdd81f1a
320 files changed
+28361
-10487
No files matched your search
@@ -2,7 +2,7 @@
|
||||
* features/chat/shipping/shippingIntents.ts
|
||||
* 用途:发货聊天用户输入意图识别,供 handleSend 前置拦截。
|
||||
* 依赖:shippingMenu.resolveShippingNumericChoice、types/shipping.types。
|
||||
* 逻辑:useChatShippingSendHandler 调用;覆盖手工上传、库存上传、Excel 生成/下载、列映射与切票。
|
||||
* 逻辑:useChatShippingSendHandler 调用;覆盖手工上传、库存上传、Excel 生成/下载与切票。
|
||||
*/
|
||||
import { resolveShippingNumericChoice } from './shippingMenu';
|
||||
import type { ShippingMenuAction } from '../types/shipping.types';
|
||||
@@ -15,43 +15,6 @@ export interface ShippingTaskSwitchIntent {
|
||||
/**
|
||||
* 从自然语言文本解析库存列映射(part_number / reservation_id / available_qty → Excel 列名)。
|
||||
*/
|
||||
export function parseShippingColumnMappingFromText(content: string): Record<string, string> | null {
|
||||
const raw = String(content || '').trim();
|
||||
if (!raw) return null;
|
||||
if (!/[→>=-]/.test(raw)) return null;
|
||||
const lines = raw.split(/\r?\n/).map((s) => s.trim()).filter(Boolean);
|
||||
const mapping: Record<string, string> = {};
|
||||
const normalizeRight = (s: string) => String(s || '')
|
||||
.replace(/[::]/g, '')
|
||||
.replace(/列$/g, '')
|
||||
.replace(/字段$/g, '')
|
||||
.replace(/^\[|\]$/g, '')
|
||||
.trim();
|
||||
const toKey = (left: string) => {
|
||||
const s = left.toLowerCase();
|
||||
if (s.includes('reservation') || left.includes('预留') || left.includes('预定')) return 'reservation_id';
|
||||
if (s.includes('qty') || s.includes('available') || left.includes('可用') || left.includes('数量')) return 'available_qty';
|
||||
if (s.includes('part_number') || s.includes('part number') || s.includes('sku') || left.includes('料号') || left.includes('物料')) {
|
||||
return 'part_number';
|
||||
}
|
||||
return '';
|
||||
};
|
||||
for (const line of lines) {
|
||||
const m = line.match(/^\s*(.+?)\s*(?:→|->|=>|=|:|:)\s*(.+?)\s*$/);
|
||||
if (!m) continue;
|
||||
const left = m[1];
|
||||
const right = m[2];
|
||||
if (!left || !right) continue;
|
||||
const key = toKey(left.trim());
|
||||
if (!key) continue;
|
||||
const col = normalizeRight(right);
|
||||
if (!col) continue;
|
||||
mapping[key] = col;
|
||||
}
|
||||
if (!mapping.part_number || !mapping.reservation_id || !mapping.available_qty) return null;
|
||||
return mapping;
|
||||
}
|
||||
|
||||
export function isShippingManualUploadIntent(text: string): boolean {
|
||||
const normalized = text.trim();
|
||||
if (!normalized) return false;
|
||||
|
||||
Reference in new issue
Block a user