92 lines
3.2 KiB
TypeScript
92 lines
3.2 KiB
TypeScript
export type SmartLoadingChannelGroup = {
|
|||
|
|
code: string
|
||
|
|
name: string
|
||
|
|
channelCodes: readonly string[]
|
||
|
|
}
|
||
|
|
|
||
|
|
export type SmartLoadingWarehouseGroup = {
|
||
|
|
code: string
|
||
|
|
name: string
|
||
|
|
nameKeyword: string
|
||
|
|
}
|
||
|
|
|
||
|
|
export const SMART_LOADING_WAREHOUSE_GROUPS: readonly SmartLoadingWarehouseGroup[] = [
|
||
|
|
{ code: 'YIWU', name: '义乌仓', nameKeyword: '义乌' },
|
||
|
|
{ code: 'DONGGUAN', name: '东莞仓', nameKeyword: '东莞' },
|
||
|
|
] as const
|
||
|
|
|
||
|
|
export const SMART_LOADING_CHANNEL_GROUPS: readonly SmartLoadingChannelGroup[] = [
|
||
|
|
{
|
||
|
|
code: 'MATSON_CLX',
|
||
|
|
name: '美森正班',
|
||
|
|
channelCodes: ['MATSON_CLX_TRUCK', 'MATSON_CLX_PARCEL', 'ZBYHK', 'ZBYHWK', 'ZBYHP'],
|
||
|
|
},
|
||
|
|
{
|
||
|
|
code: 'MATSON_MAX',
|
||
|
|
name: '美森加班',
|
||
|
|
channelCodes: ['MATSON_MAX_TRUCK', 'MATSON_MAX_PARCEL', 'BYHK', 'BYHWK', 'BYHP'],
|
||
|
|
},
|
||
|
|
{
|
||
|
|
code: 'EXX',
|
||
|
|
name: 'EXX',
|
||
|
|
channelCodes: ['EXX_TRUCK', 'EXX_RAIL_NY', 'EXXHK', 'EXXHWK', 'NYEXX'],
|
||
|
|
},
|
||
|
|
{
|
||
|
|
code: 'HEDE',
|
||
|
|
name: '合德',
|
||
|
|
channelCodes: ['HEDE_TRUCK', 'HEDE_PARCEL', 'HDHK', 'HDHWK', 'HDHP'],
|
||
|
|
},
|
||
|
|
{
|
||
|
|
code: 'OA_LA',
|
||
|
|
name: '洛杉矶普船',
|
||
|
|
channelCodes: ['OA_LA_TRUCK', 'OA_LA_FULL_TRUCK', 'OA_PARCEL', 'PCHK', 'PCHWK', 'PCKK', 'PCHP'],
|
||
|
|
},
|
||
|
|
{
|
||
|
|
code: 'OA_CHICAGO',
|
||
|
|
name: '芝加哥普船',
|
||
|
|
channelCodes: ['OA_CHICAGO_RAIL', 'CPHT'],
|
||
|
|
},
|
||
|
|
{
|
||
|
|
code: 'OA_HOUSTON',
|
||
|
|
name: '休斯顿普船',
|
||
|
|
channelCodes: ['OA_HOUSTON_TRUCK', 'HPHK'],
|
||
|
|
},
|
||
|
|
{
|
||
|
|
code: 'OA_SAVANNAH',
|
||
|
|
name: '萨凡纳普船',
|
||
|
|
channelCodes: ['OA_SAVANNAH_TRUCK', 'SPHK'],
|
||
|
|
},
|
||
|
|
{
|
||
|
|
code: 'OA_NEW_YORK_TRUCK',
|
||
|
|
name: '纽约普船海卡',
|
||
|
|
channelCodes: ['OA_NEW_YORK_TRUCK', 'NPHK', 'NPHWK'],
|
||
|
|
},
|
||
|
|
] as const
|
||
|
|
|
||
|
|
export function resolveSmartLoadingChannelGroup(channelCode?: string | null, channelName?: string | null) {
|
||
|
|
const normalizedCode = String(channelCode || '').trim().toUpperCase()
|
||
|
|
if (normalizedCode) {
|
||
|
|
const codeMatch = SMART_LOADING_CHANNEL_GROUPS.find((group) => group.channelCodes.includes(normalizedCode))
|
||
|
|
if (codeMatch) return codeMatch
|
||
|
|
}
|
||
|
|
|
||
|
|
const normalizedName = String(channelName || '').replace(/\s+/g, '')
|
||
|
|
if (!normalizedName) return null
|
||
|
|
if (normalizedName.includes('美森正班')) return SMART_LOADING_CHANNEL_GROUPS[0]
|
||
|
|
if (normalizedName.includes('美森加班')) return SMART_LOADING_CHANNEL_GROUPS[1]
|
||
|
|
if (normalizedName.toUpperCase().includes('EXX')) return SMART_LOADING_CHANNEL_GROUPS[2]
|
||
|
|
if (normalizedName.includes('合德')) return SMART_LOADING_CHANNEL_GROUPS[3]
|
||
|
|
if (normalizedName.includes('洛杉矶普船') || normalizedName === '普船海派') return SMART_LOADING_CHANNEL_GROUPS[4]
|
||
|
|
if (normalizedName.includes('芝加哥普船')) return SMART_LOADING_CHANNEL_GROUPS[5]
|
||
|
|
if (normalizedName.includes('休斯顿普船')) return SMART_LOADING_CHANNEL_GROUPS[6]
|
||
|
|
if (normalizedName.includes('萨凡纳普船')) return SMART_LOADING_CHANNEL_GROUPS[7]
|
||
|
|
if (normalizedName.includes('纽约普船')) return SMART_LOADING_CHANNEL_GROUPS[8]
|
||
|
|
return null
|
||
|
|
}
|
||
|
|
|
||
|
|
export function resolveSmartLoadingWarehouseGroup(warehouseName?: string | null) {
|
||
|
|
const normalizedName = String(warehouseName || '').replace(/\s+/g, '')
|
||
|
|
if (!normalizedName) return null
|
||
|
|
return SMART_LOADING_WAREHOUSE_GROUPS.find((group) => normalizedName.includes(group.nameKeyword)) || null
|
||
|
|
}
|