From 5505392a4fe755e5e1e02489be9bd01ac587817c Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Wed, 30 Nov 2022 10:47:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E6=8E=A8=E9=80=81debug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/schedule/alarms_push.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/api/app/lib/schedule/alarms_push.js b/api/app/lib/schedule/alarms_push.js index e061f8b..320042c 100644 --- a/api/app/lib/schedule/alarms_push.js +++ b/api/app/lib/schedule/alarms_push.js @@ -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)