管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-11-01 7e6fd5f1a403618d9d2116c483783951e17a3509
1
已修改3个文件
85 ■■■■ 文件已修改
src/main/java/com/lf/server/helper/FileHelper.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/helper/PathHelper.java 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/show/MarkService.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/helper/FileHelper.java
@@ -27,6 +27,7 @@
    /**
     * 获取文件名
     *
     * @param file
     * @return
     */
@@ -223,4 +224,39 @@
            log.error(ex.getMessage(), ex);
        }
    }
    /**
     * 删除文件夹
     *
     * @param dir 文件夹
     */
    public static void deleteDir(String dir) {
        File file = new File(dir);
        deleteFiles(file);
    }
    /**
     * 级联删除文件
     *
     * @param file 文件
     */
    public static void deleteFiles(File file) {
        if (file == null || !file.exists()) {
            return;
        }
        if (file.isDirectory()) {
            File[] files = file.listFiles();
            for (File f : files) {
                if (f.isDirectory()) {
                    deleteFiles(f);
                } else {
                    f.delete();
                }
            }
        }
        file.delete();
    }
}
src/main/java/com/lf/server/helper/PathHelper.java
@@ -81,16 +81,16 @@
    }
    /**
     * 获取导入目录
     * 获取下载完整目录
     */
    public String getImportFullPath() {
    public String getDownloadFullPath() {
        downloadPath = getSubPath(config.getDownloadPath(), downloadPath);
        return config.getDownloadPath() + File.separator + downloadPath;
    }
    /**
     * 获取出图目录
     * 获取出图完整目录
     */
    public String getExportFullPath() {
        exportPath = getSubPath(config.getExportPath(), exportPath);
@@ -99,7 +99,7 @@
    }
    /**
     * 获取上传目录
     * 获取上传完整目录
     */
    public String getUploadFullPath() {
        uploadPath = getSubPath(config.getUploadPath(), uploadPath);
@@ -108,7 +108,7 @@
    }
    /**
     * 获取共享目录
     * 获取共享完整目录
     */
    public String getShareFullPath() {
        sharePath = getSubPath(config.getSharePath(), sharePath);
@@ -151,31 +151,10 @@
                    continue;
                }
                deleteFiles(f);
                FileHelper.deleteFiles(f);
            }
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        }
    }
    /**
     * 级联删除文件
     */
    public void deleteFiles(File file) {
        if (file == null || !file.exists()) {
            return;
        }
        if (file.isDirectory()) {
            File[] files = file.listFiles();
            for (File f : files) {
                if (f.isDirectory()) {
                    deleteFiles(f);
                } else {
                    f.delete();
                }
            }
        }
        file.delete();
    }
}
src/main/java/com/lf/server/service/show/MarkService.java
@@ -1,27 +1,18 @@
package com.lf.server.service.show;
import com.lf.server.entity.all.HttpStatus;
import com.lf.server.entity.ctrl.MarkJsonEntity;
import com.lf.server.entity.show.MarkEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.helper.*;
import com.lf.server.mapper.show.MarkMapper;
import com.lf.server.service.data.UploaderService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
 * 标绘
@@ -107,9 +98,10 @@
            return "Shp文件生成失败";
        }
        String zip = getZip(parent);
        String zip = getZip();
        ZipHelper.zip(zip, parent);
        //download(res, zip);
        FileHelper.deleteDir(parent);
        return "";
    }
@@ -139,8 +131,8 @@
        return rs;
    }
    private String getZip(String parent) {
        String path = parent + File.separator + WebHelper.getRandomInt(100000, 1000000) + ".zip";
    private String getZip() {
        String path = pathHelper.getDownloadFullPath() + File.separator + WebHelper.getRandomInt(100000, 1000000) + ".zip";
        File file = new File(path);
        if (file.exists() && !file.isDirectory()) {