From e8a05976a93f546c8443965568fe4f815af95f45 Mon Sep 17 00:00:00 2001 From: wuqun Date: Tue, 1 Nov 2022 13:39:04 +0800 Subject: [PATCH] =?UTF-8?q?(*)=E5=BA=94=E7=94=A8=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E5=85=A5=E5=BA=93=E6=8E=A5=E5=8F=A3=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/alarm/app.js | 34 ++++++++++++---------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/api/app/lib/controllers/alarm/app.js b/api/app/lib/controllers/alarm/app.js index 51bd88c..d5e217b 100644 --- a/api/app/lib/controllers/alarm/app.js +++ b/api/app/lib/controllers/alarm/app.js @@ -218,27 +218,21 @@ async function apiError(ctx) { }, attributes: ['name'], }) - let projects = belongsTo.projectCorrelation.map(d => d.id);//归属项目 - if (projects.length) { - let datas = projects.map(d => {//需要 项目,告警源,异常类型,时间 - return { - projectCorrelationId: d, - alarmInfo: { messageMode: 'AlarmGeneration', sourceName: appName.name, content: alarmContent, type },//AlarmGeneration代表告警首次产生 - 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 pId = belongsTo.projectCorrelation.dataValues.id;//归属项目 + let data = { + projectCorrelationId: pId, + alarmInfo: { messageMode: 'AlarmGeneration', sourceName: appName.name, content: alarmContent, type },//AlarmGeneration代表告警首次产生 + time: now, + type: constTypes[type] } + 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); } }