From 7f726283ba931eaaeda22e09d533e59a4febadae Mon Sep 17 00:00:00 2001 From: 18209 Date: Tue, 22 Jul 2025 11:15:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E5=91=8A=E8=AD=A6=E5=81=9A?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- consumers/consumerSavoirTheme.go | 6 +++++- dbOperate/elasticsearchHelper.go | 12 ++++++------ models/esTheme.go | 1 + 3 files changed, 12 insertions(+), 7 deletions(-) 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 {