|
@ -1,4 +1,6 @@ |
|
|
'use strict'; |
|
|
'use strict'; |
|
|
|
|
|
const moment = require('moment') |
|
|
|
|
|
|
|
|
async function deviceType (ctx) { |
|
|
async function deviceType (ctx) { |
|
|
try { |
|
|
try { |
|
|
const { models } = ctx.fs.dc; |
|
|
const { models } = ctx.fs.dc; |
|
@ -46,10 +48,12 @@ async function alarmList (ctx) { |
|
|
if (kindId) { |
|
|
if (kindId) { |
|
|
cameraWhereOption.push(`camera.kind_id = ${kindId}`) |
|
|
cameraWhereOption.push(`camera.kind_id = ${kindId}`) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let statusAlarmWhereOption = [] |
|
|
if (sustainTimeStart && sustainTimeEnd) { |
|
|
if (sustainTimeStart && sustainTimeEnd) { |
|
|
let momentStart = moment(sustainTimeStart).format('YYYY-MM-DD HH:mm:ss') |
|
|
let momentStart = moment(sustainTimeStart).format('YYYY-MM-DD HH:mm:ss') |
|
|
let momentEnd = moment(sustainTimeEnd).format('YYYY-MM-DD HH:mm:ss') |
|
|
let momentEnd = moment(sustainTimeEnd).format('YYYY-MM-DD HH:mm:ss') |
|
|
whereOption.push(` |
|
|
statusAlarmWhereOption.push(` |
|
|
( |
|
|
( |
|
|
camera_status_alarm.create_time |
|
|
camera_status_alarm.create_time |
|
|
BETWEEN '${momentStart}' AND '${momentEnd}' |
|
|
BETWEEN '${momentStart}' AND '${momentEnd}' |
|
@ -68,6 +72,9 @@ async function alarmList (ctx) { |
|
|
SELECT |
|
|
SELECT |
|
|
cameraAlarm.cameraId AS cameraId, |
|
|
cameraAlarm.cameraId AS cameraId, |
|
|
cameraAlarm.cameraName AS cameraName, |
|
|
cameraAlarm.cameraName AS cameraName, |
|
|
|
|
|
cameraAlarm.cameraKindId AS cameraKindId, |
|
|
|
|
|
cameraAlarm.venderId AS venderId, |
|
|
|
|
|
cameraAlarm.venderName AS venderName, |
|
|
cameraAlarm.cameraSerialNo AS cameraSerialNo, |
|
|
cameraAlarm.cameraSerialNo AS cameraSerialNo, |
|
|
cameraAlarm.cameraChannelNo AS cameraChannelNo, |
|
|
cameraAlarm.cameraChannelNo AS cameraChannelNo, |
|
|
cameraAlarm.alarmId AS alarmId, |
|
|
cameraAlarm.alarmId AS alarmId, |
|
@ -89,6 +96,9 @@ async function alarmList (ctx) { |
|
|
camera.id AS cameraId, |
|
|
camera.id AS cameraId, |
|
|
camera.gb_id AS gbId, |
|
|
camera.gb_id AS gbId, |
|
|
camera.name AS cameraName, |
|
|
camera.name AS cameraName, |
|
|
|
|
|
camera.kind_id AS cameraKindId, |
|
|
|
|
|
camera.vender_id AS venderId, |
|
|
|
|
|
vender.name AS venderName, |
|
|
camera_status_alarm.id AS alarmId, |
|
|
camera_status_alarm.id AS alarmId, |
|
|
camera_status_alarm.create_time AS createTime, |
|
|
camera_status_alarm.create_time AS createTime, |
|
|
camera_status_alarm.update_time AS updateTime, |
|
|
camera_status_alarm.update_time AS updateTime, |
|
@ -103,9 +113,12 @@ async function alarmList (ctx) { |
|
|
ON camera.serial_no = camera_status_alarm.serial_no |
|
|
ON camera.serial_no = camera_status_alarm.serial_no |
|
|
AND camera.channel_no = camera_status_alarm.channel_no |
|
|
AND camera.channel_no = camera_status_alarm.channel_no |
|
|
${cameraWhereOption.length ? 'AND ' + cameraWhereOption.join(' AND ') : ''} |
|
|
${cameraWhereOption.length ? 'AND ' + cameraWhereOption.join(' AND ') : ''} |
|
|
|
|
|
LEFT JOIN vender |
|
|
|
|
|
ON vender.id = camera.vender_id |
|
|
WHERE |
|
|
WHERE |
|
|
camera.delete = false |
|
|
camera.delete = false |
|
|
AND camera.recycle_time is null |
|
|
AND camera.recycle_time is null |
|
|
|
|
|
${statusAlarmWhereOption.length ? 'AND ' + statusAlarmWhereOption.join(' AND ') : ''} |
|
|
AND alarmId IN ( |
|
|
AND alarmId IN ( |
|
|
SELECT camera_status_alarm.id AS alarmId |
|
|
SELECT camera_status_alarm.id AS alarmId |
|
|
FROM camera_status_alarm |
|
|
FROM camera_status_alarm |
|
@ -164,6 +177,11 @@ async function alarmList (ctx) { |
|
|
alarmId: a.alarmId, |
|
|
alarmId: a.alarmId, |
|
|
confirmContent: a.confirmContent, |
|
|
confirmContent: a.confirmContent, |
|
|
confirmTime: a.confirmTime, |
|
|
confirmTime: a.confirmTime, |
|
|
|
|
|
|
|
|
|
|
|
venderId: a.venderId, |
|
|
|
|
|
venderName: a.venderName, |
|
|
|
|
|
cameraKindId: a.cameraKindId, |
|
|
|
|
|
|
|
|
resolve: [], |
|
|
resolve: [], |
|
|
struc: [] |
|
|
struc: [] |
|
|
} |
|
|
} |
|
@ -200,8 +218,16 @@ async function alarmList (ctx) { |
|
|
async function confirm (ctx) { |
|
|
async function confirm (ctx) { |
|
|
try { |
|
|
try { |
|
|
const { models } = ctx.fs.dc; |
|
|
const { models } = ctx.fs.dc; |
|
|
|
|
|
const { alarmId, content } = ctx.request.body; |
|
|
|
|
|
|
|
|
|
|
|
// TODO: 以视频·应用的秘钥进行鉴权
|
|
|
|
|
|
await ctx.app.fs.vcmpRequest.put('status/alarm/confirm', { |
|
|
|
|
|
data: { |
|
|
|
|
|
alarmId, content |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
ctx.status = 20; |
|
|
ctx.status = 204; |
|
|
} 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; |
|
@ -213,5 +239,6 @@ async function confirm (ctx) { |
|
|
|
|
|
|
|
|
module.exports = { |
|
|
module.exports = { |
|
|
deviceType, |
|
|
deviceType, |
|
|
alarmList |
|
|
alarmList, |
|
|
|
|
|
confirm |
|
|
}; |
|
|
}; |