|  |  |  | @ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.alarm.config.constants.AlarmConstants; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.alarm.config.entity.AlarmDefaultConfigEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.alarm.config.entity.AlarmEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.alarm.config.vo.SystemAlarmVo; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.business.interruption.constants.InterruptionConstants; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.business.interruption.entity.InterruptionEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.operational.main.constant.HomePageConstant; | 
			
		
	
	
		
			
				
					|  |  |  | @ -21,10 +22,12 @@ import com.hnac.hzinfo.sdk.core.response.HzPage; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzinfo.sdk.core.response.Result; | 
			
		
	
		
			
				
					|  |  |  |  | import lombok.AllArgsConstructor; | 
			
		
	
		
			
				
					|  |  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springblade.core.tool.jackson.JsonUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springblade.core.tool.utils.CollectionUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springblade.core.tool.utils.DateUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springblade.core.tool.utils.Func; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springblade.core.tool.utils.ObjectUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springblade.mqtt.producer.IMqttSender; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.data.redis.core.RedisTemplate; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -52,6 +55,8 @@ public class AlarmServiceImpl implements AlarmService { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     private final RedisTemplate redisTemplate; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     private final IMqttSender mqttSender; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     private final static String start_stop_cache_final = "hzims:operation:start:stop:key"; | 
			
		
	
		
			
				
					|  |  |  |  |     private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -151,12 +156,12 @@ public class AlarmServiceImpl implements AlarmService { | 
			
		
	
		
			
				
					|  |  |  |  |         alarm.setDeviceCode(real.getDeviceCode()); | 
			
		
	
		
			
				
					|  |  |  |  |         alarm.setDeviceName(real.getDeviceName()); | 
			
		
	
		
			
				
					|  |  |  |  |         alarm.setAlarmId(station.getCode() + "_" + Func.randomUUID()); | 
			
		
	
		
			
				
					|  |  |  |  |         alarm.setAlarmContext(station.getName() + "_" + real.getDeviceName() + "_关机"); | 
			
		
	
		
			
				
					|  |  |  |  |         alarm.setAlarmContext(station.getName() + "." + real.getDeviceName() + "_关机"); | 
			
		
	
		
			
				
					|  |  |  |  |         alarm.setAlarmSource(AlarmConstants.START_STOP_WARNING); | 
			
		
	
		
			
				
					|  |  |  |  |         alarm.setAlarmType(AlarmConstants.STOP); | 
			
		
	
		
			
				
					|  |  |  |  |         if(state == 1){ | 
			
		
	
		
			
				
					|  |  |  |  |             alarm.setAlarmType(AlarmConstants.START); | 
			
		
	
		
			
				
					|  |  |  |  |             alarm.setAlarmContext(station.getName() + "_" + real.getDeviceName() + "_开机"); | 
			
		
	
		
			
				
					|  |  |  |  |             alarm.setAlarmContext(station.getName() + "." + real.getDeviceName() + "_开机"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         alarm.setStatus(0); | 
			
		
	
		
			
				
					|  |  |  |  |         alarm.setAlarmTime(new Date()); | 
			
		
	
	
		
			
				
					|  |  |  | @ -221,8 +226,7 @@ public class AlarmServiceImpl implements AlarmService { | 
			
		
	
		
			
				
					|  |  |  |  |         List<SoeData> soes = result.getData().getRecords(); | 
			
		
	
		
			
				
					|  |  |  |  |         // 查询当天数据中断告警记录
 | 
			
		
	
		
			
				
					|  |  |  |  |         List<InterruptionEntity> saves = this.saveInterruptions(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); | 
			
		
	
		
			
				
					|  |  |  |  |         // 批量保存中断告警数据
 | 
			
		
	
		
			
				
					|  |  |  |  |         this.interruptionAlarmService.saveBatch(soes.stream().filter(o-> CollectionUtil.isEmpty(saves) || !saves.stream().map(InterruptionEntity::getAlarmId).collect(Collectors.toList()).contains(o.getId())).map(soe->{ | 
			
		
	
		
			
				
					|  |  |  |  |         List<InterruptionEntity> entities = soes.stream().filter(o-> CollectionUtil.isEmpty(saves) || !saves.stream().map(InterruptionEntity::getAlarmId).collect(Collectors.toList()).contains(o.getId())).map(soe->{ | 
			
		
	
		
			
				
					|  |  |  |  |             InterruptionEntity entity = new InterruptionEntity(); | 
			
		
	
		
			
				
					|  |  |  |  |             List<StationEntity> soeStations = stations.stream().filter(o->o.getCode().equals(soe.getStation())).collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  |  |             if(!CollectionUtil.isEmpty(soeStations)){ | 
			
		
	
	
		
			
				
					|  |  |  | @ -243,7 +247,37 @@ public class AlarmServiceImpl implements AlarmService { | 
			
		
	
		
			
				
					|  |  |  |  |                 entity.setStatus(1); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             return entity; | 
			
		
	
		
			
				
					|  |  |  |  |         }).collect(Collectors.toList())); | 
			
		
	
		
			
				
					|  |  |  |  |         }).collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  |  |         if(CollectionUtil.isEmpty(entities)){ | 
			
		
	
		
			
				
					|  |  |  |  |             return; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         // 批量保存中断告警数据
 | 
			
		
	
		
			
				
					|  |  |  |  |         this.interruptionAlarmService.saveBatch(entities); | 
			
		
	
		
			
				
					|  |  |  |  |         // FIXME 发送HZ3000中通讯告警
 | 
			
		
	
		
			
				
					|  |  |  |  |         this.sendInterruptionMsg(entities); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 发送HZ3000中通讯告警 | 
			
		
	
		
			
				
					|  |  |  |  |      * @param entities | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     private void sendInterruptionMsg(List<InterruptionEntity> entities) { | 
			
		
	
		
			
				
					|  |  |  |  |         entities.forEach(entity->{ | 
			
		
	
		
			
				
					|  |  |  |  |             SystemAlarmVo alarm = new SystemAlarmVo(); | 
			
		
	
		
			
				
					|  |  |  |  |             if(ObjectUtil.isEmpty(entity.getId())){ | 
			
		
	
		
			
				
					|  |  |  |  |                 alarm.setId(DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME_MINI)); | 
			
		
	
		
			
				
					|  |  |  |  |             }else{ | 
			
		
	
		
			
				
					|  |  |  |  |                 alarm.setId(String.valueOf(entity.getId())); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             alarm.setTs(entity.getAlarmTime().getTime()); | 
			
		
	
		
			
				
					|  |  |  |  |             alarm.setType(Integer.parseInt(entity.getType())); | 
			
		
	
		
			
				
					|  |  |  |  |             alarm.setStation(entity.getStationId()); | 
			
		
	
		
			
				
					|  |  |  |  |             alarm.setRealId(entity.getRealId()); | 
			
		
	
		
			
				
					|  |  |  |  |             alarm.setContext(entity.getSoeExplain()); | 
			
		
	
		
			
				
					|  |  |  |  |             alarm.setState(entity.getStatus()); | 
			
		
	
		
			
				
					|  |  |  |  |             log.error("send_interruption_msg : {}",JsonUtil.toJson(alarm)); | 
			
		
	
		
			
				
					|  |  |  |  |             mqttSender.sendToMqtt(InterruptionConstants.HZ3000_TOPIC_PREFIX + entity.getStationId(), JsonUtil.toJson(alarm)); | 
			
		
	
		
			
				
					|  |  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | 
 |