|
@ -1,6 +1,6 @@ |
|
|
'use strict'; |
|
|
'use strict'; |
|
|
const moment = require('moment'); |
|
|
const moment = require('moment'); |
|
|
|
|
|
const { alarmList } = require('../alarm/video'); |
|
|
//工作台
|
|
|
//工作台
|
|
|
async function getWorkbench(ctx) { |
|
|
async function getWorkbench(ctx) { |
|
|
try { |
|
|
try { |
|
@ -22,16 +22,40 @@ async function getWorkbench(ctx) { |
|
|
async function getProjectsInfo(ctx) { |
|
|
async function getProjectsInfo(ctx) { |
|
|
try { |
|
|
try { |
|
|
const { models } = ctx.fs.dc; |
|
|
const { models } = ctx.fs.dc; |
|
|
const { clickHouse } = ctx.app.fs; |
|
|
const { clickHouse, utils: { judgeSuper, anxinStrucIdRange } } = ctx.app.fs |
|
|
const { alarmId, limit, page, projectCorrelationId } = ctx.query; |
|
|
const { database: anxinyun } = clickHouse.anxinyun.opts.config |
|
|
|
|
|
const { alarmId, limit, page, projectCorrelationId, pepProjectId, keywordTarget, keyword } = ctx.query; |
|
|
const { userInfo } = ctx.fs.api; |
|
|
const { userInfo } = ctx.fs.api; |
|
|
let where = {} |
|
|
// let where = {}
|
|
|
if (!userInfo.role.includes('SuperAdmin') && !userInfo.role.includes('admin')) { |
|
|
// if (!userInfo.role.includes('SuperAdmin') && !userInfo.role.includes('admin')) {
|
|
|
where.projectCorrelationId = { $in: userInfo.correlationProject } |
|
|
// where.projectCorrelationId = { $in: userInfo.correlationProject }
|
|
|
} |
|
|
// }
|
|
|
if (projectCorrelationId) {//查指定项目,控制台全局切换
|
|
|
// if (projectCorrelationId) {//查指定项目,控制台全局切换
|
|
|
where.projectCorrelationId = projectCorrelationId |
|
|
// where.projectCorrelationId = projectCorrelationId
|
|
|
} |
|
|
// }
|
|
|
|
|
|
let anxinStruc = await anxinStrucIdRange({ |
|
|
|
|
|
ctx, pepProjectId, keywordTarget, keyword |
|
|
|
|
|
}) |
|
|
|
|
|
const anxinStrucIds = anxinStruc.map(a => a.strucId); |
|
|
|
|
|
//先查全部的摄像头
|
|
|
|
|
|
const videoList = anxinStrucIds.length ? await clickHouse.vcmp.query( |
|
|
|
|
|
`select camera.id,
|
|
|
|
|
|
camera.name, |
|
|
|
|
|
camera.serial_no from camera where camera.delete=false and camera.recycle_time is null |
|
|
|
|
|
|
|
|
|
|
|
LEFT JOIN ${anxinyun}.t_video_ipc AS anxinIpc |
|
|
|
|
|
ON toString(anxinIpc.channel_no) = cameraAlarm.cameraChannelNo |
|
|
|
|
|
AND anxinIpc.serial_no = cameraAlarm.cameraSerialNo |
|
|
|
|
|
LEFT JOIN ${anxinyun}.t_structure AS anxinStruc |
|
|
|
|
|
ON anxinStruc.id = anxinIpc.structure |
|
|
|
|
|
AND anxinStruc.id IN (${anxinStrucIds.join(',')}) |
|
|
|
|
|
LEFT JOIN ${anxinyun}.t_video_ipc_station AS anxinIpcStation |
|
|
|
|
|
ON anxinIpcStation.ipc = anxinIpc.id |
|
|
|
|
|
LEFT JOIN ${anxinyun}.t_sensor AS anxinStation |
|
|
|
|
|
ON anxinStation.id = anxinIpcStation.station` |
|
|
|
|
|
).toPromise() : [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.status = 200; |
|
|
ctx.status = 200; |
|
|
ctx.body = [] |
|
|
ctx.body = [] |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
@ -48,9 +72,19 @@ async function getBiAnalysis(ctx) { |
|
|
try { |
|
|
try { |
|
|
const { models } = ctx.fs.dc; |
|
|
const { models } = ctx.fs.dc; |
|
|
const { clickHouse } = ctx.app.fs |
|
|
const { clickHouse } = ctx.app.fs |
|
|
const { alarmId, limit, page } = ctx.query |
|
|
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')) |
|
|
|
|
|
if (exist) { |
|
|
|
|
|
exist.number++ |
|
|
|
|
|
} else { |
|
|
|
|
|
aggDayMap.push({ day: moment(a.createTime).format('YYYY-MM-DD'), number: 1 }) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
ctx.status = 200; |
|
|
ctx.status = 200; |
|
|
ctx.body = [] |
|
|
ctx.body = aggDayMap; |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
ctx.status = 400; |
|
|
ctx.status = 400; |