feat(P19ERP3-1,P19ERP3-2): 实现资产ERP摘要服务与建卡/流转出站联动

这个提交包含在:
2026-03-09 11:15:21 +08:00
父节点 7613d7d912
当前提交 0168ebfe2e
共修改 10 个文件,包含 1128 行新增和 4 行删除
+57
查看文件
@@ -41,6 +41,13 @@ function resolveProcurementExportEndpoint(config) {
);
}
function resolveAssetExportEndpoint(config) {
return (
String(config.erpAssetExportEndpoint ?? '').trim() ||
String(config.erpSyncEndpoint ?? '').trim()
);
}
async function parseResponseBody(response) {
const contentType = response.headers.get('content-type') || '';
if (contentType.includes('application/json')) {
@@ -236,6 +243,55 @@ async function exportJournalToErp(config, payload) {
};
}
async function exportAssetToErp(config, payload) {
if (!config.erpSyncEnabled) {
return {
ok: false,
code: 'erp_sync_disabled',
message: 'ERP sync disabled',
retryable: false,
};
}
const provider = normalizeProvider(config);
if (provider === 'mock') {
const identity = payload?.assetNo ?? payload?.entityId ?? 'UNKNOWN';
return {
ok: true,
code: 'mock_synced',
message: 'mock ERP asset synced',
response: {
externalAssetId: `ERP-ASSET-${identity}`,
externalAssetNo: `ERP-ASSET-${identity}`,
},
};
}
if (provider === 'http') {
return postJsonToErp(config, {
endpoint: resolveAssetExportEndpoint(config),
timeoutMs: coerceTimeout(config.erpAssetTimeoutMs, config.erpSyncTimeoutMs),
payload,
successCode: 'http_synced',
successMessage: 'ERP asset synced',
missingEndpointCode: 'erp_asset_endpoint_missing',
missingEndpointMessage: 'ERP asset endpoint missing',
http4xxCode: 'erp_asset_http_4xx',
http5xxCode: 'erp_asset_http_5xx',
timeoutCode: 'erp_asset_timeout',
networkCode: 'erp_asset_network_error',
messagePrefix: 'ERP asset sync',
});
}
return {
ok: false,
code: 'erp_sync_provider_invalid',
message: `Unsupported ERP sync provider: ${provider}`,
retryable: false,
};
}
async function exportProcurementToErp(config, payload) {
if (!config.erpSyncEnabled) {
return {
@@ -299,6 +355,7 @@ async function pushPaidReimbursementToErp(config, payload) {
module.exports = {
buildErpPayload,
exportAssetToErp,
exportJournalToErp,
exportProcurementToErp,
normalizeProvider,