From fa0a4b0ac2c4eaf2d289983ae117488ad80511cb Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期五, 11 十月 2024 18:44:24 +0800
Subject: [PATCH] 修改2.0 bug

---
 UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java |  114 +++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 91 insertions(+), 23 deletions(-)

diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
index 151d279..d707105 100644
--- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
+++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
@@ -41,6 +41,8 @@
 import org.jsoup.nodes.Element;
 import org.jsoup.nodes.FormElement;
 import org.jsoup.select.Elements;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpEntity;
@@ -63,6 +65,8 @@
 
 @Service
 public class OrderLogisticsServiceImpl extends ServiceImpl<OrderLogisticsMapper, OrderLogistics> implements IOrderLogisticsService {
+    
+    private Logger log = LoggerFactory.getLogger(OrderLogisticsServiceImpl.class);
 
     @Resource
     private SystemPriceMapper systemPriceMapper;
@@ -596,14 +600,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);
@@ -817,14 +828,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);
@@ -934,14 +952,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);
@@ -1811,7 +1836,50 @@
                 public void run() {
                     pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
                     pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
-                    pushUtil.pushOfflinePayment(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getPayMoney());
+                    Integer language1 = driver.getLanguage();
+                    String text = "";
+                    switch (language1){
+                        case 1:
+                            text = "客户已选择支付现金,因此您必须收款。确定您已收到此订单费用:现金GHS " + orderLogistics.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 " + orderLogistics.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 " + orderLogistics.getPayMoney();
+                            break;
+        
+                    }
+                    String audioUrl = "";
+                    String fileName = "offlinePayment" + orderLogistics.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, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getPayMoney(), audioUrl);
                 }
             }).start();
 
@@ -3136,7 +3204,7 @@
             //修改行程信息
             fleetEngineUtil.updateTrip("CANCELED", null, null, orderLogistics.getTripId(), null, null, null, null);
         }
-        
+        log.warn("取消订单:{}   {}", System.currentTimeMillis(), orderLogistics.getTrackId());
         //添加消息
         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);

--
Gitblit v1.7.1