From 2418f6a550f1fe136df1df3d32b38a8be01f583c Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Wed, 28 Sep 2022 17:57:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E7=A1=AE=E8=AE=A4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/alarm/data.js | 40 +++++++++++++++------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/api/app/lib/controllers/alarm/data.js b/api/app/lib/controllers/alarm/data.js index c8ef878..ce2a1cd 100644 --- a/api/app/lib/controllers/alarm/data.js +++ b/api/app/lib/controllers/alarm/data.js @@ -241,7 +241,7 @@ function confirm (opts) { */ const alarmRes = await clickHouse.dataAlarm.query(` - SELECT * FROM alarms WHERE AlarmId = '${alarmId}' + SELECT * FROM alarms WHERE AlarmId IN (${alarmId.split(',').map(a => `'${a}'`).join(',')}) `).toPromise(); if (!alarmRes.length) { @@ -252,23 +252,27 @@ function confirm (opts) { if ([3, 4].some(s => s == corAlarm.State)) { throw '告警信息已确认' } - const message = { - messageMode: "AlarmManElimination", - sourceId: corAlarm.SourceId, - alarmTypeCode: corAlarm.AlarmTypeCode, - sponsor: opts.anxinCloud.confirmAlarmAnxinUserId, - content: content, - time: moment().toISOString() - }; - - const payloads = [{ - topic: `${opts.kafka.topicPrefix}_alarm`, - messages: [JSON.stringify(message)], - partition: 0 - }]; - - await kfkSendAsync(payloads) - + for (let corAlarm of alarmRes) { + if ([3, 4].some(s => s == corAlarm.State)) { + continue + } + const message = { + messageMode: "AlarmManElimination", + sourceId: corAlarm.SourceId, + alarmTypeCode: corAlarm.AlarmTypeCode, + sponsor: opts.anxinCloud.confirmAlarmAnxinUserId, + content: content, + time: moment().toISOString() + }; + + const payloads = [{ + topic: `${opts.kafka.topicPrefix}_alarm`, + messages: [JSON.stringify(message)], + partition: 0 + }]; + + await kfkSendAsync(payloads) + } ctx.status = 204; } catch (error) { ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);