|
|
@ -112,12 +112,18 @@ func (the *consumerAxySkAlarm) monitorInitial() error { |
|
|
|
|
|
|
|
func (the *consumerAxySkAlarm) updateTriggerStationConfig() { |
|
|
|
log.Printf("--> 定时 查询pg 更新 双控配置信息") |
|
|
|
sql := `SELECT at.*,s.id as station_id,s.name as station_name |
|
|
|
FROM t_alarm_trigger as at |
|
|
|
left join t_sensor s |
|
|
|
on at.struct_id=s.structure |
|
|
|
and at.factor_id=s.factor |
|
|
|
order by s.id,at.alarm_level;` |
|
|
|
sql := `SELECT |
|
|
|
at.*, |
|
|
|
s.id as station_id, |
|
|
|
s.name as station_name, |
|
|
|
ts.name as struct_name |
|
|
|
FROM t_alarm_trigger as at |
|
|
|
left join t_sensor s |
|
|
|
on at.struct_id = s.structure |
|
|
|
and at.factor_id = s.factor |
|
|
|
left join t_structure ts |
|
|
|
on at.struct_id = ts.id |
|
|
|
order by s.id, at.alarm_level;` |
|
|
|
err := the.infoPg.Query(&the.stationAlarmTrigger, sql) |
|
|
|
if err != nil { |
|
|
|
log.Printf("查询数据库异常:err-> %s", err.Error()) |
|
|
@ -139,6 +145,7 @@ func (the *consumerAxySkAlarm) updateTriggerStationConfig() { |
|
|
|
ConditionArray: trigger.ConditionRaw, |
|
|
|
Rule: trigger.Rule, |
|
|
|
StationIds: []int{trigger.StationId}, |
|
|
|
StructName: trigger.StructName, |
|
|
|
}) |
|
|
|
} else { |
|
|
|
the.configAlarmTrigger[len(the.configAlarmTrigger)-1].StationIds = |
|
|
@ -220,7 +227,7 @@ func (the *consumerAxySkAlarm) judgeSK() string { |
|
|
|
Time: alarmTime, |
|
|
|
} |
|
|
|
|
|
|
|
payload := the.skAlarmInfo(alarmInfoTemplate, level, detail, alarmTime, triggerTypeCodes) |
|
|
|
payload := the.skAlarmInfo(alarmInfoTemplate, level, detail, alarmTime, triggerTypeCodes, trigger.StructName) |
|
|
|
the.OutKafka.Publish(the.Info.IoConfig.Out.Kafka.AlarmTopic, payload) |
|
|
|
} else { |
|
|
|
hisK := fmt.Sprintf("%s_%s", sid, fmt.Sprintf("3077000%d", trigger.AlarmLevel)) |
|
|
@ -230,7 +237,7 @@ func (the *consumerAxySkAlarm) judgeSK() string { |
|
|
|
if v, ok := the.historyStationAlarmMap[hisK]; ok { |
|
|
|
log.Printf("trigger.Id=%d, 测点[%s]本次 恢复双控%s,时刻[%s]level=%d", trigger.Id, sid, hisK, v.Time.Format("2006-01-02 15:04:05.000"), level) |
|
|
|
|
|
|
|
payload := the.skAlarmElimination(alarmInfoTemplate, level, detail) |
|
|
|
payload := the.skAlarmElimination(alarmInfoTemplate, level, detail, trigger.StructName) |
|
|
|
the.OutKafka.Publish(the.Info.IoConfig.Out.Kafka.AlarmTopic, payload) |
|
|
|
delete(the.historyStationAlarmMap, hisK) |
|
|
|
} |
|
|
@ -271,11 +278,11 @@ func (the *consumerAxySkAlarm) isHistoryAlarm(sourceId string, level int, alarmT |
|
|
|
return isHis, hisK |
|
|
|
} |
|
|
|
|
|
|
|
func (the *consumerAxySkAlarm) skAlarmInfo(alarmInfoTemplate *models.EsAlarm, level int, detail string, alarmTime time.Time, triggerTypeCodes []string) []byte { |
|
|
|
func (the *consumerAxySkAlarm) skAlarmInfo(alarmInfoTemplate *models.EsAlarm, level int, detail string, alarmTime time.Time, triggerTypeCodes []string, structName string) []byte { |
|
|
|
alarmMsg := models.KafkaAlarm{ |
|
|
|
MessageMode: "AlarmGeneration", |
|
|
|
StructureId: alarmInfoTemplate.StructureId, |
|
|
|
StructureName: "", |
|
|
|
StructureName: structName, |
|
|
|
SourceId: alarmInfoTemplate.SourceId, |
|
|
|
SourceName: alarmInfoTemplate.SourceName, |
|
|
|
AlarmTypeCode: "3077", |
|
|
@ -290,11 +297,11 @@ func (the *consumerAxySkAlarm) skAlarmInfo(alarmInfoTemplate *models.EsAlarm, le |
|
|
|
payload, _ := json.Marshal(alarmMsg) |
|
|
|
return payload |
|
|
|
} |
|
|
|
func (the *consumerAxySkAlarm) skAlarmElimination(alarmInfoTemplate *models.EsAlarm, level int, detail string) []byte { |
|
|
|
func (the *consumerAxySkAlarm) skAlarmElimination(alarmInfoTemplate *models.EsAlarm, level int, detail string, structName string) []byte { |
|
|
|
alarmMsg := models.KafkaAlarm{ |
|
|
|
MessageMode: "AlarmAutoElimination", |
|
|
|
StructureId: alarmInfoTemplate.StructureId, |
|
|
|
StructureName: "", |
|
|
|
StructureName: structName, |
|
|
|
SourceId: alarmInfoTemplate.SourceId, |
|
|
|
SourceName: alarmInfoTemplate.SourceName, |
|
|
|
AlarmTypeCode: "3077", |
|
|
|