| | |
| | | Query query = Query.query(Criteria.where("location").withinSphere(circle)); |
| | | List<Location> locations = mongoTemplate.find(query, Location.class); |
| | | List<Integer> collect = locations.stream().map(Location::getDriverId).collect(Collectors.toList()); |
| | | if(collect.size() == 0){ |
| | | return list; |
| | | } |
| | | List<Driver> drivers = this.selectList(new EntityWrapper<Driver>().in("id", collect).eq("approvalStatus", 2).eq("serverStatus", 1).eq("status", 1)); |
| | | collect = drivers.stream().map(Driver::getId).collect(Collectors.toList()); |
| | | if(collect.size() == 0){ |
| | | return list; |
| | | } |
| | | List<DriverWork> driverWorks = driverWorkService.selectList(new EntityWrapper<DriverWork>().in("driverId", collect).eq("status", 1)); |
| | | for (DriverWork driverWork : driverWorks) { |
| | | String value = redisUtil.getValue("DRIVER" + driverWork.getDriverId()); |
| | | if(ToolUtil.isNotEmpty(value)){ |
| | | if(ToolUtil.isEmpty(value)){ |
| | | continue; |
| | | } |
| | | NearbyDriverWarpper nearbyDriverWarpper = new NearbyDriverWarpper(); |
| | | nearbyDriverWarpper.setLonLat(value); |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(value, lon + "," + lat); |
| | | nearbyDriverWarpper.setDistance(distance.get("WGS84") / 1000); |
| | | nearbyDriverWarpper.setDriverId(driverWork.getDriverId()); |
| | | list.add(nearbyDriverWarpper); |
| | | } |
| | | } |
| | | return list; |
| | | } |