Pu Zhibing
2024-10-10 19d2b6427ebed89895b402d5e61ab78f4687b550
UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
@@ -426,14 +426,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);
@@ -543,14 +550,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);
@@ -1072,14 +1086,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);
@@ -2382,7 +2403,50 @@
                public void run() {
                    pushUtil.pushOrderState(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1, orderPrivateCar.getState(), 0, "");
                    pushUtil.pushOrderState(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, orderPrivateCar.getState(), 0, "");
                    pushUtil.pushOfflinePayment(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, orderPrivateCar.getPayMoney());
                    Integer language1 = driver.getLanguage();
                    String text = "";
                    switch (language1){
                        case 1:
                            text = "客户已选择支付现金,因此您必须收款。确定您已收到此订单费用:现金GHS " + orderPrivateCar.getPayMoney();
                            break;
                        case 2:
                            text = "The client chose to pay in cash, so you must collect the payment.Confirm if you received the charge for this order: Cash GHS " + orderPrivateCar.getPayMoney();
                            break;
                        case 3:
                            text = "Le client a choisi de payer en espèces, vous devez donc encaisser le paiement.Confirmez si vous avez reçu les frais pour cette commande : Espèces GHS " + orderPrivateCar.getPayMoney();
                            break;
                    }
                    String audioUrl = "";
                    String fileName = "offlinePayment" + orderPrivateCar.getDriverId() + UUIDUtil.getRandomCode(5) + ".mp3";
                    try {
                        audioUrl = TextToSpeechUtil.create(language1 == 1 ? "cmn-CN" : language1 == 2 ? "en-US" : "fr-FR", text, fileName);
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                    //定时任务删除语音文件
                    new Timer().schedule(new TimerTask() {
                        @Override
                        public void run() {
                            try {
                                // 使用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);
                    pushUtil.pushOfflinePayment(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, orderPrivateCar.getPayMoney(), audioUrl);
                }
            }).start();