소스 검색

心跳报警后续集合修改

gao.qiang 1 년 전
부모
커밋
a0b45e9849
1개의 변경된 파일50개의 추가작업 그리고 27개의 파일을 삭제
  1. 50 27
      vehicle-sdk/src/main/java/com/ozs/controller/upload/GeoHazardMonitorTokenController.java

+ 50 - 27
vehicle-sdk/src/main/java/com/ozs/controller/upload/GeoHazardMonitorTokenController.java

@@ -655,6 +655,7 @@ public class GeoHazardMonitorTokenController {
                     } else {
                         queryWrapper2.in(MsgAlarm::getAlarmId, collect);
                     }
+                    queryWrapper2.orderByAsc(MsgAlarm::getAlarmMile);
                     List<MsgAlarm> list = msgAlarmService.list(queryWrapper2);
                     log.info("--------List<MsgAlarm>--------" + list);
                     //有报警信息的时候
@@ -766,28 +767,28 @@ public class GeoHazardMonitorTokenController {
                             respHeartbeatVo.setCameraCode(baseCameraManagementList.get(0).getCameraCode());
                             twoMap.put("currentStream", playFlv1);
                             twoMap.put("cameraCode", baseCameraManagementList.get(0).getCameraCode());
-                            //alarmInfo对象
-                            AlarmInfoVo alarmInfoVo = new AlarmInfoVo();
-                            alarmInfoVo.setAlarmId(list.get(0).getAlarmId());
-                            alarmInfoVo.setAlarmMile(list.get(0).getAlarmMile());
-                            alarmInfoVo.setAlarmTime(list.get(0).getAlarmTime().getTime());
-                            alarmInfoVo.setAlarmContent(list.get(0).getContent());
-                            alarmInfoVo.setAlarmType(list.get(0).getAlarmType());
-                            alarmInfoVo.setAlarmLevel(list.get(0).getAlarmLevel());
-                            LambdaQueryWrapper<MsgAlarmExt> ext = new LambdaQueryWrapper<>();
-                            ext.eq(MsgAlarmExt::getAlarmId, list.get(0).getAlarmId());
-                            List<MsgAlarmExt> list1 = msgAlarmExtService.list(ext);
-                            AlarmFilesVo[] files = new AlarmFilesVo[list1.size()];
-                            if (!ObjectUtils.isEmpty(list1)) {
-                                for (int i = 0; i < list1.size(); i++) {
-                                    files[i] = new AlarmFilesVo();
-                                    files[i].setAlarmAttType(list1.get(i).getAlarmAttType());
-                                    files[i].setAlarmAttPath(list1.get(i).getAlarmAttPath());
-                                }
-                                //返回结果
-                                alarmInfoVo.setAlarmFiles(files);
-                            }
-                            respHeartbeatVo.setAlarmInfo(alarmInfoVo);
+//                            //alarmInfo对象
+//                            AlarmInfoVo alarmInfoVo = new AlarmInfoVo();
+//                            alarmInfoVo.setAlarmId(list.get(0).getAlarmId());
+//                            alarmInfoVo.setAlarmMile(list.get(0).getAlarmMile());
+//                            alarmInfoVo.setAlarmTime(list.get(0).getAlarmTime().getTime());
+//                            alarmInfoVo.setAlarmContent(list.get(0).getContent());
+//                            alarmInfoVo.setAlarmType(list.get(0).getAlarmType());
+//                            alarmInfoVo.setAlarmLevel(list.get(0).getAlarmLevel());
+//                            LambdaQueryWrapper<MsgAlarmExt> ext = new LambdaQueryWrapper<>();
+//                            ext.eq(MsgAlarmExt::getAlarmId, list.get(0).getAlarmId());
+//                            List<MsgAlarmExt> list1 = msgAlarmExtService.list(ext);
+//                            AlarmFilesVo[] files = new AlarmFilesVo[list1.size()];
+//                            if (!ObjectUtils.isEmpty(list1)) {
+//                                for (int i = 0; i < list1.size(); i++) {
+//                                    files[i] = new AlarmFilesVo();
+//                                    files[i].setAlarmAttType(list1.get(i).getAlarmAttType());
+//                                    files[i].setAlarmAttPath(list1.get(i).getAlarmAttPath());
+//                                }
+//                                //返回结果
+//                                alarmInfoVo.setAlarmFiles(files);
+//                            }
+//                            respHeartbeatVo.setAlarmInfo(alarmInfoVo);
                         } else {
                             jsonObject.put("resultCode", 0);
                             jsonObject.put("message", "失败");
@@ -816,9 +817,9 @@ public class GeoHazardMonitorTokenController {
                                 ment.in(BaseCameraManagement::getMonitoringDirection, 2, 3);
                                 ment.orderByDesc(BaseCameraManagement::getInstallMile);
                             }
-                            if (i == 0) {
-                                ment.last("limit 1,1000000");
-                            }
+//                            if (i == 0) {
+//                                ment.last("limit 1,1000000");
+//                            }
                             //获取所有报警安装里程位置的相机
                             List<BaseCameraManagement> baseList = baseCameraManagementService.list(ment);
                             if (baseList.size() > 0) {
@@ -841,12 +842,32 @@ public class GeoHazardMonitorTokenController {
 //                                    //添加心跳相机日志信息
 //                                    int add1 = terminalHeartbeatLogService.add(baseList.get(o).getCameraCode(), baseList.get(o).getChannel());
 //                                    log.info("-----add1----" + add1);
+                                int minDifference = Integer.MAX_VALUE;
+                                String code = null;
+                                String channel = null;
+                                for (BaseCameraManagement baseCameraManagement : baseCameraManagementList) {
+                                    log.info("------------baseCameraManagement.getInstallMile()-------" + baseCameraManagement.getInstallMile());
+                                    log.info("------------list.get(0).getAlarmMile()-------" + list.get(0).getAlarmMile());
+                                    int difference = Math.abs(baseCameraManagement.getInstallMile() - list.get(0).getAlarmMile());
+                                    log.info("------------difference-------" + difference);
+                                    log.info("------------minDifference-------" + minDifference);
+                                    if (difference < minDifference) {
+                                        minDifference = difference;
+                                        log.info("------------minDifference变更-------" + minDifference);
+                                        code = baseCameraManagement.getCameraCode();
+                                        log.info("------------code-------" + code);
+                                        channel = baseCameraManagement.getChannel();
+                                        log.info("------------channel-------" + channel);
+                                    }
+                                }
+                                String playFlv1 = cameraUtil.heartbeatgetPlayFlv(code, channel, type);
                                 AlarmListVo alarmListVo = new AlarmListVo();
                                 //alarmList对象
-                                alarmListVo.setCameraStream(null);
+                                alarmListVo.setCameraStream(playFlv1);
                                 alarmListVo.setCameraCode(baseList.get(0).getCameraCode());
                                 //alarmInfo对象
                                 AlarmInfoVo alarmInfoVo1 = new AlarmInfoVo();
+                                log.info("----------------list.get(i).getAlarmId()---后续-----------" + list.get(i).getAlarmId());
                                 alarmInfoVo1.setAlarmId(list.get(i).getAlarmId());
                                 alarmInfoVo1.setAlarmMile(list.get(i).getAlarmMile());
                                 alarmInfoVo1.setAlarmTime(list.get(i).getAlarmTime().getTime());
@@ -866,6 +887,7 @@ public class GeoHazardMonitorTokenController {
                                     alarmInfoVo1.setAlarmFiles(vo);
                                 }
                                 alarmListVo.setAlarmInfo(alarmInfoVo1);
+                                log.info("----------------alarmListVo-----------" + alarmListVo);
                                 listVos.add(alarmListVo);
 //                                ArrayList<String> list3 = new ArrayList<>();
 //                                ////添加缓存
@@ -874,7 +896,7 @@ public class GeoHazardMonitorTokenController {
 //                                list3.add(code);
 //                                log.info("--------------heartbeat--------------:" + list3);
 //                                redisCache.setCacheObject("heartbeat", list3);
-                                break;
+//                                break;
                                 ////获取缓冲
                                 //List<String> heartbeat = redisCache.getCacheObject("heartbeat");
                                 //log.info("--------------heartbeat111--------------:" + heartbeat);
@@ -912,6 +934,7 @@ public class GeoHazardMonitorTokenController {
                             }
                         }
                         AlarmListVo[] array = listVos.toArray(new AlarmListVo[]{});
+                        log.info("----------------array-----------" + Arrays.toString(array));
                         respHeartbeatVo.setAlarmList(array);
                         //获取机车前两路视频
                         int mile = heartbeatVo.getVisualDistance() + heartbeatVo.getCurrentMile();