| | |
| | | throw new ServiceException("未查询到有效车辆信息", I18nKeyConstant.VEHICLE_NOT_EXISTS); |
| | | } |
| | | // 判断距离是否在范围之内 4米 |
| | | // List<Point> positionList = redisTemplate.opsForGeo().position("vehiclePosition:" + xpVehicle.getVehicleVin(), xpVehicle.getVehicleVin()); |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(xpVehicle.getVehicleVin())), VehiclePosition.class); |
| | | if (Objects.nonNull(vehiclePosition)) { |
| | | GeoJsonPoint point = vehiclePosition.getPoint(); |
| | | if(Objects.nonNull(point)){ |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(dto.getLongitude()+ "," + dto.getLatitude(), point.getX()+","+point.getY()); |
| | | if (null != distance) { |
| | | Double distance1 = distance.get("WGS84"); |
| | | if (distance1 > 4) { |
| | | throw new ServiceException("距离过远,无法打开", I18nKeyConstant.VEHICLE_DISTANCE_TOO_LONG); |
| | | } |
| | | }else { |
| | | throw new ServiceException("距离过远,无法打开", I18nKeyConstant.VEHICLE_DISTANCE_TOO_LONG); |
| | | } |
| | | }else { |
| | | throw new ServiceException("距离过远,无法打开", I18nKeyConstant.VEHICLE_DISTANCE_TOO_LONG); |
| | | } |
| | | } |
| | | // VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(xpVehicle.getVehicleVin())), VehiclePosition.class); |
| | | // if (Objects.nonNull(vehiclePosition)) { |
| | | // GeoJsonPoint point = vehiclePosition.getPoint(); |
| | | // if(Objects.nonNull(point)){ |
| | | // Map<String, Double> distance = GeodesyUtil.getDistance(dto.getLongitude()+ "," + dto.getLatitude(), point.getX()+","+point.getY()); |
| | | // if (null != distance) { |
| | | // Double distance1 = distance.get("WGS84"); |
| | | // if (distance1 > 4) { |
| | | // throw new ServiceException("距离过远,无法打开", I18nKeyConstant.VEHICLE_DISTANCE_TOO_LONG); |
| | | // } |
| | | // }else { |
| | | // throw new ServiceException("距离过远,无法打开", I18nKeyConstant.VEHICLE_DISTANCE_TOO_LONG); |
| | | // } |
| | | // }else { |
| | | // throw new ServiceException("距离过远,无法打开", I18nKeyConstant.VEHICLE_DISTANCE_TOO_LONG); |
| | | // } |
| | | // } |
| | | // 车门解锁、后备箱解锁 |
| | | VehiclesCommandVo vehiclesCommandVo = new VehiclesCommandVo(); |
| | | vehiclesCommandVo.setVin(xpVehicle.getVehicleVin()); |