|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.hnac.hzims.alarm.source.service.impl; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
|
import com.hnac.hzims.alarm.config.constants.AlarmConstants; |
|
|
|
|
import com.hnac.hzims.alarm.config.entity.AlarmEntity; |
|
|
|
@ -14,6 +15,7 @@ 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.apache.commons.collections4.MapUtils; |
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
@ -22,9 +24,7 @@ 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.Map; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@ -73,33 +73,28 @@ public class SystemAlarmServiceImpl implements SystemAlarmService {
|
|
|
|
|
@Override |
|
|
|
|
public List<AlarmEntity> receiveMessage(String message) { |
|
|
|
|
// 对象转换
|
|
|
|
|
List<SystemAlarmVo> alarms = JSONObject.parseArray(message, SystemAlarmVo.class); |
|
|
|
|
if (CollectionUtil.isEmpty(alarms)) { |
|
|
|
|
SystemAlarmVo systemAlarm = JSONObject.parseObject(message, SystemAlarmVo.class); |
|
|
|
|
log.error("HZ3000告警对象转换后:{}",systemAlarm); |
|
|
|
|
if (ObjectUtils.isEmpty(systemAlarm)) { |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
List<AlarmEntity> res = alarms.stream().map(s -> { |
|
|
|
|
AlarmEntity entity = getAlarmEntity(s); |
|
|
|
|
return entity; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
return res; |
|
|
|
|
return Collections.singletonList(this.getAlarmEntity(systemAlarm)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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()); |
|
|
|
|
Date date = new Date(); |
|
|
|
|
date.setTime(item.getTs()); |
|
|
|
|
entity.setAlarmTime(DateUtil.parse(DateUtil.format(date,DateUtil.PATTERN_DATETIME),DateUtil.PATTERN_DATETIME)); |
|
|
|
|
entity.setAlarmContext(item.getContext()); |
|
|
|
|
entity.setAlarmType(item.getType()); |
|
|
|
|
entity.setAlarmStatus(item.getState()); |
|
|
|
|
entity.setAlarmValue(item.getOpvalue()); |
|
|
|
|
entity.setStationId(item.getStation()); |
|
|
|
|
entity.setAlarmCount(item.getTraceCount()); |
|
|
|
|
entity.setRealId(item.getRealId()); |
|
|
|
|
entity.setAlarmSource(AlarmConstants.HZ3000_ALARM); |
|
|
|
|
entity.setTenantId("200000"); |
|
|
|
|
R<StationEntity> stationByCode = stationClient.getStationByCode(item.getStation()); |
|
|
|
|
if (stationByCode.isSuccess() && ObjectUtils.isNotEmpty(stationByCode.getData())) { |
|
|
|
|
entity.setCreateDept(stationByCode.getData().getCreateDept()); |
|
|
|
|
entity.setStationName(stationByCode.getData().getName()); |
|
|
|
|
} |
|
|
|
|
return entity; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|