From 44b1e25b165ae474aa8cef94bb5ec6a6866f909f Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 8 Aug 2024 20:01:35 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E6=97=A5=E5=BF=97=E6=89=93?= =?UTF-8?q?=E5=8D=B0=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/alarm/mqtt/MqttConfig.java | 4 ++-- .../source/service/impl/SoeAlarmServiceImpl.java | 19 +++++++++++-------- .../operation/monitor/impl/MonitorServiceImpl.java | 6 ++---- 3 files changed, 15 insertions(+), 14 deletions(-) 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 6a2c34e..2c78b7d 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 @@ -72,9 +72,9 @@ public class MqttConfig { MqttAsyncClient hz3000Client = hz3000SoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), hz300MqttConsumer); log.info(hz3000Client.toString()+hz3000Client.getClientId()); //视频 - SoeSubscribe subscribe = new SoeSubscribe(); + /*SoeSubscribe subscribe = new SoeSubscribe(); MqttAsyncClient videoClient = subscribe.subscribe(mqttConfig, Collections.singletonList("#"), videoMqttConsumer); - log.info(videoClient.toString()+videoClient.getClientId()); + log.info(videoClient.toString()+videoClient.getClientId());*/ }catch (MqttException e){ log.error(e.toString()) ; } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java index cf05d3d..dfff6be 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java @@ -3,27 +3,24 @@ package com.hnac.hzims.alarm.source.service.impl; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.hnac.hzims.alarm.config.entity.AlarmEntity; -import com.hnac.hzims.alarm.config.vo.DroolsAlarmVo; import com.hnac.hzims.alarm.config.vo.SoeAlarmVo; import com.hnac.hzims.alarm.show.service.AlarmService; -import com.hnac.hzims.alarm.source.service.DroolsAlarmService; import com.hnac.hzims.alarm.source.service.MessageService; import com.hnac.hzims.alarm.source.service.SoeAlarmService; import com.hnac.hzims.common.constant.CommonConstant; -import com.hnac.hzims.common.utils.CommonUtil; import com.hnac.hzims.common.utils.DateUtil; 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.time.LocalDateTime; import java.time.ZoneId; -import java.util.*; +import java.util.Collections; +import java.util.List; import java.util.stream.Collectors; import static com.hnac.hzims.alarm.config.constants.AlarmConstants.*; @@ -60,10 +57,9 @@ public class SoeAlarmServiceImpl implements SoeAlarmService { private AlarmEntity getAlarmEntity(SoeAlarmVo item) { AlarmEntity entity = new AlarmEntity(); - String format = DateUtil.format(item.getTs(), org.springblade.core.tool.utils.DateUtil.PATTERN_DATETIME_MINI); - entity.setAlarmId(format+"-"+item.getDeviceCode()); + String format = DateUtil.format(item.getTs(),DateUtil.PATTERN_DATETIME_MINI); + entity.setAlarmId(format); entity.setAlarmSource(LEVEL_ALARM); - entity.setAlarmType(ONE_LEVEL); entity.setAlarmContext(item.getName()); ZoneId zoneId = ZoneId.systemDefault(); LocalDateTime localDateTime = LocalDateTime.ofInstant(item.getTs().toInstant(), zoneId); @@ -71,6 +67,13 @@ public class SoeAlarmServiceImpl implements SoeAlarmService { entity.setAlarmValue(item.getCurrentValue()); entity.setAlarmSignage(item.getSignage()); entity.setAlarmLevel(Integer.valueOf(item.getLevel())); + if(entity.getAlarmLevel() == 0){ + entity.setAlarmType(ONE_LEVEL); + }else if (entity.getAlarmLevel() == 1){ + entity.setAlarmType(TWO_LEVEL); + }else { + entity.setAlarmType(THREE_LEVEL); + } entity.setAlarmStatus(1); entity.setDeviceCode(item.getDeviceCode()); entity.setTenantId(CommonConstant.TENANT_ID); diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java index ed55ba7..3fbfb56 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java @@ -78,7 +78,7 @@ public class MonitorServiceImpl implements MonitorService { private final IAnalyseDataSearchClient analyseDataSearchClient; - private static final ExecutorService pool = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-monitoring-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy()); + private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-monitoring-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy()); @Value("${hzims.equipment.emInfo.emInfoList}") @@ -191,13 +191,12 @@ public class MonitorServiceImpl implements MonitorService { // 数据切割 int limit = countStep(stationRealVos.size()); List> list = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> stationRealVos.stream().skip((long) a * 5).limit(5).parallel().collect(Collectors.toList())).collect(Collectors.toList()); - ExecutorService pool = Executors.newFixedThreadPool(limit); // Map valueMap = new ConcurrentHashMap<>(); // > Map> keyMap = new ConcurrentHashMap<>(); CountDownLatch countDownLatch = new CountDownLatch(limit); - pool.execute(()-> list.forEach(stations -> { + pool.execute(()-> list.forEach(stations -> { stations.forEach(stationReal -> { String[] realIdArr = stationReal.getRealId(); List realIds = Stream.of(realIdArr).collect(Collectors.toList()); @@ -230,7 +229,6 @@ public class MonitorServiceImpl implements MonitorService { e.printStackTrace(); Thread.currentThread().interrupt(); } - pool.shutdown(); // redis 存储 redisTemplate.opsForValue().set(real_cache_final,JSONObject.toJSONString(valueMap)); redisTemplate.opsForValue().set(real_gather_cache_final,JSONObject.toJSONString(keyMap));