From ee2bf95f3472a4179ee0fc7c8e4e2a35e1214bc8 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期三, 23 十月 2024 10:15:08 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile --- ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingGunController.java | 33 +++++++++++++++++++++------------ 1 files changed, 21 insertions(+), 12 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 446fc59..1c1442d 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 @@ -157,7 +157,7 @@ public void downloadQRCode(@PathVariable Integer id, HttpServletResponse response){ try { TChargingGun chargingGun = chargingGunService.getById(id); - TChargingPile chargingPile = chargingPileService.getById(chargingGun.getId()); + TChargingPile chargingPile = chargingPileService.getById(chargingGun.getChargingPileId()); String code = chargingPile.getCode() + chargingGun.getCode(); String fileName = URLEncoder.encode(code, "UTF-8") + ".jpg"; response.setContentType("application/force-download"); @@ -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); + // 使用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(); } - if (process != null) { - process.destroy(); - } + }catch (Exception e){ e.printStackTrace(); } @@ -244,10 +252,10 @@ TChargingGun chargingGun = chargingGunService.getById(id); siteNameVO.setGunName(chargingGun.getName()); siteNameVO.setGunNumber(chargingGun.getCode()); - TChargingPile chargingPile = chargingPileService.getById(id); + TChargingPile chargingPile = chargingPileService.getById(chargingGun.getChargingPileId()); siteNameVO.setPileName(chargingPile.getName()); siteNameVO.setPileNumber(chargingPile.getNumber()); - Site site = siteService.getById(id); + Site site = siteService.getById(chargingGun.getSiteId()); siteNameVO.setSiteName(site.getName()); return R.ok(siteNameVO); } @@ -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