From 736ab0090700c75af37b8a3456b01609e4e2d329 Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期三, 17 七月 2024 11:09:40 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/2.0' into 2.0

---
 DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java
index a28d5db..bf33bed 100644
--- a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java
+++ b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java
@@ -29,6 +29,7 @@
 import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
 import org.apache.shiro.crypto.hash.Md5Hash;
 import org.apache.shiro.util.ByteSource;
+import org.apache.shiro.util.StringUtils;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
@@ -1102,11 +1103,16 @@
     
         //司机登录,添加谷歌上的车辆信息
         Car car = carService.selectById(driver.getCarId());
-        String vehicles = fleetEngineUtil.getVehicles(driver.getCarId());
+        if(!StringUtils.hasLength(car.getVehicleId())){
+            car.setVehicleId(UUIDUtil.getRandomCode());
+            carService.updateById(car);
+        }
+        String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId());
         if(ToolUtil.isEmpty(vehicles)){
             CarModel carModel = carModelMapper.selectById(car.getCarModelId());
-            fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), driver.getCarId());
+            fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
         }
+        loginWarpper.setVehicleId(car.getVehicleId());
         return ResultUtil.success(loginWarpper);
     }
 
@@ -1191,14 +1197,19 @@
             driverWork.setState(2);
             driverWorkMapper.updateById(driverWork);
             driver.setState(1);
+            
+            if(!StringUtils.hasLength(car.getVehicleId())){
+                car.setVehicleId(UUIDUtil.getRandomCode());
+                carService.updateById(car);
+            }
     
             //司机下班,修改谷歌上的车辆信息
             CarModel carModel = carModelMapper.selectById(car.getCarModelId());
-            String vehicles = fleetEngineUtil.getVehicles(driver.getCarId());
+            String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId());
             if(ToolUtil.isEmpty(vehicles)){
-                fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), driver.getCarId());
+                fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
             }else{
-                fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), driver.getCarId());
+                fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
             }
         }else{
             LoginWarpper loginWarpper = new LoginWarpper();
@@ -1235,13 +1246,18 @@
             driverWorkMapper.insert(driverWork);
             driver.setState(2);
     
+            if(!StringUtils.hasLength(car.getVehicleId())){
+                car.setVehicleId(UUIDUtil.getRandomCode());
+                carService.updateById(car);
+            }
+            
             //司机上班,修改谷歌上的车辆信息
             CarModel carModel = carModelMapper.selectById(car.getCarModelId());
-            String vehicles = fleetEngineUtil.getVehicles(driver.getCarId());
+            String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId());
             if(ToolUtil.isEmpty(vehicles)){
-                fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), driver.getCarId());
+                fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
             }else{
-                fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), driver.getCarId());
+                fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
             }
         }
         this.updateById(driver);

--
Gitblit v1.7.1