From ba333e50ac74b8623befca2ac79c541eb25438bd Mon Sep 17 00:00:00 2001 From: tyty Date: Fri, 27 Oct 2023 14:23:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E9=A2=84=E8=AD=A6=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/alarm/constants/AlarmConstants.java | 2 +- .../java/com/hnac/hzims/alarm/vo/FdpAlarmVo.java | 21 +++-- .../com/hnac/hzims/message/MessageConstants.java | 1 + hzims-service/hzims-alarm/pom.xml | 4 + .../com/hnac/hzims/alarm/mqtt/fdpMqttConfig.java | 53 +++++++++++ .../com/hnac/hzims/alarm/mqtt/fdpMqttConsumer.java | 40 ++++++++ .../alarm/show/service/VideoAlarmService.java | 16 ++++ .../alarm/show/service/impl/AlarmServiceImpl.java | 35 +++++++ .../service/impl/ConditionAlarmServiceImpl.java | 7 +- .../show/service/impl/FdpAlarmServiceImpl.java | 21 +++-- .../show/service/impl/VideoAlarmServiceImpl.java | 104 +++++++++++++++++++++ .../hnac/hzims/alarm/task/VideoScheduledTask.java | 37 ++++++++ .../hnac/hzims/alarm/ws/fdp/FdpAlarmWebSocket.java | 3 +- .../hzims/alarm/ws/hz3000/SystemAlarmRegular.java | 6 ++ .../alarm/ws/hz3000/SystemAlarmWebSocket.java | 1 + .../hzims/alarm/ws/level/LevelAlarmWebSocket.java | 1 + 16 files changed, 330 insertions(+), 22 deletions(-) create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/fdpMqttConfig.java create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/fdpMqttConsumer.java create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/VideoAlarmService.java create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/VideoAlarmServiceImpl.java create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/task/VideoScheduledTask.java diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/constants/AlarmConstants.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/constants/AlarmConstants.java index 2b2c366..76b9947 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/constants/AlarmConstants.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/constants/AlarmConstants.java @@ -52,5 +52,5 @@ public interface AlarmConstants { List LEVEL_ALARAM = Arrays.asList(ONE_LEVEL,TWO_LEVEL,THREE_LEVEL); Integer EARLY = 30; Integer CONDITION = 40; - + String VIDEO_SCHEDULED_TASK= "VideoScheduledTask"; } diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/FdpAlarmVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/FdpAlarmVo.java index 39b6b35..196b624 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/FdpAlarmVo.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/FdpAlarmVo.java @@ -23,6 +23,10 @@ public class FdpAlarmVo { */ private String station; /** + * 故障状态 + */ + private String status; + /** * 故障名称 */ private String name; @@ -30,10 +34,7 @@ public class FdpAlarmVo { * 位置 */ private String ord; - /** - * 故障状态 - */ - private Float status; + /** * 故障的附属信息 */ @@ -47,9 +48,17 @@ public class FdpAlarmVo { */ private String finfo; /** - * 报警内容 + * 内容 + */ + private String content; + /** + * 设备名称 */ - private Object[] children; + private String deviceName; +// /** +// * 报警内容 +// */ +// private Object[] children; /** * 创建时间 */ diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java index 789e160..0f0f9a1 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java @@ -64,6 +64,7 @@ public class MessageConstants { OVERHAUL_PLAN("overhaul-plan","检修计划"), OVERHAUL_TASK("overhaul-task","检修任务"), + ; @Getter private String key; diff --git a/hzims-service/hzims-alarm/pom.xml b/hzims-service/hzims-alarm/pom.xml index c5892ec..6525fd7 100644 --- a/hzims-service/hzims-alarm/pom.xml +++ b/hzims-service/hzims-alarm/pom.xml @@ -138,6 +138,10 @@ com.xuxueli xxl-job-core + + org.eclipse.paho + org.eclipse.paho.client.mqttv3 + diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/fdpMqttConfig.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/fdpMqttConfig.java new file mode 100644 index 0000000..dde46d4 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/fdpMqttConfig.java @@ -0,0 +1,53 @@ +package com.hnac.hzims.alarm.mqtt; + +import com.hnac.hzinfo.subscribe.AnalysisSubscribe; +import com.hnac.hzinfo.subscribe.MqttConfig; +import org.eclipse.paho.client.mqttv3.MqttException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import java.util.Collections; + +/** + * @Author: ty + */ + +@Component +public class fdpMqttConfig { + + @Autowired + fdpMqttConsumer fdpMqttConsumer; + @Value("${hzims.mqtt.fdp-url}") + private String mqtt_fdp_url; + @Value("${hzims.mqtt.fdp-group}") + private String mqtt_fdp_group; + @Value("${hzims.mqtt.fdp-password}") + private String mqtt_fdp_password; + @Value("${hzims.mqtt.fdp-username}") + private String mqtt_fdp_username; + @Value("${hzims.mqtt.fdp-topname}") + private String mqtt_fdp_topname; + @PostConstruct + public void registerMqtt(){ + try { + MqttConfig mqttConfig = new MqttConfig(); + mqttConfig.setUrl("tcp://175.6.40.68:1883"); + mqttConfig.setGroup("hzims-alarm"); + mqttConfig.setPassword("hz123456"); + mqttConfig.setUsername("hzinfo"); +// mqttConfig.setUrl(mqtt_fdp_url); +// mqttConfig.setGroup(mqtt_fdp_group); +// mqttConfig.setPassword(mqtt_fdp_password); +// mqttConfig.setUsername(mqtt_fdp_username); + AnalysisSubscribe analysisSubscribe = new AnalysisSubscribe(); + analysisSubscribe.subscribe(mqttConfig, Collections.singletonList("iot/sync/analytics/#"), fdpMqttConsumer); +// analysisSubscribe.subscribe(mqttConfig, mqtt_fdp_topname, fdpMqttConsumer); + }catch (MqttException e){ + e.printStackTrace(); + } + + + } +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/fdpMqttConsumer.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/fdpMqttConsumer.java new file mode 100644 index 0000000..5fdd86a --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/fdpMqttConsumer.java @@ -0,0 +1,40 @@ +package com.hnac.hzims.alarm.mqtt; + +import com.alibaba.fastjson.JSONObject; +import com.hnac.hzims.alarm.entity.AlarmEntity; +import com.hnac.hzims.alarm.show.service.AlarmService; +import com.hnac.hzims.alarm.show.service.FdpAlarmService; +import com.hnac.hzinfo.subscribe.SubscribeCallBack; +import org.springblade.core.log.exception.ServiceException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * + * @Author: ty + */ + +@Service +public class fdpMqttConsumer implements SubscribeCallBack { + @Autowired + private FdpAlarmService fdpAlarmService; + @Autowired + private AlarmService alarmService; + @Override + public void onMessage(Map data) { + System.out.println("监听到消息"+data.toString()); + String s = JSONObject.toJSONString(data); + //消费代码 + + List alarmEntities = fdpAlarmService.receiveMessage(s); + //统一数据处理 + try { + alarmService.dealAlarmEntities(alarmEntities); + }catch (Exception e){ + throw new ServiceException("集中监控告警数据处理报错(FdpAlarm):"+e); + } + } +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/VideoAlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/VideoAlarmService.java new file mode 100644 index 0000000..69ec3b2 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/VideoAlarmService.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.alarm.show.service; + +import com.hnac.hzims.alarm.entity.AlarmEntity; + +import java.util.List; + +/** + * 告警处理接口 + * @author ysj + */ +public interface VideoAlarmService { + + List sendMessage(); + + List receiveMessage(String message); +} 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 6816733..283b00e 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 @@ -11,12 +11,17 @@ import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.show.service.MessageService; import com.hnac.hzims.alarm.vo.AlarmCountVo; import com.hnac.hzims.alarm.vo.ChildAlarmCountVo; +import com.hnac.hzims.message.dto.MailMessageDTO; +import com.hnac.hzims.message.fegin.IMessageClient; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.StringUtil; +import org.springblade.system.user.entity.User; +import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -36,6 +41,8 @@ public class AlarmServiceImpl extends BaseServiceImpl private final AlarmConfigService configService; private final MessageService messageService; + private final IMessageClient messageClient; + private final IUserClient userClient; /** * 查询告警列表 @@ -185,4 +192,32 @@ public class AlarmServiceImpl extends BaseServiceImpl } return new ArrayList<>(); } + + /** + * websocket断联发送邮件 + * @return + */ + + public void sendMailByNum(Integer num,Integer maxConnent,String name) { + if (num>=maxConnent){ + MailMessageDTO mailMessageDTO = new MailMessageDTO(); + mailMessageDTO.setDeptId(200000L); + mailMessageDTO.setDeptName("华自科技"); + mailMessageDTO.setBusinessClassify("system"); + mailMessageDTO.setBusinessKey("Mail"); + mailMessageDTO.setSubject("邮件发送"); + mailMessageDTO.setContent(name+"websocket链接失败;"+"链接失败次数:"+num); + R> res = userClient.userListByRoleAlias("200000", "sendMail"); + if (!res.isSuccess()||CollectionUtil.isEmpty(res.getData())){ + log.error("消息发送失败:无对应用户"); + } + String userIds = res.getData().stream().map(s -> s.getId().toString()).collect(Collectors.joining(",")); + mailMessageDTO.setUserIds(userIds); + mailMessageDTO.setIsHtml(false); + R booleanR = messageClient.sendMailMsgByUsers(mailMessageDTO); + if (!booleanR.isSuccess()){ + log.error("消息发送失败:"+mailMessageDTO.getUserIds()+"--->"+booleanR.getMsg()); + } + } + } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/ConditionAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/ConditionAlarmServiceImpl.java index 3409174..7fd2384 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/ConditionAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/ConditionAlarmServiceImpl.java @@ -21,8 +21,7 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; -import static com.hnac.hzims.alarm.constants.AlarmConstants.EARLY; -import static com.hnac.hzims.alarm.constants.AlarmConstants.EARLY_WARNING; +import static com.hnac.hzims.alarm.constants.AlarmConstants.*; /** * 等级告警实现类 @@ -78,10 +77,10 @@ public class ConditionAlarmServiceImpl implements ConditionAlarmService { entity.setAlarmId(item.getFaultId()); entity.setAlarmTime(item.getCreateTime()); entity.setAlarmContext(item.getFinfo()); - entity.setAlarmType(EARLY); + entity.setAlarmType(CONDITION); entity.setAlarmStatus(Integer.valueOf(String.valueOf(item.getStatus()))); entity.setStationId(item.getStation()); - entity.setAlarmStatus(EARLY_WARNING); + entity.setAlarmSource(CONDITION_ALARM); entity.setTenantId("200000"); R stationByCode = stationClient.getStationByCode(item.getStation()); if (stationByCode.isSuccess()&& ObjectUtils.isNotEmpty(stationByCode.getData())){ diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/FdpAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/FdpAlarmServiceImpl.java index 7914954..a223553 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/FdpAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/FdpAlarmServiceImpl.java @@ -20,6 +20,7 @@ import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -68,15 +69,16 @@ public class FdpAlarmServiceImpl implements FdpAlarmService { @Override public List receiveMessage(String message) { // 对象转换 - List alarms = JSONObject.parseArray(message, FdpAlarmVo.class); - if (CollectionUtil.isEmpty(alarms)) { + FdpAlarmVo alarms = JSONObject.parseObject(message, FdpAlarmVo.class); + if (ObjectUtils.isEmpty(alarms)) { return new ArrayList<>(); } - List res = alarms.stream().map(s -> { - AlarmEntity entity = getAlarmEntity(s); - return entity; - }).collect(Collectors.toList()); - return res; + AlarmEntity entity = getAlarmEntity(alarms); +// List res = alarms.stream().map(s -> { +// AlarmEntity entity = getAlarmEntity(s); +// return entity; +// }).collect(Collectors.toList()); + return Collections.singletonList(entity); } private AlarmEntity getAlarmEntity(FdpAlarmVo item) { @@ -85,9 +87,10 @@ public class FdpAlarmServiceImpl implements FdpAlarmService { entity.setAlarmTime(item.getCreateTime()); entity.setAlarmContext(item.getFinfo()); entity.setAlarmType(EARLY); - entity.setAlarmStatus(Integer.valueOf(String.valueOf(item.getStatus()))); + entity.setDeviceName(item.getDeviceName()); + entity.setAlarmStatus(Integer.valueOf(item.getStatus())); entity.setStationId(item.getStation()); - entity.setAlarmStatus(EARLY_WARNING); + entity.setAlarmSource(EARLY_WARNING); entity.setTenantId("200000"); R stationByCode = stationClient.getStationByCode(item.getStation()); if (stationByCode.isSuccess()&& ObjectUtils.isNotEmpty(stationByCode.getData())){ diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/VideoAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/VideoAlarmServiceImpl.java new file mode 100644 index 0000000..4c3b235 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/VideoAlarmServiceImpl.java @@ -0,0 +1,104 @@ +package com.hnac.hzims.alarm.show.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.hnac.hzims.alarm.constants.AlarmConstants; +import com.hnac.hzims.alarm.entity.AlarmEntity; +import com.hnac.hzims.alarm.show.service.AlarmService; +import com.hnac.hzims.alarm.show.service.VideoAlarmService; +import com.hnac.hzims.alarm.vo.SystemAlarmVo; +import com.hnac.hzims.message.fegin.IMessageClient; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.feign.IStationClient; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.system.feign.ISysClient; +import org.springblade.system.user.feign.IUserClient; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 华自3000告警实现类 + * + * @author ty + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class VideoAlarmServiceImpl implements VideoAlarmService { + + private final IUserClient userClient; + + private final ISysClient sysClient; + + private final IMessageClient messageClient; + private final AlarmService alarmService; + private final IStationClient stationClient; + + /** + * 定时查询告警信息 + * @return String + */ + @Override + public List sendMessage() { + R> listAll = stationClient.getListAll(); + if (!listAll.isSuccess() || CollectionUtil.isEmpty(listAll.getData())) { + throw new ServiceException("暂无站点信息"); + } + List stations = listAll.getData(); + List collect = stations.stream().map(StationEntity::getCode).collect(Collectors.toList()); +// em_infoService +// collect +// +// +// +// map.put("soe_type", AbnormalAlarmConstant.SYSTEM_TYPE_LIST); +// return JSONObject.toJSONString(map); + return new ArrayList<>(); + } + + + /** + * 转换接收服务推送消息 + * @param message + */ + @Override + public List receiveMessage(String message) { + // 对象转换 + List alarms = JSONObject.parseArray(message, SystemAlarmVo.class); + if (CollectionUtil.isEmpty(alarms)) { + return new ArrayList<>(); + } + List res = alarms.stream().map(s -> { + AlarmEntity entity = getAlarmEntity(s); + return entity; + }).collect(Collectors.toList()); + return res; + } + + private AlarmEntity getAlarmEntity(SystemAlarmVo item) { + AlarmEntity entity = new AlarmEntity(); + entity.setAlarmId(item.getId()); + entity.setAlarmTime(DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s")); + entity.setAlarmContext(item.getSoeExplain()); + entity.setAlarmType(item.getSoeAlarmType()); + entity.setAlarmStatus(item.getSoeStatus()); + entity.setAlarmValue(item.getOptionvals()); + entity.setStationId(item.getStation()); + entity.setAlarmSource(AlarmConstants.HZ3000_ALARM); + entity.setTenantId("200000"); + R stationByCode = stationClient.getStationByCode(item.getStation()); + if (stationByCode.isSuccess() && ObjectUtils.isNotEmpty(stationByCode.getData())) { + entity.setCreateDept(stationByCode.getData().getCreateDept()); + entity.setStationName(stationByCode.getData().getName()); + } + return entity; + } +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/task/VideoScheduledTask.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/task/VideoScheduledTask.java new file mode 100644 index 0000000..126e897 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/task/VideoScheduledTask.java @@ -0,0 +1,37 @@ +package com.hnac.hzims.alarm.task; + +import com.hnac.hzims.alarm.show.service.VideoAlarmService; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import static com.hnac.hzims.alarm.constants.AlarmConstants.VIDEO_SCHEDULED_TASK; + + +/** + * 各厂站实时/指标数据 定时任务 + * @author ysj + */ +@Slf4j +@Component +public class VideoScheduledTask { + + @Autowired + private VideoAlarmService service; + + /** + * 设备信息缓存 + * @return + * @throws Exception + */ + @XxlJob(VIDEO_SCHEDULED_TASK) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT loadEmInfo(String param) { + service.sendMessage(); + + return new ReturnT<>("SUCCESS"); + } + +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/fdp/FdpAlarmWebSocket.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/fdp/FdpAlarmWebSocket.java index 6e514e0..fc51f00 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/fdp/FdpAlarmWebSocket.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/fdp/FdpAlarmWebSocket.java @@ -57,12 +57,11 @@ public class FdpAlarmWebSocket extends WebSocketClient { List alarmEntities = fdpAlarmService.receiveMessage(message); //统一数据处理 try { + //websocket 消息推送保存 alarmService.dealAlarmEntities(alarmEntities); }catch (Exception e){ throw new ServiceException("集中监控告警数据处理报错(FdpAlarm):"+e); } - // 等级告警数据处理 - fdpAlarmService.receiveMessage(message); } } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmRegular.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmRegular.java index 06b84f2..675aa47 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmRegular.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmRegular.java @@ -28,6 +28,7 @@ public class SystemAlarmRegular { @Autowired private SystemAlarmService systemAlarmService; + int count=0; // 定时发送消息 @Scheduled(cron = "0 0/30 * * * ?") private void regular(){ @@ -35,9 +36,14 @@ public class SystemAlarmRegular { if(ObjectUtil.isNotEmpty(client) && client.isOpen()){ client.send(systemAlarmService.sendMessage()); System.out.println("systemAlarm:存活"); + count=0; }else { System.out.println("systemAlarm:链接失败"); this.createClient(); + count++; + if (count>=3){ + + } } } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmWebSocket.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmWebSocket.java index e4b6c41..9d0d12d 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmWebSocket.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmWebSocket.java @@ -57,6 +57,7 @@ public class SystemAlarmWebSocket extends WebSocketClient { List alarmEntities = systemAlarmService.receiveMessage(message); //统一数据处理 try { + //websocket 消息推送保存 alarmService.dealAlarmEntities(alarmEntities); }catch (Exception e){ throw new ServiceException("集中监控告警数据处理报错:"+e); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/level/LevelAlarmWebSocket.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/level/LevelAlarmWebSocket.java index 11ebc3f..88d7e3a 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/level/LevelAlarmWebSocket.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/level/LevelAlarmWebSocket.java @@ -58,6 +58,7 @@ public class LevelAlarmWebSocket extends WebSocketClient { List alarmEntities = levelService.receiveMessage(message); // 等级告警数据处理 try { + //websocket 消息推送保存 alarmService.dealAlarmEntities(alarmEntities); }catch (Exception e){ throw new ServiceException("集中监控告警数据处理报错(levelAlarm):"+e);