Переглянути джерело

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

gao.qiang 8 місяців тому
батько
коміт
8e619ceace

+ 80 - 1
vehicle-sdk/src/main/java/com/ozs/controller/upload/GeoHazardMonitorTokenController.java

@@ -879,7 +879,11 @@ public class GeoHazardMonitorTokenController {
                         base.eq(BaseCameraManagement::getRailwayCode, heartbeatVo.getRailwayCode());
                         base.eq(BaseCameraManagement::getOnline, 2);
                         base.eq(BaseCameraManagement::getEnableOrNot, 1);
-                        base.last("limit 1");
+                        if (array[0].getCameraStream().equals("")){
+                            base.last("limit 1");
+                        }else {
+                            base.last("limit 1,1");
+                        }
                         BaseCameraManagement baseCameraManagement = baseCameraManagementService.getOne(base);
                         //根据相机ID找出分组并排序
                         List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(baseCameraManagement.getId(), heartbeatVo.getLineDir());
@@ -1032,6 +1036,44 @@ 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找出分组并排序
+                                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);
@@ -1310,6 +1352,43 @@ 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找出分组并排序
+                            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);