Browse Source

(*)BI分析模块-视频异常接口

dev
wuqun 2 years ago
parent
commit
59cff8f6e5
  1. 16
      api/app/lib/controllers/control/data.js
  2. 4
      api/app/lib/routes/control/index.js

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

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

Loading…
Cancel
Save