优化
This commit is contained in:
@@ -6,12 +6,19 @@ import { pathToFileURL } from 'node:url'
|
||||
import process from 'node:process'
|
||||
|
||||
const CONFIGURED_MODULES = ['merchant-qualification-fixture', 'customers', 'overseas-storage-fees', 'system', 'notifications', 'master-data', 'suppliers', 'domestic-container', 'orders', 'fee-items', 'pricing', 'downloads', 'inbound-weight-ocr', 'inbound-measurement', 'inbound-fees', 'phase3-container-loading', 'phase3-container-overview', 'phase3-loading', 'phase3-loading-model-bridge', 'phase3-pda-convergence', 'phase3-evidence-gate', 'supplemental', 'supplemental-boundaries', 'ocean-bookings', 'truck-appointments', 'service-center-flow', 'phase3-loading-finalize', 'phase3-container-documents', 'phase3-customs', 'phase3-port-schedules', 'phase3-carrier-schedule-queries', 'phase3-outbound-dispatch', 'phase3-outbound-aggregate', 'phase3-dispatch-gate', 'phase3-waiting-for-loading', 'phase3-warehouse-rbac', 'phase3-order-splitting', 'manual-state-matrix', 'phase4-overseas-warehouse', 'phase4-carrier-pickup-ready', 'phase4-overseas-pda', 'phase4-overseas-pda-operations', 'phase4-overseas-inbound-operations', 'phase4-overseas-client-services', 'phase4-overseas-dispatch', 'phase4-cross-region-events', 'phase4-overseas-business', 'phase4-overseas-master-data', 'phase4-carrier-nodes', 'finance', 'finance-full-fixtures', 'finance-reconciliation-full', 'finance-settlement-full', 'finance-downloads', 'customer-operating-statistics']
|
||||
const OPTIONAL_MODULES = ['manual-order-splitting-fixture', 'manual-order-splitting-verify',
|
||||
'manual-preload-push-fixture', 'manual-preload-push-verify',
|
||||
'manual-pda-ready-fixture', 'manual-pda-ready-verify',
|
||||
'manual-pda-batch-fixture', 'manual-pda-batch-verify',
|
||||
'manual-loading-complete-fixture', 'manual-loading-complete-verify']
|
||||
const AVAILABLE_MODULES = new Set([...CONFIGURED_MODULES, ...OPTIONAL_MODULES])
|
||||
|
||||
const MODULE_DEPENDENCIES = new Map([
|
||||
['suppliers', ['merchant-qualification-fixture']],
|
||||
['supplemental', ['merchant-qualification-fixture']],
|
||||
['orders', ['merchant-qualification-fixture']],
|
||||
['inbound-measurement', ['orders']],
|
||||
['manual-order-splitting-fixture', ['inbound-measurement']],
|
||||
['phase3-container-loading', ['inbound-measurement']],
|
||||
['phase3-loading', ['phase3-container-loading']],
|
||||
['phase3-container-overview', ['phase3-loading']],
|
||||
@@ -243,6 +250,12 @@ function usage() {
|
||||
--channel-code <code> 固定物流渠道编码
|
||||
--order-profile-mode <mode> 订单档案模式:fixed 或 randomized,默认fixed
|
||||
--wait-split-count <n> 同一客户创建的 WAIT_SPLIT 订单数,1-100,默认1
|
||||
--manual-split-fixture-report <path> 人工分柜准备报告路径,仅只读核验模块使用
|
||||
--manual-split-plan-id <id> 人工操作产生的智能装柜计划 ID,仅只读核验模块使用
|
||||
--manual-preload-source-report <path> 人工推送预装前置或核验来源报告路径
|
||||
--manual-pda-source-report <path> 人工订舱关联、预装确认前置或核验来源报告路径
|
||||
--manual-pda-batch-source-report <path> PDA 人工领取、扫码批量提交前置或核验来源报告路径
|
||||
--manual-loading-complete-source-report <path> 五类证据与 PDA 最终完成前置或核验来源报告路径
|
||||
--output <path> JSON 报告路径,默认 reports/
|
||||
--help 显示帮助
|
||||
|
||||
@@ -267,9 +280,9 @@ export function parseArguments(argv) {
|
||||
values.set(name, next); index += 1
|
||||
}
|
||||
}
|
||||
const modules = normalizeModuleOrder((values.get('modules') || DEFAULT_MODULES.join(',')).split(',').map((v) => v.trim()).filter(Boolean))
|
||||
const merchantUsername = values.get('merchant-username') || process.env.MERCHANT_TEST_USERNAME || ''
|
||||
const merchantPassword = values.get('merchant-password') || process.env.MERCHANT_TEST_PASSWORD || ''
|
||||
const modules = normalizeModuleOrder((values.get('modules') || DEFAULT_MODULES.join(',')).split(',').map((v) => v.trim()).filter(Boolean))
|
||||
if (merchantUsername && merchantPassword) {
|
||||
const fixtureIndex = modules.indexOf('merchant-qualification-fixture')
|
||||
if (fixtureIndex >= 0) modules.splice(fixtureIndex, 1)
|
||||
@@ -287,12 +300,21 @@ export function parseArguments(argv) {
|
||||
channelName: values.get('channel-name') || '',
|
||||
channelCode: values.get('channel-code') || '',
|
||||
orderProfileMode: values.get('order-profile-mode') || 'fixed',
|
||||
waitSplitCount: Number(values.get('wait-split-count') || process.env.ADMIN_WAIT_SPLIT_COUNT || 1),
|
||||
waitSplitCount: Number(values.get('wait-split-count') || process.env.ADMIN_WAIT_SPLIT_COUNT
|
||||
|| (modules.includes('manual-order-splitting-fixture') ? 6 : 1)),
|
||||
manualSplitFixtureReport: values.get('manual-split-fixture-report') || '',
|
||||
manualSplitPlanId: values.get('manual-split-plan-id') || '',
|
||||
manualPreloadSourceReport: values.get('manual-preload-source-report') || '',
|
||||
manualPdaSourceReport: values.get('manual-pda-source-report') || '',
|
||||
manualPdaBatchSourceReport: values.get('manual-pda-batch-source-report') || '',
|
||||
manualLoadingCompleteSourceReport: values.get('manual-loading-complete-source-report') || '',
|
||||
output: values.get('output') || '',
|
||||
}
|
||||
}
|
||||
|
||||
export function validateExecutionOptions(options) {
|
||||
const unavailable = options.modules.filter((module) => !AVAILABLE_MODULES.has(module))
|
||||
if (unavailable.length > 0) throw new Error(`未注册的 HTTP 验收模块: ${unavailable.join(',')}`)
|
||||
for (const [name, value] of [['gateway', options.gateway], ['username', options.username], ['password', options.password]]) {
|
||||
if (typeof value !== 'string' || value.trim() === '') throw new Error(`缺少必填执行参数: ${name}`)
|
||||
}
|
||||
@@ -321,9 +343,39 @@ export function validateExecutionOptions(options) {
|
||||
throw new Error('randomized订单档案必须同时固定起运仓、渠道名称和渠道编码')
|
||||
}
|
||||
if (options.waitSplitCount > 1) {
|
||||
const fixtureModules = new Set(['merchant-qualification-fixture', 'orders', 'inbound-measurement'])
|
||||
const fixtureModules = new Set(['merchant-qualification-fixture', 'orders', 'inbound-measurement',
|
||||
'manual-order-splitting-fixture'])
|
||||
if (options.modules.some((module) => !fixtureModules.has(module))) {
|
||||
throw new Error('批量WAIT_SPLIT只允许执行merchant-qualification-fixture、orders、inbound-measurement')
|
||||
throw new Error('批量WAIT_SPLIT只允许执行merchant-qualification-fixture、orders、inbound-measurement、manual-order-splitting-fixture')
|
||||
}
|
||||
}
|
||||
if (options.modules.includes('manual-order-splitting-fixture') && options.waitSplitCount < 4) {
|
||||
throw new Error('manual-order-splitting-fixture要求wait-split-count至少为4')
|
||||
}
|
||||
if (options.modules.includes('manual-order-splitting-verify')) {
|
||||
if (!options.manualSplitFixtureReport) throw new Error('manual-order-splitting-verify缺少manual-split-fixture-report')
|
||||
if (!/^[1-9][0-9]*$/.test(String(options.manualSplitPlanId))) {
|
||||
throw new Error('manual-order-splitting-verify要求manual-split-plan-id为正整数')
|
||||
}
|
||||
}
|
||||
for (const module of ['manual-preload-push-fixture', 'manual-preload-push-verify']) {
|
||||
if (options.modules.includes(module) && !options.manualPreloadSourceReport) {
|
||||
throw new Error(`${module}缺少manual-preload-source-report`)
|
||||
}
|
||||
}
|
||||
for (const module of ['manual-pda-ready-fixture', 'manual-pda-ready-verify']) {
|
||||
if (options.modules.includes(module) && !options.manualPdaSourceReport) {
|
||||
throw new Error(`${module}缺少manual-pda-source-report`)
|
||||
}
|
||||
}
|
||||
for (const module of ['manual-pda-batch-fixture', 'manual-pda-batch-verify']) {
|
||||
if (options.modules.includes(module) && !options.manualPdaBatchSourceReport) {
|
||||
throw new Error(`${module}缺少manual-pda-batch-source-report`)
|
||||
}
|
||||
}
|
||||
for (const module of ['manual-loading-complete-fixture', 'manual-loading-complete-verify']) {
|
||||
if (options.modules.includes(module) && !options.manualLoadingCompleteSourceReport) {
|
||||
throw new Error(`${module}缺少manual-loading-complete-source-report`)
|
||||
}
|
||||
}
|
||||
return options
|
||||
|
||||
Reference in New Issue
Block a user