Pu Zhibing
2024-09-30 7124dd5c38bc60fb28ae105e7ed025b48f8321fe
修改bug
1个文件已修改
18 ■■■■ 已修改文件
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingGunController.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingGunController.java
@@ -39,10 +39,7 @@
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.PrintWriter;
import java.io.*;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
@@ -162,7 +159,7 @@
            response.setContentType("application/force-download");
            response.addHeader("Content-Disposition", "attachment;fileName=" + fileName);
            String url = "https://mxcd.zhinenganguan.com?No=" + code;
            String filePath = fileUploadConfig.getLocation();
            String filePath = fileUploadConfig.getLocation() + fileName;
            QRCodeUtils.encode(url, filePath);
            FileInputStream inputStream = new FileInputStream(filePath);
            ServletOutputStream out = response.getOutputStream();
@@ -174,6 +171,17 @@
            out.flush();
            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();
            }
        }catch (Exception e){
            e.printStackTrace();
        }