Explorar o código

车载心跳监测接口修改

gao.qiang hai 9 meses
pai
achega
9b5ec263ba

+ 13 - 8
vehicle-sdk/src/main/java/com/ozs/controller/upload/GeoHazardMonitorTokenController.java

@@ -397,7 +397,7 @@ public class GeoHazardMonitorTokenController {
                         // 使用SimpleDateFormat将Date对象格式化为指定样式的字符串
                         String formattedDate = sdf.format(msgAlarmVice.getAlarmTime());
                         log.info("-----formattedDate-----------" + formattedDate);
-                        String records = cameraUtil.getQueryRecords(finalCode + "/playback", formattedDate,"mp4",laterValue.get(0).getDictValue(),frontValue.get(0).getDictValue());
+                        String records = cameraUtil.getQueryRecords(finalCode + "/playback", formattedDate, "mp4", laterValue.get(0).getDictValue(), frontValue.get(0).getDictValue());
                         log.info("-----records-----------" + records);
                         MsgAlarm alarm1 = msgAlarmService.getById(msgAlarm.getId());
                         alarm1.setReleasedUrl(records);
@@ -582,7 +582,7 @@ public class GeoHazardMonitorTokenController {
             wrapper.eq(BaseVehicleTerminal::getTerminalCode, vehiclePosition.getTerminalCode());
             BaseVehicleTerminal baseTerminal = baseVehicleTerminalService.getOne(wrapper);
             if (ObjectUtils.isEmpty(baseTerminal)) {
-                AjaxResults1 = new AjaxResults(0, "关联表中没有终端编码的信息");
+                AjaxResults1 = new AjaxResults(0, "关联表中没有终端编码的信息");
                 return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
             }
             if (heartbeatVo.getSignalStrength() == 2) {
@@ -1220,7 +1220,7 @@ public class GeoHazardMonitorTokenController {
                                     }
                                 }
                             }
-                        }else {
+                        } else {
                             //没有报警信息的时候
                             LambdaQueryWrapper<BaseCameraManagement> base = new LambdaQueryWrapper<>();
                             if (heartbeatVo.getLineDir() == 1) {
@@ -1666,7 +1666,7 @@ public class GeoHazardMonitorTokenController {
                                 }
                             }
                         }
-                    }else {
+                    } else {
                         //没有报警信息的时候
                         LambdaQueryWrapper<BaseCameraManagement> base = new LambdaQueryWrapper<>();
                         if (heartbeatVo.getLineDir() == 1) {
@@ -2510,11 +2510,16 @@ public class GeoHazardMonitorTokenController {
             if (baseTerminalLogService.save(baseTerminalLog) && update) {
                 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()).eq(VehiclePosition::getLineDir,vehiclePosition.getLineDir()).orderByDesc(VehiclePosition::getCreateTime).last("limit 1"));
+                    VehiclePosition positionServiceOne = vehiclePositionService.getOne(new LambdaQueryWrapper<VehiclePosition>().eq(VehiclePosition::getVehicleCode, baseTerminalLog.getFrontTrainNum()).eq(VehiclePosition::getLineDir, vehiclePosition.getLineDir()).orderByDesc(VehiclePosition::getCreateTime).last("limit 1"));
                     Map<String, Object> map = new HashMap<>();
                     if (!ObjectUtils.isEmpty(positionServiceOne) && !ObjectUtils.isEmpty(vehiclePosition)) {
-                        int dif = vehiclePosition.getTravelMile() - positionServiceOne.getTravelMile();
-                        map.put("frontVehicleDistance", Math.abs(dif));
+                        if ((vehiclePosition.getLineDir() == 1 && positionServiceOne.getTravelMile() >= vehiclePosition.getTravelMile()) ||
+                                (vehiclePosition.getLineDir() == 2 && positionServiceOne.getTravelMile() <= vehiclePosition.getTravelMile())) {
+                            int dif = vehiclePosition.getTravelMile() - positionServiceOne.getTravelMile();
+                            map.put("frontVehicleDistance", Math.abs(dif));
+                        } else {
+                            map.put("frontVehicleDistance", "_");
+                        }
                     } else {
                         map.put("frontVehicleDistance", "_");
                     }
@@ -2579,7 +2584,7 @@ public class GeoHazardMonitorTokenController {
                 AjaxResults1 = new AjaxResults(1, "ok", cameraVos);
                 return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
             } else {
-                AjaxResults1 = new AjaxResults(0, "未查询到车号的相机信息");
+                AjaxResults1 = new AjaxResults(0, "未查询到车号的相机信息");
                 return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
             }
         } else {