From a850fe49a88d7e2416be88f66298f3add443a629 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Wed, 28 Sep 2022 21:23:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=91=8A=E8=AD=A6=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/.vscode/launch.json | 1 + api/app/lib/controllers/alarm/video.js | 33 +++++++++++++++++++++++--- api/app/lib/routes/alarm/index.js | 3 +++ api/config.js | 7 ++++++ 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/api/.vscode/launch.json b/api/.vscode/launch.json index b11f1ba..382e513 100644 --- a/api/.vscode/launch.json +++ b/api/.vscode/launch.json @@ -26,6 +26,7 @@ // "--apiEmisUrl http://10.8.30.112:14000", // 测试 "--apiEmisUrl http://10.8.30.161:1111", + "--apiVcmpUrl http://localhost:4000", "--godUrl https://restapi.amap.com/v3", "--godKey 21c2d970e1646bb9a795900dd00093ce", "--mqttVideoServer mqtt://10.8.30.71:30883", diff --git a/api/app/lib/controllers/alarm/video.js b/api/app/lib/controllers/alarm/video.js index 33e3560..e3b32c0 100644 --- a/api/app/lib/controllers/alarm/video.js +++ b/api/app/lib/controllers/alarm/video.js @@ -1,4 +1,6 @@ 'use strict'; +const moment = require('moment') + async function deviceType (ctx) { try { const { models } = ctx.fs.dc; @@ -46,10 +48,12 @@ async function alarmList (ctx) { if (kindId) { cameraWhereOption.push(`camera.kind_id = ${kindId}`) } + + let statusAlarmWhereOption = [] if (sustainTimeStart && sustainTimeEnd) { let momentStart = moment(sustainTimeStart).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 BETWEEN '${momentStart}' AND '${momentEnd}' @@ -68,6 +72,9 @@ async function alarmList (ctx) { SELECT cameraAlarm.cameraId AS cameraId, cameraAlarm.cameraName AS cameraName, + cameraAlarm.cameraKindId AS cameraKindId, + cameraAlarm.venderId AS venderId, + cameraAlarm.venderName AS venderName, cameraAlarm.cameraSerialNo AS cameraSerialNo, cameraAlarm.cameraChannelNo AS cameraChannelNo, cameraAlarm.alarmId AS alarmId, @@ -89,6 +96,9 @@ async function alarmList (ctx) { camera.id AS cameraId, camera.gb_id AS gbId, 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.create_time AS createTime, camera_status_alarm.update_time AS updateTime, @@ -103,9 +113,12 @@ async function alarmList (ctx) { ON camera.serial_no = camera_status_alarm.serial_no AND camera.channel_no = camera_status_alarm.channel_no ${cameraWhereOption.length ? 'AND ' + cameraWhereOption.join(' AND ') : ''} + LEFT JOIN vender + ON vender.id = camera.vender_id WHERE camera.delete = false AND camera.recycle_time is null + ${statusAlarmWhereOption.length ? 'AND ' + statusAlarmWhereOption.join(' AND ') : ''} AND alarmId IN ( SELECT camera_status_alarm.id AS alarmId FROM camera_status_alarm @@ -164,6 +177,11 @@ async function alarmList (ctx) { alarmId: a.alarmId, confirmContent: a.confirmContent, confirmTime: a.confirmTime, + + venderId: a.venderId, + venderName: a.venderName, + cameraKindId: a.cameraKindId, + resolve: [], struc: [] } @@ -200,8 +218,16 @@ async function alarmList (ctx) { async function confirm (ctx) { try { 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) { ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; @@ -213,5 +239,6 @@ async function confirm (ctx) { module.exports = { deviceType, - alarmList + alarmList, + confirm }; \ No newline at end of file diff --git a/api/app/lib/routes/alarm/index.js b/api/app/lib/routes/alarm/index.js index a811f88..162e6c9 100644 --- a/api/app/lib/routes/alarm/index.js +++ b/api/app/lib/routes/alarm/index.js @@ -51,4 +51,7 @@ module.exports = function (app, router, opts) { app.fs.api.logAttr['GET/alarm/video/list'] = { content: '查询视频告警列表', visible: true }; router.get('/alarm/video/list', videoAlarm.alarmList); + + app.fs.api.logAttr['PUT/alarm/video/confirm'] = { content: '确认视频告警信息', visible: true }; + router.put('/alarm/video/confirm', videoAlarm.confirm); }; diff --git a/api/config.js b/api/config.js index e294fc3..7707bff 100644 --- a/api/config.js +++ b/api/config.js @@ -19,6 +19,7 @@ args.option('redisPswd', 'redisPassword'); args.option('axyApiUrl', '安心云 api'); args.option('apiEmisUrl', '企业管理 api'); +args.option('apiVcmpUrl', '视频平台 api'); args.option('godUrl', '高德地图API请求地址'); args.option('godKey', '高德地图API key'); @@ -59,6 +60,8 @@ const IOTA_REDIS_SERVER_PWD = process.env.IOTA_REDIS_SERVER_PWD || flags.redisPs const API_ANXINYUN_URL = process.env.API_ANXINYUN_URL || flags.axyApiUrl; // 企业管理 api const API_EMIS_URL = process.env.API_EMIS_URL || flags.apiEmisUrl; +// 视频平台 api +const API_VCMP_URL = process.env.API_VCMP_URL || flags.apiVcmpUrl; // 高德地图的参数 const GOD_URL = process.env.GOD_URL || flags.godUrl || 'https://restapi.amap.com/v3'; @@ -95,6 +98,7 @@ if ( || !GOD_KEY || !API_ANXINYUN_URL || !API_EMIS_URL + || !API_VCMP_URL || !QINIU_DOMAIN_QNDMN_RESOURCE || !QINIU_BUCKET_RESOURCE || !QINIU_AK || !QINIU_SK || !CLICKHOUST_URL || !CLICKHOUST_PORT || !CLICKHOUST_ANXINCLOUD || !CLICKHOUST_PEP_EMIS || !CLICKHOUST_PROJECT_MANAGE || !CLICKHOUST_VCMP || !CLICKHOUST_DATA_ALARM @@ -166,6 +170,9 @@ const product = { }, { name: 'emisRequest', root: API_EMIS_URL + }, { + name: 'vcmpRequest', + root: API_VCMP_URL }, { name: 'godRequest', root: GOD_URL,