alarm sequence

This commit is contained in:
2023-08-14 23:52:44 +08:00
parent 2cce814ceb
commit f056c8d7f8
2 changed files with 19 additions and 3 deletions

View File

@@ -238,6 +238,7 @@ func PostAlarmFromNF(w http.ResponseWriter, r *http.Request) {
log.Debug("valueJson:", valueJson)
session := xEngine.NewSession()
defer session.Close()
var activeAlarmNum int = 0
for _, alarmData := range *alarmArray {
log.Debug("alarmData:", alarmData)
if alarmData.AlarmStatus == AlarmStatusClear {
@@ -327,6 +328,7 @@ func PostAlarmFromNF(w http.ResponseWriter, r *http.Request) {
// for alarm forward time format
alarmData.EventTime = eventTime
} else {
activeAlarmNum++
has, err := xEngine.Table("alarm").
Where("alarm_id=? and ne_type=? and ne_id=? and alarm_status=1",
alarmData.AlarmId, alarmData.NeType, alarmData.NeId).
@@ -351,10 +353,9 @@ func PostAlarmFromNF(w http.ResponseWriter, r *http.Request) {
if has == true {
seq, _ := strconv.Atoi(currentSeq)
if seq+1 > global.MaxInt32Number {
alarmData.AlarmSeq = seq + activeAlarmNum
if alarmData.AlarmSeq > global.MaxInt32Number {
alarmData.AlarmSeq = AlarmSeqBeginNumber
} else {
alarmData.AlarmSeq = seq + 1
}
} else {
alarmData.AlarmSeq = AlarmSeqBeginNumber

View File

@@ -770,6 +770,21 @@ func XormCheckLoginUser(name, password, cryptArgo string) (bool, *User, error) {
return true, user, nil
}
func XormIsExistUser(accid string) (bool, error) {
log.Info("XormIsExistUser processing... ")
exist, err := xEngine.Table("user").
Where("account_id=?", accid).
Exist()
if err != nil {
log.Error("Failed to exist user:", err)
return false, err
}
return exist, nil
}
func XormGetConfigValue(moduleName, configTag string) (string, error) {
var value string
_, err := xEngine.Table("config").