| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil process(Integer orderId, Integer state, Double lon, Double lat, String address, String pickUpCode, Integer language, Integer uid) throws Exception; |
| | | ResultUtil process(Integer orderId, Integer state, Double lon, Double lat, String pickUpCode, Integer language, Integer uid) throws Exception; |
| | | |
| | | |
| | | /** |
| | |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.DistancematrixVo; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.FleetEngineUtil; |
| | | 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.itextpdf.HtmlToPdfUtils; |
| | | import com.stylefeng.guns.modular.system.util.quartz.QuartzUtil; |
| | | import com.stylefeng.guns.modular.system.util.quartz.jobs.OrderTimeOutJob; |
| | |
| | | orderLogistics.setTripId(UUIDUtil.getRandomCode()); |
| | | } |
| | | String value = redisUtil.getValue("DRIVER" + driver.getId()); |
| | | String tripId = redisUtil.getValue("trip" + orderLogistics.getUserId()); |
| | | if(ToolUtil.isNotEmpty(value)) { |
| | | String[] split = value.split(","); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderLogistics.getStartLat(), orderLogistics.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0])); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderLogistics.getStartLat(), orderLogistics.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0]), tripId); |
| | | //超时时间 |
| | | long timeOut = System.currentTimeMillis() + (distancematrix.getDuration() * 1000); |
| | | orderLogistics.setEstimateArriveTime(new Date(timeOut)); |
| | |
| | | * @param state |
| | | * @param lon |
| | | * @param lat |
| | | * @param address |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil process(Integer orderId, Integer state, Double lon, Double lat, String address, String pickUpCode, Integer language, Integer uid) throws Exception { |
| | | public ResultUtil process(Integer orderId, Integer state, Double lon, Double lat, String pickUpCode, Integer language, Integer uid) throws Exception { |
| | | OrderLogistics orderLogistics = this.selectById(orderId); |
| | | String tripId = redisUtil.getValue("trip" + orderLogistics.getUserId()); |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lon, tripId); |
| | | if(null == reverseGeocode){ |
| | | return ResultUtil.error(language == 1 ? "无效的经纬度" : language == 2 ? "Invalid longitude and latitude" : "Longitude et latitude non valides"); |
| | | } |
| | | String address = reverseGeocode.getAddress(); |
| | | if(!uid.equals(orderLogistics.getDriverId())){ |
| | | return ResultUtil.error(language == 1 ? "操作失败,请刷新订单" : language == 2 ? "Operation failed, please refresh the order" : "L’opération a échoué, veuillez actualiser la commande"); |
| | | } |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil process(Integer orderId, Integer state, Double lon, Double lat, String address,String phone, Integer language, Integer uid) throws Exception; |
| | | ResultUtil process(Integer orderId, Integer state, Double lon, Double lat,String phone, Integer language, Integer uid) throws Exception; |
| | | |
| | | |
| | | /** |
| | |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.DistancematrixVo; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.FleetEngineUtil; |
| | | 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.quartz.QuartzUtil; |
| | | import com.stylefeng.guns.modular.system.util.quartz.jobs.OrderTimeOutJob; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | |
| | | @Override |
| | | public synchronized ResultUtil grabOrder(Integer orderId, Integer uid, Integer language) throws Exception { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | String tripId = redisUtil.getValue("trip" + orderPrivateCar.getUserId()); |
| | | //处理摆渡车的情况 |
| | | if(orderPrivateCar.getType() == 2){ |
| | | //查看用户下的摆渡车是否已被人抢了 |
| | |
| | | String value = redisUtil.getValue("DRIVER" + driver.getId()); |
| | | if(ToolUtil.isNotEmpty(value)) { |
| | | String[] split = value.split(","); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderPrivateCar.getStartLat(), orderPrivateCar.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0])); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderPrivateCar.getStartLat(), orderPrivateCar.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0]), tripId); |
| | | //超时时间 |
| | | long timeOut = System.currentTimeMillis() + (distancematrix.getDuration() * 1000); |
| | | orderPrivateCar.setEstimateArriveTime(new Date(timeOut)); |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil process(Integer orderId, Integer state, Double lon, Double lat, String address,String phone, Integer language, Integer uid) throws Exception { |
| | | public ResultUtil process(Integer orderId, Integer state, Double lon, Double lat,String phone, Integer language, Integer uid) throws Exception { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | String tripId = redisUtil.getValue("trip" + orderPrivateCar.getUserId()); |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lon, tripId); |
| | | if(null == reverseGeocode){ |
| | | return ResultUtil.error(language == 1 ? "无效的经纬度" : language == 2 ? "Invalid longitude and latitude" : "Longitude et latitude non valides"); |
| | | } |
| | | String address = reverseGeocode.getAddress(); |
| | | if(!uid.equals(orderPrivateCar.getDriverId())){ |
| | | return ResultUtil.error(language == 1 ? "操作失败,请刷新订单" : language == 2 ? "Operation failed, please refresh the order" : "L’opération a échoué, veuillez actualiser la commande"); |
| | | } |
| | |
| | | * @throws Exception |
| | | */ |
| | | Company query(String lon, String lat) throws Exception; |
| | | Company query1(String lon, String lat) throws Exception; |
| | | Company query1(Integer uid, String lon, String lat) throws Exception; |
| | | |
| | | |
| | | /** |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | List<Driver> queryIdleDriver(Integer type, Integer serverCarModelId, Double lon, Double lat, Double distance, Integer companyId) throws Exception; |
| | | List<Driver> queryIdleDriver(Integer userId, Integer type, Integer serverCarModelId, Double lon, Double lat, Double distance, Integer companyId) throws Exception; |
| | | } |
| | |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.AddressComponentsVo; |
| | | 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.RedisUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | @Autowired |
| | | private ICityService cityService; |
| | | |
| | | @Resource |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | /** |
| | | * 根据经纬度获取所属企业 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Company query1(String lon, String lat) throws Exception { |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(Double.valueOf(lat), Double.valueOf(lon)); |
| | | public Company query1(Integer uid, String lon, String lat) throws Exception { |
| | | String tripId = redisUtil.getValue("trip" + uid); |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(Double.valueOf(lat), Double.valueOf(lon), tripId); |
| | | if(null == reverseGeocode){ |
| | | return null; |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public Map<String, Object> queryPhone(Double lat, Double lnt) throws Exception { |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lnt); |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lnt, null); |
| | | if(null == reverseGeocode){ |
| | | System.err.println("获取地址异常"); |
| | | return null; |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<Driver> queryIdleDriver(Integer type, Integer serverCarModelId, Double lon, Double lat, Double distance, Integer companyId) throws Exception { |
| | | public List<Driver> queryIdleDriver(Integer userId, Integer type, Integer serverCarModelId, Double lon, Double lat, Double distance, Integer companyId) throws Exception { |
| | | List<Driver> drivers = driverMapper.queryIdleDriver_(type, serverCarModelId, companyId); |
| | | String tripId = redisUtil.getValue("trip" + userId); |
| | | List<Driver> list = new ArrayList<>(); |
| | | for(Driver driver : drivers){ |
| | | String value = redisUtil.getValue("DRIVER" + driver.getId()); |
| | | if(ToolUtil.isNotEmpty(value)){ |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(lat, lon, Double.parseDouble(value.split(",")[1]), Double.parseDouble(value.split(",")[0])); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(lat, lon, Double.parseDouble(value.split(",")[1]), Double.parseDouble(value.split(",")[0]), tripId); |
| | | if(null != distancematrix){ |
| | | if(distancematrix.getDistance() < (distance * 1000)){ |
| | | list.add(driver); |
| | |
| | | switch (orderType){ |
| | | case 1://专车 |
| | | map = orderPrivateCarService.queryPushOrder(orderId, language); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(map.get("startLat").toString()), Double.valueOf(map.get("startLon").toString()), Double.valueOf(lat), Double.valueOf(lon)); |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId); |
| | | String tripId = redisUtil.getValue("trip" + orderPrivateCar.getUserId()); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(map.get("startLat").toString()), Double.valueOf(map.get("startLon").toString()), Double.valueOf(lat), Double.valueOf(lon), tripId); |
| | | map.put("startDistance", null != distancematrix ? distancematrix.getDistance() / 1000 : 0); |
| | | |
| | | //总距离 |
| | | distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(map.get("startLat").toString()), Double.valueOf(map.get("startLon").toString()), Double.valueOf(map.get("endLat").toString()), Double.valueOf(map.get("endLon").toString())); |
| | | distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(map.get("startLat").toString()), Double.valueOf(map.get("startLon").toString()), Double.valueOf(map.get("endLat").toString()), Double.valueOf(map.get("endLon").toString()), tripId); |
| | | map.put("totalDistance", null != distancematrix ? distancematrix.getDistance() / 1000 : 0); |
| | | |
| | | Integer orderSource = Integer.valueOf(String.valueOf(map.get("orderSource"))); |
| | |
| | | break; |
| | | case 4://市内小件物流 |
| | | map = orderLogisticsService.queryPushOrder(orderId, language); |
| | | DistancematrixVo distancematrix1 = GoogleMapUtil.getDistancematrix(Double.valueOf(map.get("startLat").toString()), Double.valueOf(map.get("startLon").toString()), Double.valueOf(lat), Double.valueOf(lon)); |
| | | OrderLogistics orderLogistics = orderLogisticsService.selectById(orderId); |
| | | String tripId1 = redisUtil.getValue("trip" + orderLogistics.getUserId()); |
| | | DistancematrixVo distancematrix1 = GoogleMapUtil.getDistancematrix(Double.valueOf(map.get("startLat").toString()), Double.valueOf(map.get("startLon").toString()), Double.valueOf(lat), Double.valueOf(lon), tripId1); |
| | | map.put("startDistance", null != distancematrix1 ? distancematrix1.getDistance() / 1000 : 0); |
| | | |
| | | //总距离 |
| | | distancematrix1 = GoogleMapUtil.getDistancematrix(Double.valueOf(map.get("startLat").toString()), Double.valueOf(map.get("startLon").toString()), Double.valueOf(map.get("endLat").toString()), Double.valueOf(map.get("endLon").toString())); |
| | | distancematrix1 = GoogleMapUtil.getDistancematrix(Double.valueOf(map.get("startLat").toString()), Double.valueOf(map.get("startLon").toString()), Double.valueOf(map.get("endLat").toString()), Double.valueOf(map.get("endLon").toString()), tripId1); |
| | | map.put("totalDistance", null != distancematrix1 ? distancematrix1.getDistance() / 1000 : 0); |
| | | |
| | | Integer orderSource3 = Integer.valueOf(String.valueOf(map.get("orderSource"))); |
| | |
| | | */ |
| | | @Override |
| | | public ResultUtil process(Integer orderId, Integer orderType, Integer state, Integer uid, Double lon, Double lat,String phone, String pickUpCode, Integer language) throws Exception { |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lon); |
| | | if(null == reverseGeocode){ |
| | | return ResultUtil.error(language == 1 ? "无效的经纬度" : language == 2 ? "Invalid longitude and latitude" : "Longitude et latitude non valides"); |
| | | } |
| | | String address = reverseGeocode.getAddress(); |
| | | switch (orderType){ |
| | | case 1://专车 |
| | | return orderPrivateCarService.process(orderId, state, lon, lat, address, phone, language, uid); |
| | | return orderPrivateCarService.process(orderId, state, lon, lat, phone, language, uid); |
| | | case 2://出租 |
| | | // return orderTaxiService.process(orderId, state, lon, lat, address); |
| | | case 3://城际 |
| | | // return orderCrossCityService.process(orderId, state, lon, lat, address); |
| | | case 4://同城小件 |
| | | return orderLogisticsService.process(orderId, state, lon, lat, address, pickUpCode, language, uid); |
| | | return orderLogisticsService.process(orderId, state, lon, lat, pickUpCode, language, uid); |
| | | case 5://跨城小件 |
| | | // return orderLogisticsService.process(orderId, state, lon, lat, address); |
| | | case 6: |
| | |
| | | |
| | | /** |
| | | * 获取客服电话(个人中心) |
| | | * @param code |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public Map<String, Object> queryCustomerPhone(Double lat, Double lnt) throws Exception { |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lat); |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lat, null); |
| | | if(null == reverseGeocode){ |
| | | System.err.println("获取地图信息出错"); |
| | | return new HashMap<>(); |
| | |
| | | reassign.setInsertTime(new Date()); |
| | | reassign.setState(2); |
| | | this.insert(reassign); |
| | | |
| | | String tripId = ""; |
| | | //修改改派通知状态 |
| | | switch (reassign.getOrderType()){ |
| | | case 1: |
| | |
| | | orderPrivateCar.setState(11); |
| | | orderPrivateCar.setReassignNotice(2); |
| | | orderPrivateCarService.updateById(orderPrivateCar); |
| | | tripId = redisUtil.getValue("trip" + orderPrivateCar.getUserId()); |
| | | break; |
| | | case 2: |
| | | OrderTaxi orderTaxi = orderTaxiService.selectById(reassign.getOrderId()); |
| | |
| | | orderTaxi.setState(11); |
| | | orderTaxi.setReassignNotice(2); |
| | | orderTaxiService.updateById(orderTaxi); |
| | | tripId = redisUtil.getValue("trip" + orderTaxi.getUserId()); |
| | | break; |
| | | case 4: |
| | | OrderLogistics orderLogistics = orderLogisticsService.selectById(reassign.getOrderId()); |
| | |
| | | orderLogistics.setState(11); |
| | | orderLogistics.setReassignNotice(2); |
| | | orderLogisticsService.updateById(orderLogistics); |
| | | tripId = redisUtil.getValue("trip" + orderLogistics.getUserId()); |
| | | break; |
| | | case 5: |
| | | OrderLogistics orderLogistics1 = orderLogisticsService.selectById(reassign.getOrderId()); |
| | |
| | | orderLogistics1.setState(11); |
| | | orderLogistics1.setReassignNotice(2); |
| | | orderLogisticsService.updateById(orderLogistics1); |
| | | tripId = redisUtil.getValue("trip" + orderLogistics1.getUserId()); |
| | | break; |
| | | } |
| | | systemNoticeService.addSystemNotice(2, language == 1 ? "您的改派申请已成功提交,我们会尽快为你处理!" : language == 2 ? |
| | | "Your request for reassignment was submitted, we shall handle it for you as soon as possible." : |
| | | "Votre demande de réaffectation a été soumise. Nous la traiterons pour vous dans les plus brefs délais.", uid); |
| | | |
| | | |
| | | //开始自动完成改派 |
| | | switch (reassign.getOrderType()){ |
| | | case 1: |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(reassign.getOrderId()); |
| | | Company company = companyCityService.query1(String.valueOf(orderPrivateCar.getStartLon()), String.valueOf(orderPrivateCar.getStartLat()));//获取起点所属分公司 |
| | | Company company = companyCityService.query1(orderPrivateCar.getUserId(), String.valueOf(orderPrivateCar.getStartLon()), String.valueOf(orderPrivateCar.getStartLat()));//获取起点所属分公司 |
| | | PushOrder pushOrder = pushOrderService.querys(1, 1, company.getId()).get(0); |
| | | //获取空闲司机 |
| | | List<Driver> list = driverService.queryIdleDriver(1, orderPrivateCar.getServerCarModelId(), orderPrivateCar.getStartLon(), orderPrivateCar.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机 |
| | | List<Driver> list = driverService.queryIdleDriver(orderPrivateCar.getUserId(), 1, orderPrivateCar.getServerCarModelId(), orderPrivateCar.getStartLon(), orderPrivateCar.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机 |
| | | System.err.println("【" + orderPrivateCar.getId() + "】空闲司机:" + JSON.toJSONString(list)); |
| | | if(list.size() > 0){ |
| | | String text = ""; |
| | |
| | | String value = redisUtil.getValue("DRIVER" + driver1.getId()); |
| | | if(ToolUtil.isNotEmpty(value)) { |
| | | String[] split = value.split(","); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderPrivateCar.getStartLat(), orderPrivateCar.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0])); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderPrivateCar.getStartLat(), orderPrivateCar.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0]), tripId); |
| | | //超时时间 |
| | | long timeOut = System.currentTimeMillis() + (distancematrix.getDuration() * 1000); |
| | | orderPrivateCar.setEstimateArriveTime(new Date(timeOut)); |
| | |
| | | break; |
| | | case 4: |
| | | OrderLogistics orderLogistics = orderLogisticsService.selectById(reassign.getOrderId()); |
| | | Company company1 = companyCityService.query1(String.valueOf(orderLogistics.getStartLon()), String.valueOf(orderLogistics.getStartLat()));//获取起点所属分公司 |
| | | Company company1 = companyCityService.query1(orderLogistics.getUserId(), String.valueOf(orderLogistics.getStartLon()), String.valueOf(orderLogistics.getStartLat()));//获取起点所属分公司 |
| | | PushOrder pushOrder1 = pushOrderService.querys(1, 1, company1.getId()).get(0); |
| | | //获取空闲司机 |
| | | List<Driver> list1 = driverService.queryIdleDriver(orderLogistics.getType(), orderLogistics.getServerCarModelId(), orderLogistics.getStartLon(), orderLogistics.getStartLat(), pushOrder1.getPushDistance(), null);//所有附近空闲司机 |
| | | List<Driver> list1 = driverService.queryIdleDriver(orderLogistics.getUserId(), orderLogistics.getType(), orderLogistics.getServerCarModelId(), orderLogistics.getStartLon(), orderLogistics.getStartLat(), pushOrder1.getPushDistance(), null);//所有附近空闲司机 |
| | | System.err.println("【" + orderLogistics.getId() + "】空闲司机:" + JSON.toJSONString(list1)); |
| | | if(list1.size() > 0){ |
| | | Driver driver1 = list1.get(0); |
| | |
| | | String value = redisUtil.getValue("DRIVER" + driver1.getId()); |
| | | if(ToolUtil.isNotEmpty(value)) { |
| | | String[] split = value.split(","); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderLogistics.getStartLat(), orderLogistics.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0])); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderLogistics.getStartLat(), orderLogistics.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0]), tripId); |
| | | //超时时间 |
| | | long timeOut = System.currentTimeMillis() + (distancematrix.getDuration() * 1000); |
| | | orderLogistics.setEstimateArriveTime(new Date(timeOut)); |
| | |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.maps.*; |
| | | import com.google.maps.model.*; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | |
| | | /** |
| | | * 谷歌地图工具类 |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static ReverseGeocodeVo getReverseGeocode(double lat, double lng) throws Exception{ |
| | | public static ReverseGeocodeVo getReverseGeocode(double lat, double lng, String tripId) throws Exception{ |
| | | GeoApiContext context = new GeoApiContext.Builder() |
| | | .apiKey(key) |
| | | .build(); |
| | | GeocodingApiRequest request = GeocodingApi.reverseGeocode(context, new LatLng(lat, lng)); |
| | | if(ToolUtil.isNotEmpty(tripId)){ |
| | | request.header("X-Goog-Maps-Experience-ID", tripId);//行程id |
| | | } |
| | | GeocodingResult[] results = request.await(); |
| | | ReverseGeocodeVo vo = null; |
| | | if(results.length > 0){ |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static DistancematrixVo getDistancematrix(Double sLat, Double sLnt, Double eLat, Double eLnt) throws Exception{ |
| | | public static DistancematrixVo getDistancematrix(Double sLat, Double sLnt, Double eLat, Double eLnt, String tripId) throws Exception{ |
| | | GeoApiContext context = new GeoApiContext.Builder() |
| | | .apiKey(key) |
| | | .build(); |
| | |
| | | request.origins(new LatLng(sLat, sLnt)); |
| | | request.destinations(new LatLng(eLat, eLnt)); |
| | | request.mode(TravelMode.DRIVING);//出行方式(驾车) |
| | | if(ToolUtil.isNotEmpty(tripId)){ |
| | | request.header("X-Goog-Maps-Experience-ID", tripId);//行程id |
| | | } |
| | | DistanceMatrix distanceMatrix = request.await(); |
| | | Gson gson = new GsonBuilder().setPrettyPrinting().create(); |
| | | System.out.println(gson.toJson(distanceMatrix)); |
| | |
| | | |
| | | |
| | | |
| | | public static void main(String[] ages){ |
| | | try { |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | Integer oldState = 0; |
| | | Long startServiceTime = null; |
| | | Double servedMileage = null; |
| | | String tripId = ""; |
| | | switch (orderType){ |
| | | case 1: |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId); |
| | | tripId = redisUtil.getValue("trip" + orderPrivateCar.getUserId()); |
| | | if(orderPrivateCar == null){ |
| | | this.removeTask(orderId, orderType); |
| | | }else{ |
| | |
| | | break; |
| | | case 2: |
| | | OrderTaxi orderTaxi = orderTaxiService.selectById(orderId); |
| | | tripId = redisUtil.getValue("trip" + orderTaxi.getUserId()); |
| | | if(orderTaxi == null){ |
| | | this.removeTask(orderId, orderType); |
| | | }else{ |
| | |
| | | break; |
| | | case 3: |
| | | OrderCrossCity orderCrossCity = orderCrossCityService.selectById(orderId); |
| | | tripId = redisUtil.getValue("trip" + orderCrossCity.getUserId()); |
| | | if(orderCrossCity == null){ |
| | | this.removeTask(orderId, orderType); |
| | | }else{ |
| | |
| | | break; |
| | | case 4: |
| | | OrderLogistics orderLogistics = orderLogisticsService.selectById(orderId); |
| | | tripId = redisUtil.getValue("trip" + orderLogistics.getUserId()); |
| | | if(orderLogistics == null){ |
| | | this.removeTask(orderId, orderType); |
| | | }else{ |
| | |
| | | break; |
| | | case 5: |
| | | OrderLogistics orderLogistics1 = orderLogisticsService.selectById(orderId); |
| | | tripId = redisUtil.getValue("trip" + orderLogistics1.getUserId()); |
| | | if(orderLogistics1 == null){ |
| | | this.removeTask(orderId, orderType); |
| | | }else{ |
| | |
| | | if(ToolUtil.isNotEmpty(value) && ToolUtil.isNotEmpty(startLonLat)){ |
| | | String[] split = value.split(","); |
| | | String[] split1 = startLonLat.split(","); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(split[1]), Double.valueOf(split[0]), Double.valueOf(split1[1]), Double.valueOf(split1[0])); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(split[1]), Double.valueOf(split[0]), Double.valueOf(split1[1]), Double.valueOf(split1[0]), tripId); |
| | | if(null == distancematrix){ |
| | | System.err.println("地图获取距离出错"); |
| | | }else{ |
| | |
| | | if(ToolUtil.isNotEmpty(value) && ToolUtil.isNotEmpty(endLonLat)){ |
| | | String[] split = value.split(","); |
| | | String[] split1 = endLonLat.split(","); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(split[1]), Double.valueOf(split[0]), Double.valueOf(split1[1]), Double.valueOf(split1[0])); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(split[1]), Double.valueOf(split[0]), Double.valueOf(split1[1]), Double.valueOf(split1[0]), tripId); |
| | | if(null == distancematrix){ |
| | | System.err.println("地图获取距离出错"); |
| | | }else{ |