Pu Zhibing
2024-10-21 f08b7e95bc941a72d4a7b7bc64c2086ed53f1565
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GoogleMap/FleetEngineUtil.java
@@ -167,7 +167,7 @@
    * @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<>();
@@ -207,7 +207,8 @@
               return createVehicles(maximumCapacity, licensePlate, id);
            }
         }
         throw new Exception(response.body());
         log.error("添加车辆信息异常:  licensePlate={},   body={}", licensePlate, response.body());
         return false;
      }
      /**
       * 返回结果
@@ -230,7 +231,7 @@
       *    "waypointsVersion": "2024-05-23T03:05:23.293329Z"
       * }
       */
      return response.body();
      return true;
   }
   
   
@@ -241,7 +242,7 @@
    * @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)){
@@ -305,7 +306,8 @@
               return updateVehicles(vehicleState, maximumCapacity, licensePlate, id);
            }
         }
         throw new Exception(response.body());
         log.error("修改车辆信息异常:  licensePlate={},   body={}", licensePlate, response.body());
         return false;
      }
      /**
       * 返回结果
@@ -328,7 +330,7 @@
       *   "waypointsVersion": "2024-05-23T03:05:23.293329Z"
       * }
       */
      return response.body();
      return true;
   }
   
   
@@ -337,7 +339,7 @@
    * @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<>();
@@ -366,7 +368,8 @@
               return getVehicles(id);
            }
         }
         throw new Exception(response.body());
         log.error("查询车辆信息异常:  id={},   body={}", id, response.body());
         return null;
      }
      /**
       * 返回结果
@@ -446,7 +449,7 @@
    * @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<>();
@@ -495,7 +498,8 @@
               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;
      }
      /**
       * 返回结果
@@ -612,7 +616,7 @@
       *    "currentRouteSegmentTrafficVersion": "2024-05-27T02:05:37.941167Z"
       * }
       */
      return response.body();
      return true;
   }
   
   
@@ -628,7 +632,7 @@
    * @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)){
@@ -714,7 +718,8 @@
               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;
      }
      /**
       * 返回结果
@@ -834,7 +839,7 @@
       *    "numberOfPassengers": 1
       * }
       */
      return response.body();
      return true;
   }
   
   
@@ -844,7 +849,7 @@
    * @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<>();
@@ -873,7 +878,8 @@
               return getTrip(tripId);
            }
         }
         throw new Exception(response.body());
         logger.error("获取行程异常:  tripId={}  body={}", tripId, response.body());
         return null;
      }
      /**
       * 返回结果
@@ -963,7 +969,7 @@
    * @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);
@@ -973,22 +979,13 @@
      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;
   }