From c8d59856c9fcecf6e5e7f6752f59e3160d8d6e45 Mon Sep 17 00:00:00 2001 From: wuqun Date: Fri, 28 Oct 2022 16:02:26 +0800 Subject: [PATCH] =?UTF-8?q?(*)=E6=95=B0=E6=8D=AE=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E5=A4=84=E7=BD=AE=E6=95=88=E7=8E=87=E6=9F=A5=E8=AF=A2=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/schedule/alarms_handle_statistics.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/app/lib/schedule/alarms_handle_statistics.js b/api/app/lib/schedule/alarms_handle_statistics.js index e2fe67f..dcfa55d 100644 --- a/api/app/lib/schedule/alarms_handle_statistics.js +++ b/api/app/lib/schedule/alarms_handle_statistics.js @@ -191,12 +191,13 @@ module.exports = function (app, opts) { console.log('开始查数据-数据-数据类告警---' + moment().format('YYYY-MM-DD HH:mm:ss')) const alarmRes = await clickHouse.dataAlarm.query(` - SELECT + select count(AlarmId) count from + (SELECT alarms.AlarmId AS AlarmId, alarms.State AS State, alarms.StructureId AS StructureId, StartTime, EndTime - ${alarmQueryOptionStr}`).toPromise(); + ${alarmQueryOptionStr})`).toPromise(); let day1Str = getStr(alarmQueryOptionStr, 'Date(EndTime) - Date(StartTime)<=1'); let day1 = await clickHouse.dataAlarm.query(day1Str).toPromise(); @@ -244,7 +245,7 @@ module.exports = function (app, opts) { // let corConfirmedData = (confirmedAlarmDetailMax.find(cdm => cdm.AlarmId == ar.AlarmId) || {}); // ar.confirmTime = corConfirmedData.Time || ar.EndTime // }) - return { dataSum: alarmRes.length, dataMaps: { day1, day3, day7, day15, day30, day30m } }; + return { dataSum: alarmRes[0].count, dataMaps: { day1, day3, day7, day15, day30, day30m } }; } catch (error) { console.error(error); }