diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java index bee063e..cc0629b 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java @@ -24,5 +24,8 @@ public class ShowQueryVo { @ApiModelProperty(value = "告警子类") private Integer alarmType; + + @ApiModelProperty(value = "告警内容") + private String content; } 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 cff87ff..e8393f4 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 @@ -34,17 +34,22 @@ public class AlarmListener implements IQueueConsume { // 步骤1.消息对象转换 AlarmEntity alarm = JSONObject.parseObject(message,AlarmEntity.class); - // 步骤2.WEB/APP消息推送 + // 步骤2.websocket消息推送 + if(ObjectUtil.isNotEmpty(alarm.getIsRightTabulation()) && alarm.getIsRightTabulation() == 0){ + + } + + // 步骤3.WEB/APP消息推送 if(ObjectUtil.isNotEmpty(alarm.getIsPlatformMessage()) && alarm.getIsPlatformMessage() == 0){ messageService.webAppMessage(alarm); } - // 步骤3.短信推送 + // 步骤4.短信推送 if(ObjectUtil.isNotEmpty(alarm.getIsShortMessage()) && alarm.getIsShortMessage() == 0){ messageService.shortMessage(alarm); } - // 步骤4.微信公众号发送 + // 步骤5.微信公众号发送 if(ObjectUtil.isNotEmpty(alarm.getIsWxMessage()) && alarm.getIsWxMessage() == 0){ messageService.weChatMessage(alarm); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index d976531..be038f1 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -106,6 +106,9 @@ public class AlarmServiceImpl extends ServiceImpl impl if(!StringUtil.isEmpty(showQuery.getAlarmType())){ wrapper.eq("ALARM_TYPE",showQuery.getAlarmType()); } + if(!StringUtil.isEmpty(showQuery.getContent())){ + wrapper.like("alarmContext",showQuery.getContent()); + } // 处理告警过滤 :当天处理告警 List handles = alarmHandleService.handles(); @@ -186,6 +189,9 @@ public class AlarmServiceImpl extends ServiceImpl impl }).collect(Collectors.toList()); } + + + /** * 播报告警 * @param startTime diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java index f6052a0..668a4b8 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java @@ -6,6 +6,9 @@ import com.hnac.hzims.business.ws.alart.vo.AlartParamVo; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; +import org.springblade.system.feign.IDeptClient; +import org.springblade.system.feign.ISysClient; +import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.TextMessage; @@ -31,13 +34,11 @@ public class AlarmHandler extends TextWebSocketHandler { session.getAttributes().put("userId", uid); log.info("sessionId: " + session.getId()); log.info("session connection successful!"); - AlarmSocketPool.pool.put(session.getId(), this); } @Override public void afterConnectionClosed(WebSocketSession session, CloseStatus status) { AlarmSessionManager.removeAndClose(session.getId()); - AlarmSocketPool.pool.remove(session.getId()); log.info("sessionId: " + session.getId()); log.info("uri: " + session.getUri()); log.info("session closed successful!"); @@ -46,7 +47,6 @@ public class AlarmHandler extends TextWebSocketHandler { @Override public void handleTransportError(WebSocketSession session, Throwable exception) { AlarmSessionManager.removeAndClose(session.getId()); - AlarmSocketPool.pool.remove(session.getId()); } @Override diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSessionManager.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSessionManager.java index b54e6b2..d2227b9 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSessionManager.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSessionManager.java @@ -55,7 +55,6 @@ public class AlarmSessionManager { throw new RuntimeException("关闭ws会话失败!", ex); } } - SESSION_POOL.remove(uid); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketConfig.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketConfig.java index bbceab3..051da5a 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketConfig.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketConfig.java @@ -18,11 +18,11 @@ public class AlarmSocketConfig implements WebSocketConfigurer{ @Override public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { // 集中监控弹框处理器 - registry.addHandler(monitorHandler(), "/alarm/alart/{uid}").setAllowedOrigins("*"); + registry.addHandler(alarmHandler(), "/alarm/alart/{uid}").setAllowedOrigins("*"); } @Bean - public WebSocketHandler monitorHandler() { + public WebSocketHandler alarmHandler() { return new AlarmHandler(); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketPool.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketPool.java deleted file mode 100644 index c7bc6cc..0000000 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketPool.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.hnac.hzims.alarm.ws.alart; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * @author ysj - */ -public class AlarmSocketPool { - - public static Map pool = new ConcurrentHashMap<>(); - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java index 8d89a72..4e502cc 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java @@ -62,6 +62,7 @@ public class AlarmScheduledTask { */ @XxlJob(INTERRUPT_ALARM) //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT interruption(String param) { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java index 486a396..6d92b14 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java @@ -27,6 +27,7 @@ import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.mqtt.producer.IMqttSender; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -55,7 +56,7 @@ public class AlarmServiceImpl implements AlarmService { private final RedisTemplate redisTemplate; - //private final IMqttSender mqttSender; + private final IMqttSender mqttSender; private final static String start_stop_cache_final = "hzims:operation:start:stop:key"; private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; @@ -279,7 +280,7 @@ public class AlarmServiceImpl implements AlarmService { alarm.setContext(entity.getSoeExplain()); alarm.setState(entity.getStatus()); log.error("send_interruption_msg : {}",JsonUtil.toJson(alarm)); - //mqttSender.sendToMqtt(InterruptionConstants.HZ3000_TOPIC_PREFIX + entity.getStationId(), JsonUtil.toJson(alarm)); + mqttSender.sendToMqtt(InterruptionConstants.HZ3000_TOPIC_PREFIX + entity.getStationId(), JsonUtil.toJson(alarm)); }); }