perf: 更新UDM签约数据表,同步数据支持MICO和RAT操作修改
This commit is contained in:
@@ -50,12 +50,29 @@ func (r *UDMSubUser) dataByRedis(imsi, neId string) []model.UDMSubUser {
|
||||
// def_ambr,def_nssai,0,def_arfb,def_sar,3,1,12000,1,1000,0,1,-
|
||||
if v, ok := m["am-dat"]; ok {
|
||||
arr := strings.Split(v, ",")
|
||||
a.Ambr = arr[0]
|
||||
a.Nssai = arr[1]
|
||||
a.Rat = arr[2]
|
||||
a.Arfb = arr[3]
|
||||
a.Sar = arr[4]
|
||||
a.Cn = arr[5]
|
||||
a.AmDat = v
|
||||
a.UeAmbrTpl = arr[0]
|
||||
a.NssaiTpl = arr[1]
|
||||
a.RatRestrictions = arr[2]
|
||||
a.AreaForbiddenTpl = arr[3]
|
||||
a.ServiceAreaRestrictionTpl = arr[4]
|
||||
a.CnTypeRestrictions = arr[5]
|
||||
a.RfspIndex = arr[6]
|
||||
a.SubsRegTime = arr[7]
|
||||
a.UeUsageType = arr[8]
|
||||
a.ActiveTime = arr[9]
|
||||
a.MicoAllowed = "0" // arr[10]
|
||||
a.OdbPs = "1" // arr[11]
|
||||
a.GroupId = "-" // arr[12]
|
||||
if len(arr) > 10 {
|
||||
a.MicoAllowed = arr[10]
|
||||
}
|
||||
if len(arr) > 11 {
|
||||
a.OdbPs = arr[11]
|
||||
}
|
||||
if len(arr) > 12 && arr[12] != "-" {
|
||||
a.GroupId = arr[12]
|
||||
}
|
||||
}
|
||||
// 1,64,24,65,def_eps,1,2,010200000000,-
|
||||
if v, ok := m["eps-dat"]; ok {
|
||||
@@ -71,9 +88,11 @@ func (r *UDMSubUser) dataByRedis(imsi, neId string) []model.UDMSubUser {
|
||||
a.Ard = arr[3]
|
||||
a.Epstpl = arr[4]
|
||||
a.ContextId = arr[5]
|
||||
a.ApnNum = arr[6] // 导入和导出不用
|
||||
a.ApnContext = arr[7]
|
||||
// [6] 是不要的,导入和导出不用
|
||||
a.StaticIp = arr[8]
|
||||
if len(arr) >= 9 {
|
||||
a.StaticIp = arr[8]
|
||||
}
|
||||
}
|
||||
|
||||
arr = append(arr, a)
|
||||
@@ -91,27 +110,30 @@ func (r *UDMSubUser) ResetData(neId string) int64 {
|
||||
|
||||
// ParseInfo 解析单个用户imsi签约信息 data从命令MML得到的结果
|
||||
func (r *UDMSubUser) ParseInfo(imsi, neId string, data map[string]string) model.UDMSubUser {
|
||||
cnType, _ := strconv.ParseInt(data["CNType"][:4], 0, 64)
|
||||
rat, _ := strconv.ParseInt(data["RAT"][:4], 0, 64)
|
||||
u := r.udmSubRepository.SelectByIMSIAndNeID(imsi, neId)
|
||||
|
||||
cnType, _ := strconv.ParseInt(data["CNType"][:4], 0, 64) // 0x03(EPC|5GC)
|
||||
rat, _ := strconv.ParseInt(data["RAT"][:4], 0, 64) // 0x00(VIRTUAL|WLAN|EUTRA|NR)
|
||||
msisdn := data["MSISDN"]
|
||||
if imsMsisdnLen := strings.Index(msisdn, ","); imsMsisdnLen != -1 {
|
||||
msisdn = msisdn[:imsMsisdnLen]
|
||||
}
|
||||
|
||||
u := model.UDMSubUser{
|
||||
IMSI: imsi,
|
||||
MSISDN: msisdn,
|
||||
NeId: neId,
|
||||
Ambr: data["AMBR"],
|
||||
Arfb: data["AreaForbidden"],
|
||||
Cn: fmt.Sprint(cnType),
|
||||
SmData: data["SM-Data(snssai+dnn[1..n])"],
|
||||
Sar: data["ServiceAreaRestriction"],
|
||||
Nssai: data["NSSAI"],
|
||||
SmfSel: data["Smf-Selection"],
|
||||
Cag: data["cag"],
|
||||
Rat: fmt.Sprint(rat),
|
||||
}
|
||||
// 用于更新
|
||||
u.IMSI = imsi
|
||||
u.MSISDN = msisdn
|
||||
u.NeId = neId
|
||||
u.UeAmbrTpl = data["AMBR"]
|
||||
u.NssaiTpl = data["NSSAI"]
|
||||
u.AreaForbiddenTpl = data["AreaForbidden"]
|
||||
u.ServiceAreaRestrictionTpl = data["ServiceAreaRestriction"]
|
||||
u.CnTypeRestrictions = fmt.Sprint(cnType)
|
||||
u.RatRestrictions = fmt.Sprint(rat)
|
||||
u.MicoAllowed = data["MICO"]
|
||||
u.SmData = data["SM-Data(snssai+dnn[1..n])"]
|
||||
u.SmfSel = data["Smf-Selection"]
|
||||
u.Cag = data["cag"]
|
||||
|
||||
// 1,64,24,65,def_eps,1,2,010200000000,-
|
||||
if v, ok := data["EPS-Data"]; ok {
|
||||
u.EpsDat = v
|
||||
@@ -122,16 +144,11 @@ func (r *UDMSubUser) ParseInfo(imsi, neId string, data map[string]string) model.
|
||||
u.Ard = arr[3]
|
||||
u.Epstpl = arr[4]
|
||||
u.ContextId = arr[5]
|
||||
u.ApnNum = arr[6] // 导入和导出不用
|
||||
u.ApnContext = arr[7]
|
||||
// [6] 是不要的,导入和导出不用
|
||||
u.StaticIp = arr[8]
|
||||
}
|
||||
|
||||
// 补充用户ID用于更新
|
||||
sub := r.udmSubRepository.SelectByIMSIAndNeID(imsi, neId)
|
||||
if sub.IMSI == imsi {
|
||||
u.ID = sub.ID
|
||||
}
|
||||
// 补充用户拓展信息
|
||||
info := r.udmUserInfoRepository.SelectByIMSIAndNeID(imsi, neId)
|
||||
if info.IMSI == imsi {
|
||||
@@ -252,3 +269,75 @@ func (r *UDMSubUser) LoadData(neId, imsi, num, remark string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ParseCommandParams 解析数据组成命令参数 msisdn=xx,xx=xx,...
|
||||
func (r *UDMSubUser) ParseCommandParams(item model.UDMSubUser) string {
|
||||
var conditions []string
|
||||
if item.MSISDN != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("msisdn=%s", item.MSISDN))
|
||||
}
|
||||
|
||||
// AmData
|
||||
if item.UeAmbrTpl != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("ambr=%s", item.UeAmbrTpl))
|
||||
}
|
||||
if item.NssaiTpl != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("nssai=%s", item.NssaiTpl))
|
||||
}
|
||||
if item.AreaForbiddenTpl != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("arfb=%s", item.AreaForbiddenTpl))
|
||||
}
|
||||
if item.ServiceAreaRestrictionTpl != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("sar=%s", item.ServiceAreaRestrictionTpl))
|
||||
}
|
||||
if item.RatRestrictions != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("rat=%s", item.RatRestrictions))
|
||||
}
|
||||
if item.CnTypeRestrictions != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("cn=%s", item.CnTypeRestrictions))
|
||||
}
|
||||
if item.MicoAllowed != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("mico=%s", item.MicoAllowed))
|
||||
}
|
||||
|
||||
// EpsDat
|
||||
// if item.EpsDat != "" {
|
||||
// conditions = append(conditions, fmt.Sprintf("eps_dat=%s", item.EpsDat))
|
||||
// }
|
||||
if item.EpsFlag != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("eps_flag=%s", item.EpsFlag))
|
||||
}
|
||||
if item.EpsOdb != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("eps_odb=%s", item.EpsOdb))
|
||||
}
|
||||
if item.HplmnOdb != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("hplmn_odb=%s", item.HplmnOdb))
|
||||
}
|
||||
if item.Epstpl != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("epstpl=%s", item.Epstpl))
|
||||
}
|
||||
if item.Ard != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("ard=%s", item.Ard))
|
||||
}
|
||||
if item.ContextId != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("context_id=%s", item.ContextId))
|
||||
}
|
||||
if item.ApnContext != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("apn_context=%s", item.ApnContext))
|
||||
}
|
||||
if item.StaticIp != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("static_ip=%s", item.StaticIp))
|
||||
}
|
||||
|
||||
// 其他
|
||||
if item.SmfSel != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("smf_sel=%s", item.SmfSel))
|
||||
}
|
||||
if item.SmData != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("sm_data=%s", item.SmData))
|
||||
}
|
||||
if item.Cag != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("cag=%s", item.Cag))
|
||||
}
|
||||
return strings.Join(conditions, ",")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user