|
@@ -1082,174 +1082,302 @@ public class GeoHazardMonitorTokenController {
|
|
|
List<PreAlarmResponse.PreAlarmList> filteredList = preAlarmList.stream()
|
|
|
.filter(item -> item.getTargetType() != 4)
|
|
|
.collect(Collectors.toList());
|
|
|
- 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());
|
|
|
- }
|
|
|
- };
|
|
|
- //排序
|
|
|
- filteredList.sort(distanceComparator);
|
|
|
- for (int i = 0; i < filteredList.size(); i++) {
|
|
|
- PreAlarmListResponse preAlarmListResponse = new PreAlarmListResponse();
|
|
|
- int mile = 0;
|
|
|
- LambdaQueryWrapper<BaseCameraManagement> wrapper1 = new LambdaQueryWrapper<BaseCameraManagement>();
|
|
|
- if (heartbeatVo.getLineDir() == 1) {
|
|
|
- mile = filteredList.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() - filteredList.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 (!ObjectUtils.isEmpty(filteredList)) {
|
|
|
+ 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());
|
|
|
}
|
|
|
- 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);
|
|
|
+ };
|
|
|
+ //排序
|
|
|
+ filteredList.sort(distanceComparator);
|
|
|
+ for (int i = 0; i < filteredList.size(); i++) {
|
|
|
+ PreAlarmListResponse preAlarmListResponse = new PreAlarmListResponse();
|
|
|
+ int mile = 0;
|
|
|
+ LambdaQueryWrapper<BaseCameraManagement> wrapper1 = new LambdaQueryWrapper<BaseCameraManagement>();
|
|
|
+ if (heartbeatVo.getLineDir() == 1) {
|
|
|
+ mile = filteredList.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);
|
|
|
}
|
|
|
- } 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);
|
|
|
+ if (heartbeatVo.getLineDir() == 2) {
|
|
|
+ mile = heartbeatVo.getCurrentMile() - filteredList.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));
|
|
|
}
|
|
|
- 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;
|
|
|
+ if (i == 0) {
|
|
|
+ String finalCode = code;
|
|
|
+ String finalGraphicsCard = graphicsCard;
|
|
|
+ boolean finalType3 = type;
|
|
|
CompletableFuture.runAsync(() -> {
|
|
|
- String playFlv = cameraUtil.heartbeatgetPlayFlv(list1.get(0).getCameraCode(), list1.get(0).getGraphicsCard(), finalType6);
|
|
|
+ String playFlv = cameraUtil.heartbeatgetPlayFlv(finalCode, finalGraphicsCard, finalType3);
|
|
|
if (StringUtils.isEmpty(playFlv)) {
|
|
|
try {
|
|
|
- cameraUtil.heartbeatgetUrl(list1.get(0).getCameraCode(), list1.get(0).getGraphicsCard(), finalType6, httpUrl);
|
|
|
+ cameraUtil.heartbeatgetUrl(finalCode, finalGraphicsCard, finalType3, httpUrl);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- } else {
|
|
|
- cameraVos.setCameraCode("");
|
|
|
- cameraVos.setCurrentStream("");
|
|
|
- cameraVos.setCameraCode("该里程位置,没有可用的预警相机");
|
|
|
- cameraVos.setCurrentStream("");
|
|
|
+ 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);
|
|
|
}
|
|
|
- List<CameraVos> cameraVosList = new ArrayList<>();
|
|
|
- cameraVosList.add(cameraVos);
|
|
|
- respHeartbeatVo.setCameraList(cameraVosList);
|
|
|
- respHeartbeatVo.setIsAlarm(1);
|
|
|
- preAlarmListResponse.setCameraCode("");
|
|
|
- preAlarmListResponse.setCameraStream("");
|
|
|
} else {
|
|
|
- preAlarmListResponse.setCameraCode("");
|
|
|
- preAlarmListResponse.setCameraStream("");
|
|
|
+ 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(filteredList.get(i), preAlarmListResponse);
|
|
|
+ preAlarmListResponse.setPreAlarmTime(preAlarmLists.get(0).getPreAlarmTime().getTime());
|
|
|
+ responseList.add(preAlarmListResponse);
|
|
|
}
|
|
|
- BeanUtils.copyProperties(filteredList.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)) {
|
|
|
+ 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 {
|
|
|
+ //没有报警信息的时候
|
|
|
+ BaseCameraManagementReq baseCameraManagementReq = new BaseCameraManagementReq();
|
|
|
+ if (heartbeatVo.getLineDir() == 1) {
|
|
|
+ distance = heartbeatVo.getVisualDistance() + heartbeatVo.getCurrentMile();
|
|
|
+ baseCameraManagementReq.setInstallMile(heartbeatVo.getCurrentMile() + 10000);
|
|
|
+ }
|
|
|
+ if (heartbeatVo.getLineDir() == 2) {
|
|
|
+ distance = heartbeatVo.getCurrentMile() - heartbeatVo.getVisualDistance();
|
|
|
+ baseCameraManagementReq.setInstallMile(heartbeatVo.getCurrentMile() - 10000);
|
|
|
+ }
|
|
|
+ baseCameraManagementReq.setDistance(distance);
|
|
|
+ baseCameraManagementReq.setLineDir(heartbeatVo.getLineDir());
|
|
|
+ baseCameraManagementReq.setRailwayCode(heartbeatVo.getRailwayCode());
|
|
|
+ List<BaseCameraManagement> list1 = baseCameraManagementService.cameraMangemnetList(baseCameraManagementReq);
|
|
|
+ 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(), finalType2, httpUrl);
|
|
|
+ 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 {
|
|
|
//没有报警信息的时候
|
|
@@ -1517,174 +1645,302 @@ public class GeoHazardMonitorTokenController {
|
|
|
List<PreAlarmResponse.PreAlarmList> filteredList = preAlarmList.stream()
|
|
|
.filter(item -> item.getTargetType() != 4)
|
|
|
.collect(Collectors.toList());
|
|
|
- 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());
|
|
|
- }
|
|
|
- };
|
|
|
- //排序
|
|
|
- filteredList.sort(distanceComparator);
|
|
|
- for (int i = 0; i < filteredList.size(); i++) {
|
|
|
- PreAlarmListResponse preAlarmListResponse = new PreAlarmListResponse();
|
|
|
- int mile = 0;
|
|
|
- LambdaQueryWrapper<BaseCameraManagement> wrapper1 = new LambdaQueryWrapper<BaseCameraManagement>();
|
|
|
- if (heartbeatVo.getLineDir() == 1) {
|
|
|
- mile = filteredList.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() - filteredList.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 (!ObjectUtils.isEmpty(filteredList)) {
|
|
|
+ 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());
|
|
|
}
|
|
|
- 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);
|
|
|
+ };
|
|
|
+ //排序
|
|
|
+ filteredList.sort(distanceComparator);
|
|
|
+ for (int i = 0; i < filteredList.size(); i++) {
|
|
|
+ PreAlarmListResponse preAlarmListResponse = new PreAlarmListResponse();
|
|
|
+ int mile = 0;
|
|
|
+ LambdaQueryWrapper<BaseCameraManagement> wrapper1 = new LambdaQueryWrapper<BaseCameraManagement>();
|
|
|
+ if (heartbeatVo.getLineDir() == 1) {
|
|
|
+ mile = filteredList.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);
|
|
|
}
|
|
|
- } 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 (heartbeatVo.getLineDir() == 2) {
|
|
|
+ mile = heartbeatVo.getCurrentMile() - filteredList.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(list1.get(0).getCameraCode(), list1.get(0).getGraphicsCard(), finalType6, httpUrl);
|
|
|
+ cameraUtil.heartbeatgetUrl(finalCode, finalGraphicsCard, finalType3, httpUrl);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- } else {
|
|
|
- cameraVos.setCameraCode("");
|
|
|
- cameraVos.setCurrentStream("");
|
|
|
- cameraVos.setCameraCode("该里程位置,没有可用的预警相机");
|
|
|
- cameraVos.setCurrentStream("");
|
|
|
+ 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);
|
|
|
}
|
|
|
- List<CameraVos> cameraVosList = new ArrayList<>();
|
|
|
- cameraVosList.add(cameraVos);
|
|
|
- respHeartbeatVo.setCameraList(cameraVosList);
|
|
|
- respHeartbeatVo.setIsAlarm(1);
|
|
|
- preAlarmListResponse.setCameraCode("");
|
|
|
- preAlarmListResponse.setCameraStream("");
|
|
|
} else {
|
|
|
- preAlarmListResponse.setCameraCode("");
|
|
|
- preAlarmListResponse.setCameraStream("");
|
|
|
+ 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(filteredList.get(i), preAlarmListResponse);
|
|
|
+ preAlarmListResponse.setPreAlarmTime(preAlarmLists.get(0).getPreAlarmTime().getTime());
|
|
|
+ responseList.add(preAlarmListResponse);
|
|
|
}
|
|
|
- BeanUtils.copyProperties(filteredList.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> 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)) {
|
|
|
+ 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 {
|
|
|
+ //没有报警信息的时候
|
|
|
+ BaseCameraManagementReq baseCameraManagementReq = new BaseCameraManagementReq();
|
|
|
+ if (heartbeatVo.getLineDir() == 1) {
|
|
|
+ distance = heartbeatVo.getVisualDistance() + heartbeatVo.getCurrentMile();
|
|
|
+ baseCameraManagementReq.setInstallMile(heartbeatVo.getCurrentMile() + 10000);
|
|
|
+ }
|
|
|
+ if (heartbeatVo.getLineDir() == 2) {
|
|
|
+ distance = heartbeatVo.getCurrentMile() - heartbeatVo.getVisualDistance();
|
|
|
+ baseCameraManagementReq.setInstallMile(heartbeatVo.getCurrentMile() - 10000);
|
|
|
+ }
|
|
|
+ baseCameraManagementReq.setDistance(distance);
|
|
|
+ baseCameraManagementReq.setLineDir(heartbeatVo.getLineDir());
|
|
|
+ baseCameraManagementReq.setRailwayCode(heartbeatVo.getRailwayCode());
|
|
|
+ List<BaseCameraManagement> list1 = baseCameraManagementService.cameraMangemnetList(baseCameraManagementReq);
|
|
|
+ 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(), finalType2, httpUrl);
|
|
|
+ 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 {
|
|
|
//没有报警信息的时候
|