|
|
@ -21,7 +21,7 @@ async function deviceType (ctx) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async function alarmList(ctx, agg) { |
|
|
|
async function alarmList (ctx, agg) { |
|
|
|
try { |
|
|
|
const { models } = ctx.fs.dc; |
|
|
|
const { clickHouse } = ctx.app.fs |
|
|
@ -67,99 +67,101 @@ async function alarmList(ctx, agg) { |
|
|
|
) |
|
|
|
`)
|
|
|
|
} |
|
|
|
const alarmRes = anxinStrucIds.length ? await clickHouse.vcmp.query( |
|
|
|
` |
|
|
|
|
|
|
|
const queryStr = ` |
|
|
|
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, |
|
|
|
cameraAlarm.createTime AS createTime, |
|
|
|
cameraAlarm.updateTime AS updateTime, |
|
|
|
cameraAlarm.platform AS platform, |
|
|
|
cameraAlarm.confirmContent AS confirmContent, |
|
|
|
cameraAlarm.confirmTime AS confirmTime, |
|
|
|
${'cameraAlarm.autoRestore AS autoRestore,'} |
|
|
|
camera_status_resolve.id AS resolveId, |
|
|
|
camera_status.describe AS statusDescribe, |
|
|
|
camera_status_resolve.resolve AS resolve, |
|
|
|
"gbCamera".online AS cameraOnline, |
|
|
|
secret_yingshi.token AS yingshiToken, |
|
|
|
anxinIpc.t_video_ipc.name AS anxinIpcPosition, |
|
|
|
anxinStation.id AS anxinStationId, |
|
|
|
anxinStation.name AS anxinStationName, |
|
|
|
anxinStruc.name AS strucName, |
|
|
|
anxinStruc.id AS strucId |
|
|
|
FROM |
|
|
|
( |
|
|
|
SELECT |
|
|
|
camera.id AS cameraId, |
|
|
|
camera.gb_id AS gbId, |
|
|
|
camera.name AS cameraName, |
|
|
|
camera.kind_id AS cameraKindId, |
|
|
|
camera.vender_id AS venderId, |
|
|
|
camera.yingshi_secret_id AS yingshiSecretId, |
|
|
|
vender.name AS venderName, |
|
|
|
camera_status_alarm.id AS alarmId, |
|
|
|
camera_status_alarm.create_time AS createTime, |
|
|
|
camera_status_alarm.update_time AS updateTime, |
|
|
|
camera_status_alarm.platform AS platform, |
|
|
|
camera_status_alarm.status_id AS statusId, |
|
|
|
camera_status_alarm.serial_no AS cameraSerialNo, |
|
|
|
camera_status_alarm.channel_no AS cameraChannelNo, |
|
|
|
camera_status_alarm.confirm AS confirmContent, |
|
|
|
${'camera_status_alarm.auto_restore AS autoRestore,'} |
|
|
|
camera_status_alarm.confirm_time AS confirmTime |
|
|
|
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, |
|
|
|
cameraAlarm.createTime AS createTime, |
|
|
|
cameraAlarm.updateTime AS updateTime, |
|
|
|
cameraAlarm.platform AS platform, |
|
|
|
cameraAlarm.confirmContent AS confirmContent, |
|
|
|
cameraAlarm.confirmTime AS confirmTime, |
|
|
|
${'cameraAlarm.autoRestore AS autoRestore,'} |
|
|
|
camera_status_resolve.id AS resolveId, |
|
|
|
camera_status.describe AS statusDescribe, |
|
|
|
camera_status_resolve.resolve AS resolve, |
|
|
|
"gbCamera".online AS cameraOnline, |
|
|
|
secret_yingshi.token AS yingshiToken, |
|
|
|
anxinIpc.t_video_ipc.name AS anxinIpcPosition, |
|
|
|
anxinStation.id AS anxinStationId, |
|
|
|
anxinStation.name AS anxinStationName, |
|
|
|
anxinStruc.name AS strucName, |
|
|
|
anxinStruc.id AS strucId |
|
|
|
FROM |
|
|
|
( |
|
|
|
SELECT |
|
|
|
camera.id AS cameraId, |
|
|
|
camera.gb_id AS gbId, |
|
|
|
camera.name AS cameraName, |
|
|
|
camera.kind_id AS cameraKindId, |
|
|
|
camera.vender_id AS venderId, |
|
|
|
camera.yingshi_secret_id AS yingshiSecretId, |
|
|
|
vender.name AS venderName, |
|
|
|
camera_status_alarm.id AS alarmId, |
|
|
|
camera_status_alarm.create_time AS createTime, |
|
|
|
camera_status_alarm.update_time AS updateTime, |
|
|
|
camera_status_alarm.platform AS platform, |
|
|
|
camera_status_alarm.status_id AS statusId, |
|
|
|
camera_status_alarm.serial_no AS cameraSerialNo, |
|
|
|
camera_status_alarm.channel_no AS cameraChannelNo, |
|
|
|
camera_status_alarm.confirm AS confirmContent, |
|
|
|
${'camera_status_alarm.auto_restore AS autoRestore,'} |
|
|
|
camera_status_alarm.confirm_time AS confirmTime |
|
|
|
FROM camera_status_alarm |
|
|
|
INNER JOIN camera |
|
|
|
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 |
|
|
|
INNER JOIN camera |
|
|
|
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 |
|
|
|
RIGHT 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(',')})`} |
|
|
|
) |
|
|
|
${limit ? 'LIMIT ' + limit : ''} |
|
|
|
${limit && page ? 'OFFSET ' + parseInt(limit) * parseInt(page) : ''} |
|
|
|
) AS cameraAlarm |
|
|
|
LEFT JOIN camera_status |
|
|
|
ON cameraAlarm.platform = camera_status.platform |
|
|
|
AND cameraAlarm.statusId = camera_status.id |
|
|
|
LEFT JOIN camera_status_resolve |
|
|
|
ON camera_status_resolve.status_id = camera_status.id |
|
|
|
LEFT JOIN "gbCamera" |
|
|
|
ON "gbCamera".id = cameraAlarm.gbId |
|
|
|
LEFT JOIN "secret_yingshi" |
|
|
|
ON "secret_yingshi".id = cameraAlarm.yingshiSecretId |
|
|
|
RIGHT 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(',')})`} |
|
|
|
) |
|
|
|
${limit ? 'LIMIT ' + limit : ''} |
|
|
|
${limit && page ? 'OFFSET ' + parseInt(limit) * parseInt(page) : ''} |
|
|
|
) AS cameraAlarm |
|
|
|
LEFT JOIN camera_status |
|
|
|
ON cameraAlarm.platform = camera_status.platform |
|
|
|
AND cameraAlarm.statusId = camera_status.id |
|
|
|
LEFT JOIN camera_status_resolve |
|
|
|
ON camera_status_resolve.status_id = camera_status.id |
|
|
|
LEFT JOIN "gbCamera" |
|
|
|
ON "gbCamera".id = cameraAlarm.gbId |
|
|
|
LEFT JOIN "secret_yingshi" |
|
|
|
ON "secret_yingshi".id = cameraAlarm.yingshiSecretId |
|
|
|
|
|
|
|
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(',')}) |
|
|
|
${keywordTarget == 'struc' && keyword ? `AND anxinStruc.name LIKE '%${keyword}%'` : ''} |
|
|
|
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 |
|
|
|
` |
|
|
|
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(',')}) |
|
|
|
${keywordTarget == 'struc' && keyword ? `AND anxinStruc.name LIKE '%${keyword}%'` : ''} |
|
|
|
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 |
|
|
|
` |
|
|
|
const alarmRes = anxinStrucIds.length ? await clickHouse.vcmp.query( |
|
|
|
queryStr |
|
|
|
).toPromise() : [] |
|
|
|
|
|
|
|
console.log(queryStr); |
|
|
|
let returnD = [] |
|
|
|
let positionD = {} |
|
|
|
// 每个设备一个告警
|
|
|
|