| | |
| | | package com.stylefeng.guns.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; |
| | | import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService; |
| | | import com.stylefeng.guns.modular.specialTrain.server.impl.OrderPrivateCarServiceImpl; |
| | | import com.stylefeng.guns.modular.system.dao.DriverMapper; |
| | | import com.stylefeng.guns.modular.system.dao.DriverServiceMapper; |
| | | import com.stylefeng.guns.modular.system.model.Company; |
| | |
| | | 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; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private ICompanyCityService companyCityService; |
| | | @Autowired |
| | | private OrderPrivateCarServiceImpl orderPrivateCarServiceImpl; |
| | | |
| | | @Autowired |
| | | private IOrderPrivateCarService orderPrivateCarService; |
| | | |
| | | |
| | | /** |
| | |
| | | List<Driver> drivers = driverMapper.queryIdleDriver_(type, serverCarModelId, companyId); |
| | | List<Driver> list = new ArrayList<>(); |
| | | for(Driver driver : drivers){ |
| | | if(driver.getId() == 2448){ |
| | | System.err.println("司机名称---"+driver.getName()); |
| | | int count = orderPrivateCarService.selectCount(new EntityWrapper<OrderPrivateCar>().eq("driverId", driver.getId()) |
| | | .in("state", Arrays.asList(2, 3, 4, 5, 6, 11)).eq("isDelete", 1)); |
| | | if(0 != count){ |
| | | continue; |
| | | } |
| | | String value = redisUtil.getValue("DRIVER" + String.valueOf(driver.getId())); |
| | | if(null != value){ |
| | |
| | | List<Driver> drivers = driverMapper.queryIdleDriverService_(type, serverCarModelId, companyId); |
| | | 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, 11)) |
| | | .ne("orderType",2) |
| | | .eq("isDelete", 1)); |
| | | if(0 != count){ |
| | | continue; |
| | | } |
| | | String value = redisUtil.getValue("DRIVER" + driver.getId()); |
| | | if(null != value){ |
| | | /*Map<String, String> distance1 = gdMapElectricFenceUtil.getDistance(lon + "," + lat, value, 0);//计算距离 |
| | |
| | | |
| | | @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(); |