wuqun
2 years ago
5 changed files with 83 additions and 75 deletions
@ -0,0 +1,49 @@ |
|||
'use strict'; |
|||
|
|||
const moment = require('moment') |
|||
|
|||
async function alarmConfirmLog(ctx, confirmPost, content) { |
|||
try { |
|||
const { models } = ctx.fs.dc; |
|||
//存日志
|
|||
let logDatas = []; |
|||
confirmPost.map(cp => { |
|||
let { pepUserId, projectCorrelationIds, alarmInfo } = cp; |
|||
projectCorrelationIds.map(id => { |
|||
logDatas.push({ |
|||
pepUserId, |
|||
projectCorrelationId: id, |
|||
alarmInfo,//包含告警id,type,source
|
|||
confirmTime: moment().format(), |
|||
confirmContent: content |
|||
}) |
|||
}) |
|||
}) |
|||
let rslt = await models.AlarmConfirmLog.bulkCreate(logDatas, { returning: true }); |
|||
|
|||
//存最新动态
|
|||
let dynamics = rslt.map(r => { |
|||
return { |
|||
time: r.confirmTime, |
|||
alarmConfirmId: r.id, |
|||
projectCorrelationId: r.projectCorrelationId, |
|||
type: 4//告警确认
|
|||
} |
|||
}) |
|||
await models.LatestDynamicList.bulkCreate(dynamics); |
|||
|
|||
//TODO 消息推送到前端
|
|||
|
|||
|
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
module.exports = { |
|||
alarmConfirmLog |
|||
}; |
Loading…
Reference in new issue