wenlele 2 years ago
parent
commit
2665ce3be2
  1. 29
      api/app/lib/controllers/alarm/video.js

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

@ -27,7 +27,7 @@ async function alarmList (ctx) {
const { clickHouse } = ctx.app.fs
const { utils: { judgeSuper, anxinStrucIdRange } } = ctx.app.fs
const { database: anxinyun } = clickHouse.anxinyun.opts.config
const { pepProjectId, keywordTarget, keyword, state, kindId, sustainTimeStart, sustainTimeEnd, } = ctx.query
const { pepProjectId, keywordTarget, keyword, state, kindId, sustainTimeStart, sustainTimeEnd, limit, page, } = ctx.query
let anxinStruc = await anxinStrucIdRange({
ctx, pepProjectId, keywordTarget, keyword
@ -87,7 +87,9 @@ async function alarmList (ctx) {
camera_status.describe AS statusDescribe,
camera_status_resolve.resolve AS resolve,
"gbCamera".online AS cameraOnline,
anxinIpc.t_video_ipc.name,
anxinIpc.t_video_ipc.name AS anxinIpcPosition,
anxinStation.id AS anxinStationId,
anxinStation.name AS anxinStationName,
anxinStruc.name AS strucName,
anxinStruc.id AS strucId
FROM
@ -128,6 +130,8 @@ async function alarmList (ctx) {
${`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
@ -142,6 +146,10 @@ async function alarmList (ctx) {
AND anxinIpc.serial_no = cameraAlarm.cameraSerialNo
LEFT JOIN ${anxinyun}.t_structure AS anxinStruc
ON anxinStruc.id = anxinIpc.structure
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
`
).toPromise()
@ -163,6 +171,13 @@ async function alarmList (ctx) {
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,
@ -183,7 +198,8 @@ async function alarmList (ctx) {
cameraKindId: a.cameraKindId,
resolve: [],
struc: []
struc: [],
station: []
}
if (a.resolveId) {
d.resolve.push({
@ -197,6 +213,13 @@ async function alarmList (ctx) {
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

Loading…
Cancel
Save