| | |
| | | import com.stylefeng.guns.modular.system.util.RedisUtil; |
| | | import com.stylefeng.guns.modular.system.warpper.BaseWarpper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.geo.GeoResult; |
| | | import org.springframework.data.redis.connection.RedisGeoCommands; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | |
| | | List<Driver> list = new ArrayList<>(); |
| | | for(Driver driver : drivers){ |
| | | int count = orderPrivateCarService.selectCount(new EntityWrapper<OrderPrivateCar>().eq("driverId", driver.getId()) |
| | | .in("state", Arrays.asList(2, 3, 4, 5, 6, 11)).eq("isDelete", 1)); |
| | | .in("state", Arrays.asList(2, 3, 4, 11)) |
| | | .ne("orderType",2) |
| | | .eq("isDelete", 1)); |
| | | if(0 != count){ |
| | | continue; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public List<Driver> queryDriverLimitTen(Integer type, Double lon, Double lat) { |
| | | List<Driver> drivers = driverMapper.queryIdleDriver(type, null); |
| | | if(CollectionUtils.isEmpty(drivers)){ |
| | | List<GeoResult<RedisGeoCommands.GeoLocation<String>>> driverPosition = redisUtil.getNearGeoSortAscending("DRIVER_POSITION", lon, lat, 5000D); |
| | | if(CollectionUtils.isEmpty(driverPosition)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | List<RedisGeoCommands.GeoLocation<String>> geoLocations = driverPosition.stream().map(GeoResult::getContent).collect(Collectors.toList()); |
| | | driverPosition.stream().map(GeoResult::getContent).collect(Collectors.toList()); |
| | | List<String> dis = geoLocations.stream().map(RedisGeoCommands.GeoLocation::getName).collect(Collectors.toList()); |
| | | List<Driver> drivers = driverMapper.queryIdleDriverByIds(type, dis); |
| | | Iterator<Driver> iterator = drivers.iterator(); |
| | | while (iterator.hasNext()){ |
| | | Driver driver = iterator.next(); |