|  |  | @ -1,6 +1,7 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | package com.hnac.hzims.alarm.source.service.impl; |  |  |  | package com.hnac.hzims.alarm.source.service.impl; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.alibaba.fastjson.JSONObject; |  |  |  | import com.alibaba.fastjson.JSONObject; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.alibaba.fastjson.TypeReference; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |  |  |  | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.hnac.hzims.alarm.config.constants.AlarmConstants; |  |  |  | import com.hnac.hzims.alarm.config.constants.AlarmConstants; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.hnac.hzims.alarm.config.entity.AlarmEntity; |  |  |  | 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 com.hnac.hzims.operational.station.feign.IStationClient; | 
			
		
	
		
		
			
				
					
					|  |  |  | import lombok.RequiredArgsConstructor; |  |  |  | import lombok.RequiredArgsConstructor; | 
			
		
	
		
		
			
				
					
					|  |  |  | import lombok.extern.slf4j.Slf4j; |  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import org.apache.commons.collections4.MapUtils; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springblade.core.log.exception.ServiceException; |  |  |  | import org.springblade.core.log.exception.ServiceException; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springblade.core.tool.api.R; |  |  |  | import org.springblade.core.tool.api.R; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springblade.core.tool.utils.CollectionUtil; |  |  |  | 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.springblade.system.user.feign.IUserClient; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springframework.stereotype.Service; |  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.ArrayList; |  |  |  | import java.util.*; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.List; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.Map; |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | import java.util.concurrent.ConcurrentHashMap; |  |  |  | import java.util.concurrent.ConcurrentHashMap; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.stream.Collectors; |  |  |  | import java.util.stream.Collectors; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -73,33 +73,28 @@ public class SystemAlarmServiceImpl implements SystemAlarmService { | 
			
		
	
		
		
			
				
					
					|  |  |  |     @Override |  |  |  |     @Override | 
			
		
	
		
		
			
				
					
					|  |  |  |     public List<AlarmEntity> receiveMessage(String message) { |  |  |  |     public List<AlarmEntity> receiveMessage(String message) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         // 对象转换
 |  |  |  |         // 对象转换
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         List<SystemAlarmVo> alarms = JSONObject.parseArray(message, SystemAlarmVo.class); |  |  |  |         SystemAlarmVo systemAlarm = JSONObject.parseObject(message, SystemAlarmVo.class); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         if (CollectionUtil.isEmpty(alarms)) { |  |  |  |         log.error("HZ3000告警对象转换后:{}",systemAlarm); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (ObjectUtils.isEmpty(systemAlarm)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             return new ArrayList<>(); |  |  |  |             return new ArrayList<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         List<AlarmEntity> res = alarms.stream().map(s -> { |  |  |  |         return Collections.singletonList(this.getAlarmEntity(systemAlarm)); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             AlarmEntity entity = getAlarmEntity(s); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             return entity; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         }).collect(Collectors.toList()); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         return res; |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     private AlarmEntity getAlarmEntity(SystemAlarmVo item) { |  |  |  |     private AlarmEntity getAlarmEntity(SystemAlarmVo item) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         AlarmEntity entity = new AlarmEntity(); |  |  |  |         AlarmEntity entity = new AlarmEntity(); | 
			
		
	
		
		
			
				
					
					|  |  |  |         entity.setAlarmId(item.getId()); |  |  |  |         entity.setAlarmId(item.getId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |         entity.setAlarmTime(DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s")); |  |  |  |         Date date = new Date(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         entity.setAlarmContext(item.getSoeExplain()); |  |  |  |         date.setTime(item.getTs()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         entity.setAlarmType(item.getSoeAlarmType()); |  |  |  |         entity.setAlarmTime(DateUtil.parse(DateUtil.format(date,DateUtil.PATTERN_DATETIME),DateUtil.PATTERN_DATETIME)); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         entity.setAlarmStatus(item.getSoeStatus()); |  |  |  |         entity.setAlarmContext(item.getContext()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         entity.setAlarmValue(item.getOptionvals()); |  |  |  |         entity.setAlarmType(item.getType()); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         entity.setAlarmStatus(item.getState()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         entity.setAlarmValue(item.getOpvalue()); | 
			
		
	
		
		
			
				
					
					|  |  |  |         entity.setStationId(item.getStation()); |  |  |  |         entity.setStationId(item.getStation()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         entity.setAlarmCount(item.getTraceCount()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         entity.setRealId(item.getRealId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |         entity.setAlarmSource(AlarmConstants.HZ3000_ALARM); |  |  |  |         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; |  |  |  |         return entity; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |