feat:支持无通道告警

V0.5.x
xiwa 2023-12-27 06:05:55 +08:00
parent aec5a23b3f
commit 7a4c5e7390
1 changed files with 17 additions and 7 deletions

View File

@ -231,22 +231,32 @@ public class RuleManager {
List<AlertService> alertServices = new ArrayList<>();
for (AlertConfig alertConfig : alertConfigs) {
if(alertConfig.getEnable()!=null && !alertConfig.getEnable()){
continue;
}
AlertService service = new AlertService();
service.setScript(script);
service.setDeviceInfoData(deviceInfoData);
service.setMessageService(messageService);
ChannelTemplate channelTemplate = channelTemplateData.findById(alertConfig.getMessageTemplateId());
ChannelConfig channelConfig = channelConfigData.findById(channelTemplate.getChannelConfigId());
Channel channel = channelData.findById(channelConfig.getChannelId());
Long channelConfigId = channelTemplate.getChannelConfigId();
service.setMessage(Message.builder()
.channel(channel.getCode())
.channelId(channel.getId())
.channelConfig(channelConfig.getParam())
Message message = Message.builder()
.content(channelTemplate.getContent())
.alertConfigId(alertConfig.getId())
.build());
.build();
if(channelConfigId!=null) {
ChannelConfig channelConfig = channelConfigData.findById(channelTemplate.getChannelConfigId());
Channel channel = channelData.findById(channelConfig.getChannelId());
message.setChannel(channel.getCode());
message.setChannelId(channel.getId());
message.setChannelConfig(channelConfig.getParam());
}
service.setMessage(message);
alertServices.add(service);
}
alertAction.setServices(alertServices);