diff --git a/api/app/lib/controllers/control/data.js b/api/app/lib/controllers/control/data.js index d875b5e..2285e66 100644 --- a/api/app/lib/controllers/control/data.js +++ b/api/app/lib/controllers/control/data.js @@ -68,19 +68,19 @@ async function getProjectsInfo(ctx) { } //BI分析 -async function getBiAnalysis(ctx) { +async function getVideoAlarmsAggDay(ctx) { try { - const { models } = ctx.fs.dc; - const { clickHouse } = ctx.app.fs - const { alarmId, limit, page } = ctx.query; let videoAlarms = await alarmList(ctx, 'day'); let aggDayMap = []; for (let a of videoAlarms) { - let exist = aggDayMap.find(ad => ad.day == moment(a.createTime).format('YYYY-MM-DD')) + let exist = aggDayMap.find(ad => ad.day == moment(a.createTime).format('YYYY-MM-DD')); if (exist) { - exist.number++ + exist.total++;//总数 + if (a.confirmTime || a.autoRestore) { + exist.done++;//已恢复 + } } else { - aggDayMap.push({ day: moment(a.createTime).format('YYYY-MM-DD'), number: 1 }) + aggDayMap.push({ day: moment(a.createTime).format('YYYY-MM-DD'), total: 1, done: a.confirmTime || a.autoRestore ? 1 : 0 }); } } ctx.status = 200; @@ -190,6 +190,6 @@ async function getLatestDynamic(ctx) { module.exports = { getWorkbench, getProjectsInfo, - getBiAnalysis, + getVideoAlarmsAggDay, getLatestDynamic }; \ No newline at end of file diff --git a/api/app/lib/routes/control/index.js b/api/app/lib/routes/control/index.js index 548c9d0..ac4aeb6 100644 --- a/api/app/lib/routes/control/index.js +++ b/api/app/lib/routes/control/index.js @@ -24,8 +24,8 @@ module.exports = function (app, router, opts) { router.get('/projects/info', csData.getProjectsInfo); //BI分析模块 - app.fs.api.logAttr['GET/bi/analysis'] = { content: '查询BI分析数据', visible: false }; - router.get('/bi/analysis', csData.getBiAnalysis); + app.fs.api.logAttr['GET/video/alarms/agg/day'] = { content: '查询BI分析数据-视频异常', visible: false }; + router.get('/video/alarms/agg/day', csData.getVideoAlarmsAggDay); //最新动态 app.fs.api.logAttr['GET/latest/dynamic'] = { content: '查询最新动态', visible: false };