puzhibing
2023-06-23 7ee9bc8fb2e42ce2e82cd1eacb57ba584611dfc5
user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverServiceImpl.java
@@ -66,19 +66,26 @@
        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)){
                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);
            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;
    }