diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/MessageService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/MessageService.java index 92b3f74..230150e 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/MessageService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/MessageService.java @@ -7,7 +7,7 @@ import com.hnac.hzims.alarm.entity.AlarmEntity; */ public interface MessageService { - void message(AlarmEntity entity); + void shortMessage(AlarmEntity entity); void webAppMessage(AlarmEntity entity); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/impl/MessageServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/impl/MessageServiceImpl.java index 9e62c3f..fd80cc9 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/impl/MessageServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/impl/MessageServiceImpl.java @@ -40,7 +40,7 @@ public class MessageServiceImpl implements MessageService { * @param entity : 告警对象 */ @Override - public void message(AlarmEntity entity) { + public void shortMessage(AlarmEntity entity) { } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java index 4956b5d..8741a71 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java @@ -2,11 +2,14 @@ package com.hnac.hzims.alarm.monitor.listener; import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.alarm.entity.AlarmEntity; +import com.hnac.hzims.alarm.handle.service.MessageService; +import com.hnac.hzims.message.fegin.IMessageClient; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.StringUtil; import org.springblade.queue.annotation.RedisQueue; import org.springblade.queue.consume.IQueueConsume; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; /** @@ -18,11 +21,32 @@ import org.springframework.stereotype.Service; public class AlarmListener implements IQueueConsume { @Autowired - private RedisTemplate redisTemplate; + private MessageService messageService; + + @Autowired + private StringRedisTemplate redisTemplate; @Override public void handlerMessage(String message) { + if(StringUtil.isEmpty(message)){ + return; + } + // 步骤1.消息对象转换 AlarmEntity alarm = JSONObject.parseObject(message,AlarmEntity.class); - log.error("handler_message_alarm : {}",alarm); + + // 步骤2.WEB/APP消息推送 + if(alarm.getIsPlatformMessage() == 0){ + messageService.webAppMessage(alarm); + } + + // 步骤3.短信推送 + if(alarm.getIsShortMessage() == 0){ + messageService.shortMessage(alarm); + } + + // 步骤4.微信公众号发送 + if(alarm.getIsWxMessage() == 0){ + messageService.weChatMessage(alarm); + } } } \ No newline at end of file