ref: v3变更,,完成整合,同步v2.2508.4 -250902
This commit is contained in:
@@ -79,7 +79,7 @@ func (s NeInfoController) State(c *gin.Context) {
|
||||
"neUid": neInfo.NeUID,
|
||||
"neType": neInfo.NeType,
|
||||
"neName": neInfo.NeName,
|
||||
"neIP": neInfo.IPAddr,
|
||||
"ipAddr": neInfo.IPAddr,
|
||||
}
|
||||
}
|
||||
neStateCacheMap.Store(neKey, resDataCache)
|
||||
@@ -439,7 +439,7 @@ func (s NeInfoController) Remove(c *gin.Context) {
|
||||
var query struct {
|
||||
CoreUID string `form:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `form:"neUid" binding:"required"` // 网元唯一标识
|
||||
ID int64 `form:"id" binding:"required"` // 记录ID
|
||||
ID string `form:"id" binding:"required"` // 记录ID 批量多个逗号分隔
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
@@ -447,7 +447,15 @@ func (s NeInfoController) Remove(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
rows, err := s.neInfoService.DeleteById(query.ID, query.CoreUID, query.NeUID)
|
||||
// 处理字符转id数组后去重
|
||||
uniqueIDs := parse.RemoveDuplicatesToArray(query.ID, ",")
|
||||
// 转换成int64数组类型
|
||||
ids := make([]int64, 0)
|
||||
for _, v := range uniqueIDs {
|
||||
ids = append(ids, parse.Number(v))
|
||||
}
|
||||
|
||||
rows, err := s.neInfoService.DeleteByIds(ids, query.CoreUID, query.NeUID)
|
||||
if err != nil {
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, err.Error())))
|
||||
return
|
||||
|
||||
@@ -45,7 +45,7 @@ func NeState(neInfo model.NeInfo) (map[string]any, error) {
|
||||
"neUid": neInfo.NeUID,
|
||||
"neType": neInfo.NeType,
|
||||
"neName": neInfo.NeName,
|
||||
"neIP": neInfo.IPAddr,
|
||||
"ipAddr": neInfo.IPAddr,
|
||||
"refreshTime": time.Now().UnixMilli(), // 获取时间
|
||||
"standby": resData["standby"], // 是否备用服务
|
||||
"version": resData["version"],
|
||||
|
||||
@@ -93,7 +93,7 @@ func (r NeInfo) SelectByPage(query map[string]string) ([]model.NeInfo, int64) {
|
||||
// 查询数据分页
|
||||
pageNum, pageSize := db.PageNumSize(query["pageNum"], query["pageSize"])
|
||||
tx = tx.Limit(pageSize).Offset(pageSize * pageNum)
|
||||
err := tx.Order("ne_type asc").Find(&rows).Error
|
||||
err := tx.Find(&rows).Error
|
||||
if err != nil {
|
||||
logger.Errorf("query find err => %v", err.Error())
|
||||
return rows, total
|
||||
|
||||
@@ -289,8 +289,8 @@ func (r NeInfo) Insert(neInfo model.NeInfo) int64 {
|
||||
CreateBy: neInfo.CreateBy,
|
||||
}
|
||||
if v, ok := serverState["version"]; ok && v != nil {
|
||||
neVersion.Name = "-"
|
||||
neVersion.Path = "-"
|
||||
// neVersion.Name = "-"
|
||||
// neVersion.Path = "-"
|
||||
neVersion.Version = fmt.Sprint(v)
|
||||
}
|
||||
NewNeVersion.Insert(neVersion)
|
||||
@@ -366,8 +366,8 @@ func (r NeInfo) Update(neInfo model.NeInfo) int64 {
|
||||
neVersion.NeType = neInfo.NeType
|
||||
}
|
||||
if v, ok := serverState["version"]; ok && v != neVersion.Version {
|
||||
neVersion.Name = "-"
|
||||
neVersion.Path = "-"
|
||||
// neVersion.Name = "-"
|
||||
// neVersion.Path = "-"
|
||||
neVersion.Version = fmt.Sprint(v)
|
||||
}
|
||||
neVersion.UpdateBy = neInfo.UpdateBy
|
||||
@@ -403,10 +403,10 @@ func (r NeInfo) Update(neInfo model.NeInfo) int64 {
|
||||
}
|
||||
|
||||
// DeleteByIds 批量删除信息
|
||||
func (r NeInfo) DeleteById(id int64, coreUid, neUid string) (int64, error) {
|
||||
func (r NeInfo) DeleteByIds(ids []int64, coreUid, neUid string) (int64, error) {
|
||||
// 检查是否存在
|
||||
arr := r.neInfoRepository.SelectByIds([]int64{id})
|
||||
if len(arr) != 1 {
|
||||
arr := r.neInfoRepository.SelectByIds(ids)
|
||||
if len(arr) != len(ids) {
|
||||
return 0, fmt.Errorf("not match id")
|
||||
}
|
||||
|
||||
@@ -438,7 +438,7 @@ func (r NeInfo) DeleteById(id int64, coreUid, neUid string) (int64, error) {
|
||||
// 缓存信息删除
|
||||
redis.Del("", fmt.Sprintf("%s:%s:%s:%s", constants.CACHE_NE_INFO, v.CoreUID, v.NeType, v.NeUID))
|
||||
}
|
||||
rows := r.neInfoRepository.DeleteByIds([]int64{id})
|
||||
rows := r.neInfoRepository.DeleteByIds(ids)
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -64,12 +64,12 @@ func (r NeVersion) checkNeVersion(arr *[]model.NeVersion) {
|
||||
continue
|
||||
}
|
||||
if v, ok := result["version"]; ok && v != nil {
|
||||
ver := v.(string)
|
||||
if ver == item.Version {
|
||||
ver, ok := v.(string)
|
||||
if !ok || ver == item.Version {
|
||||
continue
|
||||
}
|
||||
item.Name = "-"
|
||||
item.Path = "-"
|
||||
// item.Name = "-"
|
||||
// item.Path = "-"
|
||||
item.Version = ver
|
||||
}
|
||||
if item.NeType != neInfo.NeType {
|
||||
|
||||
@@ -210,7 +210,7 @@ func (s *AMFController) NbInfoList(c *gin.Context) {
|
||||
|
||||
// 接入基站状态信息列表
|
||||
//
|
||||
// GET /nb/list-cfg
|
||||
// GET /nb/addrs
|
||||
//
|
||||
// @Tags ne_data/amf
|
||||
// @Accept json
|
||||
@@ -220,7 +220,7 @@ func (s *AMFController) NbInfoList(c *gin.Context) {
|
||||
// @Security TokenAuth
|
||||
// @Summary Access to the base station status information list
|
||||
// @Description Access to the base station status information list
|
||||
// @Router /neData/amf/nb/list-cfg [get]
|
||||
// @Router /neData/amf/nb/addrs [get]
|
||||
func (s *AMFController) NbStateList(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
|
||||
@@ -17,16 +17,18 @@ import (
|
||||
|
||||
// 实例化控制层 IMSController 结构体
|
||||
var NewIMS = &IMSController{
|
||||
neInfoService: neService.NewNeInfo,
|
||||
cdrEventService: neDataService.NewCDREvent,
|
||||
neInfoService: neService.NewNeInfo,
|
||||
cdrEventService: neDataService.NewCDREvent,
|
||||
kpiReportService: neDataService.NewKpiReport,
|
||||
}
|
||||
|
||||
// 网元IMS
|
||||
//
|
||||
// PATH /ims
|
||||
type IMSController struct {
|
||||
neInfoService *neService.NeInfo // 网元信息服务
|
||||
cdrEventService *neDataService.CDREvent // CDR会话事件服务
|
||||
neInfoService *neService.NeInfo // 网元信息服务
|
||||
cdrEventService *neDataService.CDREvent // CDR会话事件服务
|
||||
kpiReportService *neDataService.KpiReport // 统计信息服务
|
||||
}
|
||||
|
||||
// CDR会话列表
|
||||
@@ -253,3 +255,45 @@ func (s *IMSController) UeSessionList(c *gin.Context) {
|
||||
|
||||
c.JSON(200, resp.OkData(data))
|
||||
}
|
||||
|
||||
// KPI 忙时统计
|
||||
//
|
||||
// GET /kpi/busy-hour
|
||||
//
|
||||
// @Tags network_data/ims
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param neId query string true "NE ID" default(001)
|
||||
// @Param timestamp query int64 false "timestamp"
|
||||
// @Success 200 {object} object "Response Results"
|
||||
// @Security TokenAuth
|
||||
// @Summary Busy hour statistics
|
||||
// @Description Busy hour statistics
|
||||
// @Router /neData/ims/kpi/busy-hour [get]
|
||||
func (s IMSController) KPIBusyHour(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
CoreUID string `form:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `form:"neUid" binding:"required"` // 网元唯一标识
|
||||
Timestamp int64 `form:"timestamp" binding:"required"` // 时间戳毫秒 年月日返回每小时的总和 年月日时返回该小时的总和
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs))
|
||||
return
|
||||
}
|
||||
if query.Timestamp < 1e12 || query.Timestamp > 1e13 {
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "timestamp format is ms"))
|
||||
return
|
||||
}
|
||||
|
||||
// 查询网元获取IP
|
||||
neInfo := s.neInfoService.FindByCoreUidAndNeUid(query.CoreUID, query.NeUID)
|
||||
if neInfo.CoreUID != query.CoreUID || neInfo.NeUID != query.NeUID {
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
|
||||
data := s.kpiReportService.IMSBusyHour(neInfo.CoreUID, neInfo.NeUID, query.Timestamp)
|
||||
c.JSON(200, resp.OkData(data))
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ func (s *MMEController) NbInfoList(c *gin.Context) {
|
||||
|
||||
// 接入基站状态信息列表
|
||||
//
|
||||
// GET /nb/list-cfg
|
||||
// GET /nb/addrs
|
||||
//
|
||||
// @Tags ne_data/mme
|
||||
// @Accept json
|
||||
@@ -220,7 +220,7 @@ func (s *MMEController) NbInfoList(c *gin.Context) {
|
||||
// @Security TokenAuth
|
||||
// @Summary Access to the base station status information list
|
||||
// @Description Access to the base station status information list
|
||||
// @Router /neData/mme/nb/list-cfg [get]
|
||||
// @Router /neData/mme/nb/addrs [get]
|
||||
func (s *MMEController) NbStateList(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
|
||||
@@ -81,8 +81,8 @@ func (s *UDMAuthController) ResetData(c *gin.Context) {
|
||||
// @Router /ne/link/udm/auth/list [get]
|
||||
func (s *UDMAuthController) List(c *gin.Context) {
|
||||
query := reqctx.QueryMap(c)
|
||||
total, rows := s.udmAuthService.FindByPage(query)
|
||||
c.JSON(200, resp.OkData(map[string]any{"total": total, "rows": rows}))
|
||||
rows, total := s.udmAuthService.FindByPage(query)
|
||||
c.JSON(200, resp.OkData(map[string]any{"rows": rows, "total": total}))
|
||||
}
|
||||
|
||||
// UDM鉴权用户信息
|
||||
@@ -251,8 +251,8 @@ func (s *UDMAuthController) Edit(c *gin.Context) {
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs))
|
||||
return
|
||||
}
|
||||
if body.IMSI == "" {
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: imsi is empty"))
|
||||
if len(body.IMSI) != 15 {
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: IMSI length is not 15 bits"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ func (s *UDMAuthController) Remove(c *gin.Context) {
|
||||
CoreUID string `form:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `form:"neUid" binding:"required"` // 网元唯一标识
|
||||
IMSI string `form:"imsi" binding:"required"` // IMSi
|
||||
Num int64 `form:"num"` // 批量数量
|
||||
Num int64 `form:"num"` // 数量 0可拼接imsi多删除 大于1为批量
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
@@ -397,7 +397,7 @@ func (s *UDMAuthController) Export(c *gin.Context) {
|
||||
}
|
||||
fileType := c.Query("type")
|
||||
if !(fileType == "csv" || fileType == "txt") {
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "ne.udm.errImportUserSubFileFormat")))
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "file type error, only support csv,txt"))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -81,8 +81,8 @@ func (s *UDMSubController) ResetData(c *gin.Context) {
|
||||
// @Router /ne/link/udm/sub/list [get]
|
||||
func (s *UDMSubController) List(c *gin.Context) {
|
||||
query := reqctx.QueryMap(c)
|
||||
total, rows := s.udmSubService.FindByPage(query)
|
||||
c.JSON(200, resp.OkData(map[string]any{"total": total, "rows": rows}))
|
||||
rows, total := s.udmSubService.FindByPage(query)
|
||||
c.JSON(200, resp.OkData(map[string]any{"rows": rows, "total": total}))
|
||||
}
|
||||
|
||||
// UDM签约用户信息
|
||||
@@ -247,12 +247,6 @@ func (s *UDMSubController) Add(c *gin.Context) {
|
||||
// @Router /ne/link/udm/sub [put]
|
||||
func (s *UDMSubController) Edit(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
neId := c.Param("neId")
|
||||
if neId == "" {
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty"))
|
||||
return
|
||||
}
|
||||
|
||||
var body model.UDMSubUser
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
@@ -350,6 +344,7 @@ func (s *UDMSubController) Remove(c *gin.Context) {
|
||||
s.udmSubService.LoadData(neInfo.CoreUID, neInfo.NeUID, query.IMSI, query.Num, "-(Deleted)-")
|
||||
}
|
||||
c.JSON(200, resp.OkData(data))
|
||||
return
|
||||
}
|
||||
|
||||
// 处理字符转id数组后去重
|
||||
@@ -405,7 +400,7 @@ func (s *UDMSubController) Export(c *gin.Context) {
|
||||
}
|
||||
fileType := c.Query("type")
|
||||
if !(fileType == "csv" || fileType == "txt") {
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "ne.udm.errImportUserSubFileFormat")))
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "file type error, only support csv,txt"))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -82,8 +82,8 @@ func (s *UDMVOIPController) ResetData(c *gin.Context) {
|
||||
// @Router /ne/link/udm/voip/list [get]
|
||||
func (s *UDMVOIPController) List(c *gin.Context) {
|
||||
query := reqctx.QueryMap(c)
|
||||
total, rows := s.udmVOIPService.FindByPage(query)
|
||||
c.JSON(200, resp.OkData(map[string]any{"total": total, "rows": rows}))
|
||||
rows, total := s.udmVOIPService.FindByPage(query)
|
||||
c.JSON(200, resp.OkData(map[string]any{"rows": rows, "total": total}))
|
||||
}
|
||||
|
||||
// UDMVOIP用户信息
|
||||
@@ -336,14 +336,14 @@ func (s *UDMVOIPController) Remove(c *gin.Context) {
|
||||
func (s *UDMVOIPController) Export(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
// 查询结果,根据查询条件结果,单页最大值限制
|
||||
neId := c.Query("neId")
|
||||
fileType := c.Query("type")
|
||||
if neId == "" {
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty"))
|
||||
neUid := c.Query("neUid")
|
||||
if c.Query("coreUid") == "" || neUid == "" {
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: coreUid or neUid is empty"))
|
||||
return
|
||||
}
|
||||
fileType := c.Query("type")
|
||||
if !(fileType == "csv" || fileType == "txt") {
|
||||
c.JSON(200, resp.ErrMsg("file type error, only support csv,txt"))
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "file type error, only support csv,txt"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ func (s *UDMVOIPController) Export(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 文件名
|
||||
fileName := fmt.Sprintf("udm_voip_user_export_%s_%d.%s", neId, time.Now().UnixMilli(), fileType)
|
||||
fileName := fmt.Sprintf("udm_voip_user_export_%s_%d.%s", neUid, time.Now().UnixMilli(), fileType)
|
||||
filePath := filepath.Join(file.ParseUploadFileDir(constants.UPLOAD_EXPORT), fileName)
|
||||
|
||||
if fileType == "csv" {
|
||||
|
||||
@@ -81,8 +81,8 @@ func (s *UDMVolteIMSController) ResetData(c *gin.Context) {
|
||||
// @Router /ne/link/udm/volte-ims/list [get]
|
||||
func (s *UDMVolteIMSController) List(c *gin.Context) {
|
||||
query := reqctx.QueryMap(c)
|
||||
total, rows := s.udmVolteIMSService.FindByPage(query)
|
||||
c.JSON(200, resp.OkData(map[string]any{"total": total, "rows": rows}))
|
||||
rows, total := s.udmVolteIMSService.FindByPage(query)
|
||||
c.JSON(200, resp.OkData(map[string]any{"rows": rows, "total": total}))
|
||||
}
|
||||
|
||||
// UDMVolteIMS用户信息
|
||||
@@ -260,12 +260,12 @@ func (s *UDMVolteIMSController) Add(c *gin.Context) {
|
||||
func (s *UDMVolteIMSController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
CoreUID string `form:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `form:"neUid" binding:"required"` // 网元唯一标识
|
||||
IMSI string `form:"imsi" binding:"required"` // IMSi, 带数量时为批量
|
||||
MSISDN string `form:"msisdn" binding:"required"` // MSISDN, 带数量时为批量
|
||||
Volte string `form:"volte" binding:"required,oneof=0 1"` // volte
|
||||
Num int64 `form:"num"` // 批量数量
|
||||
CoreUID string `form:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `form:"neUid" binding:"required"` // 网元唯一标识
|
||||
IMSI string `form:"imsi" binding:"required"` // IMSi, 带数量时为批量
|
||||
MSISDN string `form:"msisdn" binding:"required"` // MSISDN, 带数量时为批量
|
||||
Tag string `form:"tag" binding:"required,oneof=0 1"` // tag
|
||||
Num int64 `form:"num"` // 批量数量
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
@@ -291,10 +291,10 @@ func (s *UDMVolteIMSController) Remove(c *gin.Context) {
|
||||
if query.Num > 1 {
|
||||
// 发送MML
|
||||
cmd := ""
|
||||
if query.Volte == "0" {
|
||||
if query.Tag == "0" {
|
||||
cmd = fmt.Sprintf("bde imsuser:start_msisdn=%s,sub_num=%d,volte=0", query.MSISDN, query.Num)
|
||||
}
|
||||
if query.Volte == "1" {
|
||||
if query.Tag == "1" {
|
||||
cmd = fmt.Sprintf("bde imsuser:start_imsi=%s,start_msisdn=%s,sub_num=%d,volte=1", query.IMSI, query.MSISDN, query.Num)
|
||||
}
|
||||
data, err := telnet.ConvertToStr(telnetClient, cmd)
|
||||
@@ -312,7 +312,7 @@ func (s *UDMVolteIMSController) Remove(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 发送MML
|
||||
cmd := fmt.Sprintf("del imsuser:imsi=%s,msisdn=%s,volte=%s", query.IMSI, query.MSISDN, query.Volte)
|
||||
cmd := fmt.Sprintf("del imsuser:imsi=%s,msisdn=%s,volte=%s", query.IMSI, query.MSISDN, query.Tag)
|
||||
data, err := telnet.ConvertToStr(telnetClient, cmd)
|
||||
if err != nil {
|
||||
c.JSON(200, resp.ErrMsg(err.Error()))
|
||||
@@ -352,7 +352,7 @@ func (s *UDMVolteIMSController) Export(c *gin.Context) {
|
||||
}
|
||||
fileType := c.Query("type")
|
||||
if !(fileType == "csv" || fileType == "txt") {
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "ne.udm.errImportUserSubFileFormat")))
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "file type error, only support csv,txt"))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ type UPFController struct {
|
||||
}
|
||||
|
||||
// 总流量数 N3上行 N6下行
|
||||
// 单位 比特(bit)
|
||||
// 单位 字节(Byte)
|
||||
//
|
||||
// GET /flow-total
|
||||
// GET /kpi/flow-total
|
||||
//
|
||||
// @Tags network_data/upf
|
||||
// @Accept json
|
||||
@@ -40,8 +40,8 @@ type UPFController struct {
|
||||
// @Security TokenAuth
|
||||
// @Summary Total number of flows N3 upstream N6 downstream
|
||||
// @Description Total number of flows N3 upstream N6 downstream
|
||||
// @Router /ne/link/upf/flow-total [get]
|
||||
func (s UPFController) FlowTotal(c *gin.Context) {
|
||||
// @Router /ne/link/upf/kpi/flow-total [get]
|
||||
func (s UPFController) KPIFlowTotal(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var querys struct {
|
||||
CoreUID string `form:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
|
||||
@@ -2,15 +2,16 @@ package model
|
||||
|
||||
// UDMAuthUser UDM鉴权用户 udm_auth
|
||||
type UDMAuthUser struct {
|
||||
ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"` // 主键
|
||||
CoreUID string `json:"coreUid" gorm:"column:core_uid"` // 核心网唯一标识
|
||||
NeUID string `json:"neUid" gorm:"column:ne_uid"` // 网元唯一标识
|
||||
NeType string `json:"neType" gorm:"column:ne_type"` // 网元类型
|
||||
IMSI string `json:"imsi" gorm:"column:imsi"` // SIM卡/USIM卡ID
|
||||
Amf string `json:"amf" gorm:"column:amf"` // AMF
|
||||
Ki string `json:"ki" gorm:"column:ki"` // ki
|
||||
AlgoIndex string `json:"algoIndex" gorm:"column:algo_index"` // algoIndex
|
||||
Opc string `json:"opc" gorm:"column:opc"` // OPC
|
||||
ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"` // 主键
|
||||
CoreUID string `json:"coreUid" gorm:"column:core_uid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `json:"neUid" gorm:"column:ne_uid" binding:"required"` // 网元唯一标识
|
||||
NeType string `json:"neType" gorm:"column:ne_type" binding:"required,oneof=UDM"` // 网元类型
|
||||
IMSI string `json:"imsi" gorm:"column:imsi"` // SIM卡/USIM卡ID
|
||||
Amf string `json:"amf" gorm:"column:amf"` // AMF
|
||||
Ki string `json:"ki" gorm:"column:ki"` // ki
|
||||
AlgoIndex string `json:"algoIndex" gorm:"column:algo_index"` // algoIndex
|
||||
Opc string `json:"opc" gorm:"column:opc"` // OPC
|
||||
CreateTime int64 `json:"createTime" gorm:"column:create_time"` // 创建时间
|
||||
}
|
||||
|
||||
// TableName 表名称
|
||||
|
||||
@@ -2,12 +2,12 @@ package model
|
||||
|
||||
// UDMSubUser UDM签约用户 udm_sub
|
||||
type UDMSubUser struct {
|
||||
ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"` // 主键
|
||||
CoreUID string `json:"coreUid" gorm:"column:core_uid"` // 核心网唯一标识
|
||||
NeUID string `json:"neUid" gorm:"column:ne_uid"` // 网元唯一标识
|
||||
NeType string `json:"neType" gorm:"column:ne_type"` // 网元类型
|
||||
IMSI string `json:"imsi" gorm:"column:imsi"` // SIM卡/USIM卡ID
|
||||
MSISDN string `json:"msisdn" gorm:"column:msisdn"` // 用户电话号码
|
||||
ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"` // 主键
|
||||
CoreUID string `json:"coreUid" gorm:"column:core_uid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `json:"neUid" gorm:"column:ne_uid" binding:"required"` // 网元唯一标识
|
||||
NeType string `json:"neType" gorm:"column:ne_type" binding:"required,oneof=UDM"` // 网元类型
|
||||
IMSI string `json:"imsi" gorm:"column:imsi"` // SIM卡/USIM卡ID
|
||||
MSISDN string `json:"msisdn" gorm:"column:msisdn"` // 用户电话号码
|
||||
|
||||
AmDat string `json:"amDat" gorm:"column:am_dat"` // AmData
|
||||
UeAmbrTpl string `json:"ambr" gorm:"column:ambr"` // AmData SubUeAMBRTemp
|
||||
|
||||
@@ -2,10 +2,10 @@ package model
|
||||
|
||||
// UDMVOIPUser UDMVOIP用户 udm_voip
|
||||
type UDMVOIPUser struct {
|
||||
ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"` // 主键
|
||||
CoreUID string `json:"coreUid" gorm:"column:core_uid"` // 核心网唯一标识
|
||||
NeUID string `json:"neUid" gorm:"column:ne_uid"` // 网元唯一标识
|
||||
NeType string `json:"neType" gorm:"column:ne_type"` // 网元类型
|
||||
ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"` // 主键
|
||||
CoreUID string `json:"coreUid" gorm:"column:core_uid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `json:"neUid" gorm:"column:ne_uid" binding:"required"` // 网元唯一标识
|
||||
NeType string `json:"neType" gorm:"column:ne_type" binding:"required,oneof=UDM"` // 网元类型
|
||||
|
||||
UserName string `json:"username" gorm:"column:username"` // 用户名
|
||||
Password string `json:"password" gorm:"column:password"` // 密码
|
||||
|
||||
@@ -2,12 +2,12 @@ package model
|
||||
|
||||
// UDMVolteIMSUser UDMVolteIMS用户 udm_volte_ims
|
||||
type UDMVolteIMSUser struct {
|
||||
ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"` // 主键
|
||||
CoreUID string `json:"coreUid" gorm:"column:core_uid"` // 核心网唯一标识
|
||||
NeUID string `json:"neUid" gorm:"column:ne_uid"` // 网元唯一标识
|
||||
NeType string `json:"neType" gorm:"column:ne_type"` // 网元类型
|
||||
IMSI string `json:"imsi" gorm:"column:imsi"` // SIM卡/USIM卡ID
|
||||
MSISDN string `json:"msisdn" gorm:"column:msisdn"` // 用户电话号码
|
||||
ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"` // 主键
|
||||
CoreUID string `json:"coreUid" gorm:"column:core_uid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `json:"neUid" gorm:"column:ne_uid" binding:"required"` // 网元唯一标识
|
||||
NeType string `json:"neType" gorm:"column:ne_type" binding:"required,oneof=UDM"` // 网元类型
|
||||
IMSI string `json:"imsi" gorm:"column:imsi"` // SIM卡/USIM卡ID
|
||||
MSISDN string `json:"msisdn" gorm:"column:msisdn"` // 用户电话号码
|
||||
|
||||
Tag string `json:"tag" gorm:"column:tag"` // 0=VoIP, 1=VoLTE
|
||||
VNI string `json:"vni" gorm:"column:vni"` // VNI
|
||||
|
||||
@@ -203,6 +203,10 @@ func Setup(router *gin.Engine) {
|
||||
middleware.AuthorizeUser(nil),
|
||||
controller.NewIMS.UeSessionList,
|
||||
)
|
||||
imsGroup.GET("/kpi/busy-hour",
|
||||
middleware.AuthorizeUser(nil),
|
||||
controller.NewIMS.KPIBusyHour,
|
||||
)
|
||||
}
|
||||
|
||||
// 网元SMSC
|
||||
@@ -281,9 +285,9 @@ func Setup(router *gin.Engine) {
|
||||
// 网元UPF
|
||||
upfGroup := neDataGroup.Group("/upf")
|
||||
{
|
||||
upfGroup.GET("/flow-total",
|
||||
upfGroup.GET("/kpi/flow-total",
|
||||
middleware.AuthorizeUser(nil),
|
||||
controller.NewUPF.FlowTotal,
|
||||
controller.NewUPF.KPIFlowTotal,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,24 @@ func (r KpiReport) SelectUPF(coreUid, neUid string, beginTime, endTime int64) []
|
||||
tx = tx.Where("created_at <= ?", endTime)
|
||||
// 查询数据
|
||||
rows := []model.KpiReport{}
|
||||
if err := tx.Select("kpi_values").Find(&rows).Error; err != nil {
|
||||
if err := tx.Select("kpi_values", "created_at").Find(&rows).Error; err != nil {
|
||||
logger.Errorf("query find err => %v", err.Error())
|
||||
return rows
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
// SelectIMS 查询IMS数据
|
||||
func (r KpiReport) SelectIMS(coreUid, neUid string, beginTime, endTime int64) []model.KpiReport {
|
||||
tx := db.DB("").Model(&model.KpiReport{})
|
||||
// 表名
|
||||
tx = tx.Table("kpi_report_ims")
|
||||
tx = tx.Where("core_uid = ? and ne_uid = ?", coreUid, neUid)
|
||||
tx = tx.Where("created_at >= ?", beginTime)
|
||||
tx = tx.Where("created_at <= ?", endTime)
|
||||
// 查询数据
|
||||
rows := []model.KpiReport{}
|
||||
if err := tx.Select("kpi_values", "created_at").Find(&rows).Error; err != nil {
|
||||
logger.Errorf("query find err => %v", err.Error())
|
||||
return rows
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ func (r KpiReport) TitleInsert(param model.KpiTitle) int64 {
|
||||
|
||||
// UPFTodayFlowFind 查询UPF总流量 N3上行 N6下行
|
||||
// day 统计天数
|
||||
// down * 8 / 1000 / 1000 单位M
|
||||
// down / 1000 / 1000 单位M
|
||||
func (r KpiReport) UPFTodayFlowFind(neUid string, day int) (int64, int64) {
|
||||
// 获取当前日期
|
||||
now := time.Now()
|
||||
@@ -280,3 +280,72 @@ func (r KpiReport) UPFTodayFlowLoad(day int) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// IMSBusyHour IMS忙时流量统计
|
||||
// SCSCF.06呼叫尝试次数 SCSCF.09呼叫成功次数
|
||||
func (r KpiReport) IMSBusyHour(coreUid string, neUid string, timestamp int64) []map[string]any {
|
||||
t := time.UnixMilli(timestamp)
|
||||
beginTime := t
|
||||
endTime := t
|
||||
// 检查时分秒是否都为零
|
||||
if t.Hour() == 0 && t.Minute() == 0 && t.Second() == 0 {
|
||||
// 获取当天起始时间(00:00:00)
|
||||
beginTime = t.Truncate(time.Hour)
|
||||
// 计算当天结束时间(23:59:59)
|
||||
endTime = beginTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
} else {
|
||||
// 起始时间:当前小时的 00 分 00 秒
|
||||
beginTime = t.Truncate(time.Hour)
|
||||
// 结束时间:当前小时的 59 分 59 秒 999 毫秒
|
||||
endTime = beginTime.Add(time.Hour - time.Millisecond)
|
||||
}
|
||||
// 转换为毫秒级时间戳
|
||||
rows := r.kpiReportRepository.SelectIMS(coreUid, neUid, beginTime.UnixMilli(), endTime.UnixMilli())
|
||||
|
||||
// 创建一个map来存储按时间段合并后的数据
|
||||
timeGroup := make(map[int64]map[string]int64)
|
||||
// 遍历每个数据项
|
||||
for _, row := range rows {
|
||||
// 将毫秒时间戳转换为小时级时间戳(保留到小时的起始毫秒)
|
||||
timeHour := row.CreatedAt / 3600000 * 3600000 // 1小时 = 3600000毫秒
|
||||
|
||||
// 解析 JSON 字符串为 map
|
||||
var kpiValues []map[string]any
|
||||
err := json.Unmarshal([]byte(row.KpiValues), &kpiValues)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
var callAttempts, callCompletions int64
|
||||
for _, v := range kpiValues {
|
||||
if k, ok := v["kpiId"]; ok {
|
||||
if k == "SCSCF.06" {
|
||||
callAttempts = parse.Number(v["value"])
|
||||
}
|
||||
if k == "SCSCF.09" {
|
||||
callCompletions = parse.Number(v["value"])
|
||||
}
|
||||
}
|
||||
}
|
||||
// 合并到对应的小时段
|
||||
if _, exists := timeGroup[timeHour]; !exists {
|
||||
timeGroup[timeHour] = map[string]int64{
|
||||
"callAttempts": 0,
|
||||
"callCompletions": 0,
|
||||
}
|
||||
}
|
||||
timeGroup[timeHour]["callAttempts"] += callAttempts
|
||||
timeGroup[timeHour]["callCompletions"] += callCompletions
|
||||
}
|
||||
|
||||
// 时间组合输出
|
||||
data := make([]map[string]any, 0, len(timeGroup))
|
||||
for hour, sums := range timeGroup {
|
||||
data = append(data, map[string]any{
|
||||
"timeGroup": fmt.Sprintf("%d", hour),
|
||||
"callAttempts": sums["callAttempts"],
|
||||
"callCompletions": sums["callCompletions"],
|
||||
})
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"be.ems/src/framework/database/redis"
|
||||
"be.ems/src/framework/utils/date"
|
||||
neService "be.ems/src/modules/ne/service"
|
||||
"be.ems/src/modules/ne_data/model"
|
||||
"be.ems/src/modules/ne_data/repository"
|
||||
@@ -63,15 +65,25 @@ func (r *UDMAuthUser) dataByRedis(coreUid, neUid, imsi string) []model.UDMAuthUs
|
||||
if v, ok := m["amf"]; ok {
|
||||
amf = strings.Replace(v, "\r\n", "", 1)
|
||||
}
|
||||
// 创建时间
|
||||
var createTime int64 = 0
|
||||
if v, ok := m["create_time"]; ok {
|
||||
t := date.ParseStrToDate(v, time.RFC3339)
|
||||
createTime = t.UnixMilli()
|
||||
} else {
|
||||
createTime = time.Now().UnixMilli()
|
||||
}
|
||||
|
||||
a := model.UDMAuthUser{
|
||||
CoreUID: coreUid,
|
||||
NeUID: neUid,
|
||||
NeType: "UDM",
|
||||
IMSI: imsi,
|
||||
Amf: amf,
|
||||
Ki: m["ki"],
|
||||
AlgoIndex: m["algo"],
|
||||
Opc: m["opc"],
|
||||
CoreUID: coreUid,
|
||||
NeUID: neUid,
|
||||
NeType: "UDM",
|
||||
IMSI: imsi,
|
||||
Amf: amf,
|
||||
Ki: m["ki"],
|
||||
AlgoIndex: m["algo"],
|
||||
Opc: m["opc"],
|
||||
CreateTime: createTime,
|
||||
}
|
||||
arr = append(arr, a)
|
||||
}
|
||||
|
||||
@@ -74,10 +74,14 @@ func (s *Alarm) Resolve(a oam.Alarm) error {
|
||||
if err := s.clearEvent(alarm); err != nil {
|
||||
return err
|
||||
}
|
||||
// 推送
|
||||
s.wsService.ByGroupID(fmt.Sprintf("%s_%s_%s", wsService.GROUP_ALARM_EVENT, neInfo.CoreUID, neInfo.NeUID), alarm)
|
||||
} else {
|
||||
if err := s.clear(alarm); err != nil {
|
||||
return err
|
||||
}
|
||||
// 推送
|
||||
s.wsService.ByGroupID(fmt.Sprintf("%s_%s_%s", wsService.GROUP_ALARM, neInfo.CoreUID, neInfo.NeUID), alarm)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -89,12 +93,16 @@ func (s *Alarm) Resolve(a oam.Alarm) error {
|
||||
return err
|
||||
}
|
||||
alarm.AlarmSeq = alarmSeq
|
||||
// 推送
|
||||
s.wsService.ByGroupID(fmt.Sprintf("%s_%s_%s", wsService.GROUP_ALARM_EVENT, neInfo.CoreUID, neInfo.NeUID), alarm)
|
||||
} else {
|
||||
alarmSeq, err := s.add(alarm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
alarm.AlarmSeq = alarmSeq
|
||||
// 推送
|
||||
s.wsService.ByGroupID(fmt.Sprintf("%s_%s_%s", wsService.GROUP_ALARM, neInfo.CoreUID, neInfo.NeUID), alarm)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,8 +110,7 @@ func (s *Alarm) Resolve(a oam.Alarm) error {
|
||||
if err := s.saveLog(alarm); err != nil {
|
||||
return err
|
||||
}
|
||||
// 推送
|
||||
s.wsService.ByGroupID(fmt.Sprintf("%s_%s_%s", wsService.GROUP_ALARM, neInfo.CoreUID, neInfo.NeUID), alarm)
|
||||
|
||||
// 通知
|
||||
go s.notify(alarm, neInfo)
|
||||
return nil
|
||||
|
||||
@@ -68,39 +68,6 @@ func (s *IPerfController) Version(c *gin.Context) {
|
||||
c.JSON(200, resp.OkData(data))
|
||||
}
|
||||
|
||||
// iperf 软件安装
|
||||
//
|
||||
// POST /i
|
||||
//
|
||||
// @Tags tool/iperf
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param data body object true "Request Param"
|
||||
// @Success 200 {object} object "Response Results"
|
||||
// @Security TokenAuth
|
||||
// @Summary iperf software installation
|
||||
// @Description iperf software installation
|
||||
// @Router /tool/iperf/i [post]
|
||||
func (s *IPerfController) Install(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var body struct {
|
||||
CoreUid string `form:"coreUid" binding:"required"` // 核心网唯一资源标识
|
||||
NeUid string `form:"neUid" binding:"required"` // 网元唯一资源标识
|
||||
Version string `form:"version" binding:"required,oneof=V2 V3"` // 版本
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.iperfService.Install(body.CoreUid, body.NeUid, body.Version); err != nil {
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, err.Error())))
|
||||
return
|
||||
}
|
||||
c.JSON(200, resp.Ok(nil))
|
||||
}
|
||||
|
||||
// iperf 软件运行
|
||||
//
|
||||
// GET /run
|
||||
|
||||
@@ -87,7 +87,7 @@ func (s MMLController) Command(c *gin.Context) {
|
||||
if neInfo.NeType == "UPF" && body.Type == "Standard" {
|
||||
num = 2
|
||||
}
|
||||
telnetClient, err := s.neInfoService.NeRunTelnetClient(neInfo.NeType, neInfo.NeUID, num)
|
||||
telnetClient, err := s.neInfoService.NeRunTelnetClient(neInfo.CoreUID, neInfo.NeUID, num)
|
||||
if err != nil {
|
||||
c.JSON(200, resp.ErrMsg(err.Error()))
|
||||
return
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"be.ems/src/framework/config"
|
||||
"be.ems/src/framework/logger"
|
||||
"be.ems/src/framework/resp"
|
||||
"be.ems/src/framework/ssh"
|
||||
@@ -49,89 +48,6 @@ func (s *IPerf) Version(coreUid, neUid, version string) (string, error) {
|
||||
return strings.TrimSpace(output), err
|
||||
}
|
||||
|
||||
// Install 安装iperf3
|
||||
func (s *IPerf) Install(coreUid, neUid, version string) error {
|
||||
if version != "V2" && version != "V3" {
|
||||
return fmt.Errorf("iperf version is required V2 or V3")
|
||||
}
|
||||
|
||||
// 网元主机的SSH客户端
|
||||
sshClient, err := neService.NewNeInfo.NeRunSSHClient(coreUid, neUid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer sshClient.Close()
|
||||
// 网元主机的SSH客户端进行文件传输
|
||||
sftpClient, err := sshClient.NewClientSFTP()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer sftpClient.Close()
|
||||
|
||||
nePath := "/tmp"
|
||||
depPkg := "sudo dpkg -i"
|
||||
depDir := "assets/dependency/iperf3/deb"
|
||||
|
||||
// 检查平台类型
|
||||
if _, err := sshClient.RunCMD("sudo dpkg --version"); err == nil {
|
||||
depPkg = "sudo dpkg -i"
|
||||
depDir = "assets/dependency/iperf3/deb"
|
||||
// sudo apt remove iperf3 libiperf0 libsctp1 libsctp-dev lksctp-tools
|
||||
} else if _, err := sshClient.RunCMD("sudo yum --version"); err == nil {
|
||||
depPkg = "sudo rpm -Uvh --nosignature --reinstall --force"
|
||||
depDir = "assets/dependency/iperf3/rpm"
|
||||
// yum remove iperf3 iperf3-help.noarch
|
||||
} else {
|
||||
return fmt.Errorf("iperf %s not supported install", version)
|
||||
}
|
||||
|
||||
// V2版本和V3版本的安装包路径不同
|
||||
if version == "V2" {
|
||||
depDir = strings.Replace(depDir, "iperf3", "iperf", 1)
|
||||
}
|
||||
|
||||
// 从 embed.FS 中读取默认配置文件内容
|
||||
assetsDir := config.GetAssetsDirFS()
|
||||
fsDirEntrys, err := assetsDir.ReadDir(depDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
neFilePaths := []string{}
|
||||
for _, d := range fsDirEntrys {
|
||||
// 打开本地文件
|
||||
localFile, err := assetsDir.Open(fmt.Sprintf("%s/%s", depDir, d.Name()))
|
||||
if err != nil {
|
||||
return fmt.Errorf("iperf %s file local error", version)
|
||||
}
|
||||
defer localFile.Close()
|
||||
// 创建远程文件
|
||||
remotePath := fmt.Sprintf("%s/%s", nePath, d.Name())
|
||||
remoteFile, err := sftpClient.Client.Create(remotePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("iperf %s file remote error", version)
|
||||
}
|
||||
defer remoteFile.Close()
|
||||
// 使用 io.Copy 将嵌入的文件内容复制到目标文件
|
||||
if _, err := io.Copy(remoteFile, localFile); err != nil {
|
||||
return fmt.Errorf("iperf %s file copy error", version)
|
||||
}
|
||||
neFilePaths = append(neFilePaths, remotePath)
|
||||
}
|
||||
|
||||
// 删除软件包
|
||||
defer func() {
|
||||
pkgRemove := fmt.Sprintf("sudo rm %s", strings.Join(neFilePaths, " "))
|
||||
sshClient.RunCMD(pkgRemove)
|
||||
}()
|
||||
|
||||
// 安装软件包
|
||||
pkgInstall := fmt.Sprintf("%s %s", depPkg, strings.Join(neFilePaths, " "))
|
||||
if _, err := sshClient.RunCMD(pkgInstall); err != nil {
|
||||
return fmt.Errorf("iperf %s install error", version)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// Run 接收IPerf3终端交互业务处理
|
||||
func (s *IPerf) Run(client *wsModel.WSClient, reqMsg wsModel.WSRequest) {
|
||||
// 必传requestId确认消息
|
||||
|
||||
@@ -20,11 +20,6 @@ func Setup(router *gin.Engine) {
|
||||
middleware.AuthorizeUser(nil),
|
||||
controller.NewIPerf.Version,
|
||||
)
|
||||
iperfGroup.POST("/i",
|
||||
middleware.AuthorizeUser(nil),
|
||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.iperf", collectlogs.BUSINESS_TYPE_OTHER)),
|
||||
controller.NewIPerf.Install,
|
||||
)
|
||||
iperfGroup.GET("/run",
|
||||
middleware.AuthorizeUser(nil),
|
||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.iperf", collectlogs.BUSINESS_TYPE_OTHER)),
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"be.ems/src/framework/i18n"
|
||||
"be.ems/src/framework/reqctx"
|
||||
"be.ems/src/framework/resp"
|
||||
"be.ems/src/framework/utils/parse"
|
||||
"be.ems/src/modules/trace/model"
|
||||
traceService "be.ems/src/modules/trace/service"
|
||||
|
||||
@@ -95,7 +96,7 @@ func (s *TraceTaskController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
CoreUID string `form:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
ID int64 `form:"id" binding:"required"` // 记录ID
|
||||
ID string `form:"id" binding:"required"` // 记录ID
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
@@ -103,7 +104,15 @@ func (s *TraceTaskController) Remove(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
rows, err := s.traceTaskService.DeleteByIds(query.ID, query.CoreUID)
|
||||
// 处理字符转id数组后去重
|
||||
uniqueIDs := parse.RemoveDuplicatesToArray(query.ID, ",")
|
||||
// 转换成int64数组类型
|
||||
ids := make([]int64, 0)
|
||||
for _, v := range uniqueIDs {
|
||||
ids = append(ids, parse.Number(v))
|
||||
}
|
||||
|
||||
rows, err := s.traceTaskService.DeleteByIds(ids, query.CoreUID)
|
||||
if err != nil {
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, err.Error())))
|
||||
return
|
||||
|
||||
@@ -89,7 +89,7 @@ func (s *TCPdump) DumpStart(coreUid, neUid, cmdStr string) (string, error) {
|
||||
|
||||
// 检查进程 ps aux | grep tcpdump
|
||||
// 强杀 sudo pkill tcpdump
|
||||
pidKey := fmt.Sprintf("%s_%s", neInfo.NeUID, taskCode)
|
||||
pidKey := fmt.Sprintf("%s_%s_%s", strings.ToLower(neInfo.NeType), neInfo.NeUID, taskCode)
|
||||
dumpPIDMap.Store(pidKey, PIDMap)
|
||||
return taskCode, err
|
||||
}
|
||||
|
||||
@@ -295,20 +295,20 @@ func (r TraceTask) traceNeTask(neInfo neModel.NeInfo, task model.TraceTask) erro
|
||||
}
|
||||
|
||||
// DeleteByIds 批量删除信息
|
||||
func (r TraceTask) DeleteByIds(id int64, coreUid string) (int64, error) {
|
||||
func (r TraceTask) DeleteByIds(ids []int64, coreUid string) (int64, error) {
|
||||
// 检查是否存在
|
||||
rows := r.traceTaskRepository.SelectByIds([]int64{id})
|
||||
if len(rows) != 1 {
|
||||
return 0, fmt.Errorf("not data")
|
||||
arr := r.traceTaskRepository.SelectByIds(ids)
|
||||
if len(arr) != len(ids) {
|
||||
return 0, fmt.Errorf("not match id")
|
||||
}
|
||||
|
||||
for _, v := range rows {
|
||||
for _, v := range arr {
|
||||
if v.CoreUID != coreUid {
|
||||
return 0, fmt.Errorf("data not match, id: %d", v.ID)
|
||||
}
|
||||
}
|
||||
// 删除数据同时给网元发送停止任务
|
||||
for _, v := range rows {
|
||||
for _, v := range arr {
|
||||
// 删除数据
|
||||
r.traceDataRepository.DeleteByTraceId(v.TraceId)
|
||||
|
||||
@@ -332,7 +332,7 @@ func (r TraceTask) DeleteByIds(id int64, coreUid string) (int64, error) {
|
||||
}
|
||||
}
|
||||
|
||||
num := r.traceTaskRepository.DeleteByIds([]int64{id})
|
||||
num := r.traceTaskRepository.DeleteByIds(ids)
|
||||
return num, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -33,10 +33,10 @@ import (
|
||||
func (s *WSController) ShellView(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
NeType string `form:"neType" binding:"required"` // 网元类型
|
||||
NeId string `form:"neId" binding:"required"` // 网元标识id
|
||||
Cols int `form:"cols"` // 终端单行字符数
|
||||
Rows int `form:"rows"` // 终端显示行数
|
||||
CoreUid string `form:"coreUid" binding:"required"` // 核心网唯一资源标识
|
||||
NeUid string `form:"neUid" binding:"required"` // 网元唯一资源标识
|
||||
Cols int `form:"cols"` // 终端单行字符数
|
||||
Rows int `form:"rows"` // 终端显示行数
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
@@ -58,7 +58,7 @@ func (s *WSController) ShellView(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 网元主机的SSH客户端
|
||||
sshClient, err := neService.NewNeInfo.NeRunSSHClient(query.NeType, query.NeId)
|
||||
sshClient, err := neService.NewNeInfo.NeRunSSHClient(query.CoreUid, query.NeUid)
|
||||
if err != nil {
|
||||
c.JSON(200, resp.ErrMsg(err.Error()))
|
||||
return
|
||||
|
||||
@@ -39,12 +39,12 @@ func GetNeState(requestID string, data any) ([]byte, error) {
|
||||
resultByte, err := json.Marshal(resp.Ok(map[string]any{
|
||||
"requestId": requestID,
|
||||
"data": map[string]any{
|
||||
"online": false,
|
||||
"coreUid": neInfo.CoreUID,
|
||||
"neUid": neInfo.NeUID,
|
||||
"neName": neInfo.NeName,
|
||||
"neType": neInfo.NeType,
|
||||
"neIPAddr": neInfo.IPAddr,
|
||||
"online": false,
|
||||
"coreUid": neInfo.CoreUID,
|
||||
"neUid": neInfo.NeUID,
|
||||
"neName": neInfo.NeName,
|
||||
"neType": neInfo.NeType,
|
||||
"ipAddr": neInfo.IPAddr,
|
||||
},
|
||||
}))
|
||||
return resultByte, err
|
||||
|
||||
@@ -3,6 +3,7 @@ package processor
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"be.ems/src/framework/logger"
|
||||
@@ -41,9 +42,15 @@ func GetNetConnections(requestID string, data any) ([]byte, error) {
|
||||
if query.Name != "" && !strings.Contains(name, query.Name) {
|
||||
continue
|
||||
}
|
||||
if query.Port > 0 && query.Port != int32(conn.Laddr.Port) && query.Port != int32(conn.Raddr.Port) {
|
||||
continue
|
||||
if query.Port > 0 {
|
||||
portStr := strconv.Itoa(int(query.Port))
|
||||
matchL := strings.HasPrefix(strconv.Itoa(int(conn.Laddr.Port)), portStr)
|
||||
matchR := strings.HasPrefix(strconv.Itoa(int(conn.Raddr.Port)), portStr)
|
||||
if !matchL && !matchR {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
dataArr = append(dataArr, model.NetConnectData{
|
||||
Type: netType,
|
||||
Status: conn.Status,
|
||||
|
||||
@@ -12,35 +12,35 @@ import (
|
||||
const (
|
||||
// 组号-其他
|
||||
GROUP_OTHER = "0"
|
||||
// 组号-跟踪任务网元数据变更 2_traceId
|
||||
// 组号-跟踪任务网元数据变更 2_taskId
|
||||
GROUP_TRACE_NE = "2"
|
||||
// 组号-信令跟踪Packet 4_taskNo
|
||||
// 组号-信令跟踪Packet 4_TaskNo
|
||||
GROUP_TRACE_PACKET = "4"
|
||||
// 组号-网元状态 8_neType_neId
|
||||
// 组号-网元状态 8_coreUid_neUid
|
||||
GROUP_NE_STATE = "8"
|
||||
// 组号-指标通用 10_neType_neId
|
||||
// 组号-指标通用 10_coreUid_neUid
|
||||
GROUP_KPI = "10"
|
||||
// 组号-自定义KPI指标 20_neType_neId
|
||||
// 组号-自定义KPI指标 20_coreUid_neUid
|
||||
GROUP_KPI_C = "20"
|
||||
// 组号-IMS_CDR会话事件 1005_neId
|
||||
// 组号-IMS_CDR会话事件 1005_coreUid_neUid
|
||||
GROUP_IMS_CDR = "1005"
|
||||
// 组号-SMF_CDR会话事件 1006_neId
|
||||
// 组号-SMF_CDR会话事件 1006_coreUid_neUid
|
||||
GROUP_SMF_CDR = "1006"
|
||||
// 组号-SMSC_CDR会话事件 1007_neId
|
||||
// 组号-SMSC_CDR会话事件 1007_coreUid_neUid
|
||||
GROUP_SMSC_CDR = "1007"
|
||||
// 组号-SGWC_CDR会话事件 1008_neId
|
||||
// 组号-SGWC_CDR会话事件 1008_coreUid_neUid
|
||||
GROUP_SGWC_CDR = "1008"
|
||||
// 组号-AMF_UE会话事件 1010_neId
|
||||
// 组号-AMF_UE会话事件 1010_coreUid_neUid
|
||||
GROUP_AMF_UE = "1010"
|
||||
// 组号-MME_UE会话事件 1011_neId
|
||||
// 组号-MME_UE会话事件 1011_coreUid_neUid
|
||||
GROUP_MME_UE = "1011"
|
||||
// 组号-AMF_NB状态事件 1014_neId
|
||||
// 组号-AMF_NB状态事件 1014_coreUid_neUid
|
||||
GROUP_AMF_NB = "1014"
|
||||
// 组号-MME_NB状态事件 1015_neId
|
||||
// 组号-MME_NB状态事件 1015_coreUid_neUid
|
||||
GROUP_MME_NB = "1015"
|
||||
// 组号-告警 2000_neType_neId
|
||||
// 组号-告警 2000_coreUid_neUid
|
||||
GROUP_ALARM = "2000"
|
||||
// 组号-告警事件 2002_neType_neId
|
||||
// 组号-告警事件 2002_coreUid_neUid
|
||||
GROUP_ALARM_EVENT = "2002"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user