Browse Source

心跳预警增加预拉相机逻辑

gao.qiang 8 months ago
parent
commit
e9d90c6a06

+ 75 - 84
vehicle-sdk/src/main/java/com/ozs/controller/upload/GeoHazardMonitorTokenController.java

@@ -879,11 +879,7 @@ public class GeoHazardMonitorTokenController {
                         base.eq(BaseCameraManagement::getRailwayCode, heartbeatVo.getRailwayCode());
                         base.eq(BaseCameraManagement::getOnline, 2);
                         base.eq(BaseCameraManagement::getEnableOrNot, 1);
-                        if (array[0].getCameraStream().equals("")) {
-                            base.last("limit 1");
-                        } else {
-                            base.last("limit 1,1");
-                        }
+                        base.last("limit 2");
                         BaseCameraManagement baseCameraManagement = baseCameraManagementService.getOne(base);
                         //根据相机ID找出分组并排序
                         if (!ObjectUtils.isEmpty(baseCameraManagement)) {
@@ -1038,51 +1034,48 @@ public class GeoHazardMonitorTokenController {
                                     respHeartbeatVo.setCameraList(cameraVosList);
                                     respHeartbeatVo.setIsAlarm(1);
                                 }
-
-                                //获取机车前一路视频
-                                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);
-                                if (respHeartbeatVo.getCameraList().get(0).getCurrentStream().equals("")) {
-                                    base.last("limit 1");
-                                } else {
-                                    base.last("limit 1,1");
-                                }
-                                BaseCameraManagement baseCameraManagement = baseCameraManagementService.getOne(base);
-                                //根据相机ID找出分组并排序
-                                if (!ObjectUtils.isEmpty(baseCameraManagement)) {
-                                    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();
-                                                    }
-                                                }
-                                            });
-                                        }
-                                    }
-                                }
                             }
                             BeanUtils.copyProperties(preAlarmList.get(i), preAlarmListResponse);
                             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);
+                        if (respHeartbeatVo.getCameraList().get(0).getCurrentStream().equals("")) {
+                            base.last("limit 2");
+                        }
+                        BaseCameraManagement baseCameraManagement = baseCameraManagementService.getOne(base);
+                        //根据相机ID找出分组并排序
+                        if (!ObjectUtils.isEmpty(baseCameraManagement)) {
+                            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 {
                         //没有报警信息的时候
                         if (heartbeatVo.getLineDir() == 1) {
@@ -1356,50 +1349,48 @@ public class GeoHazardMonitorTokenController {
                                 respHeartbeatVo.setCameraList(cameraVosList);
                                 respHeartbeatVo.setIsAlarm(1);
                             }
-                            //获取机车前一路视频
-                            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);
-                            if (respHeartbeatVo.getCameraList().get(0).getCurrentStream().equals("")) {
-                                base.last("limit 1");
-                            } else {
-                                base.last("limit 1,1");
-                            }
-                            BaseCameraManagement baseCameraManagement = baseCameraManagementService.getOne(base);
-                            //根据相机ID找出分组并排序
-                            if (!ObjectUtils.isEmpty(baseCameraManagement)) {
-                                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();
-                                                }
-                                            }
-                                        });
-                                    }
-                                }
-                            }
                         }
                         BeanUtils.copyProperties(preAlarmList.get(i), preAlarmListResponse);
                         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);
+                    if (respHeartbeatVo.getCameraList().get(0).getCurrentStream().equals("")) {
+                        base.last("limit 2");
+                    }
+                    BaseCameraManagement baseCameraManagement = baseCameraManagementService.getOne(base);
+                    //根据相机ID找出分组并排序
+                    if (!ObjectUtils.isEmpty(baseCameraManagement)) {
+                        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<>();