From b99caae820f1d86e1c7aa4940762131d2c005e8f Mon Sep 17 00:00:00 2001 From: tyty Date: Fri, 17 Nov 2023 10:26:56 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E9=9B=86=E4=B8=AD=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8E=A8=E9=80=81=E4=BB=A3=E7=A0=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handle/service/ConditionAlarmService.java | 16 --- .../alarm/handle/service/DroolsAlarmService.java | 16 +++ .../service/impl/ConditionAlarmServiceImpl.java | 93 -------------- .../service/impl/DroolsAlarmServiceImpl.java | 93 ++++++++++++++ .../hnac/hzims/alarm/mqtt/DroolsMqttConsumer.java | 41 ++++++ .../com/hnac/hzims/alarm/mqtt/FdpMqttConsumer.java | 40 ++++++ .../hnac/hzims/alarm/mqtt/HZ300MqttConsumer.java | 40 ++++++ .../java/com/hnac/hzims/alarm/mqtt/MqttConfig.java | 68 ++++++++++ .../com/hnac/hzims/alarm/mqtt/fdpMqttConfig.java | 53 -------- .../com/hnac/hzims/alarm/mqtt/fdpMqttConsumer.java | 40 ------ .../hzims/alarm/show/service/AlarmService.java | 2 - .../alarm/show/service/impl/AlarmServiceImpl.java | 36 ------ .../hnac/hzims/alarm/task/VideoScheduledTask.java | 6 +- .../alarm/ws/condition/ConditionAlarmRegular.java | 60 --------- .../ws/condition/ConditionAlarmWebSocket.java | 136 -------------------- .../hnac/hzims/alarm/ws/fdp/FdpAlarmRegular.java | 56 -------- .../hnac/hzims/alarm/ws/fdp/FdpAlarmWebSocket.java | 138 -------------------- .../hzims/alarm/ws/hz3000/SystemAlarmRegular.java | 60 --------- .../alarm/ws/hz3000/SystemAlarmWebSocket.java | 142 --------------------- .../hzims/alarm/ws/level/LevelAlarmWebSocket.java | 6 +- 20 files changed, 304 insertions(+), 838 deletions(-) delete mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/ConditionAlarmService.java create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/DroolsAlarmService.java delete mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/impl/ConditionAlarmServiceImpl.java create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/impl/DroolsAlarmServiceImpl.java create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/DroolsMqttConsumer.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/mqtt/HZ300MqttConsumer.java create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java delete mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/fdpMqttConfig.java delete mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/fdpMqttConsumer.java delete mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmRegular.java delete mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmWebSocket.java delete mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/fdp/FdpAlarmRegular.java delete mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/fdp/FdpAlarmWebSocket.java delete mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmRegular.java delete mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmWebSocket.java diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/ConditionAlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/ConditionAlarmService.java deleted file mode 100644 index f2c7364..0000000 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/ConditionAlarmService.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.hnac.hzims.alarm.handle.service; - -import com.hnac.hzims.alarm.entity.AlarmEntity; - -import java.util.List; - -/** - * 等级处理接口 - * @author ysj - */ -public interface ConditionAlarmService { - - String message(); - - List receiveMessage(String message); -} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/DroolsAlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/DroolsAlarmService.java new file mode 100644 index 0000000..186609a --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/DroolsAlarmService.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.alarm.handle.service; + +import com.hnac.hzims.alarm.entity.AlarmEntity; + +import java.util.List; + +/** + * 等级处理接口 + * @author ysj + */ +public interface DroolsAlarmService { + + String message(); + + List receiveMessage(String message); +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/impl/ConditionAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/impl/ConditionAlarmServiceImpl.java deleted file mode 100644 index c04ba7a..0000000 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/impl/ConditionAlarmServiceImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.hnac.hzims.alarm.handle.service.impl; - -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -import com.hnac.hzims.alarm.entity.AlarmEntity; -import com.hnac.hzims.alarm.handle.service.ConditionAlarmService; -import com.hnac.hzims.alarm.handle.service.MessageService; -import com.hnac.hzims.alarm.show.service.AlarmService; -import com.hnac.hzims.alarm.vo.ConditionAlarmVo; -import com.hnac.hzims.equipment.feign.IEmInfoClient; -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.tool.api.R; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -import static com.hnac.hzims.alarm.constants.AlarmConstants.CONDITION; -import static com.hnac.hzims.alarm.constants.AlarmConstants.CONDITION_ALARM; - -/** - * 等级告警实现类 - * @author ysj - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class ConditionAlarmServiceImpl implements ConditionAlarmService { - - private final AlarmService alarmService; - - private final MessageService messageService; - - private final RedisTemplate redisTemplate; - - private final IEmInfoClient deviceClient; - - private final IStationClient stationClient; - - public final static String device_cache_cofig_final = "hzims:equipment:emInfo:deviceCode.emInfoList"; - - /** - * 发送websocket消息 - * @return - */ - @Override - public String message() { - return ""; - } - - - /** - * 转换接收服务推送消息 - * @param message - */ - @Override - public List receiveMessage(String message) { - // 对象转换 - List alarms = JSONObject.parseArray(message, ConditionAlarmVo.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(ConditionAlarmVo item) { - AlarmEntity entity = new AlarmEntity(); - entity.setAlarmId(item.getFaultId()); - entity.setAlarmTime(item.getCreateTime()); - entity.setAlarmContext(item.getFinfo()); - entity.setAlarmType(CONDITION); - entity.setAlarmStatus(Integer.valueOf(String.valueOf(item.getStatus()))); - entity.setStationId(item.getStation()); - entity.setAlarmSource(CONDITION_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; - } -} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/impl/DroolsAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/impl/DroolsAlarmServiceImpl.java new file mode 100644 index 0000000..501b131 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/handle/service/impl/DroolsAlarmServiceImpl.java @@ -0,0 +1,93 @@ +package com.hnac.hzims.alarm.handle.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.hnac.hzims.alarm.entity.AlarmEntity; +import com.hnac.hzims.alarm.handle.service.DroolsAlarmService; +import com.hnac.hzims.alarm.handle.service.MessageService; +import com.hnac.hzims.alarm.show.service.AlarmService; +import com.hnac.hzims.alarm.vo.ConditionAlarmVo; +import com.hnac.hzims.equipment.feign.IEmInfoClient; +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.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import static com.hnac.hzims.alarm.constants.AlarmConstants.CONDITION; +import static com.hnac.hzims.alarm.constants.AlarmConstants.CONDITION_ALARM; + +/** + * 等级告警实现类 + * @author ysj + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class DroolsAlarmServiceImpl implements DroolsAlarmService { + + private final AlarmService alarmService; + + private final MessageService messageService; + + private final RedisTemplate redisTemplate; + + private final IEmInfoClient deviceClient; + + private final IStationClient stationClient; + + public final static String device_cache_cofig_final = "hzims:equipment:emInfo:deviceCode.emInfoList"; + + /** + * 发送websocket消息 + * @return + */ + @Override + public String message() { + return ""; + } + + + /** + * 转换接收服务推送消息 + * @param message + */ + @Override + public List receiveMessage(String message) { + // 对象转换 + List alarms = JSONObject.parseArray(message, ConditionAlarmVo.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(ConditionAlarmVo item) { + AlarmEntity entity = new AlarmEntity(); + entity.setAlarmId(item.getFaultId()); + entity.setAlarmTime(item.getCreateTime()); + entity.setAlarmContext(item.getFinfo()); + entity.setAlarmType(CONDITION); + entity.setAlarmStatus(Integer.valueOf(String.valueOf(item.getStatus()))); + entity.setStationId(item.getStation()); + entity.setAlarmSource(CONDITION_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; + } +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/DroolsMqttConsumer.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/DroolsMqttConsumer.java new file mode 100644 index 0000000..33a9697 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/DroolsMqttConsumer.java @@ -0,0 +1,41 @@ +package com.hnac.hzims.alarm.mqtt; + +import com.alibaba.fastjson.JSONObject; +import com.hnac.hzims.alarm.entity.AlarmEntity; +import com.hnac.hzims.alarm.handle.service.DroolsAlarmService; +import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; +import com.hnac.hzinfo.subscribe.SubscribeCallBack; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * + * @Author: ty + */ + +@Service +@Slf4j +public class DroolsMqttConsumer implements SubscribeCallBack { + @Autowired + private DroolsAlarmService droolsAlarmService; + @Autowired + private AlarmSaveService alarmSaveService; + @Override + public void onMessage(Map data) { + System.out.println("监听到消息"+data.toString()); + String s = JSONObject.toJSONString(data); + //消费代码 + List alarmEntities = droolsAlarmService.receiveMessage(s); + //统一数据处理 + try { + alarmSaveService.save(alarmEntities); + }catch (Exception e){ + log.error("规则引擎告警数据处理报错(DroolsAlarm):"+e); + System.out.println("规则引擎告警数据处理报错(DroolsAlarm):"+e); + } + } +} 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..90fd7a6 --- /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.handle.service.FdpAlarmService; +import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; +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 AlarmSaveService alarmSaveService; + @Override + public void onMessage(Map data) { + System.out.println("监听到消息"+data.toString()); + String s = JSONObject.toJSONString(data); + //消费代码 + + List alarmEntities = fdpAlarmService.receiveMessage(s); + //统一数据处理 + try { + alarmSaveService.save(alarmEntities); + }catch (Exception e){ + throw new ServiceException("集中监控告警数据处理报错(FdpAlarm):"+e); + } + } +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/HZ300MqttConsumer.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/HZ300MqttConsumer.java new file mode 100644 index 0000000..6060a59 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/HZ300MqttConsumer.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.handle.service.SystemAlarmService; +import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; +import com.hnac.hzinfo.subscribe.SubscribeCallBack; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * + * @Author: ty + */ + +@Service +@Slf4j +public class HZ300MqttConsumer implements SubscribeCallBack { + @Autowired + private SystemAlarmService systemAlarmService; + @Autowired + private AlarmSaveService alarmSaveService; + @Override + public void onMessage(Map data) { + System.out.println("监听到消息"+data.toString()); + String s = JSONObject.toJSONString(data); + //消费代码 + List alarmEntities = systemAlarmService.receiveMessage(s); + //统一数据处理 + try { + alarmSaveService.save(alarmEntities); + }catch (Exception e){ + log.error("HZ3000告警数据处理报错(HZ300Alarm):"+e); + } + } +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java new file mode 100644 index 0000000..860785f --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java @@ -0,0 +1,68 @@ +package com.hnac.hzims.alarm.mqtt; + +import com.hnac.hzinfo.subscribe.AnalysisSubscribe; +import com.hnac.hzinfo.subscribe.DroolsSoeSubscribe; +import com.hnac.hzinfo.subscribe.HZ3000SoeSubscribe; +import lombok.extern.slf4j.Slf4j; +import org.eclipse.paho.client.mqttv3.MqttAsyncClient; +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 +@Slf4j +public class MqttConfig { + + @Autowired + FdpMqttConsumer fdpMqttConsumer; + @Autowired + DroolsMqttConsumer droolsMqttConsumer; + @Autowired + HZ300MqttConsumer hz300MqttConsumer; + @Value("${hzims.mqtt.url}") + private String mqtt_fdp_url; + @Value("${hzims.mqtt.group}") + private String mqtt_fdp_group; + @Value("${hzims.mqtt.password}") + private String mqtt_fdp_password; + @Value("${hzims.mqtt.username}") + private String mqtt_fdp_username; +// @Value("${hzims.mqtt.fdp.topname}") +// private String mqtt_fdp_topname; +// @Value("${hzims.mqtt.drools.topname}") +// private String mqtt_drools_topname; +// @Value("${hzims.mqtt.system.topname}") +// private String mqtt_system_topname; + @PostConstruct + public void registerMqtt(){ + try { + com.hnac.hzinfo.subscribe.MqttConfig mqttConfig = new com.hnac.hzinfo.subscribe.MqttConfig(); + mqttConfig.setUrl(mqtt_fdp_url); + mqttConfig.setGroup(mqtt_fdp_group); + mqttConfig.setPassword(mqtt_fdp_password); + mqttConfig.setUsername(mqtt_fdp_username); + //fdp + AnalysisSubscribe analysisSubscribe = new AnalysisSubscribe(); + MqttAsyncClient fdpClient = analysisSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), fdpMqttConsumer); + log.info(fdpClient.toString()); + //drools + DroolsSoeSubscribe droolsSoeSubscribe = new DroolsSoeSubscribe(); + MqttAsyncClient droolsClient = droolsSoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), droolsMqttConsumer); + log.info(droolsClient.toString()); + //hz3000 + HZ3000SoeSubscribe hz3000SoeSubscribe = new HZ3000SoeSubscribe(); + MqttAsyncClient hz3000Client = hz3000SoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), hz300MqttConsumer); + log.info(hz3000Client.toString()); + }catch (MqttException e){ + log.error(e.toString()) ; + } + } +} 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 deleted file mode 100644 index f0f4d96..0000000 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/fdpMqttConfig.java +++ /dev/null @@ -1,53 +0,0 @@ -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 deleted file mode 100644 index fe90f1b..0000000 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/fdpMqttConsumer.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.hnac.hzims.alarm.mqtt; - -import com.alibaba.fastjson.JSONObject; -import com.hnac.hzims.alarm.entity.AlarmEntity; -import com.hnac.hzims.alarm.handle.service.FdpAlarmService; -import com.hnac.hzims.alarm.show.service.AlarmService; -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/AlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java index 1ab1026..488ae76 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java @@ -17,6 +17,4 @@ public interface AlarmService extends BaseService { List counts(); List broadcast(String startTime, String endTime); - - void dealAlarmEntities(List param); } \ No newline at end of file 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 5280909..45eccff 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 @@ -2,7 +2,6 @@ package com.hnac.hzims.alarm.show.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.alarm.config.service.AlarmConfigService; import com.hnac.hzims.alarm.constants.AlarmConstants; import com.hnac.hzims.alarm.entity.AlarmEntity; @@ -20,7 +19,6 @@ 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; @@ -28,9 +26,7 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Collections; -import java.util.Date; import java.util.List; -import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; /** @@ -159,38 +155,6 @@ public class AlarmServiceImpl extends BaseServiceImpl return this.list(wrapper); } - /** - * websocket 消息推送保存 - * @param param - */ - @Override - public void dealAlarmEntities(List param) { - if (CollectionUtil.isNotEmpty(param)) { - // 查询当天已经记录的告警 - List historys = this.list(Wrappers.lambdaQuery(). - ge(AlarmEntity::getCreateTime, DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00") - .eq(AlarmEntity::getAlarmSource, param.get(0).getAlarmSource())); - - // 数据过滤 - List entitys = param.stream() - .filter(alarm -> CollectionUtil.isNotEmpty(historys) || !historys.stream().map(AlarmEntity::getAlarmId).collect(Collectors.toList()).contains(alarm.getAlarmId())) - .map(item -> { - //消息推送 - // 短信 - CompletableFuture.runAsync(() -> messageService.shortMessage(item)); - // web/app消息推送 - CompletableFuture.runAsync(() -> messageService.webAppMessage(item)); - // 微信公众号推送 - CompletableFuture.runAsync(() -> messageService.weChatMessage(item)); - return item; - }).collect(Collectors.toList()); - if (CollectionUtil.isEmpty(entitys)) { - return; - } - // 批量保存 - this.saveBatch(entitys); - } - } 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 index 05e61aa..6b5daf0 100644 --- 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 @@ -2,7 +2,7 @@ package com.hnac.hzims.alarm.task; import com.hnac.hzims.alarm.entity.AlarmEntity; import com.hnac.hzims.alarm.handle.service.VideoAlarmService; -import com.hnac.hzims.alarm.show.service.AlarmService; +import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; import com.xxl.job.core.biz.model.ReturnT; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -22,7 +22,7 @@ public class VideoScheduledTask { @Autowired private VideoAlarmService service; @Autowired - private AlarmService alarmService; + private AlarmSaveService alarmService; /** * 设备信息缓存 @@ -37,7 +37,7 @@ public class VideoScheduledTask { List alarmEntities = service.sendMessage(); //获取消息 // List alarmEntities = service.receiveMessage(param); - alarmService.dealAlarmEntities(alarmEntities); + alarmService.save(alarmEntities); return new ReturnT<>("SUCCESS"); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmRegular.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmRegular.java deleted file mode 100644 index 900bbc0..0000000 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmRegular.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.hnac.hzims.alarm.ws.condition; - -import com.hnac.hzims.alarm.handle.service.ConditionAlarmService; -import com.hnac.hzims.alarm.ws.level.LevelAlarmWebSocket; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import java.net.URI; - -/** - * @author ysj - */ -@Slf4j -@Component -@EnableScheduling -public class ConditionAlarmRegular { - - @Autowired - private ConditionAlarmService conditionService; - - private LevelAlarmWebSocket socket; - - @Value("${hzims.condition.wss-url}") - private String condition_wss_url; - - // 两分钟进行一次检查链接是否存活,不存活了重新建立链接 - @Scheduled(cron = "0 0/2 * * * ?") - private void regular(){ - // 检查链接存活状态 - if(ObjectUtil.isEmpty(socket) || !socket.isOpen()){ - log.error("level websocket survival check : {}","死亡"); - this.createSocket(); - if(ObjectUtil.isNotEmpty(socket) && socket.isOpen()){ - String message = conditionService.message(); - if(!StringUtil.isEmpty(message)){ - socket.send(message); - } - } - log.error("conditionAlarm survival check : {}","重新建立链接"); - }else{ - log.error("conditionAlarm survival check : {}","存活"); - } - } - - // 创建websocket链接 - private void createSocket() { - try{ - socket = new LevelAlarmWebSocket(new URI(condition_wss_url)); - socket.connectBlocking(); - }catch (Exception e){ - log.error("conditionAlarm create error : {}",e.getMessage()); - } - } -} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmWebSocket.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmWebSocket.java deleted file mode 100644 index f3078ea..0000000 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmWebSocket.java +++ /dev/null @@ -1,136 +0,0 @@ -package com.hnac.hzims.alarm.ws.condition; - -import com.hnac.hzims.alarm.entity.AlarmEntity; -import com.hnac.hzims.alarm.handle.service.ConditionAlarmService; -import com.hnac.hzims.alarm.show.service.AlarmService; -import lombok.extern.slf4j.Slf4j; -import org.java_websocket.client.WebSocketClient; -import org.java_websocket.handshake.ServerHandshake; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.tool.utils.SpringUtil; -import org.springblade.core.tool.utils.StringUtil; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; -import java.net.Socket; -import java.net.URI; -import java.security.SecureRandom; -import java.security.cert.X509Certificate; -import java.util.List; -import java.util.Optional; - -/** - * @author ysj - */ -@Slf4j -public class ConditionAlarmWebSocket extends WebSocketClient { - - - private final ConditionAlarmService conditionService; - private AlarmService alarmService; - - /** - * 构造等级告警websocket - * @param uri - */ - public ConditionAlarmWebSocket(URI uri) { - super(uri); - conditionService = SpringUtil.getBean(ConditionAlarmService.class); - connection(this); - } - - // 链接到服务器回调接口 - @Override - public void onOpen(ServerHandshake handshakedata) { - log.error("conditionAlarm websocket open"); - } - - // 接收到服务器消息回调接口 - @Override - public void onMessage(String message) { - if(StringUtil.isEmpty(message)){ - log.error("conditionAlarm on message is null"); - }else{ - // 告警数据转化 - List alarmEntities = conditionService.receiveMessage(message); - // 等级告警数据处理 - try { - alarmService.dealAlarmEntities(alarmEntities); - }catch (Exception e){ - throw new ServiceException("集中监控告警数据处理报错(conditionAlarm):"+e); - } - } - } - - // 与服务器链接中断回调接口 - @Override - public void onClose(int code, String reason, boolean remote) { - log.error("conditionAlarm websocket close"); - } - - // 与服务器通讯异常触发 - @Override - public void onError(Exception e) { - log.error("conditionAlarm websocket error : {}",e.getMessage()); - } - - /** - * 建立链接 - * @param webSocket - */ - private void connection(ConditionAlarmWebSocket webSocket) { - SSLContext context = init(); - if(Optional.ofNullable(context).isPresent()){ - Socket socket = create(context); - if(Optional.ofNullable(socket).isPresent()){ - webSocket.setSocket(socket); - } - } - } - - /** - * 创建Socket - * @param context - * @return - */ - private Socket create(SSLContext context) { - Socket socket = null; - try{ - socket = context.getSocketFactory().createSocket(); - }catch (Exception e){ - log.error("conditionAlarm socket create error : {}",e.getMessage()); - } - return socket; - } - - /** - * 协议初始化 - * @return SSLContext - */ - private SSLContext init() { - SSLContext SSL = null; - try{ - SSL = SSLContext.getInstance("TLS"); - SSL.init(null, new TrustManager[]{new X509TrustManager() { - @Override - public void checkClientTrusted(X509Certificate[] chain, - String authType) { - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) { - } - - @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } - }}, new SecureRandom()); - }catch (Exception e){ - log.error("conditionAlarm SSL init error : {}",e.getMessage()); - } - return SSL; - } - -} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/fdp/FdpAlarmRegular.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/fdp/FdpAlarmRegular.java deleted file mode 100644 index 5631319..0000000 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/fdp/FdpAlarmRegular.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.hnac.hzims.alarm.ws.fdp; - -import com.hnac.hzims.alarm.handle.service.FdpAlarmService; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import java.net.URI; - -/** - * 等级告警获取数据长链接 - * @author ty - */ -@Slf4j -@Component -@EnableScheduling -public class FdpAlarmRegular { - - @Value("${hzims.fdp.alarm-url}") - private String fdp_alarm_url; - - private FdpAlarmWebSocket client; - - @Autowired - private FdpAlarmService fdpAlarmService; - - // 定时发送消息 - @Scheduled(cron = "0 0/30 * * * ?") - private void regular(){ - System.out.println("系统告警链接检查"); - // 检查链接存活状态 - if(ObjectUtil.isNotEmpty(client) && client.isOpen()){ - client.send(fdpAlarmService.sendMessage()); - System.out.println("FdpAlarm:链接成功"); - }else { - System.out.println("FdpAlarm:链接失败"); - this.createClient(); - System.out.println("FdpAlarm:重新链接"); - } - } - - // 创建websocket链接 - private void createClient() { - try{ - client = new FdpAlarmWebSocket(new URI(fdp_alarm_url)); - client.connectBlocking(); - System.out.println("FdpAlarm create success"); - }catch (Exception e){ - log.error("FdpAlarm create error : {}",e.getMessage()); - } - } -} \ 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 deleted file mode 100644 index f8513a0..0000000 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/fdp/FdpAlarmWebSocket.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.hnac.hzims.alarm.ws.fdp; - -import com.hnac.hzims.alarm.entity.AlarmEntity; -import com.hnac.hzims.alarm.handle.service.FdpAlarmService; -import com.hnac.hzims.alarm.show.service.AlarmService; -import lombok.extern.slf4j.Slf4j; -import org.java_websocket.client.WebSocketClient; -import org.java_websocket.handshake.ServerHandshake; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.tool.utils.SpringUtil; -import org.springblade.core.tool.utils.StringUtil; -import org.springframework.beans.factory.annotation.Autowired; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; -import java.net.Socket; -import java.net.URI; -import java.security.SecureRandom; -import java.security.cert.X509Certificate; -import java.util.List; -import java.util.Optional; - -/** - * 等级告警获取数据长链接 - * @author ty - */ -@Slf4j -public class FdpAlarmWebSocket extends WebSocketClient { - @Autowired - private FdpAlarmService fdpAlarmService; - private AlarmService alarmService; - - /** - * 构造等级告警websocket - * @param uri - */ - public FdpAlarmWebSocket(URI uri) { - super(uri); - fdpAlarmService = SpringUtil.getBean(FdpAlarmService.class); - connection(this); - } - - // 链接到服务器回调接口 - @Override - public void onOpen(ServerHandshake handshakedata) { - log.error("FdpAlarm websocket open"); - } - - // 接收到服务器消息回调接口 - @Override - public void onMessage(String message) { - if(StringUtil.isEmpty(message)){ - log.error("FdpAlarm on message is null"); - }else{ - // 告警数据转化 - List alarmEntities = fdpAlarmService.receiveMessage(message); - //统一数据处理 - try { - //websocket 消息推送保存 - alarmService.dealAlarmEntities(alarmEntities); - }catch (Exception e){ - throw new ServiceException("集中监控告警数据处理报错(FdpAlarm):"+e); - } - } - } - - // 与服务器链接中断回调接口 - @Override - public void onClose(int code, String reason, boolean remote) { - log.error("FdpAlarm websocket close"); - } - - // 与服务器通讯异常触发 - @Override - public void onError(Exception e) { - log.error("FdpAlarm websocket error : {}",e.getMessage()); - } - - /** - * 建立链接 - * @param webSocket - */ - private void connection(FdpAlarmWebSocket webSocket) { - SSLContext context = init(); - if(Optional.ofNullable(context).isPresent()){ - Socket socket = create(context); - if(Optional.ofNullable(socket).isPresent()){ - webSocket.setSocket(socket); - } - } - } - - /** - * 创建Socket - * @param context - * @return - */ - private Socket create(SSLContext context) { - Socket socket = null; - try{ - socket = context.getSocketFactory().createSocket(); - }catch (Exception e){ - log.error("FdpAlarm socket create error : {}",e.getMessage()); - } - return socket; - } - - /** - * 协议初始化 - * @return SSLContext - */ - private SSLContext init() { - SSLContext SSL = null; - try{ - SSL = SSLContext.getInstance("TLS"); - SSL.init(null, new TrustManager[]{new X509TrustManager() { - @Override - public void checkClientTrusted(X509Certificate[] chain, - String authType) { - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) { - } - - @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } - }}, new SecureRandom()); - }catch (Exception e){ - log.error("FdpAlarm SSL init error : {}",e.getMessage()); - } - return SSL; - } - -} \ No newline at end of file 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 deleted file mode 100644 index 71712aa..0000000 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmRegular.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.hnac.hzims.alarm.ws.hz3000; - -import com.hnac.hzims.alarm.handle.service.SystemAlarmService; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import java.net.URI; - -/** - * 等级告警获取数据长链接 - * @author ty - */ -@Slf4j -@Component -@EnableScheduling -public class SystemAlarmRegular { - - @Value("${hzims.system.wss-url}") - private String system_wss_url; - - private SystemAlarmWebSocket client; - - @Autowired - private SystemAlarmService systemAlarmService; - - int count=0; - // 定时发送消息 - @Scheduled(cron = "0 0/30 * * * ?") - private void regular(){ - // 检查链接存活状态 - 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){ - - } - } - } - - // 创建websocket链接 - private void createClient() { - try{ - client = new SystemAlarmWebSocket(new URI(system_wss_url)); - client.connectBlocking(); - System.out.println("systemAlarm create success"); - }catch (Exception e){ - log.error("systemAlarm create error : {}",e.getMessage()); - } - } -} \ No newline at end of file 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 deleted file mode 100644 index fa019c9..0000000 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmWebSocket.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.hnac.hzims.alarm.ws.hz3000; - -import com.hnac.hzims.alarm.entity.AlarmEntity; -import com.hnac.hzims.alarm.handle.service.SystemAlarmService; -import com.hnac.hzims.alarm.show.service.AlarmService; -import lombok.extern.slf4j.Slf4j; -import org.java_websocket.client.WebSocketClient; -import org.java_websocket.handshake.ServerHandshake; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.tool.utils.SpringUtil; -import org.springblade.core.tool.utils.StringUtil; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; -import java.net.Socket; -import java.net.URI; -import java.security.SecureRandom; -import java.security.cert.X509Certificate; -import java.util.List; -import java.util.Optional; - -/** - * 等级告警获取数据长链接 - * @author ty - */ -@Slf4j -public class SystemAlarmWebSocket extends WebSocketClient { - - private final SystemAlarmService systemAlarmService; - - private AlarmService alarmService; - - /** - * 构造等级告警websocket - * @param uri - */ - public SystemAlarmWebSocket(URI uri) { - super(uri); - systemAlarmService = SpringUtil.getBean(SystemAlarmService.class); - connection(this); - } - - // 链接到服务器回调接口 - @Override - public void onOpen(ServerHandshake handshakedata) { - log.error("SystemAlarmWebSocket链接到服务器回调接口"); - } - - // 接收到服务器消息回调接口 - @Override - public void onMessage(String message) { - if(StringUtil.isEmpty(message)){ - log.error("systemAlarm on message is null"); - }else{ - // 华自3000告警数据转化 - List alarmEntities = systemAlarmService.receiveMessage(message); - //统一数据处理 - try { - //websocket 消息推送保存 - alarmService.dealAlarmEntities(alarmEntities); - }catch (Exception e){ - throw new ServiceException("集中监控告警数据处理报错:"+e); - } - log.error("华自3000告警数据处理"); - } - } - - // 与服务器链接中断回调接口 - @Override - public void onClose(int code, String reason, boolean remote) { - log.error("SystemAlarmWebSocket与服务器链接中断回调接口 "); - } - - // 与服务器通讯异常触发 - @Override - public void onError(Exception e) { - log.error("systemAlarm websocket error : {}",e.getMessage()); - } - - /** - * 建立链接 - * @param webSocket - */ - private void connection(SystemAlarmWebSocket webSocket) { - SSLContext context = init(); - if(Optional.ofNullable(context).isPresent()){ - Socket socket = create(context); - if(Optional.ofNullable(socket).isPresent()){ - webSocket.setSocket(socket); - } - } - System.out.println("systemAlarm create success"); - } - - /** - * 创建Socket - * @param context - * @return - */ - private Socket create(SSLContext context) { - Socket socket = null; - try{ - socket = context.getSocketFactory().createSocket(); - log.error("SystemAlarmWebSocket链接创建成功"); - }catch (Exception e){ - log.error("systemAlarm socket create error : {}",e.getMessage()); - } - return socket; - } - - /** - * 协议初始化 - * @return SSLContext - */ - private SSLContext init() { - SSLContext SSL = null; - try{ - SSL = SSLContext.getInstance("TLS"); - SSL.init(null, new TrustManager[]{new X509TrustManager() { - @Override - public void checkClientTrusted(X509Certificate[] chain, - String authType) { - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) { - } - - @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } - }}, new SecureRandom()); - log.error("SystemAlarmWebSocket初始化成功"); - }catch (Exception e){ - log.error("systemAlarm SSL init error : {}",e.getMessage()); - } - return SSL; - } - -} \ No newline at end of file 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 b9691f3..601071c 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 @@ -2,7 +2,7 @@ package com.hnac.hzims.alarm.ws.level; import com.hnac.hzims.alarm.entity.AlarmEntity; import com.hnac.hzims.alarm.handle.service.LevelAlarmService; -import com.hnac.hzims.alarm.show.service.AlarmService; +import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; import lombok.extern.slf4j.Slf4j; import org.java_websocket.client.WebSocketClient; import org.java_websocket.handshake.ServerHandshake; @@ -29,7 +29,7 @@ public class LevelAlarmWebSocket extends WebSocketClient { private final LevelAlarmService levelService; - private AlarmService alarmService; + private AlarmSaveService alarmSaveService; /** * 构造等级告警websocket @@ -59,7 +59,7 @@ public class LevelAlarmWebSocket extends WebSocketClient { // 等级告警数据处理 try { //websocket 消息推送保存 - alarmService.dealAlarmEntities(alarmEntities); + alarmSaveService.save(alarmEntities); }catch (Exception e){ throw new ServiceException("集中监控告警数据处理报错(levelAlarm):"+e); } From 0c02434f560eb22df67ec8040b8675820dd7c3ca Mon Sep 17 00:00:00 2001 From: tyty Date: Fri, 17 Nov 2023 16:53:07 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java index 4c6ca69..5c12f53 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java @@ -1549,7 +1549,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl Date: Mon, 20 Nov 2023 09:01:37 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E9=9B=86=E4=B8=AD=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=BA=90-video?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/alarm/mqtt/MqttConfig.java | 7 ++++ .../hnac/hzims/alarm/mqtt/VideoMqttConsumer.java | 40 ++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/VideoMqttConsumer.java diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java index 860785f..facb306 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java @@ -3,6 +3,7 @@ package com.hnac.hzims.alarm.mqtt; import com.hnac.hzinfo.subscribe.AnalysisSubscribe; import com.hnac.hzinfo.subscribe.DroolsSoeSubscribe; import com.hnac.hzinfo.subscribe.HZ3000SoeSubscribe; +import com.hnac.hzinfo.subscribe.SoeSubscribe; import lombok.extern.slf4j.Slf4j; import org.eclipse.paho.client.mqttv3.MqttAsyncClient; import org.eclipse.paho.client.mqttv3.MqttException; @@ -27,6 +28,8 @@ public class MqttConfig { DroolsMqttConsumer droolsMqttConsumer; @Autowired HZ300MqttConsumer hz300MqttConsumer; + @Autowired + VideoMqttConsumer videoMqttConsumer; @Value("${hzims.mqtt.url}") private String mqtt_fdp_url; @Value("${hzims.mqtt.group}") @@ -61,6 +64,10 @@ public class MqttConfig { HZ3000SoeSubscribe hz3000SoeSubscribe = new HZ3000SoeSubscribe(); MqttAsyncClient hz3000Client = hz3000SoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), hz300MqttConsumer); log.info(hz3000Client.toString()); + //视频 + SoeSubscribe subscribe = new SoeSubscribe(); + MqttAsyncClient videoClient = subscribe.subscribe(mqttConfig, Collections.singletonList("#"), videoMqttConsumer); + log.info(videoClient.toString()); }catch (MqttException e){ log.error(e.toString()) ; } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/VideoMqttConsumer.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/VideoMqttConsumer.java new file mode 100644 index 0000000..e42bfa3 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/VideoMqttConsumer.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.handle.service.VideoAlarmService; +import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; +import com.hnac.hzinfo.subscribe.SubscribeCallBack; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * + * @Author: ty + */ + +@Service +@Slf4j +public class VideoMqttConsumer implements SubscribeCallBack { + @Autowired + private VideoAlarmService videoAlarmService; + @Autowired + private AlarmSaveService alarmSaveService; + @Override + public void onMessage(Map data) { + System.out.println("监听到消息"+data.toString()); + String s = JSONObject.toJSONString(data); + //消费代码 + List alarmEntities = videoAlarmService.receiveMessage(s); + //统一数据处理 + try { + alarmSaveService.save(alarmEntities); + }catch (Exception e){ + log.error("HZ3000告警数据处理报错(HZ300Alarm):"+e); + } + } +} From 50a06a2e08fd38c040c2c9b6ba38474b352f2447 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 20 Nov 2023 09:49:18 +0800 Subject: [PATCH 4/9] =?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 --- .../src/main/java/com/hnac/hzims/alarm/entity/AlarmConfigEntity.java | 3 --- .../hnac/hzims/alarm/config/service/impl/AlarmConfigServiceImpl.java | 3 +-- .../src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/entity/AlarmConfigEntity.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/entity/AlarmConfigEntity.java index 7022fa3..bf85187 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/entity/AlarmConfigEntity.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/entity/AlarmConfigEntity.java @@ -24,7 +24,4 @@ public class AlarmConfigEntity extends TenantEntity { @ApiModelProperty(value = "站点名称") private String stationName; - - @ApiModelProperty(value = "是否启用 :0-启用 1-不启用") - private Integer isEnable; } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigServiceImpl.java index 9b553cd..b2c012a 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigServiceImpl.java @@ -103,8 +103,7 @@ public class AlarmConfigServiceImpl extends BaseServiceImpllambdaQuery() - .eq(AlarmConfigEntity::getStationId,code) - .eq(AlarmConfigEntity::getIsEnable,"0")); + .eq(AlarmConfigEntity::getStationId,code)); if(ObjectUtil.isEmpty(config)){ return detailService.defaultMark(source,type); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java index 860785f..8065100 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java @@ -43,7 +43,7 @@ public class MqttConfig { // private String mqtt_system_topname; @PostConstruct public void registerMqtt(){ - try { + com.hnac.hzinfo.subscribe.MqttConfig mqttConfig = new com.hnac.hzinfo.subscribe.MqttConfig(); mqttConfig.setUrl(mqtt_fdp_url); mqttConfig.setGroup(mqtt_fdp_group); From 61d731589c88a08c88f6355751c1eeaf1e444139 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 20 Nov 2023 16:57:56 +0800 Subject: [PATCH 5/9] =?UTF-8?q?#=E7=AB=99=E7=82=B9=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/service/impl/HydropowerServiceImpl.java | 2 +- .../main/service/impl/SideHustleServiceImpl.java | 3 ++- .../station/service/impl/StationServiceImpl.java | 24 ++++++++++------------ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java index adf3cb8..6e1b95c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java @@ -1149,7 +1149,7 @@ public class HydropowerServiceImpl implements HydropowerService { long on = reals.stream().filter(real -> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId()) && real.getState()).count(); long sum = reals.stream().filter(real->entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId())).count(); if(Math.abs(sum) > 0){ - scale.setDeviceUse(BigDecimal.valueOf(on / sum * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); + scale.setDeviceUse(BigDecimal.valueOf(on / (double)sum * 100).setScale(1, RoundingMode.HALF_UP).doubleValue()); } } return scale; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java index 7cd4825..487c78c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java @@ -57,6 +57,7 @@ import org.springframework.stereotype.Service; import javax.validation.constraints.NotNull; import java.math.BigDecimal; +import java.math.RoundingMode; import java.sql.Time; import java.text.SimpleDateFormat; import java.time.LocalDate; @@ -1139,7 +1140,7 @@ public class SideHustleServiceImpl implements ISideHustleService { } // 机组开机总数 int onOffCount = map.entrySet().stream().filter(o->deptIds.contains(o.getKey())).mapToInt(vo-> vo.getValue().getStartingUpCount()).sum(); - return BigDecimal.valueOf(onOffCount / (double)unitSumCount * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + return BigDecimal.valueOf(onOffCount / (double)unitSumCount * 100).setScale(2, RoundingMode.HALF_UP).doubleValue(); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index cbf54a9..e73d35a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java @@ -95,11 +95,11 @@ public class StationServiceImpl extends BaseServiceImpl sort = Optional.ofNullable(this.getStationMaxOrder()); req.setSort(sort.isPresent() ? sort.get() + 1 : 1); + this.pushStation(req); boolean updateResult = this.saveOrUpdate(req); Assert.isTrue(updateResult, () -> { throw new ServiceException("创建/修改站点信息失败!"); }); - this.pushStation(req); } /** @@ -130,6 +130,7 @@ public class StationServiceImpl extends BaseServiceImpl Date: Wed, 22 Nov 2023 10:41:44 +0800 Subject: [PATCH 6/9] =?UTF-8?q?#=E6=A3=80=E4=BF=AE=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/access/dto/OperAccessPlanListDTO.java | 7 +++++++ .../access/service/impl/OperAccessPlanServiceImpl.java | 15 +++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessPlanListDTO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessPlanListDTO.java index 1a19f47..6b40770 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessPlanListDTO.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessPlanListDTO.java @@ -1,6 +1,7 @@ package com.hnac.hzims.operational.access.dto; import com.hnac.hzims.operational.access.entity.OperAccessPlanEntity; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; @@ -16,4 +17,10 @@ public class OperAccessPlanListDTO extends OperAccessPlanEntity { private static final long serialVersionUID = 1L; + @ApiModelProperty(value = "开始时间") + private String startDate; + + @ApiModelProperty(value = "结束时间") + private String endDate; + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessPlanServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessPlanServiceImpl.java index 84e1308..bfb6c10 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessPlanServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessPlanServiceImpl.java @@ -1,9 +1,7 @@ package com.hnac.hzims.operational.access.service.impl; -import cn.hutool.core.io.unit.DataUnit; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -20,17 +18,14 @@ import com.hnac.hzims.operational.access.vo.OperAccessContentVO; import com.hnac.hzims.operational.access.vo.OperAccessPlanVO; import com.hnac.hzims.operational.access.wrapper.OperAccessContentDetailWrapper; import com.hnac.hzims.operational.access.wrapper.OperAccessContentWrapper; -import com.hnac.hzims.operational.access.wrapper.OperAccessMaterialWrapper; import com.hnac.hzims.operational.access.wrapper.OperAccessPlanWrapper; import com.hnac.hzims.operational.defect.constants.RepairConstant; import com.hnac.hzims.operational.defect.constants.TreatMethodConstant; import com.hnac.hzims.operational.defect.entity.OperDefectEntity; import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; -import com.hnac.hzims.operational.defect.mapper.OperDefectMapper; import com.hnac.hzims.operational.defect.mapper.OperPhenomenonMapper; import com.hnac.hzims.operational.defect.service.IOperDefectService; import com.hnac.hzims.operational.util.WordUtils; -import com.hnac.hzims.spare.entity.WtSpTotalEntity; import com.hnac.hzims.ticket.constants.TicketConstants; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketTemplateEntity; @@ -39,7 +34,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.RandomUtils; -import org.jsoup.helper.DataUtil; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.support.Condition; @@ -60,13 +54,12 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; + import javax.servlet.http.HttpServletResponse; import java.text.DecimalFormat; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.*; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import java.util.stream.Collectors; /** @@ -445,6 +438,12 @@ public class OperAccessPlanServiceImpl extends BaseServiceImpl Date: Wed, 22 Nov 2023 16:46:17 +0800 Subject: [PATCH 7/9] =?UTF-8?q?#HZ100C=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/emParam/service/impl/ParamServiceImpl.java | 6 +++--- .../hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java | 4 ++-- .../ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java | 6 ++++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/impl/ParamServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/impl/ParamServiceImpl.java index 10b4a7b..12fced6 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/impl/ParamServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/impl/ParamServiceImpl.java @@ -70,17 +70,17 @@ public class ParamServiceImpl implements IParamService { public List recall(String emCode,String stationCode) { List result = Lists.newArrayList(); // 获取设备物模型中是参数的属性 - Result> paramDeviceAttrR = deviceDataClient.getIsParamDeviceAttr(emCode); + R> paramDeviceAttrR = deviceClient.getOnlineAttr(emCode); Assert.isTrue(paramDeviceAttrR.isSuccess() && CollectionUtil.isNotEmpty(paramDeviceAttrR.getData()),() -> { throw new ServiceException("获取设备实例物模型属性失败!"); }); // 获取实时数据 - List signageList = paramDeviceAttrR.getData().stream().map(DeviceInstanceAttrVO::getSignage).filter(StringUtil::isNotBlank).collect(Collectors.toList()); + List signageList = paramDeviceAttrR.getData().stream().filter(o->StringUtil.isNotBlank(o.getSignage()) && StringUtil.isNotBlank(o.getFacDeviceAttrId())).map(DeviceInstanceAttrVO::getSignage).collect(Collectors.toList()); Result realDataR = deviceDataClient.getDeviceRealDataByCode(emCode, signageList); Assert.isTrue(realDataR.isSuccess(),() -> { throw new ServiceException("参数召回获取实时数据失败"); }); - Map> paramGroupVOListMap = paramDeviceAttrR.getData().stream().map(this::convert).collect(Collectors.groupingBy(p -> { + Map> paramGroupVOListMap = paramDeviceAttrR.getData().stream().filter(o->StringUtil.isNotBlank(o.getFacDeviceAttrId())).map(this::convert).collect(Collectors.groupingBy(p -> { ParamGroupVO paramGroupVO = new ParamGroupVO(); paramGroupVO.setGroupId(String.valueOf(p.getModelClassifyId())); paramGroupVO.setGroupName(p.getModelClassifyName()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java index c3c6d20..4d5ec7e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java @@ -423,10 +423,10 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl pages = this.page(Condition.getPage(query), lqw); //数据转换 From 82aa13fc1f4a131a8ce2eda4feecbccd3e97b1b2 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 24 Nov 2023 08:49:48 +0800 Subject: [PATCH 8/9] =?UTF-8?q?#=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maintenance/service/impl/OperMaintenanceMonitorServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceMonitorServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceMonitorServiceImpl.java index de665d9..9c19abc 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceMonitorServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceMonitorServiceImpl.java @@ -53,8 +53,8 @@ public class OperMaintenanceMonitorServiceImpl implements IOperMaintenanceMonito }}); //获取列表班次ID集合 - List classIdList = planEntities.stream().filter(planEntity -> ObjectUtil.isNotEmpty(planEntity.getImsDutyClassId())) - .map(OperMaintenancePlanEntity::getImsDutyClassId).collect(Collectors.toList()); + List classIdList = planEntities.stream().map(OperMaintenancePlanEntity::getImsDutyClassId) + .filter(ObjectUtil::isNotEmpty).collect(Collectors.toList()); IImsDutyClassService imsDutyClassService = SpringUtil.getBean(IImsDutyClassService.class); Map> classMap = null; if (CollectionUtil.isNotEmpty(classIdList)) { From 402e860adde178666bc732be3ea5285e1a03c22d Mon Sep 17 00:00:00 2001 From: tyty Date: Fri, 24 Nov 2023 17:15:04 +0800 Subject: [PATCH 9/9] =?UTF-8?q?mqtt=E6=8A=9B=E5=87=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java index e19bc90..d6bfe52 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java @@ -46,7 +46,7 @@ public class MqttConfig { // private String mqtt_system_topname; @PostConstruct public void registerMqtt(){ - +try { com.hnac.hzinfo.subscribe.MqttConfig mqttConfig = new com.hnac.hzinfo.subscribe.MqttConfig(); mqttConfig.setUrl(mqtt_fdp_url); mqttConfig.setGroup(mqtt_fdp_group);