From 88f21851609cb14b853dc38bdd50896e1cad19c6 Mon Sep 17 00:00:00 2001 From: deartibers <947466799@qq.com> Date: Wed, 16 Nov 2022 14:16:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=B8=AD=E6=96=AD=E3=80=81?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BC=82=E5=B8=B8=E3=80=81=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=AD=A4=E5=A4=84=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/alarm/data.js | 9 +++++++-- api/app/lib/controllers/alarm/video.js | 12 +++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/api/app/lib/controllers/alarm/data.js b/api/app/lib/controllers/alarm/data.js index 817d7d9..9524981 100644 --- a/api/app/lib/controllers/alarm/data.js +++ b/api/app/lib/controllers/alarm/data.js @@ -6,16 +6,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) { diff --git a/api/app/lib/controllers/alarm/video.js b/api/app/lib/controllers/alarm/video.js index 5ba4718..24bbacf 100644 --- a/api/app/lib/controllers/alarm/video.js +++ b/api/app/lib/controllers/alarm/video.js @@ -7,9 +7,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) {