Explorar o código

代码提交15号忘记提交的东西

gao.qiang hai 10 meses
pai
achega
f7c2514ab4

+ 476 - 207
vehicle-sdk/src/main/java/com/ozs/controller/upload/GeoHazardMonitorTokenController.java

@@ -611,10 +611,9 @@ public class GeoHazardMonitorTokenController {
                 queryWrapper.eq(MsgAlarm::getIsRelease, 2);
                 List<MsgAlarm> alarmsList = msgAlarmService.list(queryWrapper);
                 //根据终端编码 判断终端忽略报警信息记录表中的是否有忽略的报警
-                PreAlarm preAlarm = preAlarmService.getOne(new LambdaQueryWrapper<PreAlarm>()
+                List<PreAlarm> preAlarmLists = preAlarmService.list(new LambdaQueryWrapper<PreAlarm>()
                         .eq(PreAlarm::getTrainId, heartbeatVo.getTrainNum())
-                        .orderByDesc(PreAlarm::getPreAlarmTime)
-                        .last("limit 1"));
+                        .orderByDesc(PreAlarm::getPreAlarmTime));
                 if (!ObjectUtils.isEmpty(alarmsList)) {
                     // 获取当前时间
                     LocalDateTime currentDateTime = LocalDateTime.now();
@@ -1046,10 +1045,456 @@ public class GeoHazardMonitorTokenController {
 //                            }
 //                            respHeartbeatVo.setPreAlarmList(responseList);
 //                        }
-                    } else if (!"[]".equals(preAlarm.getPreAlarmList())) {
-                        log.info("preAlarm.getPreAlarmList()------" + preAlarm.getPreAlarmList());
+                    } else if (!ObjectUtils.isEmpty(preAlarmLists.get(0).getPreAlarmList())) {
+                        if (!"[]".equals(preAlarmLists.get(0).getPreAlarmList())) {
+                            log.info("preAlarm.getPreAlarmList()------" + preAlarmLists.get(0).getPreAlarmList());
+                            List<PreAlarmListResponse> responseList = new ArrayList<>();
+                            List<PreAlarmResponse.PreAlarmList> preAlarmList = JSON.parseArray(preAlarmLists.get(0).getPreAlarmList(), PreAlarmResponse.PreAlarmList.class);
+                            Comparator<PreAlarmResponse.PreAlarmList> distanceComparator = new Comparator<PreAlarmResponse.PreAlarmList>() {
+                                @Override
+                                public int compare(PreAlarmResponse.PreAlarmList o1, PreAlarmResponse.PreAlarmList o2) {
+                                    return Integer.compare(o1.getDistance(), o2.getDistance());
+                                }
+                            };
+                            //排序
+                            preAlarmList.sort(distanceComparator);
+                            for (int i = 0; i < preAlarmList.size(); i++) {
+                                PreAlarmListResponse preAlarmListResponse = new PreAlarmListResponse();
+                                int mile = 0;
+                                LambdaQueryWrapper<BaseCameraManagement> wrapper1 = new LambdaQueryWrapper<BaseCameraManagement>();
+                                if (heartbeatVo.getLineDir() == 1) {
+                                    mile = preAlarmList.get(i).getDistance() + heartbeatVo.getCurrentMile();
+                                    wrapper1.ge(BaseCameraManagement::getEndMile, mile);
+                                    wrapper1.le(BaseCameraManagement::getBeginMile, mile);
+                                    wrapper1.in(BaseCameraManagement::getMonitoringDirection, 1, 3);
+                                    wrapper1.orderByAsc(BaseCameraManagement::getGrou).orderByAsc(BaseCameraManagement::getSort);
+                                }
+                                if (heartbeatVo.getLineDir() == 2) {
+                                    mile = heartbeatVo.getCurrentMile() - preAlarmList.get(i).getDistance();
+                                    wrapper1.ge(BaseCameraManagement::getEndMile, mile);
+                                    wrapper1.le(BaseCameraManagement::getBeginMile, mile);
+                                    wrapper1.in(BaseCameraManagement::getMonitoringDirection, 2, 3);
+                                    wrapper1.orderByDesc(BaseCameraManagement::getGrou).orderByDesc(BaseCameraManagement::getSort);
+                                }
+                                List<BaseCameraManagement> baseCameraManagementList = baseCameraManagementService.list(wrapper1);
+                                log.info("-------baseCameraManagementList123111--------" + baseCameraManagementList);
+                                if (!ObjectUtils.isEmpty(baseCameraManagementList)) {
+                                    int minDifference = Integer.MAX_VALUE;
+                                    String code = null;
+                                    String graphicsCard = null;
+                                    for (BaseCameraManagement baseCameraManagement : baseCameraManagementList) {
+                                        log.info("------------baseCameraManagement.getInstallMile()-------" + baseCameraManagement.getInstallMile());
+                                        log.info("------------list.get(0).getAlarmMile()-------" + mile);
+                                        int difference = Math.abs(baseCameraManagement.getInstallMile() - mile);
+                                        log.info("------------difference-------" + difference);
+                                        log.info("------------minDifference-------" + minDifference);
+                                        if (difference < minDifference) {
+                                            minDifference = difference;
+                                            log.info("------------minDifference变更-------" + minDifference);
+                                            code = baseCameraManagement.getCameraCode();
+                                            log.info("------------code-------" + code);
+                                            graphicsCard = baseCameraManagement.getGraphicsCard();
+                                            log.info("------------graphicsCard-------" + graphicsCard);
+                                        }
+                                        //添加预警信息
+                                        preAlarmListResponse.setCameraCode(baseCameraManagement.getCameraCode());
+                                        preAlarmListResponse.setCameraStream(CameraUtil.getPlayFlvRtsp(baseCameraManagement.getCameraCode(), baseCameraManagement.getGraphicsCard(), type, httpUrl));
+                                    }
+                                    if (i == 0) {
+                                        String finalCode = code;
+                                        String finalGraphicsCard = graphicsCard;
+                                        boolean finalType3 = type;
+                                        CompletableFuture.runAsync(() -> {
+                                            String playFlv = cameraUtil.heartbeatgetPlayFlv(finalCode, finalGraphicsCard, finalType3);
+                                            if (StringUtils.isEmpty(playFlv)) {
+                                                try {
+                                                    cameraUtil.heartbeatgetUrl(finalCode, finalGraphicsCard, finalType3, httpUrl);
+                                                } catch (Exception e) {
+                                                    e.printStackTrace();
+                                                }
+                                            }
+                                        });
+                                        CameraVos cameraVos = new CameraVos();
+                                        cameraVos.setCameraCode(code);
+                                        cameraVos.setCurrentStream(CameraUtil.getPlayFlvRtsp(code, graphicsCard, type, httpUrl));
+                                        List<CameraVos> cameraVosList = new ArrayList<>();
+                                        cameraVosList.add(cameraVos);
+                                        respHeartbeatVo.setCameraList(cameraVosList);
+                                        respHeartbeatVo.setIsAlarm(1);
+                                    }
+                                } else {
+                                    if (i == 0) {
+                                        LambdaQueryWrapper<BaseCameraManagement> base = new LambdaQueryWrapper<>();
+                                        if (heartbeatVo.getLineDir() == 1) {
+                                            distance = heartbeatVo.getVisualDistance() + heartbeatVo.getCurrentMile();
+                                            base.ge(BaseCameraManagement::getInstallMile, distance);
+                                            base.in(BaseCameraManagement::getMonitoringDirection, 1, 3);
+                                            base.orderByAsc(BaseCameraManagement::getGrou).orderByAsc(BaseCameraManagement::getSort);
+                                            base.le(BaseCameraManagement::getInstallMile, (heartbeatVo.getCurrentMile() + 10000));
+                                        }
+                                        if (heartbeatVo.getLineDir() == 2) {
+                                            distance = heartbeatVo.getCurrentMile() - heartbeatVo.getVisualDistance();
+                                            base.le(BaseCameraManagement::getInstallMile, distance);
+                                            base.ge(BaseCameraManagement::getInstallMile, (heartbeatVo.getCurrentMile() - 10000));
+                                            base.in(BaseCameraManagement::getMonitoringDirection, 2, 3);
+                                            base.orderByDesc(BaseCameraManagement::getGrou).orderByDesc(BaseCameraManagement::getSort);
+                                        }
+                                        base.eq(BaseCameraManagement::getRailwayCode, heartbeatVo.getRailwayCode());
+                                        base.eq(BaseCameraManagement::getOnline, 2);
+                                        base.eq(BaseCameraManagement::getEnableOrNot, 1);
+                                        base.last("limit 1");
+                                        List<BaseCameraManagement> list1 = baseCameraManagementService.list(base);
+                                        CameraVos cameraVos = new CameraVos();
+                                        if (!ObjectUtils.isEmpty(list1)) {
+                                            cameraVos.setCameraCode(list1.get(0).getCameraCode());
+                                            cameraVos.setCurrentStream(cameraUtil.getPlayFlvRtsp(list1.get(0).getCameraCode(), list1.get(0).getGraphicsCard(), type, httpUrl));
+                                            boolean finalType6 = type;
+                                            CompletableFuture.runAsync(() -> {
+                                                String playFlv = cameraUtil.heartbeatgetPlayFlv(list1.get(0).getCameraCode(), list1.get(0).getGraphicsCard(), finalType6);
+                                                if (StringUtils.isEmpty(playFlv)) {
+                                                    try {
+                                                        cameraUtil.heartbeatgetUrl(list1.get(0).getCameraCode(), list1.get(0).getGraphicsCard(), finalType6, httpUrl);
+                                                    } catch (Exception e) {
+                                                        e.printStackTrace();
+                                                    }
+                                                }
+                                            });
+                                        } else {
+                                            cameraVos.setCameraCode("");
+                                            cameraVos.setCurrentStream("");
+                                            cameraVos.setCameraCode("该里程位置,没有可用的预警相机");
+                                            cameraVos.setCurrentStream("");
+                                        }
+                                        List<CameraVos> cameraVosList = new ArrayList<>();
+                                        cameraVosList.add(cameraVos);
+                                        respHeartbeatVo.setCameraList(cameraVosList);
+                                        respHeartbeatVo.setIsAlarm(1);
+                                        preAlarmListResponse.setCameraCode("");
+                                        preAlarmListResponse.setCameraStream("");
+                                    } else {
+                                        preAlarmListResponse.setCameraCode("");
+                                        preAlarmListResponse.setCameraStream("");
+                                    }
+                                }
+                                BeanUtils.copyProperties(preAlarmList.get(i), preAlarmListResponse);
+                                preAlarmListResponse.setPreAlarmTime(preAlarmLists.get(0).getPreAlarmTime().getTime());
+                                responseList.add(preAlarmListResponse);
+                            }
+                            respHeartbeatVo.setPreAlarmList(responseList);
+                            //获取机车前一路视频
+                            int miles = heartbeatVo.getVisualDistance() + heartbeatVo.getCurrentMile();
+                            LambdaQueryWrapper<BaseCameraManagement> base = new LambdaQueryWrapper<>();
+                            if (heartbeatVo.getLineDir() == 1) {
+                                base.orderByAsc(BaseCameraManagement::getGrou).orderByAsc(BaseCameraManagement::getSort);
+                                base.gt(BaseCameraManagement::getInstallMile, miles);
+                            }
+                            if (heartbeatVo.getLineDir() == 2) {
+                                base.orderByDesc(BaseCameraManagement::getGrou).orderByDesc(BaseCameraManagement::getSort);
+                                base.lt(BaseCameraManagement::getInstallMile, miles);
+                            }
+                            base.eq(BaseCameraManagement::getRailwayCode, heartbeatVo.getRailwayCode());
+                            base.eq(BaseCameraManagement::getOnline, 2);
+                            base.eq(BaseCameraManagement::getEnableOrNot, 1);
+                            base.last("limit 2");
+                            List<BaseCameraManagement> list1 = baseCameraManagementService.list(base);
+                            //根据相机ID找出分组并排序
+                            if (!ObjectUtils.isEmpty(list1)) {
+                                for (BaseCameraManagement baseCameraManagement : list1) {
+                                    List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(baseCameraManagement.getId(), heartbeatVo.getLineDir());
+                                    if (!ObjectUtils.isEmpty(baseCameraManagementList1)) {
+                                        for (BaseCameraManagement cameraManagement : baseCameraManagementList1) {
+                                            boolean finalType2 = type;
+                                            CompletableFuture.runAsync(() -> {
+                                                String playFlv = cameraUtil.heartbeatgetPlayFlv(cameraManagement.getCameraCode(), cameraManagement.getGraphicsCard(), finalType2);
+                                                if (StringUtils.isEmpty(playFlv)) {
+                                                    try {
+                                                        cameraUtil.heartbeatgetUrl(cameraManagement.getCameraCode(), cameraManagement.getGraphicsCard(), finalType2, httpUrl);
+                                                    } catch (Exception e) {
+                                                        e.printStackTrace();
+                                                    }
+                                                }
+                                            });
+                                        }
+                                    }
+                                }
+                            }
+                        }else {
+                            //没有报警信息的时候
+                            LambdaQueryWrapper<BaseCameraManagement> base = new LambdaQueryWrapper<>();
+                            if (heartbeatVo.getLineDir() == 1) {
+                                distance = heartbeatVo.getVisualDistance() + heartbeatVo.getCurrentMile();
+                                base.ge(BaseCameraManagement::getInstallMile, distance);
+                                base.in(BaseCameraManagement::getMonitoringDirection, 1, 3);
+                                base.orderByAsc(BaseCameraManagement::getGrou).orderByAsc(BaseCameraManagement::getSort);
+                                base.le(BaseCameraManagement::getInstallMile, (heartbeatVo.getCurrentMile() + 10000));
+                            }
+                            if (heartbeatVo.getLineDir() == 2) {
+                                distance = heartbeatVo.getCurrentMile() - heartbeatVo.getVisualDistance();
+                                base.le(BaseCameraManagement::getInstallMile, distance);
+                                base.ge(BaseCameraManagement::getInstallMile, (heartbeatVo.getCurrentMile() - 10000));
+                                base.in(BaseCameraManagement::getMonitoringDirection, 2, 3);
+                                base.orderByDesc(BaseCameraManagement::getGrou).orderByDesc(BaseCameraManagement::getSort);
+                            }
+                            base.eq(BaseCameraManagement::getRailwayCode, heartbeatVo.getRailwayCode());
+                            base.eq(BaseCameraManagement::getOnline, 2);
+                            base.eq(BaseCameraManagement::getEnableOrNot, 1);
+                            base.last("limit 2");
+                            List<BaseCameraManagement> list1 = baseCameraManagementService.list(base);
+                            if (ObjectUtils.isEmpty(list1)) {
+                                AjaxResults1 = new AjaxResults(0, "前方没有摄像机", respHeartbeatVo);
+                                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+                            }
+                            log.info("流程2----------------->");
+                            //判断流媒体是否有流
+                            String playFlv = cameraUtil.heartbeatgetPlayFlv(list1.get(0).getCameraCode(), list1.get(0).getGraphicsCard(), type);
+                            log.info("playFlv------------>" + playFlv);
+                            baseVideoTrains.setVideoMile(list1.get(0).getInstallMile());
+                            long delay = System.currentTimeMillis();
+                            log.info("关联距离时间: " + sdf.format(new Date(delay)));
+                            long mile = delay - begin;
+                            log.info("关联距离请求用时时间:" + mile + "毫秒");
+                            baseVideoTrains.setDelay((int) mile);
+                            if (heartbeatVo.getLineDir() == 1) {
+                                baseVideoTrains.setDistance(list1.get(0).getInstallMile() - heartbeatVo.getCurrentMile());
+                            } else {
+                                baseVideoTrains.setDistance(heartbeatVo.getCurrentMile() - list1.get(0).getInstallMile());
+                            }
+                            if (baseVideoTrains.getDistance() >= 1000 && baseVideoTrains.getDistance() <= 10000) {
+                                baseVideoTrains.setIsAccuracy(1);
+                            } else {
+                                baseVideoTrains.setIsAccuracy(2);
+                            }
+                            //拉两路视频
+                            if (StringUtils.isEmpty(playFlv)) {
+                                log.info("--------------->>已进入拉两路视频");
+                                for (BaseCameraManagement baseCameraManagement : list1) {
+                                    boolean finalType = type;
+                                    List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(baseCameraManagement.getId(), heartbeatVo.getLineDir());
+                                    if (!ObjectUtils.isEmpty(baseCameraManagementList1)) {
+                                        for (BaseCameraManagement cameraManagement : baseCameraManagementList1) {
+                                            boolean finalType4 = type;
+                                            CompletableFuture.runAsync(() -> {
+                                                int index = 0;
+                                                String url;
+                                                if (index < 2) {
+                                                    url = httpUrl;
+                                                    index++;
+                                                } else {
+                                                    url = httpUrls;
+                                                    index = 0;
+                                                }
+                                                try {
+                                                    cameraUtil.heartbeatgetUrl(cameraManagement.getCameraCode(), cameraManagement.getGraphicsCard(), finalType4, url);
+                                                } catch (Exception e) {
+                                                    e.printStackTrace();
+                                                }
+                                            });
+                                        }
+                                    }
+                                    if (list1.size() >= 2) {
+                                        BaseCameraManagement idOne = baseCameraManagementService.getById(list1.get(0).getId());
+                                        BaseCameraManagement idTwo = baseCameraManagementService.getById(list1.get(1).getId());
+                                        if (idOne.getGrou().equals(idTwo.getGrou())) {
+                                            break;
+                                        }
+                                    }
+                                }
+                            } else {
+                                log.info("-------------->>已进入拉一路路视频");
+                                log.info("list1-------------->>" + list1.size());
+                                for (int i = 1; i < list1.size(); i++) {
+                                    List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(list1.get(i).getId(), heartbeatVo.getLineDir());
+                                    if (!ObjectUtils.isEmpty(baseCameraManagementList1)) {
+                                        for (BaseCameraManagement cameraManagement : baseCameraManagementList1) {
+                                            boolean finalType5 = type;
+                                            CompletableFuture.runAsync(() -> {
+                                                int index = 0;
+                                                String url;
+                                                if (index < 2) {
+                                                    url = httpUrl;
+                                                    index++;
+                                                } else {
+                                                    url = httpUrls;
+                                                    index = 0;
+                                                }
+                                                String playFlv2 = cameraUtil.heartbeatgetPlayFlv(cameraManagement.getCameraCode(), cameraManagement.getGraphicsCard(), finalType5);
+                                                if (StringUtils.isEmpty(playFlv2)) {
+                                                    try {
+                                                        cameraUtil.heartbeatgetUrl(cameraManagement.getCameraCode(), cameraManagement.getGraphicsCard(), finalType5, url);
+                                                    } catch (Exception e) {
+                                                        e.printStackTrace();
+                                                    }
+                                                }
+                                            });
+                                        }
+                                    }
+                                }
+                            }
+                            List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(list1.get(0).getId(), heartbeatVo.getLineDir());
+                            if (!ObjectUtils.isEmpty(baseCameraManagementList1)) {
+                                List<CameraVos> cameraVosList = new ArrayList<>();
+                                for (BaseCameraManagement baseCameraManagement : baseCameraManagementList1) {
+                                    int index = 0;
+                                    String url;
+                                    if (index < 2) {
+                                        url = httpUrl;
+                                        index++;
+                                    } else {
+                                        url = httpUrls;
+                                        index = 0;
+                                    }
+                                    CameraVos cameraVos = new CameraVos();
+                                    cameraVos.setCameraCode(baseCameraManagement.getCameraCode());
+                                    cameraVos.setCurrentStream(CameraUtil.getPlayFlvRtsp(baseCameraManagement.getCameraCode(), baseCameraManagement.getGraphicsCard(), type, url));
+                                    cameraVosList.add(cameraVos);
+                                }
+                                respHeartbeatVo.setCameraList(cameraVosList);
+                            }
+                            respHeartbeatVo.setIsAlarm(2);
+                        }
+                    } else {
+                        //没有报警信息的时候
+                        if (heartbeatVo.getLineDir() == 1) {
+                            distance = heartbeatVo.getVisualDistance() + heartbeatVo.getCurrentMile();
+                            camera.ge(BaseCameraManagement::getInstallMile, distance);
+                            camera.le(BaseCameraManagement::getInstallMile, (heartbeatVo.getCurrentMile() + 10000));
+                            camera.in(BaseCameraManagement::getMonitoringDirection, 1, 3);
+                            camera.orderByAsc(BaseCameraManagement::getGrou).orderByAsc(BaseCameraManagement::getSort);
+                        }
+                        if (heartbeatVo.getLineDir() == 2) {
+                            distance = heartbeatVo.getCurrentMile() - heartbeatVo.getVisualDistance();
+                            camera.le(BaseCameraManagement::getInstallMile, distance);
+                            camera.ge(BaseCameraManagement::getInstallMile, (heartbeatVo.getCurrentMile() - 10000));
+                            camera.in(BaseCameraManagement::getMonitoringDirection, 2, 3);
+                            camera.orderByDesc(BaseCameraManagement::getGrou).orderByDesc(BaseCameraManagement::getSort);
+                            ;
+                        }
+                        camera.eq(BaseCameraManagement::getRailwayCode, heartbeatVo.getRailwayCode());
+                        camera.eq(BaseCameraManagement::getOnline, 2);
+                        camera.eq(BaseCameraManagement::getEnableOrNot, 1);
+                        camera.last("limit 2");
+                        List<BaseCameraManagement> list1 = baseCameraManagementService.list(camera);
+                        if (ObjectUtils.isEmpty(list1)) {
+                            AjaxResults1 = new AjaxResults(0, "前方没有摄像机", respHeartbeatVo);
+                            return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+                        }
+                        log.info("流程1----------------->");
+                        //判断流媒体是否有流
+                        String playFlv = cameraUtil.heartbeatgetPlayFlv(list1.get(0).getCameraCode(), list1.get(0).getGraphicsCard(), type);
+                        log.info("playFlv------------>" + playFlv);
+                        baseVideoTrains.setVideoMile(list1.get(0).getInstallMile());
+                        long delay = System.currentTimeMillis();
+                        log.info("关联距离时间: " + sdf.format(new Date(delay)));
+                        long mile = delay - begin;
+                        log.info("关联距离请求用时时间:" + mile + "毫秒");
+                        baseVideoTrains.setDelay((int) mile);
+                        if (heartbeatVo.getLineDir() == 1) {
+                            baseVideoTrains.setDistance(list1.get(0).getInstallMile() - heartbeatVo.getCurrentMile());
+                        } else {
+                            baseVideoTrains.setDistance(heartbeatVo.getCurrentMile() - list1.get(0).getInstallMile());
+                        }
+                        if (baseVideoTrains.getDistance() >= 1000 && baseVideoTrains.getDistance() <= 10000) {
+                            baseVideoTrains.setIsAccuracy(1);
+                        } else {
+                            baseVideoTrains.setIsAccuracy(2);
+                        }
+                        //拉两路视频
+                        if (StringUtils.isEmpty(playFlv)) {
+                            log.info("--------------->>已进入拉两路视频");
+                            for (BaseCameraManagement baseCameraManagement : list1) {
+                                List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(baseCameraManagement.getId(), heartbeatVo.getLineDir());
+                                if (!ObjectUtils.isEmpty(baseCameraManagementList1)) {
+                                    for (BaseCameraManagement cameraManagement : baseCameraManagementList1) {
+                                        boolean finalType4 = type;
+                                        CompletableFuture.runAsync(() -> {
+                                            int index = 0;
+                                            String url;
+                                            if (index < 2) {
+                                                url = httpUrl;
+                                                index++;
+                                            } else {
+                                                url = httpUrls;
+                                                index = 0;
+                                            }
+                                            try {
+                                                cameraUtil.heartbeatgetUrl(cameraManagement.getCameraCode(), cameraManagement.getGraphicsCard(), finalType4, url);
+                                            } catch (Exception e) {
+                                                e.printStackTrace();
+                                            }
+                                        });
+                                    }
+                                }
+                                if (list1.size() >= 2) {
+                                    BaseCameraManagement idOne = baseCameraManagementService.getById(list1.get(0).getId());
+                                    BaseCameraManagement idTwo = baseCameraManagementService.getById(list1.get(1).getId());
+                                    if (idOne.getGrou().equals(idTwo.getGrou())) {
+                                        break;
+                                    }
+                                }
+                            }
+//                            CompletableFuture.runAsync(() -> {
+//                                cameraUtil.removePlayFlv(heartbeatVo.getLineDir(), heartbeatVo.getCurrentMile(), heartbeatVo.getVisualDistance());
+//                            });
+                        } else {
+                            log.info("-------------->>已进入拉一路视频");
+                            log.info("list1-------------->>" + list1.size());
+                            for (int i = 1; i < list1.size(); i++) {
+                                boolean finalType = type;
+                                int finalI = i;
+                                List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(list1.get(finalI).getId(), heartbeatVo.getLineDir());
+                                if (!ObjectUtils.isEmpty(baseCameraManagementList1)) {
+                                    for (BaseCameraManagement cameraManagement : baseCameraManagementList1) {
+                                        boolean finalType5 = type;
+                                        CompletableFuture.runAsync(() -> {
+                                            int index = 0;
+                                            String url;
+                                            if (index < 2) {
+                                                url = httpUrl;
+                                                index++;
+                                            } else {
+                                                url = httpUrls;
+                                                index = 0;
+                                            }
+                                            String playFlv2 = cameraUtil.heartbeatgetPlayFlv(cameraManagement.getCameraCode(), cameraManagement.getGraphicsCard(), finalType5);
+                                            if (StringUtils.isEmpty(playFlv2)) {
+                                                try {
+                                                    cameraUtil.heartbeatgetUrl(cameraManagement.getCameraCode(), cameraManagement.getGraphicsCard(), finalType5, url);
+                                                } catch (Exception e) {
+                                                    e.printStackTrace();
+                                                }
+                                            }
+                                        });
+                                    }
+                                }
+                            }
+                        }
+                        List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(list1.get(0).getId(), heartbeatVo.getLineDir());
+                        if (!ObjectUtils.isEmpty(baseCameraManagementList1)) {
+                            List<CameraVos> cameraVosList = new ArrayList<>();
+                            for (BaseCameraManagement baseCameraManagement : baseCameraManagementList1) {
+                                int index = 0;
+                                String url;
+                                if (index < 2) {
+                                    url = httpUrl;
+                                    index++;
+                                } else {
+                                    url = httpUrls;
+                                    index = 0;
+                                }
+                                CameraVos cameraVos = new CameraVos();
+                                cameraVos.setCameraCode(baseCameraManagement.getCameraCode());
+                                cameraVos.setCurrentStream(CameraUtil.getPlayFlvRtsp(baseCameraManagement.getCameraCode(), baseCameraManagement.getGraphicsCard(), type, url));
+                                cameraVosList.add(cameraVos);
+                            }
+                            respHeartbeatVo.setCameraList(cameraVosList);
+                        }
+                        respHeartbeatVo.setIsAlarm(2);
+                    }
+                } else if (!ObjectUtils.isEmpty(preAlarmLists.get(0).getPreAlarmList())) {
+                    if (!"[]".equals(preAlarmLists.get(0).getPreAlarmList())) {
+                        log.info("preAlarm.getPreAlarmList()------" + preAlarmLists.get(0).getPreAlarmList());
                         List<PreAlarmListResponse> responseList = new ArrayList<>();
-                        List<PreAlarmResponse.PreAlarmList> preAlarmList = JSON.parseArray(preAlarm.getPreAlarmList(), PreAlarmResponse.PreAlarmList.class);
+                        List<PreAlarmResponse.PreAlarmList> preAlarmList = JSON.parseArray(preAlarmLists.get(0).getPreAlarmList(), PreAlarmResponse.PreAlarmList.class);
                         Comparator<PreAlarmResponse.PreAlarmList> distanceComparator = new Comparator<PreAlarmResponse.PreAlarmList>() {
                             @Override
                             public int compare(PreAlarmResponse.PreAlarmList o1, PreAlarmResponse.PreAlarmList o2) {
@@ -1114,9 +1559,10 @@ public class GeoHazardMonitorTokenController {
                                             }
                                         }
                                     });
+                                    log.info("-------playFlv--------" + playFlv1);
                                     CameraVos cameraVos = new CameraVos();
                                     cameraVos.setCameraCode(code);
-                                    cameraVos.setCurrentStream(CameraUtil.getPlayFlvRtsp(code, graphicsCard, type, httpUrl));
+                                    cameraVos.setCurrentStream(cameraUtil.getPlayFlvRtsp(code, finalGraphicsCard, type, httpUrl));
                                     List<CameraVos> cameraVosList = new ArrayList<>();
                                     cameraVosList.add(cameraVos);
                                     respHeartbeatVo.setCameraList(cameraVosList);
@@ -1177,7 +1623,7 @@ public class GeoHazardMonitorTokenController {
                                 }
                             }
                             BeanUtils.copyProperties(preAlarmList.get(i), preAlarmListResponse);
-                            preAlarmListResponse.setPreAlarmTime(preAlarm.getPreAlarmTime().getTime());
+                            preAlarmListResponse.setPreAlarmTime(preAlarmLists.get(0).getPreAlarmTime().getTime());
                             responseList.add(preAlarmListResponse);
                         }
                         respHeartbeatVo.setPreAlarmList(responseList);
@@ -1196,10 +1642,10 @@ public class GeoHazardMonitorTokenController {
                         base.eq(BaseCameraManagement::getOnline, 2);
                         base.eq(BaseCameraManagement::getEnableOrNot, 1);
                         base.last("limit 2");
-                        List<BaseCameraManagement> list1 = baseCameraManagementService.list(base);
+                        List<BaseCameraManagement> list = baseCameraManagementService.list(base);
                         //根据相机ID找出分组并排序
-                        if (!ObjectUtils.isEmpty(list1)) {
-                            for (BaseCameraManagement baseCameraManagement : list1) {
+                        if (!ObjectUtils.isEmpty(list)) {
+                            for (BaseCameraManagement baseCameraManagement : list) {
                                 List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(baseCameraManagement.getId(), heartbeatVo.getLineDir());
                                 if (!ObjectUtils.isEmpty(baseCameraManagementList1)) {
                                     for (BaseCameraManagement cameraManagement : baseCameraManagementList1) {
@@ -1218,33 +1664,33 @@ public class GeoHazardMonitorTokenController {
                                 }
                             }
                         }
-                    } else {
+                    }else {
                         //没有报警信息的时候
+                        LambdaQueryWrapper<BaseCameraManagement> base = new LambdaQueryWrapper<>();
                         if (heartbeatVo.getLineDir() == 1) {
                             distance = heartbeatVo.getVisualDistance() + heartbeatVo.getCurrentMile();
-                            camera.ge(BaseCameraManagement::getInstallMile, distance);
-                            camera.le(BaseCameraManagement::getInstallMile, (heartbeatVo.getCurrentMile() + 10000));
-                            camera.in(BaseCameraManagement::getMonitoringDirection, 1, 3);
-                            camera.orderByAsc(BaseCameraManagement::getGrou).orderByAsc(BaseCameraManagement::getSort);
+                            base.ge(BaseCameraManagement::getInstallMile, distance);
+                            base.in(BaseCameraManagement::getMonitoringDirection, 1, 3);
+                            base.orderByAsc(BaseCameraManagement::getGrou).orderByAsc(BaseCameraManagement::getSort);
+                            base.le(BaseCameraManagement::getInstallMile, (heartbeatVo.getCurrentMile() + 10000));
                         }
                         if (heartbeatVo.getLineDir() == 2) {
                             distance = heartbeatVo.getCurrentMile() - heartbeatVo.getVisualDistance();
-                            camera.le(BaseCameraManagement::getInstallMile, distance);
-                            camera.ge(BaseCameraManagement::getInstallMile, (heartbeatVo.getCurrentMile() - 10000));
-                            camera.in(BaseCameraManagement::getMonitoringDirection, 2, 3);
-                            camera.orderByDesc(BaseCameraManagement::getGrou).orderByDesc(BaseCameraManagement::getSort);
-                            ;
+                            base.le(BaseCameraManagement::getInstallMile, distance);
+                            base.ge(BaseCameraManagement::getInstallMile, (heartbeatVo.getCurrentMile() - 10000));
+                            base.in(BaseCameraManagement::getMonitoringDirection, 2, 3);
+                            base.orderByDesc(BaseCameraManagement::getGrou).orderByDesc(BaseCameraManagement::getSort);
                         }
-                        camera.eq(BaseCameraManagement::getRailwayCode, heartbeatVo.getRailwayCode());
-                        camera.eq(BaseCameraManagement::getOnline, 2);
-                        camera.eq(BaseCameraManagement::getEnableOrNot, 1);
-                        camera.last("limit 2");
-                        List<BaseCameraManagement> list1 = baseCameraManagementService.list(camera);
+                        base.eq(BaseCameraManagement::getRailwayCode, heartbeatVo.getRailwayCode());
+                        base.eq(BaseCameraManagement::getOnline, 2);
+                        base.eq(BaseCameraManagement::getEnableOrNot, 1);
+                        base.last("limit 2");
+                        List<BaseCameraManagement> list1 = baseCameraManagementService.list(base);
                         if (ObjectUtils.isEmpty(list1)) {
                             AjaxResults1 = new AjaxResults(0, "前方没有摄像机", respHeartbeatVo);
                             return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
                         }
-                        log.info("流程1----------------->");
+                        log.info("流程2----------------->");
                         //判断流媒体是否有流
                         String playFlv = cameraUtil.heartbeatgetPlayFlv(list1.get(0).getCameraCode(), list1.get(0).getGraphicsCard(), type);
                         log.info("playFlv------------>" + playFlv);
@@ -1268,6 +1714,7 @@ public class GeoHazardMonitorTokenController {
                         if (StringUtils.isEmpty(playFlv)) {
                             log.info("--------------->>已进入拉两路视频");
                             for (BaseCameraManagement baseCameraManagement : list1) {
+                                boolean finalType = type;
                                 List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(baseCameraManagement.getId(), heartbeatVo.getLineDir());
                                 if (!ObjectUtils.isEmpty(baseCameraManagementList1)) {
                                     for (BaseCameraManagement cameraManagement : baseCameraManagementList1) {
@@ -1298,16 +1745,11 @@ public class GeoHazardMonitorTokenController {
                                     }
                                 }
                             }
-//                            CompletableFuture.runAsync(() -> {
-//                                cameraUtil.removePlayFlv(heartbeatVo.getLineDir(), heartbeatVo.getCurrentMile(), heartbeatVo.getVisualDistance());
-//                            });
                         } else {
-                            log.info("-------------->>已进入拉一路视频");
+                            log.info("-------------->>已进入拉一路路视频");
                             log.info("list1-------------->>" + list1.size());
                             for (int i = 1; i < list1.size(); i++) {
-                                boolean finalType = type;
-                                int finalI = i;
-                                List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(list1.get(finalI).getId(), heartbeatVo.getLineDir());
+                                List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(list1.get(i).getId(), heartbeatVo.getLineDir());
                                 if (!ObjectUtils.isEmpty(baseCameraManagementList1)) {
                                     for (BaseCameraManagement cameraManagement : baseCameraManagementList1) {
                                         boolean finalType5 = type;
@@ -1356,179 +1798,6 @@ public class GeoHazardMonitorTokenController {
                         }
                         respHeartbeatVo.setIsAlarm(2);
                     }
-                } else if (!"[]".equals(preAlarm.getPreAlarmList())) {
-                    log.info("preAlarm.getPreAlarmList()------" + preAlarm.getPreAlarmList());
-                    List<PreAlarmListResponse> responseList = new ArrayList<>();
-                    List<PreAlarmResponse.PreAlarmList> preAlarmList = JSON.parseArray(preAlarm.getPreAlarmList(), PreAlarmResponse.PreAlarmList.class);
-                    Comparator<PreAlarmResponse.PreAlarmList> distanceComparator = new Comparator<PreAlarmResponse.PreAlarmList>() {
-                        @Override
-                        public int compare(PreAlarmResponse.PreAlarmList o1, PreAlarmResponse.PreAlarmList o2) {
-                            return Integer.compare(o1.getDistance(), o2.getDistance());
-                        }
-                    };
-                    //排序
-                    preAlarmList.sort(distanceComparator);
-                    for (int i = 0; i < preAlarmList.size(); i++) {
-                        PreAlarmListResponse preAlarmListResponse = new PreAlarmListResponse();
-                        int mile = 0;
-                        LambdaQueryWrapper<BaseCameraManagement> wrapper1 = new LambdaQueryWrapper<BaseCameraManagement>();
-                        if (heartbeatVo.getLineDir() == 1) {
-                            mile = preAlarmList.get(i).getDistance() + heartbeatVo.getCurrentMile();
-                            wrapper1.ge(BaseCameraManagement::getEndMile, mile);
-                            wrapper1.le(BaseCameraManagement::getBeginMile, mile);
-                            wrapper1.in(BaseCameraManagement::getMonitoringDirection, 1, 3);
-                            wrapper1.orderByAsc(BaseCameraManagement::getGrou).orderByAsc(BaseCameraManagement::getSort);
-                        }
-                        if (heartbeatVo.getLineDir() == 2) {
-                            mile = heartbeatVo.getCurrentMile() - preAlarmList.get(i).getDistance();
-                            wrapper1.ge(BaseCameraManagement::getEndMile, mile);
-                            wrapper1.le(BaseCameraManagement::getBeginMile, mile);
-                            wrapper1.in(BaseCameraManagement::getMonitoringDirection, 2, 3);
-                            wrapper1.orderByDesc(BaseCameraManagement::getGrou).orderByDesc(BaseCameraManagement::getSort);
-                        }
-                        List<BaseCameraManagement> baseCameraManagementList = baseCameraManagementService.list(wrapper1);
-                        log.info("-------baseCameraManagementList123111--------" + baseCameraManagementList);
-                        if (!ObjectUtils.isEmpty(baseCameraManagementList)) {
-                            int minDifference = Integer.MAX_VALUE;
-                            String code = null;
-                            String graphicsCard = null;
-                            for (BaseCameraManagement baseCameraManagement : baseCameraManagementList) {
-                                log.info("------------baseCameraManagement.getInstallMile()-------" + baseCameraManagement.getInstallMile());
-                                log.info("------------list.get(0).getAlarmMile()-------" + mile);
-                                int difference = Math.abs(baseCameraManagement.getInstallMile() - mile);
-                                log.info("------------difference-------" + difference);
-                                log.info("------------minDifference-------" + minDifference);
-                                if (difference < minDifference) {
-                                    minDifference = difference;
-                                    log.info("------------minDifference变更-------" + minDifference);
-                                    code = baseCameraManagement.getCameraCode();
-                                    log.info("------------code-------" + code);
-                                    graphicsCard = baseCameraManagement.getGraphicsCard();
-                                    log.info("------------graphicsCard-------" + graphicsCard);
-                                }
-                                //添加预警信息
-                                preAlarmListResponse.setCameraCode(baseCameraManagement.getCameraCode());
-                                preAlarmListResponse.setCameraStream(CameraUtil.getPlayFlvRtsp(baseCameraManagement.getCameraCode(), baseCameraManagement.getGraphicsCard(), type, httpUrl));
-                            }
-                            if (i == 0) {
-                                String finalCode = code;
-                                String finalGraphicsCard = graphicsCard;
-                                boolean finalType3 = type;
-                                CompletableFuture.runAsync(() -> {
-                                    String playFlv = cameraUtil.heartbeatgetPlayFlv(finalCode, finalGraphicsCard, finalType3);
-                                    if (StringUtils.isEmpty(playFlv)) {
-                                        try {
-                                            cameraUtil.heartbeatgetUrl(finalCode, finalGraphicsCard, finalType3, httpUrl);
-                                        } catch (Exception e) {
-                                            e.printStackTrace();
-                                        }
-                                    }
-                                });
-                                log.info("-------playFlv--------" + playFlv1);
-                                CameraVos cameraVos = new CameraVos();
-                                cameraVos.setCameraCode(code);
-                                cameraVos.setCurrentStream(cameraUtil.getPlayFlvRtsp(code, finalGraphicsCard, type, httpUrl));
-                                List<CameraVos> cameraVosList = new ArrayList<>();
-                                cameraVosList.add(cameraVos);
-                                respHeartbeatVo.setCameraList(cameraVosList);
-                                respHeartbeatVo.setIsAlarm(1);
-                            }
-                        } else {
-                            if (i == 0) {
-                                LambdaQueryWrapper<BaseCameraManagement> base = new LambdaQueryWrapper<>();
-                                if (heartbeatVo.getLineDir() == 1) {
-                                    distance = heartbeatVo.getVisualDistance() + heartbeatVo.getCurrentMile();
-                                    base.ge(BaseCameraManagement::getInstallMile, distance);
-                                    base.in(BaseCameraManagement::getMonitoringDirection, 1, 3);
-                                    base.orderByAsc(BaseCameraManagement::getGrou).orderByAsc(BaseCameraManagement::getSort);
-                                    base.le(BaseCameraManagement::getInstallMile, (heartbeatVo.getCurrentMile() + 10000));
-                                }
-                                if (heartbeatVo.getLineDir() == 2) {
-                                    distance = heartbeatVo.getCurrentMile() - heartbeatVo.getVisualDistance();
-                                    base.le(BaseCameraManagement::getInstallMile, distance);
-                                    base.ge(BaseCameraManagement::getInstallMile, (heartbeatVo.getCurrentMile() - 10000));
-                                    base.in(BaseCameraManagement::getMonitoringDirection, 2, 3);
-                                    base.orderByDesc(BaseCameraManagement::getGrou).orderByDesc(BaseCameraManagement::getSort);
-                                }
-                                base.eq(BaseCameraManagement::getRailwayCode, heartbeatVo.getRailwayCode());
-                                base.eq(BaseCameraManagement::getOnline, 2);
-                                base.eq(BaseCameraManagement::getEnableOrNot, 1);
-                                base.last("limit 1");
-                                List<BaseCameraManagement> list1 = baseCameraManagementService.list(base);
-                                CameraVos cameraVos = new CameraVos();
-                                if (!ObjectUtils.isEmpty(list1)) {
-                                    cameraVos.setCameraCode(list1.get(0).getCameraCode());
-                                    cameraVos.setCurrentStream(cameraUtil.getPlayFlvRtsp(list1.get(0).getCameraCode(), list1.get(0).getGraphicsCard(), type, httpUrl));
-                                    boolean finalType6 = type;
-                                    CompletableFuture.runAsync(() -> {
-                                        String playFlv = cameraUtil.heartbeatgetPlayFlv(list1.get(0).getCameraCode(), list1.get(0).getGraphicsCard(), finalType6);
-                                        if (StringUtils.isEmpty(playFlv)) {
-                                            try {
-                                                cameraUtil.heartbeatgetUrl(list1.get(0).getCameraCode(), list1.get(0).getGraphicsCard(), finalType6, httpUrl);
-                                            } catch (Exception e) {
-                                                e.printStackTrace();
-                                            }
-                                        }
-                                    });
-                                } else {
-                                    cameraVos.setCameraCode("");
-                                    cameraVos.setCurrentStream("");
-                                    cameraVos.setCameraCode("该里程位置,没有可用的预警相机");
-                                    cameraVos.setCurrentStream("");
-                                }
-                                List<CameraVos> cameraVosList = new ArrayList<>();
-                                cameraVosList.add(cameraVos);
-                                respHeartbeatVo.setCameraList(cameraVosList);
-                                respHeartbeatVo.setIsAlarm(1);
-                                preAlarmListResponse.setCameraCode("");
-                                preAlarmListResponse.setCameraStream("");
-                            } else {
-                                preAlarmListResponse.setCameraCode("");
-                                preAlarmListResponse.setCameraStream("");
-                            }
-                        }
-                        BeanUtils.copyProperties(preAlarmList.get(i), preAlarmListResponse);
-                        preAlarmListResponse.setPreAlarmTime(preAlarm.getPreAlarmTime().getTime());
-                        responseList.add(preAlarmListResponse);
-                    }
-                    respHeartbeatVo.setPreAlarmList(responseList);
-                    //获取机车前一路视频
-                    int miles = heartbeatVo.getVisualDistance() + heartbeatVo.getCurrentMile();
-                    LambdaQueryWrapper<BaseCameraManagement> base = new LambdaQueryWrapper<>();
-                    if (heartbeatVo.getLineDir() == 1) {
-                        base.orderByAsc(BaseCameraManagement::getGrou).orderByAsc(BaseCameraManagement::getSort);
-                        base.gt(BaseCameraManagement::getInstallMile, miles);
-                    }
-                    if (heartbeatVo.getLineDir() == 2) {
-                        base.orderByDesc(BaseCameraManagement::getGrou).orderByDesc(BaseCameraManagement::getSort);
-                        base.lt(BaseCameraManagement::getInstallMile, miles);
-                    }
-                    base.eq(BaseCameraManagement::getRailwayCode, heartbeatVo.getRailwayCode());
-                    base.eq(BaseCameraManagement::getOnline, 2);
-                    base.eq(BaseCameraManagement::getEnableOrNot, 1);
-                    base.last("limit 2");
-                    List<BaseCameraManagement> list = baseCameraManagementService.list(base);
-                    //根据相机ID找出分组并排序
-                    if (!ObjectUtils.isEmpty(list)) {
-                        for (BaseCameraManagement baseCameraManagement : list) {
-                            List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(baseCameraManagement.getId(), heartbeatVo.getLineDir());
-                            if (!ObjectUtils.isEmpty(baseCameraManagementList1)) {
-                                for (BaseCameraManagement cameraManagement : baseCameraManagementList1) {
-                                    boolean finalType2 = type;
-                                    CompletableFuture.runAsync(() -> {
-                                        String playFlv = cameraUtil.heartbeatgetPlayFlv(cameraManagement.getCameraCode(), cameraManagement.getGraphicsCard(), finalType2);
-                                        if (StringUtils.isEmpty(playFlv)) {
-                                            try {
-                                                cameraUtil.heartbeatgetUrl(cameraManagement.getCameraCode(), cameraManagement.getGraphicsCard(), finalType2, httpUrl);
-                                            } catch (Exception e) {
-                                                e.printStackTrace();
-                                            }
-                                        }
-                                    });
-                                }
-                            }
-                        }
-                    }
                 } else {
                     //没有报警信息的时候
                     LambdaQueryWrapper<BaseCameraManagement> base = new LambdaQueryWrapper<>();