From f08b7e95bc941a72d4a7b7bc64c2086ed53f1565 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期一, 21 十月 2024 15:48:27 +0800
Subject: [PATCH] 修改2.0 bug

---
 DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java |  106 +++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 87 insertions(+), 19 deletions(-)

diff --git a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
index 77d54f6..2d6aea2 100644
--- a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
+++ b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
@@ -390,13 +390,53 @@
                     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();
             }
@@ -584,11 +624,21 @@
         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 推送状态
@@ -711,12 +761,21 @@
     
         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();
@@ -1067,12 +1126,21 @@
             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("");

--
Gitblit v1.7.1