Browse Source

(*)应用异常告警入库接口修改

dev
wuqun 2 years ago
parent
commit
e8a05976a9
  1. 24
      api/app/lib/controllers/alarm/app.js

24
api/app/lib/controllers/alarm/app.js

@ -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 {
projectCorrelationId: d,
alarmInfo: { messageMode: 'AlarmGeneration', sourceName: appName.name, content: alarmContent, type },//AlarmGeneration代表告警首次产生 alarmInfo: { messageMode: 'AlarmGeneration', sourceName: appName.name, content: alarmContent, type },//AlarmGeneration代表告警首次产生
time: now, time: now,
type: constTypes[type] type: constTypes[type]
} }
}) let r = await models.AlarmAppearRecord.create(data, { returning: true });
let rslt = await models.AlarmAppearRecord.bulkCreate(datas, { returning: true }); let dynamic = {
let dynamics = rslt.map(r => { time: r.dataValues.time,
return { alarmAppearId: r.dataValues.id,
time: r.time, projectCorrelationId: r.dataValues.projectCorrelationId,
alarmAppearId: r.id,
projectCorrelationId: r.projectCorrelationId,
type: 1//发现 type: 1//发现
} }
}) await models.LatestDynamicList.create(dynamic);
await models.LatestDynamicList.bulkCreate(dynamics);
}
} }
} }

Loading…
Cancel
Save