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.
49 lines
1.4 KiB
49 lines
1.4 KiB
'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
|
|
};
|