diff --git a/consumers/consumerAxySkAlarm.go b/consumers/consumerAxySkAlarm.go index 1bba256..ca61814 100644 --- a/consumers/consumerAxySkAlarm.go +++ b/consumers/consumerAxySkAlarm.go @@ -241,10 +241,12 @@ func (the *consumerAxySkAlarm) judgeSK() string { } func (the *consumerAxySkAlarm) isHistoryAlarm(sourceId string, level int, alarmTime time.Time) (bool, string) { + isHis := false //特别注意 告警进程:产生一级后,后续触发二级 也会算到一级头上,所有双控产生二级 如果二级不存在 要往上高等级判断 rawK := fmt.Sprintf("%s_%s", sourceId, fmt.Sprintf("3077000%d", level)) + hisK := rawK for i := level; i >= 1; i-- { - hisK := fmt.Sprintf("%s_%s", sourceId, fmt.Sprintf("3077000%d", i)) + hisK = fmt.Sprintf("%s_%s", sourceId, fmt.Sprintf("3077000%d", i)) if hv, ok := the.historyStationAlarmMap[hisK]; ok { if !alarmTime.After(hv.Time) { log.Printf("测点[%s]本次触发时刻[%s]%s(实际es=%s) 对比历史有效时刻[%s] 非新", @@ -254,18 +256,19 @@ func (the *consumerAxySkAlarm) isHistoryAlarm(sourceId string, level int, alarmT hisK, hv.Time.Format("2006-01-02 15:04:05.000"), ) + isHis = true continue } if hv.AlarmLevel < level { //低等级告警过滤 log.Printf("测点[%s]本次触发 %s(实际es=%s) 低于 历史有效等级%d,历史时刻%s,不再重复触发", sourceId, rawK, hisK, hv.AlarmLevel, hv.Time.Format("2006-01-02 15:04:05.000")) + isHis = true continue } - return false, hisK } } - return true, rawK + return isHis, hisK } func (the *consumerAxySkAlarm) skAlarmInfo(alarmInfoTemplate *models.EsAlarm, level int, detail string, alarmTime time.Time, triggerTypeCodes []string) []byte {