From a41e23347029bf69a3f59438749658252de81d2e Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期二, 15 十月 2024 09:41:30 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingGunController.java |   31 ++++++++++++++++++++-----------
 1 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingGunController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingGunController.java
index 765d06c..1d083c1 100644
--- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingGunController.java
+++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingGunController.java
@@ -176,16 +176,24 @@
             out.close();
             inputStream.close();
             
-            //清楚服务器上的文件
-//            Process process = null;
-//            try {
-//                process = Runtime.getRuntime().exec("sudo rm -rf " + filePath);
-//            } catch (IOException e) {
-//                throw new RuntimeException(e);
-//            }
-//            if (process != null) {
-//                process.destroy();
-//            }
+            //清除服务器上的文件
+            try {
+                // 使用Runtime执行命令
+                Process process = Runtime.getRuntime().exec("sudo rm -rf " + filePath);
+                // 读取命令的输出
+                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();
+            }
+            
         }catch (Exception e){
             e.printStackTrace();
         }
@@ -258,7 +266,8 @@
      */
     @PostMapping("/getChargingGunByCode")
     public R<TChargingGun> getChargingGunByCode(@RequestBody GetChargingGunByCode code){
-        TChargingPile chargingPile = chargingPileService.getOne(new LambdaQueryWrapper<TChargingPile>().eq(TChargingPile::getCode, code.getCharging_pile_code()).eq(TChargingPile::getDelFlag, 0));
+        TChargingPile chargingPile = chargingPileService.getOne(new LambdaQueryWrapper<TChargingPile>()
+                .eq(TChargingPile::getCode, code.getCharging_pile_code()).eq(TChargingPile::getDelFlag, 0));
         return R.ok(chargingGunService.getOne(Wrappers.lambdaQuery(TChargingGun.class)
                         .eq(TChargingGun::getChargingPileId, chargingPile.getId())
                         .eq(TChargingGun::getCode, code.getCharging_gun_code())

--
Gitblit v1.7.1