From 19d2b6427ebed89895b402d5e61ab78f4687b550 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 10 十月 2024 11:31:11 +0800
Subject: [PATCH] 修改bug

---
 DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ReassignServiceImpl.java |   83 ++++++++++++++++++++++++++---------------
 1 files changed, 52 insertions(+), 31 deletions(-)

diff --git a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ReassignServiceImpl.java b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ReassignServiceImpl.java
index 39b20ea..b9713a2 100644
--- a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ReassignServiceImpl.java
+++ b/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.*;
@@ -159,7 +161,7 @@
         reassign.setInsertTime(new Date());
         reassign.setState(2);
         this.insert(reassign);
-
+        String tripId = "";
         //修改改派通知状态
         switch (reassign.getOrderType()){
             case 1:
@@ -168,6 +170,7 @@
                 orderPrivateCar.setState(11);
                 orderPrivateCar.setReassignNotice(2);
                 orderPrivateCarService.updateById(orderPrivateCar);
+                tripId = redisUtil.getValue("trip" + orderPrivateCar.getUserId());
                 break;
             case 2:
                 OrderTaxi orderTaxi = orderTaxiService.selectById(reassign.getOrderId());
@@ -175,6 +178,7 @@
                 orderTaxi.setState(11);
                 orderTaxi.setReassignNotice(2);
                 orderTaxiService.updateById(orderTaxi);
+                tripId = redisUtil.getValue("trip" + orderTaxi.getUserId());
                 break;
             case 4:
                 OrderLogistics orderLogistics = orderLogisticsService.selectById(reassign.getOrderId());
@@ -182,6 +186,7 @@
                 orderLogistics.setState(11);
                 orderLogistics.setReassignNotice(2);
                 orderLogisticsService.updateById(orderLogistics);
+                tripId = redisUtil.getValue("trip" + orderLogistics.getUserId());
                 break;
             case 5:
                 OrderLogistics orderLogistics1 = orderLogisticsService.selectById(reassign.getOrderId());
@@ -189,20 +194,22 @@
                 orderLogistics1.setState(11);
                 orderLogistics1.setReassignNotice(2);
                 orderLogisticsService.updateById(orderLogistics1);
+                tripId = redisUtil.getValue("trip" + orderLogistics1.getUserId());
                 break;
         }
         systemNoticeService.addSystemNotice(2, language == 1 ? "您的改派申请已成功提交,我们会尽快为你处理!" : language == 2 ?
                 "Your request for reassignment was submitted, we shall handle it for you as soon as possible." :
                 "Votre demande de réaffectation a été soumise. Nous la traiterons pour vous dans les plus brefs délais.", uid);
-
+    
+        
         //开始自动完成改派
         switch (reassign.getOrderType()){
             case 1:
                 OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(reassign.getOrderId());
-                Company company = companyCityService.query1(String.valueOf(orderPrivateCar.getStartLon()), String.valueOf(orderPrivateCar.getStartLat()));//获取起点所属分公司
+                Company company = companyCityService.query1(orderPrivateCar.getUserId(), String.valueOf(orderPrivateCar.getStartLon()), String.valueOf(orderPrivateCar.getStartLat()));//获取起点所属分公司
                 PushOrder pushOrder = pushOrderService.querys(1, 1, company.getId()).get(0);
                 //获取空闲司机
-                List<Driver> list = driverService.queryIdleDriver(1, orderPrivateCar.getServerCarModelId(), orderPrivateCar.getStartLon(), orderPrivateCar.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机
+                List<Driver> list = driverService.queryIdleDriver(orderPrivateCar.getUserId(), 1, orderPrivateCar.getServerCarModelId(), orderPrivateCar.getStartLon(), orderPrivateCar.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机
                 System.err.println("【" + orderPrivateCar.getId() + "】空闲司机:" + JSON.toJSONString(list));
                 if(list.size() > 0){
                     String text = "";
@@ -223,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;
             
                     }
@@ -238,14 +245,21 @@
                     new Timer().schedule(new TimerTask() {
                         @Override
                         public void run() {
-                            Process process = null;
                             try {
-                                process = Runtime.getRuntime().exec("rm -rf /usr/local/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);
@@ -265,7 +279,7 @@
                         String value = redisUtil.getValue("DRIVER" + driver1.getId());
                         if(ToolUtil.isNotEmpty(value)) {
                             String[] split = value.split(",");
-                            DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderPrivateCar.getStartLat(), orderPrivateCar.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0]));
+                            DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderPrivateCar.getStartLat(), orderPrivateCar.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0]), tripId);
                             //超时时间
                             long timeOut = System.currentTimeMillis() + (distancematrix.getDuration() * 1000);
                             orderPrivateCar.setEstimateArriveTime(new Date(timeOut));
@@ -438,23 +452,23 @@
                             pushUtil.pushOrderReassign(orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, finalAudioUrl);
                         }
                     }).start();
-        
-        
+    
+                    Integer language2 = userInfoMapper.selectById(orderPrivateCar.getUserId()).getLanguage();
                     systemNoticeService.addSystemNotice(2, language1 == 1 ? "您已成功抢得打车订单,请及时联系客户!" :
                             language1 == 2 ? "You have grabbed the ride order, please contact the client timely."
                                     : "Vous avez saisi la commande de course, veuillez contacter le client en temps opportun.", orderPrivateCar.getDriverId());
-                    systemNoticeService.addSystemNotice(1, language1 == 1 ? "您的订单已指派给" + driver1.getFirstName() + "师傅,请保持电话畅通!" :
-                            language1 == 2 ? "Your order has been assigned to the driver- " + driver1.getFirstName() + ", please keep your line on."
+                    systemNoticeService.addSystemNotice(1, language2 == 1 ? "您的订单已指派给" + driver1.getFirstName() + "师傅,请保持电话畅通!" :
+                            language2 == 2 ? "Your order has been assigned to the driver- " + driver1.getFirstName() + ", please keep your line on."
                                     : "Votre commande a été attribuée au chauffeur- " + driver1.getFirstName() + ", S'il vous plaît, restez en ligne.", orderPrivateCar.getUserId());
         
                 }
                 break;
             case 4:
                 OrderLogistics orderLogistics = orderLogisticsService.selectById(reassign.getOrderId());
-                Company company1 = companyCityService.query1(String.valueOf(orderLogistics.getStartLon()), String.valueOf(orderLogistics.getStartLat()));//获取起点所属分公司
+                Company company1 = companyCityService.query1(orderLogistics.getUserId(), String.valueOf(orderLogistics.getStartLon()), String.valueOf(orderLogistics.getStartLat()));//获取起点所属分公司
                 PushOrder pushOrder1 = pushOrderService.querys(1, 1, company1.getId()).get(0);
                 //获取空闲司机
-                List<Driver> list1 = driverService.queryIdleDriver(orderLogistics.getType(), orderLogistics.getServerCarModelId(), orderLogistics.getStartLon(), orderLogistics.getStartLat(), pushOrder1.getPushDistance(), null);//所有附近空闲司机
+                List<Driver> list1 = driverService.queryIdleDriver(orderLogistics.getUserId(), orderLogistics.getType(), orderLogistics.getServerCarModelId(), orderLogistics.getStartLon(), orderLogistics.getStartLat(), pushOrder1.getPushDistance(), null);//所有附近空闲司机
                 System.err.println("【" + orderLogistics.getId() + "】空闲司机:" + JSON.toJSONString(list1));
                 if(list1.size() > 0){
                     Driver driver1 = list1.get(0);
@@ -474,7 +488,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;
             
                     }
@@ -489,14 +503,21 @@
                     new Timer().schedule(new TimerTask() {
                         @Override
                         public void run() {
-                            Process process = null;
                             try {
-                                process = Runtime.getRuntime().exec("rm -rf /usr/local/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);
@@ -515,7 +536,7 @@
                     String value = redisUtil.getValue("DRIVER" + driver1.getId());
                     if(ToolUtil.isNotEmpty(value)) {
                         String[] split = value.split(",");
-                        DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderLogistics.getStartLat(), orderLogistics.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0]));
+                        DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderLogistics.getStartLat(), orderLogistics.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0]), tripId);
                         //超时时间
                         long timeOut = System.currentTimeMillis() + (distancematrix.getDuration() * 1000);
                         orderLogistics.setEstimateArriveTime(new Date(timeOut));
@@ -615,12 +636,12 @@
                             pushUtil.pushOrderReassign(orderLogistics.getDriverId(), 2, orderLogistics.getId(), 4, finalAudioUrl);
                         }
                     }).start();
-        
+                    Integer language2 = userInfoMapper.selectById(orderLogistics.getUserId()).getLanguage();
                     systemNoticeService.addSystemNotice(2, language1 == 1 ? "您已成功抢得包裹订单,请及时联系客户!" :
                             language1 == 2 ? "You have grabbed the delivery order, please contact the client timely."
                                     : "Vous avez saisi la commande du livraison. Veuillez contacter le client en temps opportun.", orderLogistics.getDriverId());
-                    systemNoticeService.addSystemNotice(1, language1 == 1 ? "您的订单已指派给" + driver1.getFirstName() + "师傅,请保持电话畅通!" :
-                            language1 == 2 ? "Your order has been assigned to the driver- " + driver1.getFirstName() + ", please keep your line on."
+                    systemNoticeService.addSystemNotice(1, language2 == 1 ? "您的订单已指派给" + driver1.getFirstName() + "师傅,请保持电话畅通!" :
+                            language2 == 2 ? "Your order has been assigned to the driver- " + driver1.getFirstName() + ", please keep your line on."
                                     : "Votre commande a été attribuée au chauffeur- " + driver1.getFirstName() + ", S'il vous plaît, restez en ligne.", orderLogistics.getUserId());
         
                 }

--
Gitblit v1.7.1