You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
'use strict';
|
|
|
|
|
|
|
|
async function list (ctx) {
|
|
|
|
try {
|
|
|
|
const { models } = ctx.fs.dc;
|
|
|
|
const { clickHouse } = ctx.app.fs
|
|
|
|
const { utils: { judgeSuper, anxinStrucRange } } = ctx.app.fs
|
|
|
|
const { database: anxinyun } = clickHouse.anxinyun.opts.config
|
|
|
|
|
|
|
|
const isSuper = judgeSuper(ctx)
|
|
|
|
let anxinStrucIds = null
|
|
|
|
if (!isSuper) {
|
|
|
|
anxinStrucIds = await anxinStrucRange(ctx)
|
|
|
|
}
|
|
|
|
const alarmRes = await clickHouse.dataAlarm.query(`
|
|
|
|
SELECT
|
|
|
|
AlarmId, SourceName, name
|
|
|
|
FROM
|
|
|
|
alarms
|
|
|
|
LEFT JOIN ${anxinyun}.t_structure
|
|
|
|
ON ${anxinyun}.t_structure.id = alarms.StructureId
|
|
|
|
`).toPromise();
|
|
|
|
|
|
|
|
ctx.status = 200;
|
|
|
|
ctx.body = []
|
|
|
|
} catch (error) {
|
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: error`);
|
|
|
|
ctx.status = 400;
|
|
|
|
ctx.body = {
|
|
|
|
message: typeof error == 'string' ? error : undefined
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
list
|
|
|
|
};
|