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); };