puzhibing
2024-10-08 6f1a56eb02cb6eb7848e2df6773bc5abfee11efd
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingGunController.java
@@ -155,7 +155,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");
@@ -175,15 +175,15 @@
            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();
            }
//            Process process = null;
//            try {
//                process = Runtime.getRuntime().exec("sudo rm -rf " + filePath);
//            } catch (IOException e) {
//                throw new RuntimeException(e);
//            }
//            if (process != null) {
//                process.destroy();
//            }
        }catch (Exception e){
            e.printStackTrace();
        }