|
|
@ -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}`); |
|
|
|