diff --git a/consumers/consumerSavoirTheme.go b/consumers/consumerSavoirTheme.go index f0fc38d..8784fcf 100644 --- a/consumers/consumerSavoirTheme.go +++ b/consumers/consumerSavoirTheme.go @@ -156,7 +156,11 @@ func (the *consumerSavoirTheme) judgeOffline() { log.Printf("查询es 异常") } for _, alarmThemeName := range allAlarmThemes { - if theme.SensorName == alarmThemeName { + StateValue := true + if alarmThemeName.State == 0 || alarmThemeName.State == 1 || alarmThemeName.State == 2 { + StateValue = false + } + if theme.SensorName == alarmThemeName.SensorName && StateValue == true { if offlineMin < float64(gap.OfflineGap) { alarmMsg := models.KafkaAlarm{ MessageMode: "AlarmAutoElimination", diff --git a/dbOperate/elasticsearchHelper.go b/dbOperate/elasticsearchHelper.go index 587e198..22d49ae 100644 --- a/dbOperate/elasticsearchHelper.go +++ b/dbOperate/elasticsearchHelper.go @@ -208,17 +208,17 @@ func (the *ESHelper) SearchThemeData(index string, queryBody string) ([]models.E return themes, err } -func (the *ESHelper) SearchAlarmThemeData(index string, queryBody string) ([]string, error) { - var sensorNames []string +func (the *ESHelper) SearchAlarmThemeData(index string, queryBody string) ([]models.EsAlarmTheme, error) { + var sensors []models.EsAlarmTheme themesResp, err := the.searchAlarmThemes(index, queryBody) - var sensorName string + var sensor models.EsAlarmTheme for _, themesResptheme := range themesResp.Hits.Hits { - sensorName = themesResptheme.Source.SensorName - sensorNames = append(sensorNames, sensorName) + sensor = themesResptheme.Source + sensors = append(sensors, sensor) } - return sensorNames, err + return sensors, err } func (the *ESHelper) BulkWrite(index, reqBody string) { diff --git a/models/esTheme.go b/models/esTheme.go index 1e15871..ccaa4e8 100644 --- a/models/esTheme.go +++ b/models/esTheme.go @@ -20,6 +20,7 @@ type EsAlarmTheme struct { SensorName string `json:"source_name"` SensorId string `json:"source_id"` Detail string `json:"detail"` + State int `json:"state"` } type EsThemeResp struct {