fix: 网元PLMN新增修改使用最后记录信息

This commit is contained in:
TsMask
2025-06-27 15:46:12 +08:00
parent a54de8a9bb
commit b9bcd4c265

View File

@@ -215,14 +215,14 @@ const supportMapper = {
name: 'guami', name: 'guami',
display: 'GUAMI List', display: 'GUAMI List',
key: ['plmnId'], key: ['plmnId'],
item: (index, param) => { item: (index, param, lastItem) => {
const plmn = `${param.plmnId.mcc}${param.plmnId.mnc}`; const plmn = `${param.plmnId.mcc}${param.plmnId.mnc}`;
return { return {
index: index, index: index,
plmnId: plmn, plmnId: plmn,
pointer: 1, pointer: lastItem.pointer,
regionId: 1, regionId: lastItem.regionId,
setId: 1, setId: lastItem.setId,
}; };
}, },
}, },
@@ -231,7 +231,7 @@ const supportMapper = {
name: 'tai', name: 'tai',
display: 'TAI List', display: 'TAI List',
key: ['plmnId'], key: ['plmnId'],
item: (index, param) => { item: (index, param, lastItem) => {
const plmn = `${param.plmnId.mcc}${param.plmnId.mnc}`; const plmn = `${param.plmnId.mcc}${param.plmnId.mnc}`;
return { return {
index: index, index: index,
@@ -245,12 +245,12 @@ const supportMapper = {
name: 'slice', name: 'slice',
display: 'Slice List', display: 'Slice List',
key: ['plmnId'], key: ['plmnId'],
item: (index, param) => { item: (index, param, lastItem) => {
const plmn = `${param.plmnId.mcc}${param.plmnId.mnc}`; const plmn = `${param.plmnId.mcc}${param.plmnId.mnc}`;
return { return {
index: index, index: index,
plmnId: plmn, plmnId: plmn,
sd: param.snssai.sd, sd: parseInt(param.snssai.sd),
sst: param.snssai.sst, sst: param.snssai.sst,
}; };
}, },
@@ -262,9 +262,10 @@ const supportMapper = {
name: 'plmn', name: 'plmn',
display: 'PLMN List', display: 'PLMN List',
key: ['mcc', 'mnc'], key: ['mcc', 'mnc'],
item: (index, param) => { item: (index, param, lastItem) => {
const plmn = `${param.plmnId.mcc}${param.plmnId.mnc}`; const plmn = `${param.plmnId.mcc}${param.plmnId.mnc}`;
const domain = `ims.mnc${param.plmnId.mnc}.mcc${param.plmnId.mcc}.3gppnetwork.org`; const mccDomain = param.plmnId.mcc.padStart(3, '0');
const domain = `ims.mnc${param.plmnId.mnc}.mcc${mccDomain}.3gppnetwork.org`;
return { return {
index: index, index: index,
domain: domain, domain: domain,
@@ -293,14 +294,12 @@ const supportMapper = {
name: 'gummei', name: 'gummei',
display: 'Gummei List', display: 'Gummei List',
key: ['plmnId'], key: ['plmnId'],
item: (index, param) => { item: (index, param, lastItem) => {
const plmn = `${param.plmnId.mcc}${param.plmnId.mnc}`; const plmn = `${param.plmnId.mcc}${param.plmnId.mnc}`;
return { return Object.assign(lastItem, {
index: index, index: index,
plmnId: plmn, plmnId: plmn,
groupId: 1, });
code: 1,
};
}, },
}, },
{ {
@@ -308,7 +307,7 @@ const supportMapper = {
name: 'tai', name: 'tai',
display: 'TAI List', display: 'TAI List',
key: ['plmnId'], key: ['plmnId'],
item: (index, param) => { item: (index, param, lastItem) => {
const plmn = `${param.plmnId.mcc}${param.plmnId.mnc}`; const plmn = `${param.plmnId.mcc}${param.plmnId.mnc}`;
return { return {
index: index, index: index,
@@ -322,16 +321,12 @@ const supportMapper = {
name: 'hss', name: 'hss',
display: 'HSS List', display: 'HSS List',
key: ['imsiPre'], key: ['imsiPre'],
item: (index, param) => { item: (index, param, lastItem) => {
const plmn = `${param.plmnId.mcc}${param.plmnId.mnc}`; const plmn = `${param.plmnId.mcc}${param.plmnId.mnc}`;
const Hostname = `hss.ims.mnc${param.plmnId.mnc}.mcc${param.plmnId.mcc}.3gppnetwork.org`; return Object.assign(lastItem, {
return {
index: index, index: index,
hssHostname: Hostname,
hssPort: 3868,
imsiPre: plmn, imsiPre: plmn,
protocol: 'SCTP', });
};
}, },
}, },
{ {
@@ -339,14 +334,13 @@ const supportMapper = {
name: 'sgw', name: 'sgw',
display: 'SGW List', display: 'SGW List',
key: ['plmnId'], key: ['plmnId'],
item: (index, param) => { item: (index, param, lastItem) => {
const plmn = `${param.plmnId.mcc}${param.plmnId.mnc}`; const plmn = `${param.plmnId.mcc}${param.plmnId.mnc}`;
return { return Object.assign(lastItem, {
index: index, index: index,
plmnId: plmn, plmnId: plmn,
sgwIp: '172.16.5.150', tac: parseInt(param.tac),
tac: param.tac, });
};
}, },
}, },
], ],
@@ -441,7 +435,7 @@ async function toConfig(
continue; continue;
} }
const index = item.index; const index = item.index;
const updateItem = rule.item(index, param); const updateItem = rule.item(index, param, item);
// console.log('存在修改', rule.name, index, updateItem); // console.log('存在修改', rule.name, index, updateItem);
const resList = await editNeConfigData({ const resList = await editNeConfigData({
neType: ntType, neType: ntType,
@@ -454,14 +448,12 @@ async function toConfig(
resList.code != RESULT_CODE_SUCCESS ? 'failed' : 'success'; resList.code != RESULT_CODE_SUCCESS ? 'failed' : 'success';
errMsgArr.push(`${ntType}_${neId} ${rule.display} modify ${state}`); errMsgArr.push(`${ntType}_${neId} ${rule.display} modify ${state}`);
} else { } else {
const item = res.data.sort((a, b) => b.index - a.index); let lastIndex = 0;
if (!item) { const arr = res.data.sort((a, b) => b.index - a.index);
// console.log('没有找到', rule.name, index); if (arr.length != 0) {
errMsgArr.push(`${ntType}_${neId} ${rule.display} not found`); lastIndex = arr[0].index + 1;
continue;
} }
const lastIndex = item[0].index + 1; const addItem = rule.item(lastIndex, param, arr[0]);
const addItem = rule.item(lastIndex, param);
// console.log('不存在新增', rule.name, lastIndex, addItem); // console.log('不存在新增', rule.name, lastIndex, addItem);
const resList = await addNeConfigData({ const resList = await addNeConfigData({
neType: ntType, neType: ntType,