|
|
@ -7,8 +7,10 @@ import com.hnac.hzims.alarm.config.entity.AlarmEntity; |
|
|
|
import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; |
|
|
|
import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; |
|
|
|
import com.hnac.hzims.alarm.show.service.AlarmService; |
|
|
|
import com.hnac.hzims.alarm.show.service.AlarmService; |
|
|
|
import com.hnac.hzims.alarm.config.vo.AlarmHandleMarkVo; |
|
|
|
import com.hnac.hzims.alarm.config.vo.AlarmHandleMarkVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.message.entity.MessagePushRecordEntity; |
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
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 com.hnac.hzims.safeproduct.constants.RedisConstants; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
@ -18,6 +20,8 @@ import org.springframework.data.redis.core.StringRedisTemplate; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -49,12 +53,20 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { |
|
|
|
log.error("alarm_query_station_is_null : {}",alarms.stream().map(AlarmEntity::getAlarmId).collect(Collectors.toList())); |
|
|
|
log.error("alarm_query_station_is_null : {}",alarms.stream().map(AlarmEntity::getAlarmId).collect(Collectors.toList())); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Set<String> keys = stringRedisTemplate.keys("hzims:queue:filter:alarm" + "*"); |
|
|
|
// 步骤2.遍历保存告警数据
|
|
|
|
// 步骤2.遍历保存告警数据
|
|
|
|
alarms.forEach(alarm->{ |
|
|
|
alarms.forEach(alarm->{ |
|
|
|
List<StationEntity> stations = result.getData().stream().filter(o->o.getCode().equals(alarm.getStationId())).collect(Collectors.toList()); |
|
|
|
List<StationEntity> stations = result.getData().stream().filter(o->o.getCode().equals(alarm.getStationId())).collect(Collectors.toList()); |
|
|
|
if(CollectionUtil.isEmpty(stations)){ |
|
|
|
if(CollectionUtil.isEmpty(stations)){ |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//根据最近5分钟的数据,做去重
|
|
|
|
|
|
|
|
for (String key : keys) { |
|
|
|
|
|
|
|
String value = stringRedisTemplate.opsForValue().get(key); |
|
|
|
|
|
|
|
if (value.equals(alarm.getAlarmContext())){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
// 步骤3.站点参数设置
|
|
|
|
// 步骤3.站点参数设置
|
|
|
|
alarm.setCreateDept(stations.get(0).getCreateDept()); |
|
|
|
alarm.setCreateDept(stations.get(0).getCreateDept()); |
|
|
|
alarm.setStationName(stations.get(0).getName()); |
|
|
|
alarm.setStationName(stations.get(0).getName()); |
|
|
@ -81,7 +93,9 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { |
|
|
|
log.error("alarm_save_fail : {}",alarm.getAlarmId()); |
|
|
|
log.error("alarm_save_fail : {}",alarm.getAlarmId()); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
String key="hzims:queue:filter:alarm"+alarm.getAlarmId(); |
|
|
|
|
|
|
|
stringRedisTemplate.opsForValue().set(key,alarm.getAlarmContext()); |
|
|
|
|
|
|
|
stringRedisTemplate.expire(key,5, TimeUnit.MINUTES); |
|
|
|
// 步骤7.发生数据至redis告警队列
|
|
|
|
// 步骤7.发生数据至redis告警队列
|
|
|
|
stringRedisTemplate.opsForList().rightPush("hzims:queue:alarm", JSON.toJSONString(alarm)); |
|
|
|
stringRedisTemplate.opsForList().rightPush("hzims:queue:alarm", JSON.toJSONString(alarm)); |
|
|
|
}); |
|
|
|
}); |
|
|
|