月球大数据地理空间分析展示平台-【后端】-月球后台服务
1
13693261870
2024-11-17 796b44ea813a1133beae4f3a67f1c0263510c0c7
src/main/java/com/moon/server/service/all/BaseUploadService.java
@@ -21,11 +21,8 @@
import java.sql.Timestamp;
import java.util.*;
/**
 * 父上传服务
 * @author WWW
 */
@Service
@SuppressWarnings("ALL")
public class BaseUploadService {
    @Autowired
    protected DirService dirService;
@@ -35,16 +32,10 @@
    public final Log log = LogFactory.getLog(getClass());
    /**
     * 查询目录
     */
    public String selectPath() {
        return pathHelper.getTempPathName();
    }
    /**
     * 上传文件
     */
    public <T> List<MetaFileEntity> uploadData(T t, String path, boolean isGetGuid, HttpServletRequest req, HttpServletResponse res) throws Exception {
        StandardMultipartHttpServletRequest request = (StandardMultipartHttpServletRequest) req;
        req.setCharacterEncoding("utf-8");
@@ -57,9 +48,6 @@
        return getFiles(path, isGetGuid, request);
    }
    /**
     * 设置实体类
     */
    private <T> void setEntity(T t, StandardMultipartHttpServletRequest req) {
        Enumeration<String> enumeration = req.getParameterNames();
        while (enumeration.hasMoreElements()) {
@@ -94,9 +82,6 @@
        }
    }
    /**
     * 获取文件
     */
    public List<MetaFileEntity> getFiles(String subPath, boolean isGetGuid, StandardMultipartHttpServletRequest req) throws Exception {
        List<MetaFileEntity> list = new ArrayList<>();
@@ -126,9 +111,6 @@
        return list;
    }
    /**
     * 查询文件
     */
    public List<MetaFileEntity> selectFiles(String subPath, boolean hasMd5) {
        String root = pathHelper.getConfig().getTempPath() + File.separator + subPath;
@@ -164,9 +146,6 @@
        return list;
    }
    /**
     * 删除文件
     */
    public Integer deleteFiles(List<MetaFileEntity> list) {
        String root = pathHelper.getConfig().getTempPath();
@@ -186,9 +165,6 @@
        return count;
    }
    /**
     * 查询映射
     */
    public List<MetaFileEntity> selectMappers(UserEntity ue, String path, DirEntity dir, VerEntity ver) {
        List<MetaFileEntity> metas = selectFiles(path, true);
        if (null == metas || metas.isEmpty()) {
@@ -219,9 +195,6 @@
        return list;
    }
    /**
     * 获取映射文件
     */
    private List<MetaFileEntity> getMapperFiles(String path, DirEntity dir, List<DirEntity> dirs, MetaFileEntity meta) {
        String tempPath = pathHelper.getConfig().getTempPath();
        String zipFile = tempPath + File.separator + meta.getPath();
@@ -245,9 +218,6 @@
        return getMapperFiles(files, dir, dirs, meta, tempPath.length() + 1);
    }
    /**
     * 根据路径获取文件
     */
    private void getFilesByPath(List<File> list, String path) {
        File file = new File(path);
        if (!file.isDirectory()) {
@@ -277,9 +247,6 @@
        }
    }
    /**
     * 文件是/否有效
     */
    private boolean isFileValid(String fileName) {
        String extName = FileHelper.getExtension(fileName);
        if (fileName.startsWith(StaticData.TILDE) || !StaticData.ALL_EXTENSION.contains(extName)) {
@@ -296,9 +263,6 @@
        return true;
    }
    /**
     * 获取映射文件
     */
    private List<MetaFileEntity> getMapperFiles(List<File> files, DirEntity dir, List<DirEntity> dirs, MetaFileEntity meta, int start) {
        List<MetaFileEntity> list = new ArrayList<>();
        for (File f : files) {
@@ -337,9 +301,6 @@
        return list;
    }
    /**
     * 创建元数据文件实体类
     */
    private MetaFileEntity createMetaFileEntity(File f, MetaFileEntity meta, String fileName, String extName) {
        boolean isShp = StaticData.SHP.equals(extName);
@@ -361,9 +322,6 @@
        return mf;
    }
    /**
     * 创建元数据文件实体类
     */
    private MetaFileEntity createMetaFileEntity(MetaFileEntity meta) {
        MetaFileEntity mf = new MetaFileEntity();
        mf.setDircode(meta.getDircode());
@@ -375,9 +333,6 @@
        return mf;
    }
    /**
     * 根据文件路径获取目录ID
     */
    private String getDirByPath(String filePath,String fileName, DirEntity dir, List<DirEntity> dirs) {
        if (0 != dir.getPid() || null == dirs || dirs.isEmpty()) {
            return dir.getCode();
@@ -397,9 +352,6 @@
        return dir.getCode();
    }
    /**
     * 获取SHP文件集合
     */
    private List<String> getShpFiles(String shpPath) {
        List<String> list = new ArrayList<>();
        list.add(shpPath);
@@ -416,9 +368,6 @@
        return list;
    }
    /**
     * 获取GDB文件集合
     */
    private List<String> getGdbFiles(String path) {
        List<String> list = new ArrayList<>();
@@ -433,9 +382,6 @@
        return list;
    }
    /**
     * 获取多文件的MD5
     */
    private String getFilesMd5(List<String> files) {
        List<String> list = new ArrayList<>();
        for (String file : files) {
@@ -453,9 +399,6 @@
        return StringHelper.getGuid();
    }
    /**
     * 获取多文件的大小
     */
    private double getFilesSize(List<String> files) {
        long size = 0L;
        for (String file : files) {
@@ -468,9 +411,6 @@
        return FileHelper.sizeToMb(size);
    }
    /**
     * 获取GDB文件映射
     */
    private List<MetaFileEntity> getGdbMappers(File f, MetaFileEntity meta, String dircode, int start) {
        List<String> tabs = GdbHelper.getTabNames(f.getPath());
        if (null == tabs || tabs.size() == 0) {
@@ -502,9 +442,6 @@
        return list;
    }
    /**
     * 是/否为GDB文件
     */
    private boolean isGdbFile(File f) {
        if (f.isDirectory() && f.getName().toLowerCase().endsWith(StaticData.GDB)) {
            File gdb = new File(f.getPath() + File.separator + "gdb");
@@ -515,9 +452,6 @@
        return false;
    }
    /**
     * 设置元数据文件的类型
     */
    private void setMetaType(List<MetaFileEntity> list) {
        for (MetaFileEntity mf : list) {
            if (null != mf.getExtName()) {
@@ -526,9 +460,6 @@
        }
    }
    /**
     * 处理目录
     */
    public void copePath(List<MetaFileEntity> list) {
        String basePath = pathHelper.getConfig().getTempPath() + File.separator;
        for (MetaFileEntity mf : list) {
@@ -536,9 +467,6 @@
        }
    }
    /**
     * 是/否为OSGB文件
     */
    private boolean isOsgbFile(File f) {
        if (f.isDirectory()) {
            File meta = new File(f.getPath() + File.separator + "metadata.xml");
@@ -550,10 +478,6 @@
        return false;
    }
    /**
     * 获取OSGB文件映射
     */
    private MetaFileEntity getOsgbMapper(File f,  MetaFileEntity meta, String dircode, int start) {
        String fileName = FileHelper.getFileName(f.getPath());
@@ -576,11 +500,6 @@
        return mf;
    }
    /**
     * 获取参数 *
     * Enumeration<String> headers = req.getHeaderNames();
     * Enumeration<String> attributes = req.getAttributeNames();
     */
    public Map<String, String> getParams(StandardMultipartHttpServletRequest req) {
        Map<String, String> map = new HashMap<>(3);