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 --- UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java | 108 +++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 86 insertions(+), 22 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..443b590 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 @@ -596,14 +596,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 +824,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 +948,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 +1832,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(); -- Gitblit v1.7.1