|
|
@ -252,19 +252,27 @@ async function count (ctx) { |
|
|
|
|
|
|
|
const alarmRes = anxinStrucIds.length ? await clickHouse.vcmp.query( |
|
|
|
` |
|
|
|
SELECT |
|
|
|
SELECT |
|
|
|
cameraAlarm.cameraId AS cameraId, |
|
|
|
cameraAlarm.cameraName AS cameraName, |
|
|
|
cameraAlarm.cameraKindId AS cameraKindId, |
|
|
|
cameraAlarm.statusId AS statusId, |
|
|
|
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.platform AS platform, |
|
|
|
cameraAlarm.confirmTime AS confirmTime, |
|
|
|
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, |
|
|
@ -275,13 +283,20 @@ async function count (ctx) { |
|
|
|
SELECT |
|
|
|
camera.id AS cameraId, |
|
|
|
camera.gb_id AS gbId, |
|
|
|
camera.name AS cameraName, |
|
|
|
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.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 |
|
|
@ -292,14 +307,14 @@ async function count (ctx) { |
|
|
|
WHERE |
|
|
|
camera.delete = '0' |
|
|
|
AND camera.recycle_time is null |
|
|
|
AND camera_status_alarm.create_time >= '${moment().startOf("day").format('YYYY-MM-DD HH:mm:ss')}' |
|
|
|
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(',')}, -1)` |
|
|
|
} |
|
|
|
${`WHERE ${anxinyun}.t_video_ipc.structure IN (${anxinStrucIds.join(',')})`} |
|
|
|
) |
|
|
|
) AS cameraAlarm |
|
|
|
LEFT JOIN camera_status |
|
|
@ -309,12 +324,15 @@ async function count (ctx) { |
|
|
|
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(',')}, -1) |
|
|
|
AND anxinStruc.id IN (${anxinStrucIds.join(',')}) |
|
|
|
LEFT JOIN ${anxinyun}.t_video_ipc_station AS anxinIpcStation |
|
|
|
ON anxinIpcStation.ipc = anxinIpc.id |
|
|
|
LEFT JOIN ${anxinyun}.t_sensor AS anxinStation |
|
|
@ -328,16 +346,83 @@ async function count (ctx) { |
|
|
|
for (let a of alarmRes) { |
|
|
|
if (positionD[a.cameraId]) { |
|
|
|
let curD = returnD[positionD[a.cameraId].positionReturnD] |
|
|
|
|
|
|
|
if (a.resolveId && !curD.resolve.some(r => r.id == a.resolveId)) { |
|
|
|
curD.resolve.push({ |
|
|
|
id: a.resolveId, |
|
|
|
resolve: a.resolve |
|
|
|
}) |
|
|
|
} |
|
|
|
if (a.strucId && !curD.struc.some(s => s.id == a.strucId)) { |
|
|
|
curD.struc.push({ |
|
|
|
id: a.strucId, |
|
|
|
projectId: a.projectId, |
|
|
|
name: a.strucName |
|
|
|
}) |
|
|
|
} |
|
|
|
if (a.anxinStationId && !curD.station.some(s => s.id == a.anxinStationId)) { |
|
|
|
curD.station.push({ |
|
|
|
id: a.anxinStationId, |
|
|
|
name: a.anxinStationName, |
|
|
|
position: a.anxinIpcPosition |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
let d = { |
|
|
|
cameraId: a.cameraId, |
|
|
|
cameraName: a.cameraName, |
|
|
|
statusId: a.statusId, |
|
|
|
camerOnline: a.cameraOnline, |
|
|
|
cameraSerialNo: a.cameraSerialNo, |
|
|
|
cameraChannelNo: a.cameraChannelNo, |
|
|
|
autoRestore: a.autoRestore, |
|
|
|
createTime: a.createTime, |
|
|
|
updateTime: a.updateTime, |
|
|
|
platform: a.platform, |
|
|
|
statusDescribe: a.statusDescribe, |
|
|
|
alarmId: a.alarmId, |
|
|
|
confirmContent: a.confirmContent, |
|
|
|
confirmTime: a.confirmTime, |
|
|
|
|
|
|
|
venderId: a.venderId, |
|
|
|
venderName: a.venderName, |
|
|
|
cameraKindId: a.cameraKindId, |
|
|
|
yingshiToken: a.yingshiToken, |
|
|
|
|
|
|
|
resolve: [], |
|
|
|
struc: [], |
|
|
|
station: [] |
|
|
|
} |
|
|
|
|
|
|
|
// pep 项目
|
|
|
|
d.pomsProject = ( |
|
|
|
anxinStruc.find(as => as.strucId == a.strucId) || |
|
|
|
{ |
|
|
|
pomsProject: [ |
|
|
|
|
|
|
|
] |
|
|
|
} |
|
|
|
).pomsProject |
|
|
|
|
|
|
|
if (a.resolveId) { |
|
|
|
d.resolve.push({ |
|
|
|
id: a.resolveId, |
|
|
|
resolve: a.resolve |
|
|
|
}) |
|
|
|
} |
|
|
|
if (a.strucId) { |
|
|
|
d.struc.push({ |
|
|
|
id: a.strucId, |
|
|
|
projectId: a.projectId, |
|
|
|
name: a.strucName |
|
|
|
}) |
|
|
|
} |
|
|
|
if (a.anxinStationId) { |
|
|
|
d.station.push({ |
|
|
|
id: a.anxinStationId, |
|
|
|
name: a.anxinStationName, |
|
|
|
position: a.anxinIpcPosition |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
returnD.push(d) |
|
|
|
positionD[a.cameraId] = { |
|
|
|
positionReturnD: returnD.length - 1 |
|
|
|