Merge branch 'main' into multi-tenant

This commit is contained in:
2024-10-31 17:50:10 +08:00
229 changed files with 11395 additions and 11870 deletions

View File

@@ -22,22 +22,19 @@ import (
)
// 实例化控制层 SMFController 结构体
var NewSMFController = &SMFController{
neInfoService: neService.NewNeInfoImpl,
cdrEventService: neDataService.NewCDREventSMFImpl,
udmUserInfoService: *neDataService.NewUDMUserInfo,
var NewSMF = &SMFController{
neInfoService: neService.NewNeInfo,
cdrEventService: neDataService.NewCDREventSMF,
udmUserInfoService: neDataService.NewUDMUserInfo,
}
// 网元SMF
//
// PATH /smf
type SMFController struct {
// 网元信息服务
neInfoService neService.INeInfo
// CDR会话事件服务
cdrEventService neDataService.ICDREventSMF
// UDM用户信息服务
udmUserInfoService neDataService.UDMUserInfo
neInfoService *neService.NeInfo // 网元信息服务
cdrEventService *neDataService.CDREventSMF // CDR会话事件服务
udmUserInfoService *neDataService.UDMUserInfo // UDM用户信息服务
}
// CDR会话列表
@@ -131,18 +128,31 @@ func (s *SMFController) CDRExport(c *gin.Context) {
headerCells := map[string]string{
"A1": "ID",
"B1": "Charging ID",
"C1": "Subscriber ID Data",
"D1": "Subscriber ID Type",
"E1": "Data Volume Uplink",
"F1": "Data Volume Downlink",
"G1": "Data Total Volume",
"H1": "Duration",
"I1": "Invocation Time",
"J1": "PDU Session Charging Information",
"K1": "Tenant Name", // for multi-tenancy
"C1": "NE Name",
"D1": "Resource Unique ID",
"E1": "Subscriber ID Data",
"F1": "Subscriber ID Type",
"G1": "Data Volume Uplink",
"H1": "Data Volume Downlink",
"I1": "Data Total Volume",
"J1": "Duration",
"K1": "Invocation Time",
"L1": "User Identifier",
"M1": "SSC Mode",
"N1": "DNN ID",
"O1": "PDU Type",
"P1": "RAT Type",
"Q1": "PDU IPv4 Address",
"R1": "Network Function IPv4",
"S1": "PDU IPv6 Address Swith Prefix",
"T1": "Record Network Function ID",
"U1": "Record Type",
"V1": "Record Opening Time",
"W1": "Tenant Name", // for multi-tenancy
}
// 从第二行开始的数据
dataCells := make([]map[string]any, 0)
for i, row := range rows {
idx := strconv.Itoa(i + 2)
// 解析 JSON 字符串为 map
@@ -167,12 +177,22 @@ func (s *SMFController) CDRExport(c *gin.Context) {
subscriptionIDData = sub["subscriptionIDData"].(string)
}
}
// 网络功能 IPv4 地址
networkFunctionIPv4Address := ""
if v, ok := cdrJSON["nFunctionConsumerInformation"]; ok && v != nil {
if conInfo, conInfoOk := v.(map[string]any); conInfoOk && conInfo != nil {
networkFunctionIPv4Address = conInfo["networkFunctionIPv4Address"].(string)
}
}
// 数据量上行链路
dataVolumeUplink := []string{}
// 数据量下行链路
dataVolumeDownlink := []string{}
// 数据总量
dataTotalVolume := []string{}
if v, ok := cdrJSON["listOfMultipleUnitUsage"]; ok && v != nil {
usageList := v.([]any)
if len(usageList) > 0 {
@@ -207,32 +227,31 @@ func (s *SMFController) CDRExport(c *gin.Context) {
invocationTimestamp = v.(string)
}
// 记录打开时间
pduSessionChargingInformation := ""
User_Identifier := ""
SSC_Mode := ""
RAT_Type := ""
DNN_ID := ""
PDU_Type := ""
PDU_IPv4 := ""
PDU_IPv6 := ""
if v, ok := cdrJSON["pDUSessionChargingInformation"]; ok && v != nil {
pduInfo := v.(map[string]any)
User_Identifier := ""
if v, ok := pduInfo["userIdentifier"]; ok && v != nil {
User_Identifier = v.(string)
}
SSC_Mode := ""
if v, ok := pduInfo["sSCMode"]; ok && v != nil {
SSC_Mode = v.(string)
}
RAT_Type := ""
if v, ok := pduInfo["rATType"]; ok && v != nil {
RAT_Type = v.(string)
}
DNN_ID := ""
if v, ok := pduInfo["dNNID"]; ok && v != nil {
DNN_ID = v.(string)
}
PDU_Type := ""
if v, ok := pduInfo["pDUType"]; ok && v != nil {
PDU_Type = v.(string)
}
PDU_IPv4 := ""
PDU_IPv6 := ""
if v, ok := pduInfo["pDUAddress"]; ok && v != nil {
pDUAddress := v.(map[string]any)
if addr, ok := pDUAddress["pDUIPv4Address"]; ok && addr != nil {
@@ -243,11 +262,29 @@ func (s *SMFController) CDRExport(c *gin.Context) {
}
}
pduSessionChargingInformation = fmt.Sprintf(`User Identifier: %s
SSC Mode: %s RAT Type: %s DNN ID: %s
PDU Type: %s
PDU IPv4 Address: %s
PDU IPv6 Addres Swith Prefix: %s`, User_Identifier, SSC_Mode, RAT_Type, DNN_ID, PDU_Type, PDU_IPv4, PDU_IPv6)
// pduSessionChargingInformation = fmt.Sprintf(`User Identifier: %s
// SSC Mode: %s RAT Type: %s DNN ID: %s
// PDU Type: %s
// PDU IPv4 Address: %s
// PDU IPv6 Addres Swith Prefix: %s`, User_Identifier, SSC_Mode, RAT_Type, DNN_ID, PDU_Type, PDU_IPv4, PDU_IPv6)
}
// 记录网络参数ID
recordNFID := ""
if v, ok := cdrJSON["recordingNetworkFunctionID"]; ok && v != nil {
recordNFID = v.(string)
}
//记录开始时间
recordOpeningTime := ""
if v, ok := cdrJSON["recordOpeningTime"]; ok && v != nil {
recordOpeningTime = v.(string)
}
//记录类型
recordType := ""
if v, ok := cdrJSON["recordType"]; ok && v != nil {
recordType = v.(string)
}
// for multi-tenant, get tenant name
tenantName := row.TenantName
@@ -255,15 +292,27 @@ PDU IPv6 Addres Swith Prefix: %s`, User_Identifier, SSC_Mode, RAT_Type, DNN_ID,
dataCells = append(dataCells, map[string]any{
"A" + idx: row.ID,
"B" + idx: chargingID,
"C" + idx: subscriptionIDData,
"D" + idx: subscriptionIDType,
"E" + idx: strings.Join(dataVolumeUplink, ","),
"F" + idx: strings.Join(dataVolumeDownlink, ","),
"G" + idx: strings.Join(dataTotalVolume, ","),
"H" + idx: duration,
"I" + idx: invocationTimestamp,
"J" + idx: pduSessionChargingInformation,
"K" + idx: tenantName,
"C" + idx: row.NeName,
"D" + idx: row.RmUID,
"E" + idx: subscriptionIDData,
"F" + idx: subscriptionIDType,
"G" + idx: strings.Join(dataVolumeUplink, ","),
"H" + idx: strings.Join(dataVolumeDownlink, ","),
"I" + idx: strings.Join(dataTotalVolume, ","),
"J" + idx: duration,
"K" + idx: invocationTimestamp,
"L" + idx: User_Identifier,
"M" + idx: SSC_Mode,
"N" + idx: DNN_ID,
"O" + idx: PDU_Type,
"P" + idx: RAT_Type,
"Q" + idx: PDU_IPv4,
"R" + idx: networkFunctionIPv4Address,
"S" + idx: PDU_IPv6,
"T" + idx: recordNFID,
"U" + idx: recordType,
"V" + idx: recordOpeningTime,
"W" + idx: tenantName,
})
}