refactor: 移除未使用的函数和导入,优化告警处理逻辑
This commit is contained in:
@@ -5,13 +5,10 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"be.ems/lib/config"
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/core/ctx"
|
"be.ems/lib/core/ctx"
|
||||||
"be.ems/lib/dborm"
|
|
||||||
"be.ems/lib/global"
|
"be.ems/lib/global"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
@@ -105,32 +102,7 @@ var (
|
|||||||
CustomUriAlarmsFmt = config.UriPrefix + "/faultManagement/v1/elementType/%s/objectType/alarms"
|
CustomUriAlarmsFmt = config.UriPrefix + "/faultManagement/v1/elementType/%s/objectType/alarms"
|
||||||
)
|
)
|
||||||
|
|
||||||
func IsNeedToAckAlarm(valueJson *dborm.ValueJson, alarm *Alarm) bool {
|
// PostAlarmFromNF 网元告警数据上报接收
|
||||||
log.Info("IsNeedToAckAlarm processing... ")
|
|
||||||
if valueJson != nil {
|
|
||||||
status, _ := strconv.Atoi(valueJson.AlarmStatus)
|
|
||||||
log.Tracef("alarm.AlarmStatus=%d, alarm.AlarmType=%s, alarm.OrigSeverity=%s", alarm.AlarmStatus, alarm.AlarmType, alarm.OrigSeverity)
|
|
||||||
log.Tracef("status=%d, valueJson.AlarmType=%s, valueJson.OrigSeverity=%s", status, valueJson.AlarmType, valueJson.OrigSeverity)
|
|
||||||
|
|
||||||
if alarm.AlarmStatus == status &&
|
|
||||||
alarm.AlarmType == valueJson.AlarmType &&
|
|
||||||
alarm.OrigSeverity == valueJson.OrigSeverity {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetAlarmAckInfo(valueJson *dborm.ValueJson, alarm *Alarm) {
|
|
||||||
log.Info("SetAlarmAckInfo processing... ")
|
|
||||||
alarm.AckState = AckStateAcked
|
|
||||||
alarm.AckTime.Valid = true
|
|
||||||
alarm.AckTime.Time = time.Now()
|
|
||||||
alarm.AckUser = valueJson.AckUser
|
|
||||||
}
|
|
||||||
|
|
||||||
// process alarm post message from NFs
|
|
||||||
func PostAlarmFromNF(w http.ResponseWriter, r *http.Request) {
|
func PostAlarmFromNF(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Debug("PostAlarmFromNF processing... ")
|
log.Debug("PostAlarmFromNF processing... ")
|
||||||
apiVer := ctx.GetParam(r, "apiVersion")
|
apiVer := ctx.GetParam(r, "apiVersion")
|
||||||
@@ -512,7 +484,7 @@ func mapToAlarm(data []map[string]any) []Alarm {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// process alarm get from NFs
|
// GetAlarmFromNF 告警历史数据,从网元获取
|
||||||
func GetAlarmFromNF(w http.ResponseWriter, r *http.Request) {
|
func GetAlarmFromNF(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Debug("GetAlarmFromNF processing... ")
|
log.Debug("GetAlarmFromNF processing... ")
|
||||||
neType := ctx.GetParam(r, "elementTypeValue")
|
neType := ctx.GetParam(r, "elementTypeValue")
|
||||||
@@ -591,5 +563,5 @@ func GetAlarmFromNF(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
services.ResponseStatusOK204NoContent(w)
|
services.ResponseWithJson(w, 200, resp.OkMsg("sync alarms success"))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user