Browse Source

报警接口修改

gao.qiang 10 months ago
parent
commit
02acf06d43

+ 32 - 30
vehicle-sdk/src/main/java/com/ozs/controller/upload/GeoHazardMonitorTokenController.java

@@ -328,22 +328,24 @@ public class GeoHazardMonitorTokenController {
                 String source = split[split.length - 2];
                 msgAlarm.setSource(source);
                 msgAlarmService.save(msgAlarm);
-                Files[] files1 = reqMsgAlarmVo.getFiles();
-                if (files1.length > 0) {
-                    for (int i = 0; i < files1.length; i++) {
-                        if (ObjectUtils.isEmpty(files1[i].fileUrl)) {
-                            AjaxResults1 = new AjaxResults(0, "上传文件地址不能为空!!!");
-                            return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
-                        }
-                        if (files1[i].fileType < 1 || files1[i].fileType > 3) {
-                            AjaxResults1 = new AjaxResults(0, "文件类型填写错误!!!");
-                            return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+                if (!ObjectUtils.isEmpty(reqMsgAlarmVo.getFiles())) {
+                    Files[] files1 = reqMsgAlarmVo.getFiles();
+                    if (files1.length > 0) {
+                        for (int i = 0; i < files1.length; i++) {
+                            if (ObjectUtils.isEmpty(files1[i].fileUrl)) {
+                                AjaxResults1 = new AjaxResults(0, "上传文件地址不能为空!!!");
+                                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+                            }
+                            if (files1[i].fileType < 1 || files1[i].fileType > 3) {
+                                AjaxResults1 = new AjaxResults(0, "文件类型填写错误!!!");
+                                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
+                            }
+                            MsgAlarmExt msgAlarmExt = new MsgAlarmExt();
+                            msgAlarmExt.setAlarmId(msgAlarm.getAlarmId());
+                            msgAlarmExt.setAlarmAttPath(files1[i].fileUrl);
+                            msgAlarmExt.setAlarmAttType(files1[i].fileType);
+                            msgAlarmExtService.save(msgAlarmExt);
                         }
-                        MsgAlarmExt msgAlarmExt = new MsgAlarmExt();
-                        msgAlarmExt.setAlarmId(msgAlarm.getAlarmId());
-                        msgAlarmExt.setAlarmAttPath(files1[i].fileUrl);
-                        msgAlarmExt.setAlarmAttType(files1[i].fileType);
-                        msgAlarmExtService.save(msgAlarmExt);
                     }
                 }
                 msgAlarmVice.setCreateBy(admin.getUserId());
@@ -359,7 +361,7 @@ public class GeoHazardMonitorTokenController {
                 log.info("result:{}", result);
                 if (!ObjectUtils.isEmpty(baseCameraManagementList)) {
                     CompletableFuture.runAsync(() -> {
-                        String records = CameraUtil.getPlayFlvRtsp(baseCameraManagementList.get(0).getCameraCode(), baseCameraManagementList.get(0).getChannel(),true);
+                        String records = CameraUtil.getPlayFlvRtsp(baseCameraManagementList.get(0).getCameraCode(), baseCameraManagementList.get(0).getChannel(), true);
                         log.info("-----records-----------" + records);
                         MsgAlarm alarm1 = msgAlarmService.getById(msgAlarm.getId());
                         alarm1.setReleasedUrl(records);
@@ -806,17 +808,17 @@ public class GeoHazardMonitorTokenController {
                         preAlarmList.sort(distanceComparator);
                         for (int i = 0; i < preAlarmList.size(); i++) {
                             PreAlarmListResponse preAlarmListResponse = new PreAlarmListResponse();
-                            int mile=0;
+                            int mile = 0;
                             LambdaQueryWrapper<BaseCameraManagement> wrapper1 = new LambdaQueryWrapper<BaseCameraManagement>();
                             if (heartbeatVo.getLineDir() == 1) {
-                                 mile = preAlarmList.get(i).getDistance() + heartbeatVo.getCurrentMile();
+                                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();
+                                mile = heartbeatVo.getCurrentMile() - preAlarmList.get(i).getDistance();
                                 wrapper1.ge(BaseCameraManagement::getEndMile, mile);
                                 wrapper1.le(BaseCameraManagement::getBeginMile, mile);
                                 wrapper1.in(BaseCameraManagement::getMonitoringDirection, 2, 3);
@@ -866,7 +868,7 @@ public class GeoHazardMonitorTokenController {
                                     twoMap.put("currentStream", playFlv1);
                                     twoMap.put("cameraCode", baseCameraManagementList.get(0).getCameraCode());
                                 }
-                            }else {
+                            } else {
                                 preAlarmListResponse.setCameraCode("");
                                 preAlarmListResponse.setCameraStream("");
                             }
@@ -897,7 +899,7 @@ public class GeoHazardMonitorTokenController {
                         camera.last("limit 2");
                         List<BaseCameraManagement> list1 = baseCameraManagementService.list(camera);
                         if (list1.size() <= 0) {
-                            AjaxResults1 = new AjaxResults(0, "前方没有摄像机",respHeartbeatVo);
+                            AjaxResults1 = new AjaxResults(0, "前方没有摄像机", respHeartbeatVo);
                             return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
                         }
                         log.info("流程1----------------->");
@@ -993,17 +995,17 @@ public class GeoHazardMonitorTokenController {
                     preAlarmList.sort(distanceComparator);
                     for (int i = 0; i < preAlarmList.size(); i++) {
                         PreAlarmListResponse preAlarmListResponse = new PreAlarmListResponse();
-                        int mile=0;
+                        int mile = 0;
                         LambdaQueryWrapper<BaseCameraManagement> wrapper1 = new LambdaQueryWrapper<BaseCameraManagement>();
                         if (heartbeatVo.getLineDir() == 1) {
-                             mile = preAlarmList.get(i).getDistance() + heartbeatVo.getCurrentMile();
+                            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();
+                            mile = heartbeatVo.getCurrentMile() - preAlarmList.get(i).getDistance();
                             wrapper1.ge(BaseCameraManagement::getEndMile, mile);
                             wrapper1.le(BaseCameraManagement::getBeginMile, mile);
                             wrapper1.in(BaseCameraManagement::getMonitoringDirection, 2, 3);
@@ -1053,7 +1055,7 @@ public class GeoHazardMonitorTokenController {
                                 twoMap.put("currentStream", playFlv1);
                                 twoMap.put("cameraCode", baseCameraManagementList.get(0).getCameraCode());
                             }
-                        }else {
+                        } else {
                             preAlarmListResponse.setCameraCode("");
                             preAlarmListResponse.setCameraStream("");
                         }
@@ -1084,7 +1086,7 @@ public class GeoHazardMonitorTokenController {
                     base.last("limit 2");
                     List<BaseCameraManagement> list1 = baseCameraManagementService.list(base);
                     if (list1.size() <= 0) {
-                        AjaxResults1 = new AjaxResults(0,"前方没有摄像机",respHeartbeatVo);
+                        AjaxResults1 = new AjaxResults(0, "前方没有摄像机", respHeartbeatVo);
                         return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
                     }
 
@@ -1737,13 +1739,13 @@ public class GeoHazardMonitorTokenController {
             terminal.eq(BaseTerminal::getTerminalCode, baseTerminalLog.getTerminalCode());
             boolean update = baseTerminalService.update(baseTerminal1, terminal);
             if (baseTerminalLogService.save(baseTerminalLog) && update) {
-                if (!ObjectUtils.isEmpty(baseTerminalLog.getTrainNum())&&!ObjectUtils.isEmpty(baseTerminalLog.getFrontTrainNum())){
+                if (!ObjectUtils.isEmpty(baseTerminalLog.getTrainNum()) && !ObjectUtils.isEmpty(baseTerminalLog.getFrontTrainNum())) {
                     VehiclePosition vehiclePosition = vehiclePositionService.getOne(new LambdaQueryWrapper<VehiclePosition>().eq(VehiclePosition::getVehicleCode, baseTerminalLog.getTrainNum()).orderByDesc(VehiclePosition::getCreateTime).last("limit 1"));
                     VehiclePosition positionServiceOne = vehiclePositionService.getOne(new LambdaQueryWrapper<VehiclePosition>().eq(VehiclePosition::getVehicleCode, baseTerminalLog.getFrontTrainNum()).orderByDesc(VehiclePosition::getCreateTime).last("limit 1"));
                     Map<String, Object> map = new HashMap<>();
-                    map.put("frontVehicleDistance", vehiclePosition.getTravelMile()-positionServiceOne.getTravelMile());
+                    map.put("frontVehicleDistance", vehiclePosition.getTravelMile() - positionServiceOne.getTravelMile());
                     AjaxResults1 = new AjaxResults(1, "ok", map);
-                }else {
+                } else {
                     AjaxResults1 = new AjaxResults(1, "ok");
                 }
                 return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
@@ -1799,7 +1801,7 @@ public class GeoHazardMonitorTokenController {
                 CameraVos cameraVos = new CameraVos();
                 cameraVos.setCameraCode(baseCameraManagement.getCameraCode());
                 cameraVos.setCurrentStream("1111");
-                AjaxResults1 = new AjaxResults(1, "ok",cameraVos);
+                AjaxResults1 = new AjaxResults(1, "ok", cameraVos);
                 return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
             } else {
                 AjaxResults1 = new AjaxResults(0, "未查询到改车号的相机信息");