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