| | |
| | | * @param licensePlate 车牌号 |
| | | * @param id 车辆id |
| | | */ |
| | | public String createVehicles(int maximumCapacity, String licensePlate, String id) throws Exception{ |
| | | public boolean createVehicles(int maximumCapacity, String licensePlate, String id) { |
| | | String url = "https://fleetengine.googleapis.com/v1/providers/" + provider + "/vehicles?vehicleId=" + id; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | Map<String, String> headers = new HashMap<>(); |
| | |
| | | return createVehicles(maximumCapacity, licensePlate, id); |
| | | } |
| | | } |
| | | throw new Exception(response.body()); |
| | | log.error("添加车辆信息异常: licensePlate={}, body={}", licensePlate, response.body()); |
| | | return false; |
| | | } |
| | | /** |
| | | * 返回结果 |
| | |
| | | * "waypointsVersion": "2024-05-23T03:05:23.293329Z" |
| | | * } |
| | | */ |
| | | return response.body(); |
| | | return true; |
| | | } |
| | | |
| | | |
| | |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public String updateVehicles(String vehicleState, Integer maximumCapacity, String licensePlate, String id) throws Exception{ |
| | | public boolean updateVehicles(String vehicleState, Integer maximumCapacity, String licensePlate, String id) { |
| | | String url = "https://fleetengine.googleapis.com/v1/providers/" + provider + "/vehicles/" + id + "?updateMask="; |
| | | List<String> sb = new ArrayList<>(); |
| | | if(StringUtils.hasLength(vehicleState)){ |
| | |
| | | return updateVehicles(vehicleState, maximumCapacity, licensePlate, id); |
| | | } |
| | | } |
| | | throw new Exception(response.body()); |
| | | log.error("修改车辆信息异常: licensePlate={}, body={}", licensePlate, response.body()); |
| | | return false; |
| | | } |
| | | /** |
| | | * 返回结果 |
| | |
| | | * "waypointsVersion": "2024-05-23T03:05:23.293329Z" |
| | | * } |
| | | */ |
| | | return response.body(); |
| | | return true; |
| | | } |
| | | |
| | | |
| | |
| | | * @param id 车辆id |
| | | * @return |
| | | */ |
| | | public String getVehicles(String id) throws Exception{ |
| | | public String getVehicles(String id){ |
| | | String url = "https://fleetengine.googleapis.com/v1/providers/" + provider + "/vehicles/" + (null != id ? id : ""); |
| | | HttpRequest get = HttpUtil.createGet(url); |
| | | Map<String, String> headers = new HashMap<>(); |
| | |
| | | return getVehicles(id); |
| | | } |
| | | } |
| | | throw new Exception(response.body()); |
| | | log.error("查询车辆信息异常: id={}, body={}", id, response.body()); |
| | | return null; |
| | | } |
| | | /** |
| | | * 返回结果 |
| | |
| | | * @param end_lng 终点经度 |
| | | * @return |
| | | */ |
| | | public String createTrip(String vehicleId, Integer numberOfPassengers, String tripId, String start_lat, String start_lng, String end_lat, String end_lng) throws Exception{ |
| | | public boolean createTrip(String vehicleId, Integer numberOfPassengers, String tripId, String start_lat, String start_lng, String end_lat, String end_lng) { |
| | | String url = "https://fleetengine.googleapis.com/v1/providers/" + provider + "/trips?tripId=" + tripId; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | Map<String, String> headers = new HashMap<>(); |
| | |
| | | return createTrip(vehicleId, numberOfPassengers, tripId, start_lat, start_lng, end_lat, end_lng); |
| | | } |
| | | } |
| | | throw new Exception(response.body()); |
| | | logger.error("创建行程异常: tripId={} body={}", tripId, response.body()); |
| | | return false; |
| | | } |
| | | /** |
| | | * 返回结果 |
| | |
| | | * "currentRouteSegmentTrafficVersion": "2024-05-27T02:05:37.941167Z" |
| | | * } |
| | | */ |
| | | return response.body(); |
| | | return true; |
| | | } |
| | | |
| | | |
| | |
| | | * @param end_lng 终点经度 |
| | | * @return |
| | | */ |
| | | public String updateTrip(String tripStatus, String vehicleId, Integer numberOfPassengers, String tripId, String start_lat, String start_lng, String end_lat, String end_lng) throws Exception { |
| | | public boolean updateTrip(String tripStatus, String vehicleId, Integer numberOfPassengers, String tripId, String start_lat, String start_lng, String end_lat, String end_lng) { |
| | | String url = "https://fleetengine.googleapis.com/v1/providers/" + provider + "/trips/" + tripId + "?updateMask="; |
| | | List<String> sb = new ArrayList<>(); |
| | | if(StringUtils.hasLength(vehicleId)){ |
| | |
| | | return updateTrip(tripStatus, vehicleId, numberOfPassengers, tripId, start_lat, start_lng, end_lat, end_lng); |
| | | } |
| | | } |
| | | throw new Exception(response.body()); |
| | | logger.error("修改行程异常: tripId={} body={}", tripId, response.body()); |
| | | return false; |
| | | } |
| | | /** |
| | | * 返回结果 |
| | |
| | | * "numberOfPassengers": 1 |
| | | * } |
| | | */ |
| | | return response.body(); |
| | | return true; |
| | | } |
| | | |
| | | |
| | |
| | | * @param tripId 订单id |
| | | * @return |
| | | */ |
| | | public String getTrip(String tripId) throws Exception { |
| | | public String getTrip(String tripId) { |
| | | String url = "https://fleetengine.googleapis.com/v1/providers/" + provider + "/trips/" + tripId; |
| | | HttpRequest get = HttpUtil.createGet(url); |
| | | Map<String, String> headers = new HashMap<>(); |
| | |
| | | return getTrip(tripId); |
| | | } |
| | | } |
| | | throw new Exception(response.body()); |
| | | logger.error("获取行程异常: tripId={} body={}", tripId, response.body()); |
| | | return null; |
| | | } |
| | | /** |
| | | * 返回结果 |
| | |
| | | * @param tripId 行程id |
| | | * @return |
| | | */ |
| | | public boolean reportBillableEvent(String tripId) throws Exception { |
| | | public boolean reportBillableEvent(String tripId) { |
| | | String billableEventId = UUIDUtil.getRandomCode(); |
| | | String url = "https://mobilitybilling.googleapis.com/v1:reportBillableEvent?regionCode=GH&key=" + key + "&billableEventId=" + billableEventId; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | |
| | | post.addHeaders(headers); |
| | | JSONObject body = new JSONObject(); |
| | | body.put("related_ids", "[\"" + tripId + "\"]"); |
| | | body.put("regionCode", "GH"); |
| | | post.body(body.toJSONString()); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //上线客户测试和上线运营开放 |
| | | // HttpResponse response = post.execute(); |
| | | // if(200 != response.getStatus()){ |
| | | // logger.error(response.body()); |
| | | // throw new Exception(response.body()); |
| | | // logger.error("google地图上报结算 tripId:{} 异常:{}", tripId,response.body()); |
| | | // return false; |
| | | // } |
| | | return true; |
| | | } |