From a725c2a79a09b4231a452c981dedae683659ab68 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Wed, 15 Nov 2023 15:15:05 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/alarm/handle/service/MessageService.java | 2 +- .../handle/service/impl/MessageServiceImpl.java | 2 +- .../alarm/monitor/listener/AlarmListener.java | 30 +++++++++++++++++++--- 3 files changed, 29 insertions(+), 5 deletions(-) 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