Browse Source

Merge remote-tracking branch 'origin/prod-5.1.3' into prod-5.1.3

zhongwei
ty 4 months ago
parent
commit
c85e25babb
  1. 3
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java
  2. 11
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java
  3. 6
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java
  4. 6
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java
  5. 1
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSessionManager.java
  6. 4
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketConfig.java
  7. 13
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketPool.java
  8. 1
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java
  9. 5
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java

3
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;
}

11
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);
}

6
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<AlarmMapper, AlarmEntity> impl
if(!StringUtil.isEmpty(showQuery.getAlarmType())){
wrapper.eq("ALARM_TYPE",showQuery.getAlarmType());
}
if(!StringUtil.isEmpty(showQuery.getContent())){
wrapper.like("alarmContext",showQuery.getContent());
}
// 处理告警过滤 :当天处理告警
List<String> handles = alarmHandleService.handles();
@ -186,6 +189,9 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
}).collect(Collectors.toList());
}
/**
* 播报告警
* @param startTime

6
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

1
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);
}

4
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();
}

13
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketPool.java

@ -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<String, AlarmHandler> pool = new ConcurrentHashMap<>();
}

1
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<String> interruption(String param) {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");

5
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));
});
}

Loading…
Cancel
Save