From 35d66606223d393408ed12cfa686f10d9a987946 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Fri, 23 Sep 2022 11:40:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E8=AF=A6=E6=83=85=E8=81=9A?= =?UTF-8?q?=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/alarm/data.js | 8 +++++++- api/app/lib/routes/alarm/index.js | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/api/app/lib/controllers/alarm/data.js b/api/app/lib/controllers/alarm/data.js index 82da6a4..76a52f5 100644 --- a/api/app/lib/controllers/alarm/data.js +++ b/api/app/lib/controllers/alarm/data.js @@ -161,9 +161,15 @@ async function confirm (ctx) { async function detailAggregation (ctx) { try { const { models } = ctx.fs.dc; + const { alarmId } = ctx.query + const { clickHouse } = ctx.app.fs + + const alarmDetailAggRes = await clickHouse.dataAlarm.query(` + SELECT formatDateTime(Time,'%F %H') days, count(AlarmId) count from alarm_details WHERE AlarmId=${AlarmId} group by days; + `).toPromise(); ctx.status = 200; - ctx.body = [] + ctx.body = alarmDetailAggRes } catch (error) { ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.status = 400; diff --git a/api/app/lib/routes/alarm/index.js b/api/app/lib/routes/alarm/index.js index dd9d3b6..ca64541 100644 --- a/api/app/lib/routes/alarm/index.js +++ b/api/app/lib/routes/alarm/index.js @@ -35,6 +35,9 @@ module.exports = function (app, router, opts) { app.fs.api.logAttr['GET/alarm/data/detail'] = { content: '查询数据告警详情', visible: true }; router.get('/alarm/data/detail', dataAlarm.detail); + app.fs.api.logAttr['GET/alarm/data/detail_agg'] = { content: '查询数据告警详情聚集数据', visible: true }; + router.get('/alarm/data/detail_agg', dataAlarm.detailAggregation); + app.fs.api.logAttr['PUT/alarm/data/confirm'] = { content: '确认数据告警', visible: true }; router.put('/alarm/data/confirm', dataAlarm.confirm); };