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分析 //BI分析
async function getBiAnalysis(ctx) { async function getVideoAlarmsAggDay(ctx) {
try { try {
const { models } = ctx.fs.dc;
const { clickHouse } = ctx.app.fs
const { alarmId, limit, page } = ctx.query;
let videoAlarms = await alarmList(ctx, 'day'); let videoAlarms = await alarmList(ctx, 'day');
let aggDayMap = []; let aggDayMap = [];
for (let a of videoAlarms) { 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) { if (exist) {
exist.number++ exist.total++;//总数
if (a.confirmTime || a.autoRestore) {
exist.done++;//已恢复
}
} else { } 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; ctx.status = 200;
@ -190,6 +190,6 @@ async function getLatestDynamic(ctx) {
module.exports = { module.exports = {
getWorkbench, getWorkbench,
getProjectsInfo, getProjectsInfo,
getBiAnalysis, getVideoAlarmsAggDay,
getLatestDynamic 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); router.get('/projects/info', csData.getProjectsInfo);
//BI分析模块 //BI分析模块
app.fs.api.logAttr['GET/bi/analysis'] = { content: '查询BI分析数据', visible: false }; app.fs.api.logAttr['GET/video/alarms/agg/day'] = { content: '查询BI分析数据-视频异常', visible: false };
router.get('/bi/analysis', csData.getBiAnalysis); router.get('/video/alarms/agg/day', csData.getVideoAlarmsAggDay);
//最新动态 //最新动态
app.fs.api.logAttr['GET/latest/dynamic'] = { content: '查询最新动态', visible: false }; app.fs.api.logAttr['GET/latest/dynamic'] = { content: '查询最新动态', visible: false };

Loading…
Cancel
Save