From b25edbd233ac126f82513eab5c9be4aa961ce16b Mon Sep 17 00:00:00 2001 From: CODE <1650192445@qq.com> Date: Tue, 12 Sep 2023 17:15:55 +0800 Subject: [PATCH] =?UTF-8?q?fix=20dataAlarmSubType=20=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E6=9C=89=E6=95=B0=E6=8D=AE=E4=B8=BA=E7=A9=BA=20=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=20sql=20=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/schedule/alarms_push.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/api/app/lib/schedule/alarms_push.js b/api/app/lib/schedule/alarms_push.js index b7cb884..3206d1f 100644 --- a/api/app/lib/schedule/alarms_push.js +++ b/api/app/lib/schedule/alarms_push.js @@ -307,15 +307,15 @@ module.exports = function (app, opts) { // 判断告警数据范围 if (c.alarmType.includes('data_outages')) { dataAlarmGroupOption.push(1) - if (c.alarmSubType) dataAlarmSubType = dataAlarmSubType.concat(c.alarmSubType['data_outages']) + if (c.alarmSubType) dataAlarmSubType = dataAlarmSubType.concat(c.alarmSubType['data_outages'] || []) } if (c.alarmType.includes('data_exception')) { dataAlarmGroupOption.push(2) - if (c.alarmSubType) dataAlarmSubType = dataAlarmSubType.concat(c.alarmSubType['data_exception']) + if (c.alarmSubType) dataAlarmSubType = dataAlarmSubType.concat(c.alarmSubType['data_exception'] || []) } if (c.alarmType.includes('strategy_hit')) { dataAlarmGroupOption.push(3) - if (c.alarmSubType) dataAlarmSubType = dataAlarmSubType.concat(c.alarmSubType['strategy_hit']) + if (c.alarmSubType) dataAlarmSubType = dataAlarmSubType.concat(c.alarmSubType['strategy_hit'] || []) } if (c.alarmType.includes('video_exception')) { let videoAlarmSubType = c.alarmSubType ? @@ -515,13 +515,14 @@ module.exports = function (app, opts) { if (dataAlarmGroupOption.length && searchStrucIds.length) { dataAlarmGroupOption.push(-1) dataAlarmOption.push(`AlarmGroup IN (${dataAlarmGroupOption.join(',')})`) - if (c.alarmSubType && dataAlarmSubType.length) { - dataAlarmSubType.push(-1) - dataAlarmOption.push(`AlarmGroupUnit IN (${dataAlarmSubType.join(',')})`) + let dataAlarmSubType_ = dataAlarmSubType.filter(s => s) + if (c.alarmSubType && dataAlarmSubType_.length) { + dataAlarmSubType_.push(-1) + dataAlarmOption.push(`AlarmGroupUnit IN (${dataAlarmSubType_.join(',')})`) } dataAlarms = - !c.alarmSubType || dataAlarmSubType.length ? + !c.alarmSubType || dataAlarmSubType_.length ? await clickHouse.dataAlarm.query(` SELECT * FROM alarms LEFT JOIN ${anxinyun}.t_sensor