|
|
@ -6,15 +6,16 @@ async function list (ctx) { |
|
|
|
const { clickHouse } = ctx.app.fs |
|
|
|
const { utils: { judgeSuper, anxinStrucIdRange } } = ctx.app.fs |
|
|
|
const { database: anxinyun } = clickHouse.anxinyun.opts.config |
|
|
|
const { pepProjectId } = ctx.query |
|
|
|
|
|
|
|
const isSuper = judgeSuper(ctx) |
|
|
|
let anxinStrucIds = null |
|
|
|
if (!isSuper) { |
|
|
|
anxinStrucIds = await anxinStrucIdRange(ctx) |
|
|
|
if (!isSuper || pepProjectId) { |
|
|
|
anxinStrucIds = await anxinStrucIdRange({ ctx, pepProjectId }) |
|
|
|
} |
|
|
|
const alarmRes = await clickHouse.dataAlarm.query(` |
|
|
|
SELECT |
|
|
|
AlarmId, SourceName, name |
|
|
|
AlarmId, SourceName, name AS StructureName, StructureId |
|
|
|
FROM |
|
|
|
alarms |
|
|
|
LEFT JOIN ${anxinyun}.t_structure |
|
|
@ -33,6 +34,28 @@ async function list (ctx) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async function detail (ctx) { |
|
|
|
try { |
|
|
|
const { models } = ctx.fs.dc; |
|
|
|
const { clickHouse } = ctx.app.fs |
|
|
|
const { alarmId } = ctx.query |
|
|
|
|
|
|
|
const detailRes = await clickHouse.dataAlarm.query(` |
|
|
|
SELECT * FROM alarm_details WHERE AlarmId = '${alarmId}' ORDER BY Time ASC |
|
|
|
`).toPromise()
|
|
|
|
|
|
|
|
ctx.status = 200; |
|
|
|
ctx.body = detailRes |
|
|
|
} 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 |
|
|
|
list, |
|
|
|
detail |
|
|
|
}; |