| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.PriorityBlockingQueue; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | private Map<String,Integer> guideCountMap=new HashMap<>(); |
| | | /** |
| | | * @描述 异步处理接收的报警 |
| | | * @参数 [topic, message] |
| | |
| | | //判断当前报警点5分钟内是否已引导 |
| | | ardAlarmRadar.setGuideFlag(1); |
| | | // ArdAlarmRadar AlarmRadar = ardAlarmRadarMapper.getArdAlarmRadarWithGuide(ardAlarmRadar); |
| | | ArdAlarmRadar AlarmRadar = redisCache.getCacheObject("global_alarm:guideNew");//从redis中取出最新引导的报警数据 |
| | | if (StringUtils.isNull(AlarmRadar)) { |
| | | ArdAlarmRadar AlarmRadar = redisCache.getCacheObject("global_alarm:"+ardAlarmRadar.getName());//从redis中取出最新引导的报警数据 |
| | | if (AlarmRadar==null) { |
| | | //5分钟内未引导直接入库 |
| | | ardAlarmRadarMapper.insertArdAlarmRadar(ardAlarmRadar); |
| | | redisCache.setCacheObject("global_alarm:guideNew",ardAlarmRadar);//引导数据写入redis |
| | | redisCache.setCacheObject("global_alarm:"+ardAlarmRadar.getName(),ardAlarmRadar,5, TimeUnit.MINUTES);//引导数据写入redis |
| | | guideCountMap.put(ardAlarmRadar.getName(),0); |
| | | //获取雷达所在塔上的大光电 |
| | | String cameraIdWithTower = ardAlarmRadarMapper.getCameraByRadar(radarAlarmData.getRadarId()); |
| | | if (StringUtils.isNotNull(cameraIdWithTower) && StringUtils.isNotEmpty(cameraIdWithTower)) { |
| | |
| | | messagesEnqueued(cameraId, uuid, alarmType, ardAlarmRadar.getCreateTime(), 1, 2, coordinate); |
| | | } |
| | | } else { |
| | | //5分钟内有引导 |
| | | ardAlarmRadar.setGuideFlag(0); |
| | | int count = ardAlarmRadarMapper.getArdAlarmRadarWithNotGuide(ardAlarmRadar, AlarmRadar.getCreateTime()); |
| | | //未引导超过3次,直接入库入队 |
| | | if (count >= 3) { |
| | | ardAlarmRadar.setGuideFlag(1); |
| | | ardAlarmRadarMapper.insertArdAlarmRadar(ardAlarmRadar); |
| | | redisCache.setCacheObject("global_alarm:guideNew",ardAlarmRadar);//引导数据写入redis |
| | | //获取雷达所在塔上的大光电 |
| | | String cameraIdWithTower = ardAlarmRadarMapper.getCameraByRadar(radarAlarmData.getRadarId()); |
| | | if (StringUtils.isNotNull(cameraIdWithTower) && StringUtils.isNotEmpty(cameraIdWithTower)) { |
| | | log.info("获取到雷达塔上的光电:" + cameraIdWithTower); |
| | | //如果雷达塔上有光电 |
| | | messagesEnqueued(cameraIdWithTower, uuid, alarmType, ardAlarmRadar.getCreateTime(), count, 1, coordinate); |
| | | } |
| | | //获取报警点关联的大光电 |
| | | ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellId(alarmpointName); |
| | | if (StringUtils.isNotNull(ardAlarmpointsWell) && StringUtils.isNotEmpty(ardAlarmpointsWell.getCameraId())) { |
| | | String cameraId = ardAlarmpointsWell.getCameraId(); |
| | | if (cameraId.equals(cameraIdWithTower)) { |
| | | return; |
| | | //获取当前报警点的未引导次数 |
| | | Integer count = guideCountMap.get(ardAlarmRadar.getName()); |
| | | if(count!=null) |
| | | { |
| | | if(count>2) |
| | | { |
| | | ardAlarmRadar.setGuideFlag(1); |
| | | redisCache.setCacheObject("global_alarm:"+ardAlarmRadar.getName(),ardAlarmRadar,5, TimeUnit.MINUTES);//引导数据写入redis |
| | | count=0; |
| | | |
| | | //获取雷达所在塔上的大光电 |
| | | String cameraIdWithTower = ardAlarmRadarMapper.getCameraByRadar(radarAlarmData.getRadarId()); |
| | | if (StringUtils.isNotNull(cameraIdWithTower) && StringUtils.isNotEmpty(cameraIdWithTower)) { |
| | | log.info("获取到雷达塔上的光电:" + cameraIdWithTower); |
| | | //如果雷达塔上有光电 |
| | | messagesEnqueued(cameraIdWithTower, uuid, alarmType, ardAlarmRadar.getCreateTime(), count, 1, coordinate); |
| | | } |
| | | log.info("获取到报警点关联的光电:" + cameraId); |
| | | //如果报警点关联了光电 |
| | | messagesEnqueued(cameraId, uuid, alarmType, ardAlarmRadar.getCreateTime(), count, 2, coordinate); |
| | | //获取报警点关联的大光电 |
| | | ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellId(alarmpointName); |
| | | if (StringUtils.isNotNull(ardAlarmpointsWell) && StringUtils.isNotEmpty(ardAlarmpointsWell.getCameraId())) { |
| | | String cameraId = ardAlarmpointsWell.getCameraId(); |
| | | if (cameraId.equals(cameraIdWithTower)) { |
| | | return; |
| | | } |
| | | log.info("获取到报警点关联的光电:" + cameraId); |
| | | //如果报警点关联了光电 |
| | | messagesEnqueued(cameraId, uuid, alarmType, ardAlarmRadar.getCreateTime(), count, 2, coordinate); |
| | | } |
| | | } |
| | | } else { |
| | | //未引导未超过3次,直接入库 |
| | | ardAlarmRadarMapper.insertArdAlarmRadar(ardAlarmRadar); |
| | | else |
| | | { |
| | | ardAlarmRadar.setGuideFlag(0); |
| | | count++; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ardAlarmRadar.setGuideFlag(0); |
| | | count=0; |
| | | } |
| | | guideCountMap.put(ardAlarmRadar.getName(),count); |
| | | ardAlarmRadarMapper.insertArdAlarmRadar(ardAlarmRadar); |
| | | } |
| | | // 结束时间 |
| | | long etime = System.currentTimeMillis(); |
| | | // 计算执行时间 |
| | | log.info("查询API执行时长:"+(etime-stime)+"毫秒"); |
| | | log.info("雷达报警处理时长:"+(etime-stime)+"毫秒"); |
| | | } |
| | | |
| | | //endregion |