|
|
@ -6,6 +6,12 @@ async function deviceType (ctx) { |
|
|
|
try { |
|
|
|
const { models } = ctx.fs.dc; |
|
|
|
const { clickHouse } = ctx.app.fs |
|
|
|
const { database: anxinyun } = clickHouse.anxinyun.opts.config |
|
|
|
const { utils: { judgeSuper, anxinStrucIdRange } } = ctx.app.fs |
|
|
|
let anxinStruc = await anxinStrucIdRange({ |
|
|
|
ctx, |
|
|
|
}) |
|
|
|
const anxinStrucIds = anxinStruc.map(a => a.strucId) |
|
|
|
|
|
|
|
const kindRes = await clickHouse.vcmp.query(` |
|
|
|
SELECT DISTINCT |
|
|
@ -16,6 +22,10 @@ async function deviceType (ctx) { |
|
|
|
INNER JOIN camera_status_alarm |
|
|
|
ON camera.channel_no = camera_status_alarm.channel_no |
|
|
|
AND camera.serial_no = camera_status_alarm.serial_no |
|
|
|
INNER JOIN ${anxinyun}.t_video_ipc |
|
|
|
ON toString(${anxinyun}.t_video_ipc.channel_no) = camera_status_alarm.channel_no |
|
|
|
AND ${anxinyun}.t_video_ipc.serial_no = camera_status_alarm.serial_no |
|
|
|
${`WHERE ${anxinyun}.t_video_ipc.structure IN (${anxinStrucIds.join(',')})`} |
|
|
|
`).toPromise()
|
|
|
|
ctx.status = 200; |
|
|
|
ctx.body = kindRes |
|
|
@ -28,13 +38,46 @@ async function deviceType (ctx) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async function exceptionType(ctx) { |
|
|
|
try { |
|
|
|
const { models } = ctx.fs.dc; |
|
|
|
const { clickHouse } = ctx.app.fs |
|
|
|
const { database: anxinyun } = clickHouse.anxinyun.opts.config |
|
|
|
const { utils: { judgeSuper, anxinStrucIdRange } } = ctx.app.fs |
|
|
|
let anxinStruc = await anxinStrucIdRange({ |
|
|
|
ctx, |
|
|
|
}) |
|
|
|
const anxinStrucIds = anxinStruc.map(a => a.strucId) |
|
|
|
|
|
|
|
const statusRes = await clickHouse.vcmp.query(` |
|
|
|
SELECT DISTINCT |
|
|
|
camera_status.id AS statusId,camera_status.describe AS describe |
|
|
|
FROM camera_status |
|
|
|
INNER JOIN camera_status_alarm |
|
|
|
ON camera_status.id = camera_status_alarm.status_id |
|
|
|
INNER JOIN ${anxinyun}.t_video_ipc |
|
|
|
ON toString(${anxinyun}.t_video_ipc.channel_no) = camera_status_alarm.channel_no |
|
|
|
AND ${anxinyun}.t_video_ipc.serial_no = camera_status_alarm.serial_no |
|
|
|
${`WHERE ${anxinyun}.t_video_ipc.structure IN (${anxinStrucIds.join(',')})`} |
|
|
|
`).toPromise()
|
|
|
|
ctx.status = 200; |
|
|
|
ctx.body = statusRes |
|
|
|
} catch (error) { |
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
|
ctx.status = 400; |
|
|
|
ctx.body = { |
|
|
|
message: typeof error == 'string' ? error : undefined |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async function alarmList (ctx) { |
|
|
|
try { |
|
|
|
const { models } = ctx.fs.dc; |
|
|
|
const { clickHouse } = ctx.app.fs |
|
|
|
const { utils: { judgeSuper, anxinStrucIdRange } } = ctx.app.fs |
|
|
|
const { database: anxinyun } = clickHouse.anxinyun.opts.config |
|
|
|
const { pepProjectId, keywordTarget, keyword, state, kindId, sustainTimeStart, sustainTimeEnd, limit, page, statusId, toExport} = ctx.query |
|
|
|
const { pepProjectId, keywordTarget, keyword, state, kindId, sustainTimeStart, sustainTimeEnd, limit, page, statusId, toExport } = ctx.query |
|
|
|
|
|
|
|
let anxinStruc = await anxinStrucIdRange({ |
|
|
|
ctx, pepProjectId, keywordTarget, keyword |
|
|
@ -78,7 +121,7 @@ async function alarmList (ctx) { |
|
|
|
) |
|
|
|
`)
|
|
|
|
} |
|
|
|
if(statusId){ |
|
|
|
if (statusId) { |
|
|
|
statusAlarmWhereOption.push(`camera_status_alarm.status_id = ${statusId}`) |
|
|
|
} |
|
|
|
|
|
|
@ -279,7 +322,7 @@ async function alarmList (ctx) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async function exportVideoAlarms(ctx, alarmList) { |
|
|
|
async function exportVideoAlarms (ctx, alarmList) { |
|
|
|
let accessType = { yingshi: "萤石云", nvr: "NVR", ipc: "IPC", cascade: "级联" } |
|
|
|
try { |
|
|
|
const { clickHouse, utils: { simpleExcelDown, getExportAlarmHeader } } = ctx.app.fs; |
|
|
@ -328,7 +371,7 @@ async function exportVideoAlarms(ctx, alarmList) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
async function confirm(ctx) { |
|
|
|
async function confirm (ctx) { |
|
|
|
try { |
|
|
|
const { alarmId, content, confirmPost } = ctx.request.body; |
|
|
|
// TODO: 以视频·应用的秘钥进行鉴权
|
|
|
@ -451,5 +494,6 @@ module.exports = { |
|
|
|
alarmList, |
|
|
|
confirm, |
|
|
|
alarmAdded, |
|
|
|
vcmpAppAuthToken |
|
|
|
vcmpAppAuthToken, |
|
|
|
exceptionType |
|
|
|
}; |