| | |
| | | import com.stylefeng.guns.modular.system.service.IServerCarModelService; |
| | | import com.stylefeng.guns.modular.system.util.GDMapElectricFenceUtil; |
| | | import com.stylefeng.guns.modular.system.util.GDMapGeocodingUtil; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.AddressComponentsVo; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.DistancematrixVo; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.GoogleMapUtil; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.ReverseGeocodeVo; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.system.warpper.ServerCarModelWarpper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @Override |
| | | public ResultUtil<List<ServerCarModelWarpper>> queryServerCarModel(String startLonLat, String endLonLat, Integer type) throws Exception { |
| | | //查找与起点匹配的企业(经营范围) |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(startLonLat.split(",")[0], startLonLat.split(",")[1]); |
| | | Company query = companyCityService.query(geocode.get("districtCode")); |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(Double.valueOf(startLonLat.split(",")[1]), Double.valueOf(startLonLat.split(",")[0])); |
| | | if(null == reverseGeocode){ |
| | | return ResultUtil.error("获取地址信息失败"); |
| | | } |
| | | AddressComponentsVo[] addressComponentsVos = reverseGeocode.getAddressComponentsVos(); |
| | | String[] city = new String[addressComponentsVos.length]; |
| | | for (int i = 0; i < addressComponentsVos.length; i++) { |
| | | city[i] = addressComponentsVos[i].getLongName(); |
| | | } |
| | | Company query = companyCityService.query(city); |
| | | if(null == query){ |
| | | return ResultUtil.error("起点暂无企业提供服务", new ArrayList<>()); |
| | | } |
| | | Map<String, String> distance = gdMapElectricFenceUtil.getDistance(startLonLat, endLonLat, 1); |
| | | if(null == distance){ |
| | | Double slnt = Double.valueOf(startLonLat.split(",")[0]); |
| | | Double slat = Double.valueOf(startLonLat.split(",")[1]); |
| | | Double elnt = Double.valueOf(startLonLat.split(",")[0]); |
| | | Double elat = Double.valueOf(startLonLat.split(",")[1]); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(slat, slnt, elat, elnt); |
| | | if(null == distancematrix){ |
| | | return ResultUtil.error("获取预估距离出错", new ArrayList<>()); |
| | | } |
| | | String distance1 = distance.get("distance");//距离(米) |
| | | long distance1 = distancematrix.getDistance();//距离(米) |
| | | double distance1_ = Double.valueOf(distance1).doubleValue(); |
| | | String duration = distance.get("duration");//时间(秒) |
| | | long duration = distancematrix.getDuration();//时间(秒) |
| | | long duration_ = Long.valueOf(duration).longValue(); |
| | | |
| | | List<ServerCarModelWarpper> price = this.getPrice(query.getId(), distance1_, duration_, 0, 1); |