Pu Zhibing
2024-10-21 f08b7e95bc941a72d4a7b7bc64c2086ed53f1565
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ReassignServiceImpl.java
@@ -33,7 +33,9 @@
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -228,7 +230,7 @@
                            text = "Received a new ride order, starting from " + orderPrivateCar.getStartAddress() + ", the whole journey is about " + orderPrivateCar.getEstimatedMileage() + "kilometre";
                            break;
                        case 3:
                            text = "J'ai reçu une nouvelle commande de course, à partir de " + orderPrivateCar.getStartAddress() + ", le trajet complet est d’environ " + orderPrivateCar.getEstimatedMileage() + "kilométrage";
                            text = "Reçu une nouvelle commande de course, à partir de " + orderPrivateCar.getStartAddress() + ", le trajet complet est d’environ " + orderPrivateCar.getEstimatedMileage();
                            break;
            
                    }
@@ -243,14 +245,21 @@
                    new Timer().schedule(new TimerTask() {
                        @Override
                        public void run() {
                            Process process = null;
                            try {
                                process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName);
                            } catch (IOException e) {
                                throw new RuntimeException(e);
                            }
                            if (process != null) {
                                process.destroy();
                                // 使用Runtime执行命令
                                Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName);
                                // 读取命令的输出
                                BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
                                String line;
                                while ((line = reader.readLine()) != null) {
                                    System.out.println(line);
                                }
                                // 等待命令执行完成
                                process.waitFor();
                                // 关闭流
                                reader.close();
                            } catch (IOException | InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    }, 30000);
@@ -422,13 +431,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();
                        }
@@ -479,7 +528,7 @@
                            text = "Received a new delivery order, starting from " + orderLogistics.getStartAddress() + ", the whole journey is about " + orderLogistics.getEstimatedMileage() + "kilometre";
                            break;
                        case 3:
                            text = "J'ai reçu une nouvelle commande de livraison, à partir de " + orderLogistics.getStartAddress() + ", le trajet complet est d’environ " + orderLogistics.getEstimatedMileage() + "kilométrage";
                            text = "Reçu une nouvelle commande de livraison, à partir de " + orderLogistics.getStartAddress() + ", le trajet complet est d’environ " + orderLogistics.getEstimatedMileage();
                            break;
            
                    }
@@ -494,14 +543,21 @@
                    new Timer().schedule(new TimerTask() {
                        @Override
                        public void run() {
                            Process process = null;
                            try {
                                process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName);
                            } catch (IOException e) {
                                throw new RuntimeException(e);
                            }
                            if (process != null) {
                                process.destroy();
                                // 使用Runtime执行命令
                                Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName);
                                // 读取命令的输出
                                BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
                                String line;
                                while ((line = reader.readLine()) != null) {
                                    System.out.println(line);
                                }
                                // 等待命令执行完成
                                process.waitFor();
                                // 关闭流
                                reader.close();
                            } catch (IOException | InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    }, 30000);
@@ -598,13 +654,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, 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();