| | |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.util.GDMapElectricFenceUtil; |
| | | import com.stylefeng.guns.modular.system.util.GDMapGeocodingUtil; |
| | | import com.stylefeng.guns.modular.system.util.GeodesyUtil; |
| | | 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; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private GDMapElectricFenceUtil gdMapElectricFenceUtil; |
| | | |
| | | @Autowired |
| | | private GeodesyUtil geodesyUtil; |
| | | |
| | | @Autowired |
| | | private ICompanyCityService companyCityService; |
| | |
| | | if(0 != count){ |
| | | continue; |
| | | } |
| | | String value = redisUtil.getValue("DRIVER" + String.valueOf(driver.getId())); |
| | | String value = redisUtil.getValue("DRIVER" + driver.getId()); |
| | | if(null != value){ |
| | | /*Map<String, String> distance1 = gdMapElectricFenceUtil.getDistance(lon + "," + lat, value, 0);//计算距离 |
| | | double d = Double.valueOf(distance1.get("distance")).doubleValue();*/ |
| | | // double d = GDMapGeocodingUtil.getDistance(lat,lon,Double.parseDouble(value.split(",")[1]),Double.parseDouble(value.split(",")[0])); |
| | | double d = gdMapElectricFenceUtil.getDrivingRoute(lat,lon,Double.parseDouble(value.split(",")[1]),Double.parseDouble(value.split(",")[0])); |
| | | if(d < (distance * 1000)){ |
| | | Map<String, Double> distance1 = geodesyUtil.getDistance(lon + "," + lat, value); |
| | | Double wgs84 = distance1.get("WGS84"); |
| | | if(wgs84 < (distance * 1000)){ |
| | | list.add(driver); |
| | | } |
| | | } |
| | |
| | | |
| | | @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(); |