Browse Source

数据中断、数据异常、视频异常此处类型

dev
deartibers 2 years ago
parent
commit
88f2185160
  1. 9
      api/app/lib/controllers/alarm/data.js
  2. 12
      api/app/lib/controllers/alarm/video.js

9
api/app/lib/controllers/alarm/data.js

@ -6,16 +6,21 @@ async function groupList (ctx) {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
const { clickHouse } = ctx.app.fs const { clickHouse } = ctx.app.fs
const { database: dataAlarm } = clickHouse.dataAlarm.opts.config
const groupRes = await clickHouse.anxinyun.query(` const groupRes = await clickHouse.anxinyun.query(`
SELECT * FROM t_alarm_group SELECT * FROM t_alarm_group
`).toPromise(); `).toPromise();
for (let g of groupRes) { for (let g of groupRes) {
g.unit = await await clickHouse.anxinyun.query(` g.unit = await await clickHouse.anxinyun.query(`
SELECT * FROM t_alarm_group_unit WHERE group_id = ${g.id} SELECT DISTINCT
t_alarm_group_unit.id AS id,t_alarm_group_unit.name AS name,t_alarm_group_unit.group_id AS groupId
FROM t_alarm_group_unit
INNER JOIN ${dataAlarm}.alarms
ON t_alarm_group_unit.id = ${dataAlarm}.alarms.AlarmGroupUnit
WHERE group_id = ${g.id}
`).toPromise(); `).toPromise();
} }
ctx.status = 200; ctx.status = 200;
ctx.body = groupRes ctx.body = groupRes
} catch (error) { } catch (error) {

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

@ -7,9 +7,15 @@ async function deviceType (ctx) {
const { clickHouse } = ctx.app.fs const { clickHouse } = ctx.app.fs
const kindRes = await clickHouse.vcmp.query(` const kindRes = await clickHouse.vcmp.query(`
SELECT * FROM camera_kind SELECT DISTINCT
`).toPromise() camera_kind.id AS id,camera_kind.kind AS kind
FROM camera_kind
INNER JOIN camera
ON camera_kind.id = camera.kind_id
INNER JOIN camera_status_alarm
ON camera.channel_no = camera_status_alarm.channel_no
AND camera.serial_no = camera_status_alarm.serial_no
`).toPromise()
ctx.status = 200; ctx.status = 200;
ctx.body = kindRes ctx.body = kindRes
} catch (error) { } catch (error) {

Loading…
Cancel
Save