Browse Source

#告警修改

zhongwei
yang_shj 1 year ago
parent
commit
a725c2a79a
  1. 2
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/MessageService.java
  2. 2
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/impl/MessageServiceImpl.java
  3. 30
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java

2
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 { public interface MessageService {
void message(AlarmEntity entity); void shortMessage(AlarmEntity entity);
void webAppMessage(AlarmEntity entity); void webAppMessage(AlarmEntity entity);

2
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 : 告警对象 * @param entity : 告警对象
*/ */
@Override @Override
public void message(AlarmEntity entity) { public void shortMessage(AlarmEntity entity) {
} }

30
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.alibaba.fastjson.JSONObject;
import com.hnac.hzims.alarm.entity.AlarmEntity; 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 lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.queue.annotation.RedisQueue; import org.springblade.queue.annotation.RedisQueue;
import org.springblade.queue.consume.IQueueConsume; import org.springblade.queue.consume.IQueueConsume;
import org.springframework.beans.factory.annotation.Autowired; 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; import org.springframework.stereotype.Service;
/** /**
@ -18,11 +21,32 @@ import org.springframework.stereotype.Service;
public class AlarmListener implements IQueueConsume { public class AlarmListener implements IQueueConsume {
@Autowired @Autowired
private RedisTemplate redisTemplate; private MessageService messageService;
@Autowired
private StringRedisTemplate redisTemplate;
@Override @Override
public void handlerMessage(String message) { public void handlerMessage(String message) {
if(StringUtil.isEmpty(message)){
return;
}
// 步骤1.消息对象转换
AlarmEntity alarm = JSONObject.parseObject(message,AlarmEntity.class); 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);
}
} }
} }
Loading…
Cancel
Save