Browse Source

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

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

34
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 { 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);
} }
} }

Loading…
Cancel
Save