Browse Source

告警推送debug

dev
巴林闲侠 2 years ago
parent
commit
5505392a4f
  1. 23
      api/app/lib/schedule/alarms_push.js

23
api/app/lib/schedule/alarms_push.js

@ -3,6 +3,9 @@ const moment = require('moment')
let isDev = false let isDev = false
// isDev = true // isDev = true
let proDebug = false
proDebug = true
module.exports = function (app, opts) { module.exports = function (app, opts) {
const alarmsPush = app.fs.scheduleInit( const alarmsPush = app.fs.scheduleInit(
{ {
@ -62,6 +65,9 @@ module.exports = function (app, opts) {
for (let { dataValues: c } of configListRes) { for (let { dataValues: c } of configListRes) {
if (c.tacticsParams && c.tactics) { if (c.tacticsParams && c.tactics) {
if (proDebug) {
console.log(`当前运行EM配置:id=${c.id} name=${c.name}`);
}
// pomsProjectId 是个数组 [] // pomsProjectId 是个数组 []
const { strucId, pomsProjectId, pomsStrucFactorId } = c const { strucId, pomsProjectId, pomsStrucFactorId } = c
const { interval, deviceProportion } = c.tacticsParams const { interval, deviceProportion } = c.tacticsParams
@ -667,6 +673,10 @@ module.exports = function (app, opts) {
let dataAlarmG45 = []; let dataAlarmG45 = [];
let deviceStatistic = new Set() let deviceStatistic = new Set()
let dataAlarmDetails = [] let dataAlarmDetails = []
if (proDebug) {
console.log(`查得数据告警 ${dataAlarms.length}`);
console.log(dataAlarms);
}
if (dataAlarms.length) { if (dataAlarms.length) {
dataAlarmDetails = dataAlarmDetails =
await clickHouse.dataAlarm.query(` await clickHouse.dataAlarm.query(`
@ -675,6 +685,12 @@ module.exports = function (app, opts) {
AND AlarmState = 0 AND AlarmState = 0
`) `)
} }
if (proDebug) {
console.log(`查得数据告警详情数据 ${dataAlarmDetails.length}`);
}
if (proDebug) {
console.log(`pomsStrucFactorId:`, pomsStrucFactorId);
}
for (let d of dataAlarms) { for (let d of dataAlarms) {
/** 按监测因素筛选 且为测点告警 */ /** 按监测因素筛选 且为测点告警 */
@ -712,6 +728,9 @@ module.exports = function (app, opts) {
continue continue
} else { } else {
let corDetail = dataAlarmDetails.find(da => da.AlarmId == d.AlarmId) let corDetail = dataAlarmDetails.find(da => da.AlarmId == d.AlarmId)
if (proDebug) {
console.log(`相应告警详情(策略命中):`, corDetail);
}
if (corDetail) { if (corDetail) {
// 判断告警详情信息里有没有监测项关键字 // 判断告警详情信息里有没有监测项关键字
if (!pomsStrucFactorId[d.StructureId].some(factorItemName => { if (!pomsStrucFactorId[d.StructureId].some(factorItemName => {
@ -724,7 +743,9 @@ module.exports = function (app, opts) {
} }
} }
} }
if (proDebug) {
console.log(`符合条件的策略命中 + 1`, d);
}
dataAlarmG3.push(d) dataAlarmG3.push(d)
} else if (d.AlarmGroup == 4 || d.AlarmGroup == 5) { } else if (d.AlarmGroup == 4 || d.AlarmGroup == 5) {
dataAlarmG45.push(d) dataAlarmG45.push(d)

Loading…
Cancel
Save