|
@ -7,16 +7,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) { |
|
|