Browse Source

视频告警确认

dev
巴林闲侠 2 years ago
parent
commit
a850fe49a8
  1. 1
      api/.vscode/launch.json
  2. 33
      api/app/lib/controllers/alarm/video.js
  3. 3
      api/app/lib/routes/alarm/index.js
  4. 7
      api/config.js

1
api/.vscode/launch.json

@ -26,6 +26,7 @@
// "--apiEmisUrl http://10.8.30.112:14000", // "--apiEmisUrl http://10.8.30.112:14000",
// //
"--apiEmisUrl http://10.8.30.161:1111", "--apiEmisUrl http://10.8.30.161:1111",
"--apiVcmpUrl http://localhost:4000",
"--godUrl https://restapi.amap.com/v3", "--godUrl https://restapi.amap.com/v3",
"--godKey 21c2d970e1646bb9a795900dd00093ce", "--godKey 21c2d970e1646bb9a795900dd00093ce",
"--mqttVideoServer mqtt://10.8.30.71:30883", "--mqttVideoServer mqtt://10.8.30.71:30883",

33
api/app/lib/controllers/alarm/video.js

@ -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
}; };

3
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 }; app.fs.api.logAttr['GET/alarm/video/list'] = { content: '查询视频告警列表', visible: true };
router.get('/alarm/video/list', videoAlarm.alarmList); 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);
}; };

7
api/config.js

@ -19,6 +19,7 @@ args.option('redisPswd', 'redisPassword');
args.option('axyApiUrl', '安心云 api'); args.option('axyApiUrl', '安心云 api');
args.option('apiEmisUrl', '企业管理 api'); args.option('apiEmisUrl', '企业管理 api');
args.option('apiVcmpUrl', '视频平台 api');
args.option('godUrl', '高德地图API请求地址'); args.option('godUrl', '高德地图API请求地址');
args.option('godKey', '高德地图API key'); 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; const API_ANXINYUN_URL = process.env.API_ANXINYUN_URL || flags.axyApiUrl;
// 企业管理 api // 企业管理 api
const API_EMIS_URL = process.env.API_EMIS_URL || flags.apiEmisUrl; 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'; const GOD_URL = process.env.GOD_URL || flags.godUrl || 'https://restapi.amap.com/v3';
@ -95,6 +98,7 @@ if (
|| !GOD_KEY || !GOD_KEY
|| !API_ANXINYUN_URL || !API_ANXINYUN_URL
|| !API_EMIS_URL || !API_EMIS_URL
|| !API_VCMP_URL
|| !QINIU_DOMAIN_QNDMN_RESOURCE || !QINIU_BUCKET_RESOURCE || !QINIU_AK || !QINIU_SK || !QINIU_DOMAIN_QNDMN_RESOURCE || !QINIU_BUCKET_RESOURCE || !QINIU_AK || !QINIU_SK
|| !CLICKHOUST_URL || !CLICKHOUST_PORT || !CLICKHOUST_URL || !CLICKHOUST_PORT
|| !CLICKHOUST_ANXINCLOUD || !CLICKHOUST_PEP_EMIS || !CLICKHOUST_PROJECT_MANAGE || !CLICKHOUST_VCMP || !CLICKHOUST_DATA_ALARM || !CLICKHOUST_ANXINCLOUD || !CLICKHOUST_PEP_EMIS || !CLICKHOUST_PROJECT_MANAGE || !CLICKHOUST_VCMP || !CLICKHOUST_DATA_ALARM
@ -166,6 +170,9 @@ const product = {
}, { }, {
name: 'emisRequest', name: 'emisRequest',
root: API_EMIS_URL root: API_EMIS_URL
}, {
name: 'vcmpRequest',
root: API_VCMP_URL
}, { }, {
name: 'godRequest', name: 'godRequest',
root: GOD_URL, root: GOD_URL,

Loading…
Cancel
Save