wuqun 2 years ago
parent
commit
87febdf306
  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

@ -7,16 +7,21 @@ async function groupList (ctx) {
const { models } = ctx.fs.dc;
const { clickHouse } = ctx.app.fs
const { database: dataAlarm } = clickHouse.dataAlarm.opts.config
const groupRes = await clickHouse.anxinyun.query(`
SELECT * FROM t_alarm_group
`).toPromise();
for (let g of groupRes) {
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();
}
ctx.status = 200;
ctx.body = groupRes
} catch (error) {

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

@ -8,9 +8,15 @@ async function deviceType (ctx) {
const { clickHouse } = ctx.app.fs
const kindRes = await clickHouse.vcmp.query(`
SELECT * FROM camera_kind
`).toPromise()
SELECT DISTINCT
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.body = kindRes
} catch (error) {

Loading…
Cancel
Save