- synonym:补齐陆运类型 G14-G20、车型 G21-G31、城市 G32-G51;纯英文同义词在长值里按整词命中(SHA/SIN 不再从 KAUSHAL/SINGH 截出),英文街道地址(逗号/门牌/邮编)不做城市归一;新增 display_value 让核对卡显示带括号说明的标准值;通用 harvest_field_value 按 field_key 扫表,包装沿用句内最后一个、贸易条款多值不猜。 - extract_text:同一行多个「字段名:值」时值收到下一个字段名前(英文城市/公司名不再被 \S+ 截断);补问示例与标签同行只删冒号后示例;陆运原话用同义词表兜底通关口岸/运输类型/线路类别,海运按表补贸易条款;客户名称纳入截断集合。 - field_validate / land_options / sea_options / tms_air_query:地名地址片段保护、补问改车型可覆盖旧值、陆运枚举先用表归一、海运 CY-CY/D2P 识别、机场码先查表(PKG/PEN→KUL)。 - 协同群:报价待确认时先记处理人(不同产品不因空 facts 的幂等键被吞),空运/海运/多段共用 remember_quote_actor。 - Java:TMS 无价把原因原文追加到「状态流转与备注」(同因不重复、不改六态);绑定/激活群的时间线备注改中文,不再写 chatid。 - 后台:需求格与列表改展示「业务类型 / 报价场景」,旧单按运输类型+线路类别反查,错配退回运输类型;时间线过滤企微 chatid;补单测。 - migration_inq_synonym_v1.sql 与 tools/gen_inq_synonym_seed.py 同步扩批。
173 lines
6.1 KiB
TypeScript
173 lines
6.1 KiB
TypeScript
/**
|
||
* 工单需求字段展示单测:海运拼柜隐藏箱型箱量(产品口径 2026-11-22)。
|
||
* 拼柜按体积计费,承运人不指定箱型,所以格子、列表第二行、多段详情都不出现箱型。
|
||
*/
|
||
import { buildDemandFields, isSeaLcl, quantitySummary, multiSegmentViews } from '/@/views/inquiry/workOrder/demandFields';
|
||
|
||
function labelsOf(fields: { label: string }[]): string[] {
|
||
return fields.map((f) => f.label);
|
||
}
|
||
|
||
test('isSeaLcl 识别拼柜口语,否定说法按整柜', () => {
|
||
['拼柜', '拼箱', '散货', 'LCL', 'lcl 拼箱'].forEach((v) => expect(isSeaLcl(v)).toBe(true));
|
||
['整柜', '非拼柜', '不拼柜', '', null, undefined, 'FCL'].forEach((v) =>
|
||
expect(isSeaLcl(v as string)).toBe(false),
|
||
);
|
||
});
|
||
|
||
test('海运拼柜:需求格子不列箱型箱量', () => {
|
||
const ticket = {
|
||
businessLine: 'SEA',
|
||
origin: '上海',
|
||
destination: '洛杉矶',
|
||
goodsName: '普货',
|
||
factsJson: JSON.stringify({
|
||
起运港: '上海',
|
||
目的港: '洛杉矶',
|
||
品名: '普货',
|
||
货量: '20吨',
|
||
整柜或拼柜: '拼柜',
|
||
箱型箱量: '1x40HQ',
|
||
贸易条款: '门到门',
|
||
}),
|
||
};
|
||
const labels = labelsOf(buildDemandFields(ticket));
|
||
expect(labels).toContain('整柜或拼柜');
|
||
expect(labels).not.toContain('箱型箱量');
|
||
});
|
||
|
||
test('海运整柜:需求格子保留箱型箱量', () => {
|
||
const ticket = {
|
||
businessLine: 'SEA',
|
||
factsJson: JSON.stringify({
|
||
起运港: '上海',
|
||
目的港: '洛杉矶',
|
||
品名: '普货',
|
||
货量: '20吨',
|
||
整柜或拼柜: '整柜',
|
||
箱型箱量: '1x40HQ',
|
||
贸易条款: '门到门',
|
||
}),
|
||
};
|
||
const fields = buildDemandFields(ticket);
|
||
expect(labelsOf(fields)).toContain('箱型箱量');
|
||
expect(fields.find((f) => f.label === '箱型箱量')?.value).toBe('1x40HQ');
|
||
});
|
||
|
||
test('海运拼柜:列表第二行不写箱型', () => {
|
||
const ticket = {
|
||
businessLine: 'SEA',
|
||
factsJson: JSON.stringify({
|
||
货量: '20吨',
|
||
整柜或拼柜: '拼柜',
|
||
箱型箱量: '1x40HQ',
|
||
}),
|
||
};
|
||
const summary = quantitySummary(ticket);
|
||
expect(summary).toContain('整柜或拼柜 拼柜');
|
||
expect(summary).not.toContain('箱型箱量');
|
||
});
|
||
|
||
test('多段里海运段是拼柜时不显示箱型', () => {
|
||
const ticket = {
|
||
businessLine: 'MULTI',
|
||
factsJson: JSON.stringify({
|
||
segments_json: JSON.stringify([
|
||
{
|
||
mode: 'SEA',
|
||
facts: { 起运港: '上海', 目的港: '洛杉矶', 整柜或拼柜: '拼柜', 箱型箱量: '1x40HQ' },
|
||
},
|
||
]),
|
||
}),
|
||
};
|
||
const views = multiSegmentViews(ticket);
|
||
expect(views.length).toBeGreaterThan(0);
|
||
expect(views[0].detailLine).not.toContain('1x40HQ');
|
||
expect(views[0].detailLine).toContain('拼柜');
|
||
});
|
||
|
||
test('陆运需求格子展示业务类型与报价场景,不再列运输类型/线路类别/运输分类', () => {
|
||
const ticket = {
|
||
businessLine: 'LAND',
|
||
factsJson: JSON.stringify({
|
||
运输类型: '中港整车',
|
||
线路类别: '中港/中亚/中欧',
|
||
运输分类: '普件(常用线路)',
|
||
起运港: '广州',
|
||
目的港: '香港',
|
||
品名: '衣服',
|
||
'车型/数量': '9米6/1',
|
||
}),
|
||
};
|
||
const fields = buildDemandFields(ticket);
|
||
const labels = labelsOf(fields);
|
||
expect(labels).toContain('业务类型');
|
||
expect(labels).toContain('报价场景');
|
||
expect(labels).not.toContain('运输类型');
|
||
expect(labels).not.toContain('线路类别');
|
||
expect(labels).not.toContain('运输分类');
|
||
expect(fields.find((f) => f.label === '业务类型')?.value).toBe('中港/亚/欧整车');
|
||
expect(fields.find((f) => f.label === '报价场景')?.value).toBe('普件(常用线路)');
|
||
});
|
||
|
||
test('陆运业务类型优先取会话事实,旧单按类型+线路反查,错配退回运输类型', () => {
|
||
const withBiz = buildDemandFields({
|
||
businessLine: 'LAND',
|
||
factsJson: JSON.stringify({ 陆运业务类型: '东南亚拼车', 运输类型: '跨境集拼', 线路类别: '东南亚' }),
|
||
});
|
||
expect(withBiz.find((f) => f.label === '业务类型')?.value).toBe('东南亚拼车');
|
||
|
||
const legacy = buildDemandFields({
|
||
businessLine: 'LAND',
|
||
factsJson: JSON.stringify({ 运输类型: '国内运输拼车', 线路类别: '国内长途/零担' }),
|
||
});
|
||
expect(legacy.find((f) => f.label === '业务类型')?.value).toBe('国内拼车');
|
||
|
||
// 历史错配单(中港整车 + 国内线路)对不上 7 项:退回运输类型,不让格子空白。
|
||
const mismatch = buildDemandFields({
|
||
businessLine: 'LAND',
|
||
factsJson: JSON.stringify({ 运输类型: '中港整车', 线路类别: '国内长途/零担' }),
|
||
});
|
||
expect(mismatch.find((f) => f.label === '业务类型')?.value).toBe('中港整车');
|
||
});
|
||
|
||
test('陆运列表第二行同样写业务类型', () => {
|
||
const summary = quantitySummary({
|
||
businessLine: 'LAND',
|
||
factsJson: JSON.stringify({
|
||
运输类型: '国内运输整车',
|
||
线路类别: '国内长途/零担',
|
||
'车型/数量': '9米6/1',
|
||
}),
|
||
});
|
||
expect(summary).toContain('业务类型 国内整车');
|
||
expect(summary).not.toContain('运输类型');
|
||
});
|
||
|
||
test('中港集拼:需求格子看体积毛重,不看车型/数量', () => {
|
||
const ticket = {
|
||
businessLine: 'LAND',
|
||
factsJson: JSON.stringify({
|
||
运输类型: '中港零担/集拼',
|
||
线路类别: '中港/中亚/中欧',
|
||
运输分类: '普件(东南亚、中港常用线路/常规车型)',
|
||
起运港: '广州',
|
||
目的港: '香港',
|
||
品名: '衣服',
|
||
体积: '20CBM',
|
||
毛重: '3000KG',
|
||
}),
|
||
};
|
||
const fields = buildDemandFields(ticket);
|
||
const labels = labelsOf(fields);
|
||
expect(labels).toContain('体积(CBM)');
|
||
expect(labels).toContain('重量(KG)');
|
||
expect(labels).not.toContain('车型/数量');
|
||
expect(fields.find((f) => f.label === '体积(CBM)')?.value).toBe('20CBM');
|
||
expect(fields.find((f) => f.label === '重量(KG)')?.value).toBe('3000KG');
|
||
const summary = quantitySummary(ticket);
|
||
expect(summary).toContain('体积(CBM) 20CBM');
|
||
expect(summary).toContain('重量(KG) 3000KG');
|
||
expect(summary).not.toContain('车型/数量');
|
||
});
|