Merge remote-tracking branch 'origin/main' into multi-tenant
This commit is contained in:
@@ -48,8 +48,8 @@ func (s *AlarmController) List(c *gin.Context) {
|
||||
querys.RmUID = neInfo.RmUID
|
||||
|
||||
// 查询数据
|
||||
data := s.alarmService.SelectPage(querys)
|
||||
c.JSON(200, result.Ok(data))
|
||||
rows, total := s.alarmService.SelectPage(querys)
|
||||
c.JSON(200, result.Ok(map[string]any{"rows": rows, "total": total}))
|
||||
}
|
||||
|
||||
// 告警删除
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"be.ems/src/framework/vo/result"
|
||||
"be.ems/src/modules/network_data/model"
|
||||
neDataService "be.ems/src/modules/network_data/service"
|
||||
neFetchlink "be.ems/src/modules/network_element/fetch_link"
|
||||
neService "be.ems/src/modules/network_element/service"
|
||||
sysService "be.ems/src/modules/system/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -57,7 +58,7 @@ func (s *AMFController) UEList(c *gin.Context) {
|
||||
// for multi-tenancy
|
||||
querys.UserName = ctx.LoginUserToUserName(c)
|
||||
// 查询数据
|
||||
data := s.ueEventService.SelectPage(querys)
|
||||
data := s.ueEventService.SelectPageMT(querys)
|
||||
c.JSON(200, result.Ok(data))
|
||||
}
|
||||
|
||||
@@ -105,7 +106,7 @@ func (s *AMFController) UEExport(c *gin.Context) {
|
||||
if querys.PageSize > 10000 {
|
||||
querys.PageSize = 10000
|
||||
}
|
||||
data := s.ueEventService.SelectPage(querys)
|
||||
data := s.ueEventService.SelectPageMT(querys)
|
||||
if parse.Number(data["total"]) == 0 {
|
||||
// 导出数据记录为空
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
|
||||
@@ -215,3 +216,36 @@ func (s *AMFController) UEExport(c *gin.Context) {
|
||||
|
||||
c.FileAttachment(saveFilePath, fileName)
|
||||
}
|
||||
|
||||
// 接入基站信息列表
|
||||
//
|
||||
// GET /nb/list
|
||||
func (s *AMFController) NbInfoList(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
NeId string `form:"neId" binding:"required"`
|
||||
NbId string `form:"nbId"`
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
|
||||
// 查询网元信息
|
||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("AMF", query.NeId)
|
||||
if neInfo.NeId != query.NeId || neInfo.IP == "" {
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
|
||||
// 网元直连
|
||||
data, err := neFetchlink.AMFNbInfoList(neInfo, map[string]string{
|
||||
"nbId": query.NbId,
|
||||
})
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, result.OkData(data))
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"be.ems/src/framework/vo/result"
|
||||
"be.ems/src/modules/network_data/model"
|
||||
neDataService "be.ems/src/modules/network_data/service"
|
||||
neFetchlink "be.ems/src/modules/network_element/fetch_link"
|
||||
neService "be.ems/src/modules/network_element/service"
|
||||
sysService "be.ems/src/modules/system/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -58,7 +59,7 @@ func (s *IMSController) CDRList(c *gin.Context) {
|
||||
querys.RmUID = neInfo.RmUID
|
||||
|
||||
// 查询数据
|
||||
data := s.cdrEventService.SelectPage(querys)
|
||||
data := s.cdrEventService.SelectPageMT(querys)
|
||||
c.JSON(200, result.Ok(data))
|
||||
}
|
||||
|
||||
@@ -113,7 +114,7 @@ func (s *IMSController) CDRExport(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
querys.RmUID = neInfo.RmUID
|
||||
data := s.cdrEventService.SelectPage(querys)
|
||||
data := s.cdrEventService.SelectPageMT(querys)
|
||||
if parse.Number(data["total"]) == 0 {
|
||||
// 导出数据记录为空
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
|
||||
@@ -155,16 +156,6 @@ func (s *IMSController) CDRExport(c *gin.Context) {
|
||||
if v, ok := cdrJSON["recordType"]; ok && v != nil {
|
||||
recordType = v.(string)
|
||||
}
|
||||
// 被叫
|
||||
called := ""
|
||||
if v, ok := cdrJSON["calledParty"]; ok && v != nil {
|
||||
called = v.(string)
|
||||
}
|
||||
// 主叫
|
||||
caller := ""
|
||||
if v, ok := cdrJSON["callerParty"]; ok && v != nil {
|
||||
caller = v.(string)
|
||||
}
|
||||
// 呼叫类型
|
||||
callType := "sms"
|
||||
callTypeLable := "SMS"
|
||||
@@ -177,6 +168,16 @@ func (s *IMSController) CDRExport(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// 被叫
|
||||
called := ""
|
||||
if v, ok := cdrJSON["calledParty"]; ok && v != nil {
|
||||
called = v.(string)
|
||||
}
|
||||
// 主叫
|
||||
caller := ""
|
||||
if v, ok := cdrJSON["callerParty"]; ok && v != nil {
|
||||
caller = v.(string)
|
||||
}
|
||||
// 时长
|
||||
duration := "-"
|
||||
if v, ok := cdrJSON["callDuration"]; ok && v != nil && callType != "sms" {
|
||||
@@ -196,8 +197,11 @@ func (s *IMSController) CDRExport(c *gin.Context) {
|
||||
// 取时间
|
||||
timeStr := ""
|
||||
if v, ok := cdrJSON["releaseTime"]; ok && v != nil {
|
||||
releaseTime := parse.Number(v)
|
||||
timeStr = date.ParseDateToStr(releaseTime, date.YYYY_MM_DDTHH_MM_SSZ)
|
||||
if releaseTime := parse.Number(v); releaseTime > 0 {
|
||||
timeStr = date.ParseDateToStr(releaseTime, date.YYYY_MM_DDTHH_MM_SSZ)
|
||||
} else {
|
||||
timeStr = v.(string)
|
||||
}
|
||||
}
|
||||
// for multi-tenant, get tenant name
|
||||
tenantName := row.TenantName
|
||||
@@ -224,3 +228,68 @@ func (s *IMSController) CDRExport(c *gin.Context) {
|
||||
|
||||
c.FileAttachment(saveFilePath, fileName)
|
||||
}
|
||||
|
||||
// 在线会话用户数量
|
||||
//
|
||||
// GET /session/num
|
||||
func (s *IMSController) UeSessionNum(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
NeId string `form:"neId" binding:"required"`
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
|
||||
// 查询网元信息
|
||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("IMS", query.NeId)
|
||||
if neInfo.NeId != query.NeId || neInfo.IP == "" {
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
|
||||
// 网元直连
|
||||
num, err := neFetchlink.IMSUeSessionNum(neInfo)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, result.OkData(num))
|
||||
}
|
||||
|
||||
// 在线会话用户列表信息
|
||||
//
|
||||
// GET /session/list
|
||||
func (s *IMSController) UeSessionList(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
NeId string `form:"neId" binding:"required"`
|
||||
IMSI string `form:"imsi"`
|
||||
MSISDN string `form:"msisdn"`
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
|
||||
// 查询网元信息
|
||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("IMS", query.NeId)
|
||||
if neInfo.NeId != query.NeId || neInfo.IP == "" {
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
|
||||
// 网元直连
|
||||
data, err := neFetchlink.IMSUeSessionList(neInfo, map[string]string{
|
||||
"imsi": query.IMSI,
|
||||
"msisdn": query.MSISDN,
|
||||
})
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, result.OkData(data))
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"be.ems/src/framework/vo/result"
|
||||
"be.ems/src/modules/network_data/model"
|
||||
neDataService "be.ems/src/modules/network_data/service"
|
||||
neFetchlink "be.ems/src/modules/network_element/fetch_link"
|
||||
neService "be.ems/src/modules/network_element/service"
|
||||
sysService "be.ems/src/modules/system/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -58,7 +59,7 @@ func (s *MMEController) UEList(c *gin.Context) {
|
||||
// for multi-tenancy
|
||||
querys.UserName = ctx.LoginUserToUserName(c)
|
||||
// 查询数据
|
||||
data := s.ueEventService.SelectPage(querys)
|
||||
data := s.ueEventService.SelectPageMT(querys)
|
||||
c.JSON(200, result.Ok(data))
|
||||
}
|
||||
|
||||
@@ -106,7 +107,7 @@ func (s *MMEController) UEExport(c *gin.Context) {
|
||||
if querys.PageSize > 10000 {
|
||||
querys.PageSize = 10000
|
||||
}
|
||||
data := s.ueEventService.SelectPage(querys)
|
||||
data := s.ueEventService.SelectPageMT(querys)
|
||||
if parse.Number(data["total"]) == 0 {
|
||||
// 导出数据记录为空
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
|
||||
@@ -205,3 +206,36 @@ func (s *MMEController) UEExport(c *gin.Context) {
|
||||
|
||||
c.FileAttachment(saveFilePath, fileName)
|
||||
}
|
||||
|
||||
// 接入基站信息列表
|
||||
//
|
||||
// GET /nb/list
|
||||
func (s *MMEController) NbInfoList(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
NeId string `form:"neId" binding:"required"`
|
||||
NbId string `form:"nbId"`
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
|
||||
// 查询网元信息
|
||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("MME", query.NeId)
|
||||
if neInfo.NeId != query.NeId || neInfo.IP == "" {
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
|
||||
// 网元直连
|
||||
data, err := neFetchlink.MMENbInfoList(neInfo, map[string]string{
|
||||
"nbId": query.NbId,
|
||||
})
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, result.OkData(data))
|
||||
}
|
||||
|
||||
292
src/modules/network_data/controller/sgwc.go
Normal file
292
src/modules/network_data/controller/sgwc.go
Normal file
@@ -0,0 +1,292 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"be.ems/src/framework/i18n"
|
||||
"be.ems/src/framework/logger"
|
||||
"be.ems/src/framework/utils/ctx"
|
||||
"be.ems/src/framework/utils/file"
|
||||
"be.ems/src/framework/utils/parse"
|
||||
"be.ems/src/framework/vo/result"
|
||||
"be.ems/src/modules/network_data/model"
|
||||
neDataService "be.ems/src/modules/network_data/service"
|
||||
neService "be.ems/src/modules/network_element/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// 实例化控制层 SGWCController 结构体
|
||||
var NewSGWC = &SGWCController{
|
||||
neInfoService: neService.NewNeInfo,
|
||||
cdrEventService: neDataService.NewCDREventSGWC,
|
||||
udmUserInfoService: neDataService.NewUDMUserInfo,
|
||||
}
|
||||
|
||||
// 网元SGWC
|
||||
//
|
||||
// PATH /SGWC
|
||||
type SGWCController struct {
|
||||
neInfoService *neService.NeInfo // 网元信息服务
|
||||
cdrEventService *neDataService.CDREventSGWC // CDR会话事件服务
|
||||
udmUserInfoService *neDataService.UDMUserInfo // UDM用户信息服务
|
||||
}
|
||||
|
||||
// CDR会话列表
|
||||
//
|
||||
// GET /cdr/list
|
||||
func (s *SGWCController) CDRList(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var querys model.CDREventSGWCQuery
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
|
||||
// 查询网元信息 rmUID
|
||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(querys.NeType, querys.NeID)
|
||||
if neInfo.NeId != querys.NeID || neInfo.IP == "" {
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
querys.RmUID = neInfo.RmUID
|
||||
|
||||
// 查询数据
|
||||
rows, total := s.cdrEventService.SelectPage(querys)
|
||||
c.JSON(200, result.Ok(map[string]any{"rows": rows, "total": total}))
|
||||
}
|
||||
|
||||
// CDR会话删除
|
||||
//
|
||||
// DELETE /cdr/:cdrIds
|
||||
func (s *SGWCController) CDRRemove(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
cdrIds := c.Param("cdrIds")
|
||||
if cdrIds == "" {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
// 处理字符转id数组后去重
|
||||
ids := strings.Split(cdrIds, ",")
|
||||
uniqueIDs := parse.RemoveDuplicates(ids)
|
||||
if len(uniqueIDs) <= 0 {
|
||||
c.JSON(200, result.Err(nil))
|
||||
return
|
||||
}
|
||||
rows, err := s.cdrEventService.DeleteByIds(uniqueIDs)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, err.Error())))
|
||||
return
|
||||
}
|
||||
msg := i18n.TTemplate(language, "app.common.deleteSuccess", map[string]any{"num": rows})
|
||||
c.JSON(200, result.OkMsg(msg))
|
||||
}
|
||||
|
||||
// CDR会话列表导出
|
||||
//
|
||||
// POST /cdr/export
|
||||
func (s *SGWCController) CDRExport(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
// 查询结果,根据查询条件结果,单页最大值限制
|
||||
var querys model.CDREventSGWCQuery
|
||||
if err := c.ShouldBindBodyWithJSON(&querys); err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
// 限制导出数据集
|
||||
if querys.PageSize > 10000 {
|
||||
querys.PageSize = 10000
|
||||
}
|
||||
// 查询网元信息 rmUID
|
||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(querys.NeType, querys.NeID)
|
||||
if neInfo.NeId != querys.NeID || neInfo.IP == "" {
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
querys.RmUID = neInfo.RmUID
|
||||
rows, total := s.cdrEventService.SelectPage(querys)
|
||||
if total == 0 {
|
||||
// 导出数据记录为空
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
|
||||
return
|
||||
}
|
||||
|
||||
// 导出文件名称
|
||||
fileName := fmt.Sprintf("sgwc_cdr_event_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
|
||||
// 第一行表头标题
|
||||
headerCells := map[string]string{
|
||||
"A1": "ID",
|
||||
"B1": "NE Name",
|
||||
"C1": "Resource Unique ID",
|
||||
"D1": "Charging ID",
|
||||
"E1": "IMSI",
|
||||
"F1": "MSISDN",
|
||||
"G1": "GPRS Uplink",
|
||||
"H1": "GPRS Downlink",
|
||||
"I1": "Duration",
|
||||
"J1": "Invocation Time",
|
||||
"K1": "PGW Address Used",
|
||||
"L1": "SGW Address",
|
||||
"M1": "RAT Type",
|
||||
"N1": "PDPPDN Type",
|
||||
"O1": "PDPPDN Address",
|
||||
"P1": "Node Address",
|
||||
"Q1": "Node Type",
|
||||
"R1": "Record Access Point Name NI",
|
||||
"S1": "Record Cause For Rec Closing",
|
||||
"T1": "Record Sequence Number",
|
||||
"U1": "Local Record Sequence Number",
|
||||
}
|
||||
// 从第二行开始的数据
|
||||
dataCells := make([]map[string]any, 0)
|
||||
for i, row := range rows {
|
||||
idx := strconv.Itoa(i + 2)
|
||||
// 解析 JSON 字符串为 map
|
||||
var cdrJSON map[string]interface{}
|
||||
err := json.Unmarshal([]byte(row.CDRJSONStr), &cdrJSON)
|
||||
if err != nil {
|
||||
logger.Warnf("CDRExport Error parsing JSON: %s", err.Error())
|
||||
continue
|
||||
}
|
||||
// 计费ID
|
||||
chargingID := ""
|
||||
if v, ok := cdrJSON["chargingID"]; ok && v != nil {
|
||||
chargingID = fmt.Sprint(parse.Number(v))
|
||||
}
|
||||
// IMSI
|
||||
servedIMSI := ""
|
||||
if v, ok := cdrJSON["servedIMSI"]; ok && v != nil {
|
||||
servedIMSI = fmt.Sprint(v)
|
||||
}
|
||||
// MSISDN
|
||||
servedMSISDN := ""
|
||||
if v, ok := cdrJSON["servedMSISDN"]; ok && v != nil {
|
||||
servedMSISDN = fmt.Sprint(v)
|
||||
}
|
||||
// pGWAddressUsed
|
||||
pGWAddressUsed := ""
|
||||
if v, ok := cdrJSON["pGWAddressUsed"]; ok && v != nil {
|
||||
pGWAddressUsed = fmt.Sprint(v)
|
||||
}
|
||||
// sGWAddress
|
||||
sGWAddress := ""
|
||||
if v, ok := cdrJSON["sGWAddress"]; ok && v != nil {
|
||||
sGWAddress = fmt.Sprint(v)
|
||||
}
|
||||
// rATType
|
||||
rATType := ""
|
||||
if v, ok := cdrJSON["rATType"]; ok && v != nil {
|
||||
rATType = fmt.Sprint(v)
|
||||
}
|
||||
// pdpPDNType
|
||||
pdpPDNType := ""
|
||||
if v, ok := cdrJSON["pdpPDNType"]; ok && v != nil {
|
||||
pdpPDNType = fmt.Sprint(v)
|
||||
}
|
||||
// servedPDPPDNAddress
|
||||
servedPDPPDNAddress := ""
|
||||
if v, ok := cdrJSON["servedPDPPDNAddress"]; ok && v != nil {
|
||||
servedPDPPDNAddress = fmt.Sprint(v)
|
||||
}
|
||||
// servedPDPPDNAddress
|
||||
servingNodeAddress := []string{}
|
||||
if v, ok := cdrJSON["servingNodeAddress"]; ok && v != nil {
|
||||
for _, v := range v.([]any) {
|
||||
servingNodeAddress = append(servingNodeAddress, fmt.Sprint(v))
|
||||
}
|
||||
}
|
||||
// servingNodeType
|
||||
servingNodeType := []string{}
|
||||
if v, ok := cdrJSON["servingNodeType"]; ok && v != nil {
|
||||
for _, v := range v.([]any) {
|
||||
if v, ok := v.(map[string]any)["servingNodeType"]; ok && v != nil {
|
||||
servingNodeType = append(servingNodeType, fmt.Sprint(v))
|
||||
}
|
||||
}
|
||||
}
|
||||
// accessPointNameNI
|
||||
accessPointNameNI := ""
|
||||
if v, ok := cdrJSON["accessPointNameNI"]; ok && v != nil {
|
||||
accessPointNameNI = fmt.Sprint(v)
|
||||
}
|
||||
// causeForRecClosing
|
||||
causeForRecClosing := ""
|
||||
if v, ok := cdrJSON["causeForRecClosing"]; ok && v != nil {
|
||||
causeForRecClosing = fmt.Sprint(v)
|
||||
}
|
||||
// recordSequenceNumber
|
||||
recordSequenceNumber := ""
|
||||
if v, ok := cdrJSON["recordSequenceNumber"]; ok && v != nil {
|
||||
recordSequenceNumber = fmt.Sprint(v)
|
||||
}
|
||||
// localRecordSequenceNumber
|
||||
localRecordSequenceNumber := ""
|
||||
if v, ok := cdrJSON["localRecordSequenceNumber"]; ok && v != nil {
|
||||
localRecordSequenceNumber = fmt.Sprint(v)
|
||||
}
|
||||
// 数据量上行链路
|
||||
dataVolumeGPRSUplink := []string{}
|
||||
// 数据量下行链路
|
||||
dataVolumeGPRSDownlink := []string{}
|
||||
if v, ok := cdrJSON["listOfTrafficVolumes"]; ok && v != nil {
|
||||
usageList := v.([]any)
|
||||
if len(usageList) > 0 {
|
||||
for _, used := range usageList {
|
||||
usedUnit := used.(map[string]any)
|
||||
if dup, dupOk := usedUnit["dataVolumeGPRSUplink"]; dupOk {
|
||||
dataVolumeGPRSUplink = append(dataVolumeGPRSUplink, fmt.Sprint(parse.Number(dup)))
|
||||
}
|
||||
if ddown, ddownOk := usedUnit["dataVolumeGPRSDownlink"]; ddownOk {
|
||||
dataVolumeGPRSDownlink = append(dataVolumeGPRSDownlink, fmt.Sprint(parse.Number(ddown)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 时长
|
||||
duration := "-"
|
||||
if v, ok := cdrJSON["duration"]; ok && v != nil {
|
||||
duration = fmt.Sprint(parse.Number(v))
|
||||
}
|
||||
// 调用时间
|
||||
invocationTimestamp := ""
|
||||
if v, ok := cdrJSON["recordOpeningTime"]; ok && v != nil {
|
||||
invocationTimestamp = v.(string)
|
||||
}
|
||||
|
||||
dataCells = append(dataCells, map[string]any{
|
||||
"A" + idx: row.ID,
|
||||
"B" + idx: row.NeName,
|
||||
"C" + idx: row.RmUID,
|
||||
"D" + idx: chargingID,
|
||||
"E" + idx: servedIMSI,
|
||||
"F" + idx: servedMSISDN,
|
||||
"G" + idx: strings.Join(dataVolumeGPRSUplink, ","),
|
||||
"H" + idx: strings.Join(dataVolumeGPRSDownlink, ","),
|
||||
"I" + idx: duration,
|
||||
"J" + idx: invocationTimestamp,
|
||||
"K" + idx: pGWAddressUsed,
|
||||
"L" + idx: sGWAddress,
|
||||
"M" + idx: rATType,
|
||||
"N" + idx: pdpPDNType,
|
||||
"O" + idx: servedPDPPDNAddress,
|
||||
"P" + idx: strings.Join(servingNodeAddress, ","),
|
||||
"Q" + idx: strings.Join(servingNodeType, ","),
|
||||
"R" + idx: accessPointNameNI,
|
||||
"S" + idx: causeForRecClosing,
|
||||
"T" + idx: recordSequenceNumber,
|
||||
"U" + idx: localRecordSequenceNumber,
|
||||
})
|
||||
}
|
||||
|
||||
// 导出数据表格
|
||||
saveFilePath, err := file.WriteSheet(headerCells, dataCells, fileName, "")
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
c.FileAttachment(saveFilePath, fileName)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func (s *SMFController) CDRList(c *gin.Context) {
|
||||
querys.RmUID = neInfo.RmUID
|
||||
|
||||
// 查询数据
|
||||
data := s.cdrEventService.SelectPage(querys)
|
||||
data := s.cdrEventService.SelectPageMT(querys)
|
||||
c.JSON(200, result.Ok(data))
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ func (s *SMFController) CDRExport(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
querys.RmUID = neInfo.RmUID
|
||||
data := s.cdrEventService.SelectPage(querys)
|
||||
data := s.cdrEventService.SelectPageMT(querys)
|
||||
if parse.Number(data["total"]) == 0 {
|
||||
// 导出数据记录为空
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
|
||||
@@ -326,9 +326,39 @@ func (s *SMFController) CDRExport(c *gin.Context) {
|
||||
c.FileAttachment(saveFilePath, fileName)
|
||||
}
|
||||
|
||||
// 在线订阅用户数量
|
||||
//
|
||||
// GET /sub/num
|
||||
func (s *SMFController) SubUserNum(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
NeId string `form:"neId" binding:"required"`
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
|
||||
// 查询网元信息
|
||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("SMF", query.NeId)
|
||||
if neInfo.NeId != query.NeId || neInfo.IP == "" {
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
|
||||
// 网元直连
|
||||
num, err := neFetchlink.SMFSubNum(neInfo)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, result.OkData(num))
|
||||
}
|
||||
|
||||
// 在线订阅用户列表信息
|
||||
//
|
||||
// GET /subscribers
|
||||
// GET /sub/list
|
||||
func (s *SMFController) SubUserList(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
@@ -343,7 +373,7 @@ func (s *SMFController) SubUserList(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 查询网元信息 rmUID
|
||||
// 查询网元信息
|
||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("SMF", query.NeId)
|
||||
if neInfo.NeId != query.NeId || neInfo.IP == "" {
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"be.ems/src/modules/network_data/model"
|
||||
neDataService "be.ems/src/modules/network_data/service"
|
||||
neService "be.ems/src/modules/network_element/service"
|
||||
sysService "be.ems/src/modules/system/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
)
|
||||
@@ -57,7 +58,7 @@ func (s *SMSCController) CDRList(c *gin.Context) {
|
||||
querys.RmUID = neInfo.RmUID
|
||||
|
||||
// 查询数据
|
||||
data := s.cdrEventService.SelectPage(querys)
|
||||
data := s.cdrEventService.SelectPageMT(querys)
|
||||
c.JSON(200, result.Ok(data))
|
||||
}
|
||||
|
||||
@@ -112,7 +113,7 @@ func (s *SMSCController) CDRExport(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
querys.RmUID = neInfo.RmUID
|
||||
data := s.cdrEventService.SelectPage(querys)
|
||||
data := s.cdrEventService.SelectPageMT(querys)
|
||||
if parse.Number(data["total"]) == 0 {
|
||||
// 导出数据记录为空
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
|
||||
@@ -133,6 +134,8 @@ func (s *SMSCController) CDRExport(c *gin.Context) {
|
||||
"G1": "Time",
|
||||
"H1": "Tenant Name", // for multi-tenancy
|
||||
}
|
||||
// 读取字典数据 CDR 原因码
|
||||
dictCDRCauseCode := sysService.NewSysDictData.SelectDictDataByType("cdr_cause_code")
|
||||
// 从第二行开始的数据
|
||||
dataCells := make([]map[string]any, 0)
|
||||
for i, row := range rows {
|
||||
@@ -172,11 +175,24 @@ func (s *SMSCController) CDRExport(c *gin.Context) {
|
||||
callResult = "Success"
|
||||
}
|
||||
}
|
||||
// 结果原因
|
||||
if v, ok := cdrJSON["cause"]; ok && v != nil && callResult == "Fail" {
|
||||
cause := fmt.Sprint(v)
|
||||
for _, v := range dictCDRCauseCode {
|
||||
if cause == v.DictValue {
|
||||
callResult = fmt.Sprintf("%s, %s", callResult, i18n.TKey(language, v.DictLabel))
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
// 取时间
|
||||
timeStr := ""
|
||||
if v, ok := cdrJSON["updateTime"]; ok && v != nil {
|
||||
releaseTime := parse.Number(v)
|
||||
timeStr = date.ParseDateToStr(releaseTime, date.YYYY_MM_DDTHH_MM_SSZ)
|
||||
if releaseTime := parse.Number(v); releaseTime > 0 {
|
||||
timeStr = date.ParseDateToStr(releaseTime, date.YYYY_MM_DDTHH_MM_SSZ)
|
||||
} else {
|
||||
timeStr = v.(string)
|
||||
}
|
||||
}
|
||||
// for multi-tenant, get tenant name
|
||||
tenantName := row.TenantName
|
||||
|
||||
@@ -381,7 +381,7 @@ func (s *UDMAuthController) Export(c *gin.Context) {
|
||||
|
||||
// 文件名
|
||||
fileName := fmt.Sprintf("udm_auth_user_export_%s_%d.%s", neId, time.Now().UnixMilli(), fileType)
|
||||
filePath := fmt.Sprintf("%s/%s", file.ParseUploadFileDir(uploadsubpath.EXPORT), fileName)
|
||||
filePath := filepath.Join(file.ParseUploadFileDir(uploadsubpath.EXPORT), fileName)
|
||||
|
||||
if fileType == "csv" {
|
||||
// 转换数据
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
|
||||
// 实例化控制层 UDMSubController 结构体
|
||||
var NewUDMSub = &UDMSubController{
|
||||
udmSubService: neDataService.NewUDMSub,
|
||||
udmSubService: neDataService.NewUDMSubUser,
|
||||
neInfoService: neService.NewNeInfo,
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ func (s *UDMSubController) Export(c *gin.Context) {
|
||||
|
||||
// 文件名
|
||||
fileName := fmt.Sprintf("udm_sub_user_export_%s_%d.%s", neId, time.Now().UnixMilli(), fileType)
|
||||
filePath := fmt.Sprintf("%s/%s", file.ParseUploadFileDir(uploadsubpath.EXPORT), fileName)
|
||||
filePath := filepath.Join(file.ParseUploadFileDir(uploadsubpath.EXPORT), fileName)
|
||||
|
||||
if fileType == "csv" {
|
||||
// 转换数据
|
||||
|
||||
Reference in New Issue
Block a user