|
@ -218,27 +218,21 @@ async function apiError(ctx) { |
|
|
}, |
|
|
}, |
|
|
attributes: ['name'], |
|
|
attributes: ['name'], |
|
|
}) |
|
|
}) |
|
|
let projects = belongsTo.projectCorrelation.map(d => d.id);//归属项目
|
|
|
let pId = belongsTo.projectCorrelation.dataValues.id;//归属项目
|
|
|
if (projects.length) { |
|
|
let data = { |
|
|
let datas = projects.map(d => {//需要 项目,告警源,异常类型,时间
|
|
|
projectCorrelationId: pId, |
|
|
return { |
|
|
alarmInfo: { messageMode: 'AlarmGeneration', sourceName: appName.name, content: alarmContent, type },//AlarmGeneration代表告警首次产生
|
|
|
projectCorrelationId: d, |
|
|
time: now, |
|
|
alarmInfo: { messageMode: 'AlarmGeneration', sourceName: appName.name, content: alarmContent, type },//AlarmGeneration代表告警首次产生
|
|
|
type: constTypes[type] |
|
|
time: now, |
|
|
|
|
|
type: constTypes[type] |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
let rslt = await models.AlarmAppearRecord.bulkCreate(datas, { returning: true }); |
|
|
|
|
|
let dynamics = rslt.map(r => { |
|
|
|
|
|
return { |
|
|
|
|
|
time: r.time, |
|
|
|
|
|
alarmAppearId: r.id, |
|
|
|
|
|
projectCorrelationId: r.projectCorrelationId, |
|
|
|
|
|
type: 1//发现
|
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
await models.LatestDynamicList.bulkCreate(dynamics); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
let r = await models.AlarmAppearRecord.create(data, { returning: true }); |
|
|
|
|
|
let dynamic = { |
|
|
|
|
|
time: r.dataValues.time, |
|
|
|
|
|
alarmAppearId: r.dataValues.id, |
|
|
|
|
|
projectCorrelationId: r.dataValues.projectCorrelationId, |
|
|
|
|
|
type: 1//发现
|
|
|
|
|
|
} |
|
|
|
|
|
await models.LatestDynamicList.create(dynamic); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|