fix: close phase4 overseas acceptance gaps

This commit is contained in:
2026-08-24 21:00:22 +08:00
parent 005c3f54e2
commit 3607bebbfd
42 changed files with 860 additions and 203 deletions
+51 -7
View File
@@ -7,6 +7,49 @@ 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-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-overseas-pda', '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 MODULE_DEPENDENCIES = new Map([
['orders', ['merchant-qualification-fixture']],
['inbound-measurement', ['orders']],
['phase3-container-loading', ['inbound-measurement']],
['phase3-loading', ['phase3-container-loading']],
['phase3-container-overview', ['phase3-loading']],
['phase3-loading-model-bridge', ['phase3-loading']],
['phase3-pda-convergence', ['phase3-loading']],
['phase3-evidence-gate', ['phase3-pda-convergence']],
['ocean-bookings', ['phase3-loading']],
['truck-appointments', ['merchant-qualification-fixture']],
['service-center-flow', ['ocean-bookings', 'truck-appointments']],
['phase3-loading-finalize', ['phase3-loading', 'phase3-evidence-gate']],
['phase3-customs', ['phase3-loading-finalize']],
['phase3-port-schedules', ['ocean-bookings']],
['phase3-outbound-dispatch', ['phase3-customs']],
['phase3-outbound-aggregate', ['phase3-outbound-dispatch']],
['phase3-dispatch-gate', ['phase3-outbound-dispatch']],
['phase3-waiting-for-loading', ['phase3-outbound-dispatch']],
['phase3-carrier-schedule-queries', ['phase3-outbound-dispatch']],
['phase3-order-splitting', ['phase3-loading-finalize']],
['manual-state-matrix', ['phase3-loading-finalize', 'phase3-customs', 'ocean-bookings']],
['phase4-overseas-pda', ['phase3-loading-finalize']],
['phase4-cross-region-events', ['system', 'phase3-customs', 'phase4-overseas-pda']],
['phase4-carrier-nodes', ['phase3-carrier-schedule-queries']],
])
function stableTopologicalOrder(modules) {
const selected = new Set(modules)
const pending = [...modules]
const result = []
const completed = new Set()
while (pending.length > 0) {
const readyIndex = pending.findIndex((module) => (MODULE_DEPENDENCIES.get(module) || [])
.every((dependency) => !selected.has(dependency) || completed.has(dependency)))
if (readyIndex < 0) throw new Error(`HTTP 验收模块依赖存在循环: ${pending.join(',')}`)
const [module] = pending.splice(readyIndex, 1)
result.push(module)
completed.add(module)
}
return result
}
export function normalizeModuleOrder(modules) {
const normalized = [...modules]
const manualGroups = ['order-inbound-status-fixtures', 'manual-state-loading-pda', 'manual-state-ocean-trucking']
@@ -68,9 +111,9 @@ export function normalizeModuleOrder(modules) {
const prerequisites = ['system', 'merchant-qualification-fixture', 'orders', 'inbound-measurement',
'phase3-container-loading', 'phase3-loading', 'phase3-pda-convergence', 'phase3-evidence-gate',
'phase3-loading-finalize', 'phase3-customs', 'phase4-overseas-pda']
const withoutPrerequisites = normalized.filter((module) => !prerequisites.includes(module))
withoutPrerequisites.splice(withoutPrerequisites.indexOf('phase4-cross-region-events'), 0, ...prerequisites)
normalized.splice(0, normalized.length, ...withoutPrerequisites)
const targetIndex = normalized.indexOf('phase4-cross-region-events')
const missing = prerequisites.filter((name) => !normalized.includes(name))
if (missing.length > 0) normalized.splice(targetIndex, 0, ...missing)
}
const financeChain = ['finance-full-fixtures', 'finance-reconciliation-full', 'finance-settlement-full']
const firstFinanceIndex = normalized.findIndex((name) => financeChain.includes(name))
@@ -122,10 +165,11 @@ export function normalizeModuleOrder(modules) {
}
const loadingIndex = normalized.indexOf('phase3-loading')
const overviewIndex = normalized.indexOf('phase3-container-overview')
if (loadingIndex < 0 || overviewIndex < 0 || overviewIndex > loadingIndex) return normalized
normalized.splice(overviewIndex, 1)
normalized.splice(normalized.indexOf('phase3-loading') + 1, 0, 'phase3-container-overview')
return normalized
if (loadingIndex >= 0 && overviewIndex >= 0 && overviewIndex < loadingIndex) {
normalized.splice(overviewIndex, 1)
normalized.splice(normalized.indexOf('phase3-loading') + 1, 0, 'phase3-container-overview')
}
return stableTopologicalOrder(normalized)
}
const DEFAULT_MODULES = normalizeModuleOrder(CONFIGURED_MODULES)