Browse Source

#告警日志打印修改

zhongwei
yang_shj 4 months ago
parent
commit
44b1e25b16
  1. 4
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java
  2. 19
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java
  3. 4
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java

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

19
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);

4
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,7 +191,6 @@ public class MonitorServiceImpl implements MonitorService {
// 数据切割
int limit = countStep(stationRealVos.size());
List<List<StationRealVo>> 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);
// <real,value>
Map<String,String> valueMap = new ConcurrentHashMap<>();
// <real,<attribute,value>>
@ -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));

Loading…
Cancel
Save