| | |
| | | BaseWarpper baseWarpper = new BaseWarpper(); |
| | | baseWarpper.setDay(String.valueOf(null != map.get("time") ? map.get("time") : "")); |
| | | baseWarpper.setAmount(Double.valueOf(String.valueOf(null != map.get("money") ? map.get("money") : 0))); |
| | | baseWarpper.setType(Integer.valueOf(type)); |
| | | if("2".equals(type)){ |
| | | switch (Integer.valueOf(String.valueOf(null != map.get("orderType") ? map.get("orderType") : 0))){ |
| | | case 1: |
| | |
| | | } |
| | | |
| | | new Thread(()->{ |
| | | try { |
| | | Car car = carService.selectById(orderLogistics.getCarId()); |
| | | if(!StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | String trip = fleetEngineUtil.getTrip(orderLogistics.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | Car car = carService.selectById(orderLogistics.getCarId()); |
| | | if(!StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | String trip = fleetEngineUtil.getTrip(orderLogistics.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | }else{ |
| | | //开始修改行程数据 |
| | | fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | boolean createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | if(!createTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | if(createTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | //开始修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }).start(); |
| | | |
| | |
| | | new Thread(()->{ |
| | | Car car = carMapper.selectById(driver.getCarId()); |
| | | //修改行程数据 |
| | | try { |
| | | fleetEngineUtil.updateTrip(finalTripStatus, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(finalTripStatus, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(finalTripStatus, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }).start(); |
| | | |
| | |
| | | orderLogistics.setEndLat(Double.valueOf(orderLogistics.getDestinationLat())); |
| | | orderLogistics.setEndAddress(orderLogistics.getDestination()); |
| | | //修改google地图行程终点 |
| | | try { |
| | | fleetEngineUtil.updateTrip(null, null, null, orderLogistics.getTripId(), |
| | | null, null, orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException(e); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, null, null, orderLogistics.getTripId(), |
| | | null, null, orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, null, null, orderLogistics.getTripId(), |
| | | null, null, orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | orderLogistics.setDestinationLon(""); |
| | |
| | | //上报google |
| | | OrderLogistics finalOrderLogistics = orderLogistics; |
| | | new Thread(()->{ |
| | | try { |
| | | fleetEngineUtil.reportBillableEvent(finalOrderLogistics.getTripId()); |
| | | log.warn("行程结束:{} {}", System.currentTimeMillis(), finalOrderLogistics.getTripId()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | log.warn("行程结束:{} {}", System.currentTimeMillis(), finalOrderLogistics.getTripId()); |
| | | boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(finalOrderLogistics.getTripId()); |
| | | if(!reportBillableEvent){ |
| | | for (int i = 0; i < 5; i++) { |
| | | reportBillableEvent = fleetEngineUtil.reportBillableEvent(finalOrderLogistics.getTripId()); |
| | | if(reportBillableEvent){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }).start(); |
| | | return ResultUtil.success(); |
| | |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | boolean createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(!createTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(createTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //开始修改行程数据 |
| | | fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | String finalTripStatus = tripStatus; |
| | | new Thread(()->{ |
| | | //修改行程数据 |
| | | try { |
| | | fleetEngineUtil.updateTrip(finalTripStatus, null, 1, orderPrivateCar.getTripId(), null, null, null, null); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(finalTripStatus, null, 1, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(finalTripStatus, null, 1, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | }).start(); |
| | | |
| | | // TODO: 2020/6/5 推送状态 |
| | |
| | | |
| | | OrderPrivateCar finalOrderPrivateCar = orderPrivateCar; |
| | | new Thread(()->{ |
| | | try { |
| | | //上报google |
| | | fleetEngineUtil.reportBillableEvent(finalOrderPrivateCar.getTripId()); |
| | | log.warn("行程结束:{} {}", System.currentTimeMillis(), finalOrderPrivateCar.getTripId()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | //上报google |
| | | log.warn("行程结束:{} {}", System.currentTimeMillis(), finalOrderPrivateCar.getTripId()); |
| | | boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(finalOrderPrivateCar.getTripId()); |
| | | if(!reportBillableEvent){ |
| | | for (int i = 0; i < 5; i++) { |
| | | reportBillableEvent = fleetEngineUtil.reportBillableEvent(finalOrderPrivateCar.getTripId()); |
| | | if(reportBillableEvent){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }).start(); |
| | | return ResultUtil.success(); |
| | |
| | | orderPrivateCar.setEndLat(Double.valueOf(orderPrivateCar.getDestinationLat())); |
| | | orderPrivateCar.setEndAddress(orderPrivateCar.getDestination()); |
| | | //修改google地图行程终点 |
| | | try { |
| | | fleetEngineUtil.updateTrip(null, null, null, orderPrivateCar.getTripId(), |
| | | null, null, orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException(e); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, null, null, orderPrivateCar.getTripId(), |
| | | null, null, orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, null, null, orderPrivateCar.getTripId(), |
| | | null, null, orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | orderPrivateCar.setDestinationLon(""); |
| | |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)) { |
| | | fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | boolean createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(!createTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(createTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //开始修改行程数据 |
| | | fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), |
| | | boolean createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | if(!createTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | if(createTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | //开始修改行程数据 |
| | | fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | * @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; |
| | | } |
| | |
| | | private String day; |
| | | @ApiModelProperty("其他内容") |
| | | private Object data; |
| | | |
| | | @ApiModelProperty("类型(1=活动收入,2=跑单收入,3=取消订单收入,4=改派订单收入,5=优惠券补贴,6=折扣不贴,7=红包补贴)") |
| | | private Integer type; |
| | | |
| | | public BaseWarpper() { |
| | | this.id = 0; |
| | |
| | | public void setData(Object data) { |
| | | this.data = data; |
| | | } |
| | | |
| | | |
| | | public Integer getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(Integer type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "BaseWarpper{" + |
| | |
| | | baseWarpper.setLat(null != map.get("lat") ? Double.valueOf(map.get("lat").toString()) : 0.0); |
| | | baseWarpper.setDay(null != map.get("day") ? map.get("day").toString() : ""); |
| | | baseWarpper.setData(null != map.get("data") ? map.get("data") : new Object()); |
| | | baseWarpper.setType(null != map.get("type") ? Integer.valueOf(map.get("type").toString()) : 0); |
| | | } |
| | | return baseWarpper; |
| | | } |
| | |
| | | |
| | | private String driverClassName = "com.mysql.cj.jdbc.Driver"; |
| | | |
| | | private Integer initialSize = 2; |
| | | private Integer initialSize = 100; |
| | | |
| | | private Integer minIdle = 1; |
| | | private Integer minIdle = 100; |
| | | |
| | | private Integer maxActive = 20; |
| | | private Integer maxActive = 500; |
| | | |
| | | private Integer maxWait = 60000; |
| | | |
| | |
| | | |
| | | //修改行程信息 |
| | | try { |
| | | fleetEngineUtil.updateTrip("CANCELED", null, null, tOrderLogistics.getTripId(), null, null, null, null); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tOrderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tOrderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | |
| | | |
| | | //修改行程信息 |
| | | try { |
| | | fleetEngineUtil.updateTrip("CANCELED", null, null, tOrderPrivateCar.getTripId(), null, null, null, null); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tOrderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tOrderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | |
| | | tEmail.setLink(link); |
| | | tEmail.setUserId(user.getId()); |
| | | tEmail.setType(1); |
| | | tEmail.setName("Discount activities"); |
| | | tEmail.setName(1 == language ? "折扣活动" : 2 == language ? "Discount activities" : "Activités à rabais"); |
| | | tEmail.setCreateTime(new Date()); |
| | | int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1; |
| | | tEmail.setWeek(EmailUtil.getWeek(2,i)); |
| | |
| | | |
| | | /** |
| | | * Fleet Engine API 工具类 |
| | | * |
| | | * @author zhibing.pu |
| | | * @Date 2024/5/17 9:59 |
| | | */ |
| | |
| | | |
| | | static Logger logger = LoggerFactory.getLogger(FleetEngineUtil.class); |
| | | |
| | | private final static String key = "AIzaSyCG6PsfkaCEc94VK2vIAZk1YYKvOS_Ewts"; |
| | | |
| | | private final String SERVICE_ACCOUNT = "odrd-fleetengine-ondemandadmin@i-go-odrd-testing.iam.gserviceaccount.com"; |
| | | |
| | | |
| | | private final String DRIVER_ACCOUNT = "odrd-fleetengine-driversdkuser@i-go-odrd-testing.iam.gserviceaccount.com"; |
| | | |
| | | |
| | | private final String CONSUMER_ACCOUNT = "odrd-fleetengine-consumersdkus@i-go-odrd-testing.iam.gserviceaccount.com"; |
| | | |
| | | |
| | | private final String serverPrivateKeyId = "254e18eefa9fdcca64d5899cdcd793d466c47c7d"; |
| | | |
| | | |
| | | private final String serverPrivateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCfbNAWnukqLKIxItqmSABxsH5glySEHJ2gfL5KsRF0M02e0Z8/KNKZkoh7I6bOMt1fEtttFaWOeq70IdI2WAd5wVazL3upvl5FW4P08ly33LklfGyLljlJ7ChPny9x6OjAaiS0yD9fh7NWti7rZKU7gzcGL8HddNYXgXV5OajvoG3TGdu52WTxce9AUzU6gLPboz/RbGqrdrmgVJVb0EPlhTJf/NSsaiW4NoL8SEzf/pJGYBmqJs97mXwCHTY4avaC+CP/zz9yS8AQEJlApbVT6lSOhYoR0hNOBj5B886EZOssjubO6hQaiwRnGrV2RdpHynqA1iekfGpUGEtWTsqjAgMBAAECggEALyPbMd0iP8y71sCiG4nty7Au5ju62e+mMkbAc9CAwzXKTVxZdLEK+MsJ3TNxBsami47FYC+G6SbgpaJ8iIImD7v5+XjgXZRDRsnlLmAdx2YWPv3YELxGS1PvpX+B5XJDpGWeXfBaQNKc1lZ/cC4t53eIpSUo82UxSvkGNea1S8lR6vIByhNyCQOvLG4yqaxUy0hZi0kge37XrjYMGS+BivBBnDiVlBPLBVbrNBxOf31Lzz+XX0iwXX7Zl2jN759oe0xQyuIGWUSj8xBDIF8nNaJrla7rWVml3sZJh6/3r1Acj0mhZtE0ZMu5hiPGiIXgb1ng30j3dMP4yVPhXrpAtQKBgQDaU01VnHsnHxc0DQHE2vEOPGmPxVS0/JAssePAEUmKEueUogGef91YY+Vm/ItbhLwGjbytnXxe88zRAdB1u07efZ83ey93TrGl2CJUzLHIcgb+Q1tT642rqlfl+q8ep86hcZ+63pDiIPt2Z+HkbKIR0SWf5LIH4flquQOTQufXXQKBgQC674qDsjOJepZjMMN6PkVMcWBYDNmXHnqa5Oto0rZM745UulbXqEFGuBOsXPU7O33Kfz1vbtoluubKZi5B6cFNnPypE2SCfvdObHq4FuTuKPV6lN93SyhZchmSEXEs0PU4cGDRt+RRqQcjft1Wigiy4Y1y1SInCtcaP1hLejEJ/wKBgFAhvwKrGnBzctrB42JTUaJ9/eis7rg28tvUttjp/2nUIndlNt7r41vr3mj8TFHc1/43y4aVhO584THdTpvHkd0LkoKUjglmMsHCIGercZ02bOap5j1Y+XiGXxij995yjN6oi43U3qyAmosM+dYTITEU6JBVKhrGj/rhyTQlnF5pAoGBAKFGmo0mR/pbDbYD0xH6+VSLGCC+7VbIT+SkjUjBSdA0eOo2XUfvfGmj1C1HgbcZi1wRzJH/5CrbBdQmtc/d+QyZ3Q2NkpBXM8uwIWwDLH0gTzDzkZvc9rG8k70GWUrd+EI6Cf3FFjExj9wazqCjs/+IQr2Ijc97NbsKXYW4pOhHAoGAKf5wYk+cn0cVTsyAom0UbGD5Uijqh5732MeqFYs2Rcwx0OErJZo68COSFFF40hJmmIKn7p3qycIyd1FcYlXN1l4s8mEWTGTInRE0OlBU0+jLtIV9pwNgffpbPYcrWZU6s6YVeJ2nDwl+aD+4QvN0rkPTfho9kjgeyF3PW0I2u4E="; |
| | | |
| | | |
| | | private final String driverPrivateKeyId = "859e85fb3aa4d18b4afaac3e24e8f65700da5cc9"; |
| | | |
| | | |
| | | private final String driverPrivateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCmzL1BqSH+Zh9Fct5mXqe5sYOMTnJtOJhwKXnjjo2tNPXv4alzUHz8Vbj6nMar5u5IuKRZMeRBlhoRSFrLm+J1+sfvpH8N4wsnG7hDANknqWzdsk9a68qMHxNQF3hFzs9+KKrR1LAG8e9ytMfliN0kX+xls4uPZDPu1Q39K6V9KXrH/GrMA56i3TtWi7Hmakt5YTELeGjhx4nGrfuQLFFovs1Z9uJtf7E8R95+65StrOAmbJNf7VciEqwBpWYlU5VeyLXMg/oHwnTv2cjdcFozyDrlUHbDmtTiVeBBsYFVLyAsDGfl1p6eiVTiBBuo56YSYLWfaLgYvTyEcZ9jBQsfAgMBAAECggEAQzbTuObX3PT3+vtb5XKVMf33XY2rDJo2y1PbWzhxnO9vf3e22dIAW4qLnOmaIWFQeht1lr/FFCzRWk+Gzu+FJTemY8osrMLmFp9T9CQeXZ4nUXruAVxs5WQMW0Tp4W+CK3tlwmJrgJDzhYyV1Mf/HQ5Oa3kbbu/ZAY/3MCLrb/ClJQvD2rZSDdzAkNMQm8P2hsE71+rH7mI2hHrSCHl2OIp2A64QT8HjtyRc5yHZtTp6ZST1ge9SSIsT0ZfmXKtKF7yGEIPtKNU+oLrGyK5P30xBWJ/bwb3PEz2MZcPvz31+B2+UvZMm7OTkqfcRwEztAf8Ckiuo4im2BRYbVmd9OQKBgQDd0MeLxR+Qtv12bVA0bHtagFEq36THgWG7IM1/1vS4Cl9sveKSOS8A6oKLy624fGE7PKcuTTIzkVA81GXtWBQ9Coq/4TmllQkFTH7pz9C2PNHSCychPwNNV8qUx3lE3d4DOjGKgoVFD4l90AO7lOvmLTSc3pDpr+jSjUH4lqGrbQKBgQDAgXBmpXfCTxwqkBzGwxX+hwJen9qSkCM47qnQ1L4NnXPL6s0EN6rQ3FnFemGIzBUGJ2tajntkKlUu5DzsQeoBGu/SaSwgqD+1UQDcUyo+retmqZ+QYbpeyd3l53bLJJuJNsfak0X76Ft6hrm4julx6RGlmboQyx4kZWbhx4YNOwKBgEG9/2aNpi1eDwFqpLrk7CqGnYf3gP8gebbcoguhyiZB7MZuARkVmbjLyKVmWLa1JpxH/cTbXGWsS/u7d/pAgL8WwMjeGBfbdDD92x+xWEqq/AUlCRPxeSkTPBech3TBzWtndAd5Z8ZwNG/1lyWhnck63L0huhGI8Zh2BXeILaKBAoGAKK3xq69BvGztPc1QV2w4RJ4RER/kl14gI1LDzd52/veL1cabZk3BKfu2eLWg0MCXnMJNvEgpqQQNFiii+yX+phckIKma6pfDRrSEYwqr/azQ9tPXZTJRqOAtpPyhrNHikD9kQjsm6dGzKxQ3QNnqWOjwkrcGi6/wga5v7Dw2hqsCgYEA2T/kSNQ9dqpVBAkfi2J50hqnfFESPjKeirJJZllqhVqsiV0ly8a8Fz8SjGqTzrq+UErko+QmtSlo5h3Uq9Ln+0CwYfrUL+74q2zLHdS0DpY3QsGTEDJXTxCyy9kO26X2UsM3Ez3YUAkdMwdpVz0uVZtinv2735QZOBxoVQV2kQ8="; |
| | | |
| | | |
| | | private final String consumerPrivateKeyId = "40acf82cbd5250de2f5123caff40738bdd403b08"; |
| | | |
| | | |
| | | private final String consumerPrivateKey = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDSwtbSBFgIXna6mWeKFWCK31NXUJH6uGduR1XrODGRedrqrTgr0BdNg8PDo6/zh/T+K0Svor6kgqpwnl9soOdn73oC4Nu+Ad7EiKa38j650jlZdLAr4hR0Ou9Kcnv45x/94auUO8jBz844cu24swLKiPsK9OnX65wVlKRfhhkGFuS/4OI76CmE7NqZDqPOW16o8tBO5TsgPVNkglFAU73fTp0kcHoLauT9QOB0+yZi39mnNXyU+2cL3Ylp5oaQCJpyssDRUqz/EiHa7FxUUgzCadG00+ePf5iYSnZKQRKWoOIawFvcCfcHx8GAl8Nn+79HtVQHB9hLsQ5+jqcdfKPfAgMBAAECggEAE9Ufz912xzrUY1TCKH1Ae3Dub732Lqihmv/9dsfv6ieUURcBvSW0u6eViVhi20DE7hH2QazH0cU18qkEg71UaTRgv9qW8vdMFiRhw9d4zZWZrfBMD6UTlahiEhhZ0B83pHVS5v0FNC+w0SEHe6Tks1hWfz5yrs3N/z3ghdihjC/5i1jeBoHXs1262SMazuwNGHblLApGPG+86taeFtbDI+31TKvZ8nomZHkEVFnARRUoBBcIwowRMqNfwlpcJhlz6kDWnoD08kHJ2zzJokozu7Lim+Ugt/MWwUOcA0hgq2QdymZFpkRkDl7tZmJtwTfTirjbGlpnPHVXEc1bWM7ocQKBgQD0LJ8e7JXf6bVFngq0jSJNKK7XDHYg0KhHXMApF59xxi29hdHXWPzgRJ45KkoUJc7MITpIJLXfCmi1XyDMf9m8lIf/oaqhJ7idYi7iAAPOJkdnHbSt0lebyjBWzCQ6OgS4NfF1+LEibTzRqiFs5K8EAyPYAVSTrpWoguoWtTzIGQKBgQDc9/I2PS+91Eb5RvuidTNsDqZJliTJQFlBjlDViFo3+l1N7jDFYwPBR/Tv4TVM5p9Zb+/Lo9X1pjDbm8QriTR4V+4HaLXkcCnmOsdSRInFUW4UIafwLX5ifjgfyaWgdKdn2UP1Lu/1qBN6GU1xjSfBQ6N3UqQiKkNPb7tuPJGqtwKBgQCQ4hU8vTclGMC14VQK1B/BVt1/vuYtDIJ9bZycBWdXlDc52LitpiDOVgjodJ5mHBT77M9vVVERWlTNIfgNP+OL0TptRZlAbJhP0p1s/oNDhFUj6211InVXfH54UkNAxYJdZ6yxynIYsma/JcsVmQ/8Ony/Q/LSempVBfEurjW1qQKBgQCQWPjFLdtOKqnildg0HFPnNvqx/38waPTluk5b76LgBpGFIyCBEVmWnacIPRpQjidyiYkggnp26oXoMC1KM2svYmGAPYr1G8CDQcqLl3JYkAVU6VeHsnBpbwLC4TttQkdJs8iNFohy9cUjcfwBPbDGs6TJghbuqqUl81uBe9e8qQKBgQDZm8T2KB34J7HAc5A+vqkmAo7mQLZg51OrzB1KnDU86pSAf0o3eSvfDUT6dpU9fRuZ1XYnbPnpoJwjFH3m4u9gqKF3PtVYfZyJrEqYwmhB9z6vd+dcsUlXM0fi37bGZkKBD0JGGt5OljM1qJG15x/LYfC/nwOmqWoOhNPCst2Z7w=="; |
| | | |
| | | private final String provider = "i-go-odrd-testing"; |
| | | |
| | | private final static String key = "AIzaSyCG6PsfkaCEc94VK2vIAZk1YYKvOS_Ewts"; |
| | | |
| | | // private final String SERVICE_ACCOUNT = "odrd-fleetengine-ondemandadmin@i-go-gcp.iam.gserviceaccount.com"; |
| | | // |
| | | // private final String DRIVER_ACCOUNT = "odrd-fleetengine-driversdkuser@i-go-gcp.iam.gserviceaccount.com"; |
| | |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取jwt token |
| | | * |
| | | * @param type 0=服务端,1=乘客,2=司机 |
| | | * @return |
| | | */ |
| | | public Map<String, Object> fleetEngineAuth(int type, String id) { |
| | | public Map<String, Object> fleetEngineAuth(int type, String id){ |
| | | try { |
| | | //谷歌云服务器使用这部分代码 |
| | | // AuthTokenMinter minter = AuthTokenMinter.builder() |
| | |
| | | |
| | | String jwt = ""; |
| | | Long expirationTimestamp = 0L; |
| | | if (0 == type) { |
| | | if(0 == type){ |
| | | FleetEngineToken serverToken = minter.getServerToken(); |
| | | jwt = serverToken.jwt(); |
| | | expirationTimestamp = serverToken.expirationTimestamp().getTime(); |
| | | } |
| | | if (1 == type) { |
| | | if(1 == type){ |
| | | FleetEngineToken consumerToken = minter.getConsumerToken(TripClaims.create(id)); |
| | | jwt = consumerToken.jwt(); |
| | | expirationTimestamp = consumerToken.expirationTimestamp().getTime(); |
| | | } |
| | | if (2 == type) { |
| | | if(2 == type){ |
| | | FleetEngineToken driverToken = minter.getDriverToken(VehicleClaims.create(id)); |
| | | jwt = driverToken.jwt(); |
| | | expirationTimestamp = driverToken.expirationTimestamp().getTime(); |
| | |
| | | } |
| | | |
| | | |
| | | public String getToken() { |
| | | |
| | | public String getToken(){ |
| | | String token_json = redisUtil.getValue("google_token"); |
| | | String google_token = ""; |
| | | if (!StringUtils.hasLength(token_json)) { |
| | | if(!StringUtils.hasLength(token_json)){ |
| | | Map<String, Object> map = fleetEngineAuth(0, null); |
| | | redisUtil.setStrValue("google_token", JSON.toJSONString(map)); |
| | | google_token = map.get("token").toString(); |
| | | } else { |
| | | }else{ |
| | | JSONObject jsonObject1 = JSON.parseObject(token_json); |
| | | Long expirationTimestamp = jsonObject1.getLong("expirationTimestamp"); |
| | | google_token = jsonObject1.getString("token"); |
| | | if ((expirationTimestamp - 10000L) <= System.currentTimeMillis()) { |
| | | if((expirationTimestamp - 10000L) <= System.currentTimeMillis()){ |
| | | Map<String, Object> map = fleetEngineAuth(0, null); |
| | | redisUtil.setStrValue("google_token", JSON.toJSONString(map)); |
| | | google_token = map.get("token").toString(); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 添加车辆 |
| | | * |
| | | * @param maximumCapacity 这辆车可以搭载的乘客总数 |
| | | * @param licensePlate 车牌号 |
| | | * @param id 车辆id |
| | | * @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<>(); |
| | |
| | | logger.info("创建车辆结果:{}", response.body()); |
| | | JSONObject jsonObject = JSON.parseObject(response.body().replaceAll("@type", "type")); |
| | | JSONObject error = jsonObject.getJSONObject("error"); |
| | | if (null != error) { |
| | | if(null != error){ |
| | | Integer code = error.getInteger("code"); |
| | | if (code == 401) { |
| | | if(code == 401){ |
| | | String status = error.getString("status"); |
| | | if (StringUtils.hasLength(status) && status.equals("UNAUTHENTICATED")) { |
| | | if(StringUtils.hasLength(status) && status.equals("UNAUTHENTICATED")){ |
| | | redisUtil.remove("google_token"); |
| | | return createVehicles(maximumCapacity, licensePlate, id); |
| | | } |
| | | String reason = error.getJSONArray("details").getJSONObject(0).getString("reason"); |
| | | if (reason.equals("ACCESS_TOKEN_EXPIRED")) { |
| | | if(reason.equals("ACCESS_TOKEN_EXPIRED")){ |
| | | redisUtil.remove("google_token"); |
| | | 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(); |
| | | } |
| | | |
| | | /** |
| | | * 上报google可结算订单 |
| | | * |
| | | * @param tripId 行程id |
| | | * @return |
| | | */ |
| | | public boolean reportBillableEvent(String tripId) throws Exception { |
| | | String billableEventId = UUIDUtil.getRandomCode(); |
| | | String url = "https://mobilitybilling.googleapis.com/v1:reportBillableEvent?regionCode=GH&key=" + key + "&billableEventId=" + billableEventId; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Authorization", "Bearer " + getToken()); |
| | | headers.put("Content-Type", "application/json"); |
| | | post.addHeaders(headers); |
| | | JSONObject body = new JSONObject(); |
| | | body.put("related_ids", "[\"" + tripId + "\"]"); |
| | | post.body(body.toJSONString()); |
| | | |
| | | |
| | | //上线客户测试和上线运营开放 |
| | | // HttpResponse response = post.execute(); |
| | | // if(200 != response.getStatus()){ |
| | | // logger.error(response.body()); |
| | | // throw new Exception(response.body()); |
| | | // } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改车辆信息 |
| | | * |
| | | * @param maximumCapacity |
| | | * @param licensePlate |
| | | * @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)) { |
| | | if(StringUtils.hasLength(vehicleState)){ |
| | | sb.add("vehicleState"); |
| | | } |
| | | if (null != maximumCapacity) { |
| | | if(null != maximumCapacity){ |
| | | sb.add("maximumCapacity"); |
| | | } |
| | | if (StringUtils.hasLength(licensePlate)) { |
| | | if(StringUtils.hasLength(licensePlate)){ |
| | | sb.add("licensePlate"); |
| | | } |
| | | String collect = sb.stream().collect(Collectors.joining(",")); |
| | |
| | | * OFFLINE 车辆不接受新行程。注意:在完成分配给车辆的行程时,车辆仍可继续在此状态下运行。 |
| | | * ONLINE 车辆正在接受新行程。 |
| | | */ |
| | | if (StringUtils.hasLength(vehicleState)) { |
| | | if(StringUtils.hasLength(vehicleState)){ |
| | | body.put("vehicleState", vehicleState); |
| | | } |
| | | if (null != maximumCapacity) { |
| | | if(null != maximumCapacity){ |
| | | body.put("maximumCapacity", maximumCapacity); |
| | | } |
| | | if (StringUtils.hasLength(licensePlate)) { |
| | | if(StringUtils.hasLength(licensePlate)){ |
| | | JSONObject licensePlate1 = new JSONObject(); |
| | | licensePlate1.put("countryCode", "GH"); |
| | | licensePlate1.put("lastCharacter", getLastNumber(licensePlate)); |
| | |
| | | logger.info("修改车辆信息结果:{}", response.body()); |
| | | JSONObject jsonObject = JSON.parseObject(response.body().replaceAll("@type", "type")); |
| | | JSONObject error = jsonObject.getJSONObject("error"); |
| | | if (null != error) { |
| | | if(null != error){ |
| | | Integer code = error.getInteger("code"); |
| | | if (code == 401) { |
| | | if(code == 401){ |
| | | String status = error.getString("status"); |
| | | if (StringUtils.hasLength(status) && status.equals("UNAUTHENTICATED")) { |
| | | if(StringUtils.hasLength(status) && status.equals("UNAUTHENTICATED")){ |
| | | redisUtil.remove("google_token"); |
| | | return updateVehicles(vehicleState, maximumCapacity, licensePlate, id); |
| | | } |
| | | String reason = error.getJSONArray("details").getJSONObject(0).getString("reason"); |
| | | if (reason.equals("ACCESS_TOKEN_EXPIRED")) { |
| | | if(reason.equals("ACCESS_TOKEN_EXPIRED")){ |
| | | redisUtil.remove("google_token"); |
| | | 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<>(); |
| | |
| | | logger.info("查询车辆结果:{}", response.body()); |
| | | JSONObject jsonObject = JSON.parseObject(response.body().replaceAll("@type", "type")); |
| | | JSONObject error = jsonObject.getJSONObject("error"); |
| | | if (null != error) { |
| | | if(null != error){ |
| | | Integer code = error.getInteger("code"); |
| | | if (code == 404) { |
| | | if(code == 404){ |
| | | return ""; |
| | | } |
| | | if (code == 401) { |
| | | if(code == 401){ |
| | | String status = error.getString("status"); |
| | | if (StringUtils.hasLength(status) && status.equals("UNAUTHENTICATED")) { |
| | | if(StringUtils.hasLength(status) && status.equals("UNAUTHENTICATED")){ |
| | | redisUtil.remove("google_token"); |
| | | return getVehicles(id); |
| | | } |
| | | String reason = error.getJSONArray("details").getJSONObject(0).getString("reason"); |
| | | if (reason.equals("ACCESS_TOKEN_EXPIRED")) { |
| | | if(reason.equals("ACCESS_TOKEN_EXPIRED")){ |
| | | redisUtil.remove("google_token"); |
| | | return getVehicles(id); |
| | | } |
| | | } |
| | | throw new Exception(response.body()); |
| | | log.error("查询车辆信息异常: id={}, body={}", id, response.body()); |
| | | return null; |
| | | } |
| | | /** |
| | | * 返回结果 |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取最后一个数字 |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | private String getLastNumber(String str) { |
| | | private String getLastNumber(String str){ |
| | | for (int i = str.length(); i > 0; i--) { |
| | | char c = str.charAt(i - 1); |
| | | if (String.valueOf(c).matches("\\d")) { |
| | | if(String.valueOf(c).matches("\\d")){ |
| | | return str.substring(i - 1, i); |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 创建新的行程 |
| | | * |
| | | * @param vehicleId 车辆id |
| | | * @param vehicleId 车辆id |
| | | * @param numberOfPassengers 人数 |
| | | * @param tripId 订单id |
| | | * @param start_lat 起点纬度 |
| | | * @param start_lng 起点经度 |
| | | * @param end_lat 终点纬度 |
| | | * @param end_lng 终点经度 |
| | | * @param tripId 订单id |
| | | * @param start_lat 起点纬度 |
| | | * @param start_lng 起点经度 |
| | | * @param end_lat 终点纬度 |
| | | * @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<>(); |
| | |
| | | post.addHeaders(headers); |
| | | |
| | | JSONObject body = new JSONObject(); |
| | | if (StringUtils.hasLength(vehicleId)) { |
| | | if(StringUtils.hasLength(vehicleId)){ |
| | | body.put("vehicleId", vehicleId); |
| | | } |
| | | body.put("tripStatus", "NEW"); |
| | |
| | | logger.info("创建行程结果:{}", response.body()); |
| | | JSONObject jsonObject = JSON.parseObject(response.body().replaceAll("@type", "type")); |
| | | JSONObject error = jsonObject.getJSONObject("error"); |
| | | if (null != error) { |
| | | if(null != error){ |
| | | Integer code = error.getInteger("code"); |
| | | if (code == 401) { |
| | | if(code == 401){ |
| | | String status = error.getString("status"); |
| | | if (StringUtils.hasLength(status) && status.equals("UNAUTHENTICATED")) { |
| | | if(StringUtils.hasLength(status) && status.equals("UNAUTHENTICATED")){ |
| | | redisUtil.remove("google_token"); |
| | | return createTrip(vehicleId, numberOfPassengers, tripId, start_lat, start_lng, end_lat, end_lng); |
| | | } |
| | | String reason = error.getJSONArray("details").getJSONObject(0).getString("reason"); |
| | | if (reason.equals("ACCESS_TOKEN_EXPIRED")) { |
| | | if(reason.equals("ACCESS_TOKEN_EXPIRED")){ |
| | | redisUtil.remove("google_token"); |
| | | 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 tripStatus 行程状态 |
| | | * @param vehicleId 车辆id |
| | | * @param tripStatus 行程状态 |
| | | * @param vehicleId 车辆id |
| | | * @param numberOfPassengers 人数 |
| | | * @param tripId 订单id |
| | | * @param start_lat 起点纬度 |
| | | * @param start_lng 起点经度 |
| | | * @param end_lat 终点纬度 |
| | | * @param end_lng 终点经度 |
| | | * @param tripId 订单id |
| | | * @param start_lat 起点纬度 |
| | | * @param start_lng 起点经度 |
| | | * @param end_lat 终点纬度 |
| | | * @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)) { |
| | | if(StringUtils.hasLength(vehicleId)){ |
| | | sb.add("vehicleId"); |
| | | } |
| | | if (StringUtils.hasLength(tripStatus)) { |
| | | if(StringUtils.hasLength(tripStatus)){ |
| | | sb.add("tripStatus"); |
| | | } |
| | | if (null != numberOfPassengers) { |
| | | if(null != numberOfPassengers){ |
| | | sb.add("numberOfPassengers"); |
| | | } |
| | | if (StringUtils.hasLength(start_lat) && StringUtils.hasLength(start_lng)) { |
| | | if(StringUtils.hasLength(start_lat) && StringUtils.hasLength(start_lng)){ |
| | | sb.add("pickupPoint"); |
| | | } |
| | | |
| | | if (StringUtils.hasLength(end_lat) && StringUtils.hasLength(end_lng)) { |
| | | if(StringUtils.hasLength(end_lat) && StringUtils.hasLength(end_lng)){ |
| | | sb.add("dropoffPoint"); |
| | | } |
| | | String collect = sb.stream().collect(Collectors.joining(",")); |
| | |
| | | put.addHeaders(headers); |
| | | |
| | | JSONObject body = new JSONObject(); |
| | | if (StringUtils.hasLength(vehicleId)) { |
| | | if(StringUtils.hasLength(vehicleId)){ |
| | | body.put("vehicleId", vehicleId); |
| | | } |
| | | /** |
| | |
| | | * COMPLETE 乘客已下车,行程已完成。 |
| | | * CANCELED 在司机、乘客或拼车服务提供商取车之前,行程被取消。 |
| | | */ |
| | | if (StringUtils.hasLength(tripStatus)) { |
| | | if(StringUtils.hasLength(tripStatus)){ |
| | | body.put("tripStatus", tripStatus); |
| | | } |
| | | if (null != numberOfPassengers) { |
| | | if(null != numberOfPassengers){ |
| | | body.put("numberOfPassengers", numberOfPassengers); |
| | | } |
| | | if (StringUtils.hasLength(start_lat) && StringUtils.hasLength(start_lng)) { |
| | | if(StringUtils.hasLength(start_lat) && StringUtils.hasLength(start_lng)){ |
| | | JSONObject pickupPoint = new JSONObject(); |
| | | JSONObject point = new JSONObject(); |
| | | point.put("latitude", start_lat); |
| | |
| | | body.put("pickupPoint", pickupPoint); |
| | | } |
| | | |
| | | if (StringUtils.hasLength(end_lat) && StringUtils.hasLength(end_lng)) { |
| | | if(StringUtils.hasLength(end_lat) && StringUtils.hasLength(end_lng)){ |
| | | JSONObject dropoffPoint = new JSONObject(); |
| | | JSONObject end_point = new JSONObject(); |
| | | end_point.put("latitude", end_lat); |
| | |
| | | logger.info("修改行程结果:{}", response.body()); |
| | | JSONObject jsonObject = JSON.parseObject(response.body().replaceAll("@type", "type")); |
| | | JSONObject error = jsonObject.getJSONObject("error"); |
| | | if (null != error) { |
| | | if(null != error){ |
| | | Integer code = error.getInteger("code"); |
| | | if (code == 401) { |
| | | if(code == 401){ |
| | | String status = error.getString("status"); |
| | | if (StringUtils.hasLength(status) && status.equals("UNAUTHENTICATED")) { |
| | | if(StringUtils.hasLength(status) && status.equals("UNAUTHENTICATED")){ |
| | | redisUtil.remove("google_token"); |
| | | return updateTrip(tripStatus, vehicleId, numberOfPassengers, tripId, start_lat, start_lng, end_lat, end_lng); |
| | | } |
| | | String reason = error.getJSONArray("details").getJSONObject(0).getString("reason"); |
| | | if (reason.equals("ACCESS_TOKEN_EXPIRED")) { |
| | | if(reason.equals("ACCESS_TOKEN_EXPIRED")){ |
| | | redisUtil.remove("google_token"); |
| | | 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<>(); |
| | |
| | | logger.info("查询行程结果:{}", response.body()); |
| | | JSONObject jsonObject = JSON.parseObject(response.body().replaceAll("@type", "type")); |
| | | JSONObject error = jsonObject.getJSONObject("error"); |
| | | if (null != error) { |
| | | if(null != error){ |
| | | Integer code = error.getInteger("code"); |
| | | if (code == 404) { |
| | | if(code == 404){ |
| | | return ""; |
| | | } |
| | | if (code == 401) { |
| | | if(code == 401){ |
| | | String status = error.getString("status"); |
| | | if (StringUtils.hasLength(status) && status.equals("UNAUTHENTICATED")) { |
| | | if(StringUtils.hasLength(status) && status.equals("UNAUTHENTICATED")){ |
| | | redisUtil.remove("google_token"); |
| | | return getTrip(tripId); |
| | | } |
| | | String reason = error.getJSONArray("details").getJSONObject(0).getString("reason"); |
| | | if (reason.equals("ACCESS_TOKEN_EXPIRED")) { |
| | | if(reason.equals("ACCESS_TOKEN_EXPIRED")){ |
| | | redisUtil.remove("google_token"); |
| | | return getTrip(tripId); |
| | | } |
| | | } |
| | | throw new Exception(response.body()); |
| | | logger.error("获取行程异常: tripId={} body={}", tripId, response.body()); |
| | | return null; |
| | | } |
| | | /** |
| | | * 返回结果 |
| | |
| | | |
| | | return response.body(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 上报google可结算订单 |
| | | * @param tripId 行程id |
| | | * @return |
| | | */ |
| | | 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); |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Authorization", "Bearer " + getToken()); |
| | | headers.put("Content-Type", "application/json"); |
| | | 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("google地图上报结算 tripId:{} 异常:{}", tripId,response.body()); |
| | | // return false; |
| | | // } |
| | | return true; |
| | | } |
| | | |
| | | } |
| | |
| | | <#button name="修改" icon="fa-edit" clickFun="SettlementAllocation.setSettlementAllocation()"/> |
| | | <div class="form-group"> |
| | | <input type="radio" name="type" value="1" ${null != item && item.type == '1' ? 'checked' : ''}> |
| | | 每天超过 <input type="number" min="1" max="31"class="date" value="${null != item && item.type == '1' ? item.maxPrice : ''}" style="background-color: #FFFFFF;background-image: none;border: 1px solid #e5e6e7;border-radius: 1px;color: inherit;padding: 6px 12px;"/> 必须结算 |
| | | 每天 超过 <input type="number" class="date" value="${null != item && item.type == '1' ? item.maxPrice : ''}" style="background-color: #FFFFFF;background-image: none;border: 1px solid #e5e6e7;border-radius: 1px;color: inherit;padding: 6px 12px;"/> 必须结算 |
| | | </div> |
| | | <div class="form-group"> |
| | | <input type="radio" name="type" value="3" ${null != item && item.type == '3' ? 'checked' : ''}> 每月 |
| | | 每月<input type="number" min="1" max="31" class="date" value="${null != item && item.type == '3' ? item.day : ''}" style="background-color: #FFFFFF;background-image: none;border: 1px solid #e5e6e7;border-radius: 1px;color: inherit;padding: 6px 12px;"/> 号可结算 |
| | | 每月 每月<input type="number" min="1" max="31" class="date" value="${null != item && item.type == '3' ? item.day : ''}" style="background-color: #FFFFFF;background-image: none;border: 1px solid #e5e6e7;border-radius: 1px;color: inherit;padding: 6px 12px;"/> 号可结算 |
| | | </div> |
| | | <div class="form-group"> |
| | | <input type="radio" name="type" value="2" ${null != item && item.type == '2' ? 'checked' : ''}> 每周 |
| | | 每周 <input type="number" min="1" max="7" class="date" value="${null != item && item.type == '2' ? item.day : ''}" style="background-color: #FFFFFF;background-image: none;border: 1px solid #e5e6e7;border-radius: 1px;color: inherit;padding: 6px 12px;"/> (几)可结算 |
| | | 每周 每周<input type="number" min="1" max="7" class="date" value="${null != item && item.type == '2' ? item.day : ''}" style="background-color: #FFFFFF;background-image: none;border: 1px solid #e5e6e7;border-radius: 1px;color: inherit;padding: 6px 12px;"/> (几)可结算 |
| | | </div> |
| | | <div class="form-group"> |
| | | 周/月日上限超过 <input type="number" min="1" max="31" id="maxPrice" value="${null != item && item.type != '1' ? item.maxPrice : ''}" style="background-color: #FFFFFF;background-image: none;border: 1px solid #e5e6e7;border-radius: 1px;color: inherit;padding: 6px 12px;"/> 必须结算 |
| | | 周/月 日上限超过 <input type="number" id="maxPrice" value="${null != item && item.type != '1' ? item.maxPrice : ''}" style="background-color: #FFFFFF;background-image: none;border: 1px solid #e5e6e7;border-radius: 1px;color: inherit;padding: 6px 12px;"/> 必须结算 |
| | | </div> |
| | | </div> |
| | | <div class="row"> |
| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.google.api.client.http.UrlEncodedParser; |
| | | import com.stylefeng.guns.core.util.MD5Util; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.CharteredCar.server.IOrderCharteredCarService; |
| | | import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; |
| | |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | String format = String.format("payType=%s&orderId=%s&orderType=%s", payType, orderId, orderType); |
| | | String key = MD5Util.encrypt(format); |
| | | String value = redisUtil.getValue(key); |
| | | if(ToolUtil.isNotEmpty(value) && (System.currentTimeMillis() - Long.valueOf(value)) >= 1000){ |
| | | return ResultUtil.error(language == 1 ? "请勿重复操作" : language == 2 ? "Don't repeat the operation" : "Ne répétez pas l’opération"); |
| | | } |
| | | redisUtil.setStrValue(key, System.currentTimeMillis() + "", 5); |
| | | |
| | | switch (orderType){ |
| | | case 1: |
| | | return orderPrivateCarService.payPrivateCarOrder(payType, bankCardId, orderId, couponId, redDeduction, type, language); |
| | |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.util.StringUtils; |
| | |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | //创建行程数据 |
| | | fleetEngineUtil.createTrip(vehicleId, 1, orderLogistics.getTripId(), |
| | | boolean createTrip = fleetEngineUtil.createTrip(vehicleId, 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | if(!createTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(vehicleId, 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | if(createTrip){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public ResultUtil payLogisticsOrder(Integer payType, Integer bankCardId, Integer orderId,Integer couponId, Integer redDeduction, Integer type, Integer language) throws Exception { |
| | | OrderLogistics orderLogistics = this.selectById(orderId); |
| | | if(orderLogistics.getState() != 7){ |
| | | if(orderLogistics.getState() == 8 || orderLogistics.getState() == 9){ |
| | | return ResultUtil.error(language == 1 ? "订单已完成支付,不允许重复支付" : language == 2 ? "The order has been paid, recurring payments is not allowed." : "La commande a été payée, les paiements récurrents ne sont pas autorisés.", ""); |
| | | } |
| | | if(orderLogistics.getState() != 7){ |
| | | return ResultUtil.error(language == 1 ? "订单不在待支付状态,不允许支付" : language == 2 ? "The order is no longer with Pending Payment, making payments is not allowed." : "La commande n’est plus en attente de paiement, il n’est pas permis d’effectuer des paiements.", ""); |
| | | } |
| | | Integer uid = orderLogistics.getUserId(); |
| | | BigDecimal orderMoney = new BigDecimal(orderLogistics.getOrderMoney()); |
| | |
| | | //计算优惠券 |
| | | UserCouponRecord userCouponRecord = null; |
| | | if(null != couponId){ |
| | | //TODO 待翻译 |
| | | if(null != redDeduction && 1 == redDeduction){ |
| | | return ResultUtil.error(language == 1 ? "优惠券和红包不能同时使用" : language == 2 ? "Coupons and lucky-promo cannot be used at the same time." : "Les coupons et les bonus ne peuvent pas être utilisés en même temps", ""); |
| | | } |
| | |
| | | |
| | | |
| | | language = userInfo.getLanguage(); |
| | | String payTypeChinese = ""; |
| | | String payTypeEnglish = ""; |
| | | String payTypeFrench = ""; |
| | | if(orderLogistics.getPayType() == 3){ |
| | | payTypeChinese = "余额支付"; |
| | | payTypeEnglish = "I-GO Wallet"; |
| | | payTypeFrench = "Portefeuille I-GO"; |
| | | } |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/receiptLogistics.html"; |
| | |
| | | Element xj_chinese = document.getElementById("xj_chinese"); |
| | | xj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_chinese = document.getElementById("pay_type_chinese"); |
| | | pay_type_chinese.text(payTypeChinese); |
| | | pay_type_chinese.text("余额支付"); |
| | | Element pay_money_chinese = document.getElementById("pay_money_chinese"); |
| | | pay_money_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element dispute_chinese = document.getElementById("dispute_chinese"); |
| | |
| | | Element xj_english = document.getElementById("xj_english"); |
| | | xj_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_english = document.getElementById("pay_type_english"); |
| | | pay_type_english.text(payTypeEnglish); |
| | | pay_type_english.text("I-GO Wallet"); |
| | | Element pay_money_english = document.getElementById("pay_money_english"); |
| | | pay_money_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element dispute_english = document.getElementById("dispute_english"); |
| | |
| | | Element xj_french = document.getElementById("xj_french"); |
| | | xj_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_french = document.getElementById("pay_type_french"); |
| | | pay_type_french.text(payTypeFrench); |
| | | pay_type_french.text("Portefeuille I-GO"); |
| | | Element pay_money_french = document.getElementById("pay_money_french"); |
| | | pay_money_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element dispute_french = document.getElementById("dispute_french"); |
| | |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | }else{ |
| | | fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | "Vous avez payé la commande de livraison avec succès, merci d’utiliser I-GO", uid, 1); |
| | | |
| | | language = userInfo.getLanguage(); |
| | | String payTypeChinese = ""; |
| | | String payTypeEnglish = ""; |
| | | String payTypeFrench = ""; |
| | | if(orderLogistics.getPayType() == 3){ |
| | | payTypeChinese = "现金"; |
| | | payTypeEnglish = "Cash"; |
| | | payTypeFrench = "En espèces"; |
| | | } |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/receiptLogistics.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | |
| | | Element xj_chinese = document.getElementById("xj_chinese"); |
| | | xj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_chinese = document.getElementById("pay_type_chinese"); |
| | | pay_type_chinese.text(payTypeChinese); |
| | | pay_type_chinese.text("现金"); |
| | | Element pay_money_chinese = document.getElementById("pay_money_chinese"); |
| | | pay_money_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element dispute_chinese = document.getElementById("dispute_chinese"); |
| | |
| | | Element xj_english = document.getElementById("xj_english"); |
| | | xj_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_english = document.getElementById("pay_type_english"); |
| | | pay_type_english.text(payTypeEnglish); |
| | | pay_type_english.text("Cash"); |
| | | Element pay_money_english = document.getElementById("pay_money_english"); |
| | | pay_money_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element dispute_english = document.getElementById("dispute_english"); |
| | |
| | | Element xj_french = document.getElementById("xj_french"); |
| | | xj_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_french = document.getElementById("pay_type_french"); |
| | | pay_type_french.text(payTypeFrench); |
| | | pay_type_french.text("En espèces"); |
| | | Element pay_money_french = document.getElementById("pay_money_french"); |
| | | pay_money_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element dispute_french = document.getElementById("dispute_french"); |
| | |
| | | query.setState(2); |
| | | query.setCode(order_id); |
| | | paymentRecordService.updateById(query); |
| | | if(orderLogistics.getIsplatPay()==1){ |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderLogistics.getCompanyId()); |
| | | Double speMoney = company.getSpeMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(speMoney); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机 |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderLogistics.getStartMoney() + orderLogistics.getMileageMoney() + orderLogistics.getWaitMoney() + orderLogistics.getDurationMoney() + orderLogistics.getLongDistanceMoney(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | incomeService.saveData(1, orderLogistics.getCompanyId(), 2, orderLogistics.getId(), 4, d.doubleValue()); |
| | | incomeService.saveData(2, orderLogistics.getDriverId(), 2, orderLogistics.getId(), 4, c.doubleValue()); |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | // TODO: 2020/5/24 这里需要给司机和用户推送订单状态 |
| | | new Thread(new Runnable() { |
| | |
| | | "Vous avez payé la commande de livraison avec succès, merci d’utiliser I-GO", orderLogistics.getUserId(), 1); |
| | | |
| | | language = userInfo.getLanguage(); |
| | | String payTypeChinese = ""; |
| | | String payTypeEnglish = ""; |
| | | String payTypeFrench = ""; |
| | | if(orderLogistics.getPayType() == 1){ |
| | | payTypeChinese = "手机支付"; |
| | | payTypeEnglish = "Mobile money"; |
| | | payTypeFrench = "Argent mobile"; |
| | | } |
| | | if(orderLogistics.getPayType() == 2){ |
| | | payTypeChinese = "银行卡支付"; |
| | | payTypeEnglish = "Bank card"; |
| | | payTypeFrench = "Carte bancaire"; |
| | | } |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/receiptLogistics.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | |
| | | Element xj_chinese = document.getElementById("xj_chinese"); |
| | | xj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_chinese = document.getElementById("pay_type_chinese"); |
| | | pay_type_chinese.text(payTypeChinese); |
| | | pay_type_chinese.text(orderLogistics.getPayType() == 1 ? "手机支付" : (orderLogistics.getPayType() == 2?"银行卡支付":(orderLogistics.getPayType() == 3?"余额支付":"现金支付"))); |
| | | Element pay_money_chinese = document.getElementById("pay_money_chinese"); |
| | | pay_money_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element dispute_chinese = document.getElementById("dispute_chinese"); |
| | |
| | | Element xj_english = document.getElementById("xj_english"); |
| | | xj_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_english = document.getElementById("pay_type_english"); |
| | | pay_type_english.text(payTypeEnglish); |
| | | pay_type_english.text(orderLogistics.getPayType() == 1 ? "Mobile money" :(orderLogistics.getPayType() == 2?"Bank card":(orderLogistics.getPayType() == 3?"I-GO Wallet":"Cash"))); |
| | | Element pay_money_english = document.getElementById("pay_money_english"); |
| | | pay_money_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element dispute_english = document.getElementById("dispute_english"); |
| | |
| | | Element xj_french = document.getElementById("xj_french"); |
| | | xj_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_french = document.getElementById("pay_type_french"); |
| | | pay_type_french.text(payTypeFrench); |
| | | pay_type_french.text(orderLogistics.getPayType() == 1 ? "Argent mobile" : (orderLogistics.getPayType() == 2?"Carte bancaire":(orderLogistics.getPayType() == 3?"Portefeuille I-GO":"En espèces"))); |
| | | Element pay_money_french = document.getElementById("pay_money_french"); |
| | | pay_money_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element dispute_french = document.getElementById("dispute_french"); |
| | |
| | | |
| | | if((orderLogistics.getState() == 10 || orderLogistics.getState() == 12) && null != orderLogistics.getDriverId()){ |
| | | //修改行程信息 |
| | | fleetEngineUtil.updateTrip("CANCELED", null, null, orderLogistics.getTripId(), null, null, null, null); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | } |
| | | log.warn("取消订单:{} {}", System.currentTimeMillis(), orderLogistics.getTrackId()); |
| | | log.warn("取消订单:{} {}", System.currentTimeMillis(), orderLogistics.getTripId()); |
| | | //添加消息 |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功取消包裹订单,谢谢使用!" : language == 2 ? "You've cancelled the delivery order successfully, thank you for using I-GO " |
| | | : "Vous avez annulé la commande de livraison avec succès, merci d’utiliser I-GO", orderLogistics.getUserId(), 1); |
| | |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.util.StringUtils; |
| | |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //创建行程数据 |
| | | fleetEngineUtil.createTrip(vehicleId, 1, orderPrivateCar.getTripId(), |
| | | boolean createTrip = fleetEngineUtil.createTrip(vehicleId, 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(!createTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(vehicleId, 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(createTrip){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | } |
| | | |
| | | }catch (Exception e){ |
| | |
| | | |
| | | //修改行程信息 |
| | | if((orderPrivateCar.getState() == 10 || orderPrivateCar.getState() == 12) && null != orderPrivateCar.getDriverId()){ |
| | | fleetEngineUtil.updateTrip("CANCELED", null, null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | } |
| | | log.warn("取消订单:{} {}", System.currentTimeMillis(), orderPrivateCar.getTrackId()); |
| | | log.warn("取消订单:{} {}", System.currentTimeMillis(), orderPrivateCar.getTripId()); |
| | | //添加消息 |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功取消出行订单,谢谢使用!" : language == 2 ? "You've cancelled the ride order successfully, thank you for using I-GO " : "Vous avez annulé la commande de course avec succès, merci d’utiliser I-GO", orderPrivateCar.getUserId(), 1); |
| | | Map<String, Object> map = new HashMap<>(); |
| | |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public ResultUtil payPrivateCarOrder(Integer payType, Integer bankCardId, Integer orderId, Integer couponId, Integer redDeduction, Integer type, Integer language) throws Exception { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | if(orderPrivateCar.getState() == 8 || orderPrivateCar.getState() == 9){ |
| | |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | }else{ |
| | | fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | import com.google.fleetengine.auth.token.VehicleClaims; |
| | | import com.google.fleetengine.auth.token.factory.signer.*; |
| | | import com.stylefeng.guns.modular.system.util.RedisUtil; |
| | | import com.stylefeng.guns.modular.system.util.UUIDUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | static Logger logger = LoggerFactory.getLogger(FleetEngineUtil.class); |
| | | |
| | | private final String SERVICE_ACCOUNT = "odrd-fleetengine-ondemandadmin@i-go-odrd-testing.iam.gserviceaccount.com"; |
| | | |
| | | |
| | | private final String DRIVER_ACCOUNT = "odrd-fleetengine-driversdkuser@i-go-odrd-testing.iam.gserviceaccount.com"; |
| | | |
| | | |
| | | private final String CONSUMER_ACCOUNT = "odrd-fleetengine-consumersdkus@i-go-odrd-testing.iam.gserviceaccount.com"; |
| | | |
| | | |
| | | private final String serverPrivateKeyId = "254e18eefa9fdcca64d5899cdcd793d466c47c7d"; |
| | | |
| | | |
| | | private final String serverPrivateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCfbNAWnukqLKIxItqmSABxsH5glySEHJ2gfL5KsRF0M02e0Z8/KNKZkoh7I6bOMt1fEtttFaWOeq70IdI2WAd5wVazL3upvl5FW4P08ly33LklfGyLljlJ7ChPny9x6OjAaiS0yD9fh7NWti7rZKU7gzcGL8HddNYXgXV5OajvoG3TGdu52WTxce9AUzU6gLPboz/RbGqrdrmgVJVb0EPlhTJf/NSsaiW4NoL8SEzf/pJGYBmqJs97mXwCHTY4avaC+CP/zz9yS8AQEJlApbVT6lSOhYoR0hNOBj5B886EZOssjubO6hQaiwRnGrV2RdpHynqA1iekfGpUGEtWTsqjAgMBAAECggEALyPbMd0iP8y71sCiG4nty7Au5ju62e+mMkbAc9CAwzXKTVxZdLEK+MsJ3TNxBsami47FYC+G6SbgpaJ8iIImD7v5+XjgXZRDRsnlLmAdx2YWPv3YELxGS1PvpX+B5XJDpGWeXfBaQNKc1lZ/cC4t53eIpSUo82UxSvkGNea1S8lR6vIByhNyCQOvLG4yqaxUy0hZi0kge37XrjYMGS+BivBBnDiVlBPLBVbrNBxOf31Lzz+XX0iwXX7Zl2jN759oe0xQyuIGWUSj8xBDIF8nNaJrla7rWVml3sZJh6/3r1Acj0mhZtE0ZMu5hiPGiIXgb1ng30j3dMP4yVPhXrpAtQKBgQDaU01VnHsnHxc0DQHE2vEOPGmPxVS0/JAssePAEUmKEueUogGef91YY+Vm/ItbhLwGjbytnXxe88zRAdB1u07efZ83ey93TrGl2CJUzLHIcgb+Q1tT642rqlfl+q8ep86hcZ+63pDiIPt2Z+HkbKIR0SWf5LIH4flquQOTQufXXQKBgQC674qDsjOJepZjMMN6PkVMcWBYDNmXHnqa5Oto0rZM745UulbXqEFGuBOsXPU7O33Kfz1vbtoluubKZi5B6cFNnPypE2SCfvdObHq4FuTuKPV6lN93SyhZchmSEXEs0PU4cGDRt+RRqQcjft1Wigiy4Y1y1SInCtcaP1hLejEJ/wKBgFAhvwKrGnBzctrB42JTUaJ9/eis7rg28tvUttjp/2nUIndlNt7r41vr3mj8TFHc1/43y4aVhO584THdTpvHkd0LkoKUjglmMsHCIGercZ02bOap5j1Y+XiGXxij995yjN6oi43U3qyAmosM+dYTITEU6JBVKhrGj/rhyTQlnF5pAoGBAKFGmo0mR/pbDbYD0xH6+VSLGCC+7VbIT+SkjUjBSdA0eOo2XUfvfGmj1C1HgbcZi1wRzJH/5CrbBdQmtc/d+QyZ3Q2NkpBXM8uwIWwDLH0gTzDzkZvc9rG8k70GWUrd+EI6Cf3FFjExj9wazqCjs/+IQr2Ijc97NbsKXYW4pOhHAoGAKf5wYk+cn0cVTsyAom0UbGD5Uijqh5732MeqFYs2Rcwx0OErJZo68COSFFF40hJmmIKn7p3qycIyd1FcYlXN1l4s8mEWTGTInRE0OlBU0+jLtIV9pwNgffpbPYcrWZU6s6YVeJ2nDwl+aD+4QvN0rkPTfho9kjgeyF3PW0I2u4E="; |
| | | |
| | | |
| | | private final String driverPrivateKeyId = "859e85fb3aa4d18b4afaac3e24e8f65700da5cc9"; |
| | | |
| | | |
| | | private final String driverPrivateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCmzL1BqSH+Zh9Fct5mXqe5sYOMTnJtOJhwKXnjjo2tNPXv4alzUHz8Vbj6nMar5u5IuKRZMeRBlhoRSFrLm+J1+sfvpH8N4wsnG7hDANknqWzdsk9a68qMHxNQF3hFzs9+KKrR1LAG8e9ytMfliN0kX+xls4uPZDPu1Q39K6V9KXrH/GrMA56i3TtWi7Hmakt5YTELeGjhx4nGrfuQLFFovs1Z9uJtf7E8R95+65StrOAmbJNf7VciEqwBpWYlU5VeyLXMg/oHwnTv2cjdcFozyDrlUHbDmtTiVeBBsYFVLyAsDGfl1p6eiVTiBBuo56YSYLWfaLgYvTyEcZ9jBQsfAgMBAAECggEAQzbTuObX3PT3+vtb5XKVMf33XY2rDJo2y1PbWzhxnO9vf3e22dIAW4qLnOmaIWFQeht1lr/FFCzRWk+Gzu+FJTemY8osrMLmFp9T9CQeXZ4nUXruAVxs5WQMW0Tp4W+CK3tlwmJrgJDzhYyV1Mf/HQ5Oa3kbbu/ZAY/3MCLrb/ClJQvD2rZSDdzAkNMQm8P2hsE71+rH7mI2hHrSCHl2OIp2A64QT8HjtyRc5yHZtTp6ZST1ge9SSIsT0ZfmXKtKF7yGEIPtKNU+oLrGyK5P30xBWJ/bwb3PEz2MZcPvz31+B2+UvZMm7OTkqfcRwEztAf8Ckiuo4im2BRYbVmd9OQKBgQDd0MeLxR+Qtv12bVA0bHtagFEq36THgWG7IM1/1vS4Cl9sveKSOS8A6oKLy624fGE7PKcuTTIzkVA81GXtWBQ9Coq/4TmllQkFTH7pz9C2PNHSCychPwNNV8qUx3lE3d4DOjGKgoVFD4l90AO7lOvmLTSc3pDpr+jSjUH4lqGrbQKBgQDAgXBmpXfCTxwqkBzGwxX+hwJen9qSkCM47qnQ1L4NnXPL6s0EN6rQ3FnFemGIzBUGJ2tajntkKlUu5DzsQeoBGu/SaSwgqD+1UQDcUyo+retmqZ+QYbpeyd3l53bLJJuJNsfak0X76Ft6hrm4julx6RGlmboQyx4kZWbhx4YNOwKBgEG9/2aNpi1eDwFqpLrk7CqGnYf3gP8gebbcoguhyiZB7MZuARkVmbjLyKVmWLa1JpxH/cTbXGWsS/u7d/pAgL8WwMjeGBfbdDD92x+xWEqq/AUlCRPxeSkTPBech3TBzWtndAd5Z8ZwNG/1lyWhnck63L0huhGI8Zh2BXeILaKBAoGAKK3xq69BvGztPc1QV2w4RJ4RER/kl14gI1LDzd52/veL1cabZk3BKfu2eLWg0MCXnMJNvEgpqQQNFiii+yX+phckIKma6pfDRrSEYwqr/azQ9tPXZTJRqOAtpPyhrNHikD9kQjsm6dGzKxQ3QNnqWOjwkrcGi6/wga5v7Dw2hqsCgYEA2T/kSNQ9dqpVBAkfi2J50hqnfFESPjKeirJJZllqhVqsiV0ly8a8Fz8SjGqTzrq+UErko+QmtSlo5h3Uq9Ln+0CwYfrUL+74q2zLHdS0DpY3QsGTEDJXTxCyy9kO26X2UsM3Ez3YUAkdMwdpVz0uVZtinv2735QZOBxoVQV2kQ8="; |
| | | |
| | | |
| | | private final String consumerPrivateKeyId = "40acf82cbd5250de2f5123caff40738bdd403b08"; |
| | | |
| | | |
| | | private final String consumerPrivateKey = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDSwtbSBFgIXna6mWeKFWCK31NXUJH6uGduR1XrODGRedrqrTgr0BdNg8PDo6/zh/T+K0Svor6kgqpwnl9soOdn73oC4Nu+Ad7EiKa38j650jlZdLAr4hR0Ou9Kcnv45x/94auUO8jBz844cu24swLKiPsK9OnX65wVlKRfhhkGFuS/4OI76CmE7NqZDqPOW16o8tBO5TsgPVNkglFAU73fTp0kcHoLauT9QOB0+yZi39mnNXyU+2cL3Ylp5oaQCJpyssDRUqz/EiHa7FxUUgzCadG00+ePf5iYSnZKQRKWoOIawFvcCfcHx8GAl8Nn+79HtVQHB9hLsQ5+jqcdfKPfAgMBAAECggEAE9Ufz912xzrUY1TCKH1Ae3Dub732Lqihmv/9dsfv6ieUURcBvSW0u6eViVhi20DE7hH2QazH0cU18qkEg71UaTRgv9qW8vdMFiRhw9d4zZWZrfBMD6UTlahiEhhZ0B83pHVS5v0FNC+w0SEHe6Tks1hWfz5yrs3N/z3ghdihjC/5i1jeBoHXs1262SMazuwNGHblLApGPG+86taeFtbDI+31TKvZ8nomZHkEVFnARRUoBBcIwowRMqNfwlpcJhlz6kDWnoD08kHJ2zzJokozu7Lim+Ugt/MWwUOcA0hgq2QdymZFpkRkDl7tZmJtwTfTirjbGlpnPHVXEc1bWM7ocQKBgQD0LJ8e7JXf6bVFngq0jSJNKK7XDHYg0KhHXMApF59xxi29hdHXWPzgRJ45KkoUJc7MITpIJLXfCmi1XyDMf9m8lIf/oaqhJ7idYi7iAAPOJkdnHbSt0lebyjBWzCQ6OgS4NfF1+LEibTzRqiFs5K8EAyPYAVSTrpWoguoWtTzIGQKBgQDc9/I2PS+91Eb5RvuidTNsDqZJliTJQFlBjlDViFo3+l1N7jDFYwPBR/Tv4TVM5p9Zb+/Lo9X1pjDbm8QriTR4V+4HaLXkcCnmOsdSRInFUW4UIafwLX5ifjgfyaWgdKdn2UP1Lu/1qBN6GU1xjSfBQ6N3UqQiKkNPb7tuPJGqtwKBgQCQ4hU8vTclGMC14VQK1B/BVt1/vuYtDIJ9bZycBWdXlDc52LitpiDOVgjodJ5mHBT77M9vVVERWlTNIfgNP+OL0TptRZlAbJhP0p1s/oNDhFUj6211InVXfH54UkNAxYJdZ6yxynIYsma/JcsVmQ/8Ony/Q/LSempVBfEurjW1qQKBgQCQWPjFLdtOKqnildg0HFPnNvqx/38waPTluk5b76LgBpGFIyCBEVmWnacIPRpQjidyiYkggnp26oXoMC1KM2svYmGAPYr1G8CDQcqLl3JYkAVU6VeHsnBpbwLC4TttQkdJs8iNFohy9cUjcfwBPbDGs6TJghbuqqUl81uBe9e8qQKBgQDZm8T2KB34J7HAc5A+vqkmAo7mQLZg51OrzB1KnDU86pSAf0o3eSvfDUT6dpU9fRuZ1XYnbPnpoJwjFH3m4u9gqKF3PtVYfZyJrEqYwmhB9z6vd+dcsUlXM0fi37bGZkKBD0JGGt5OljM1qJG15x/LYfC/nwOmqWoOhNPCst2Z7w=="; |
| | | |
| | | |
| | | private final String provider = "i-go-odrd-testing"; |
| | | |
| | | private final static String key = "AIzaSyCG6PsfkaCEc94VK2vIAZk1YYKvOS_Ewts"; |
| | | |
| | | // private final String SERVICE_ACCOUNT = "odrd-fleetengine-ondemandadmin@i-go-gcp.iam.gserviceaccount.com"; |
| | | // |
| | | // private final String DRIVER_ACCOUNT = "odrd-fleetengine-driversdkuser@i-go-gcp.iam.gserviceaccount.com"; |
| | |
| | | * @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; |
| | | } |
| | | /** |
| | | * 返回结果 |
| | |
| | | |
| | | return response.body(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 上报google可结算订单 |
| | | * @param tripId 行程id |
| | | * @return |
| | | */ |
| | | 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); |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Authorization", "Bearer " + getToken()); |
| | | headers.put("Content-Type", "application/json"); |
| | | 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("google地图上报结算 tripId:{} 异常:{}", tripId,response.body()); |
| | | // return false; |
| | | // } |
| | | return true; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | private String driverClassName = "com.mysql.cj.jdbc.Driver"; |
| | | |
| | | private Integer initialSize = 2; |
| | | private Integer initialSize = 100; |
| | | |
| | | private Integer minIdle = 1; |
| | | private Integer minIdle = 100; |
| | | |
| | | private Integer maxActive = 20; |
| | | private Integer maxActive = 500; |
| | | |
| | | private Integer maxWait = 60000; |
| | | |