管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-01-09 11d8cde28030e33b5406582d6310a00b8d78ad43
src/main/java/com/lf/server/service/all/BaseUploadService.java
@@ -1,7 +1,10 @@
package com.lf.server.service.all;
import com.lf.server.entity.ctrl.TabMapperEntity;
import com.lf.server.entity.all.StaticData;
import com.lf.server.entity.data.DirEntity;
import com.lf.server.entity.data.MetaFileEntity;
import com.lf.server.entity.data.VerEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.helper.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -147,21 +150,17 @@
        List<MetaFileEntity> list = new ArrayList<>();
        for (File f : files) {
            String fileName = FileHelper.getFileName(f.getPath());
            if (null != extList) {
                String extName = FileHelper.getExtension(fileName);
                if (!extList.contains(extName)) {
                    continue;
                }
            String extName = FileHelper.getExtension(fileName);
            if (null != extList && !extList.contains(extName)) {
                continue;
            }
            double sizes = FileHelper.sizeToMb(f.length());
            String filePath = subPath + File.separator + fileName;
            MetaFileEntity mf = new MetaFileEntity();
            mf.setName(fileName);
            mf.setSizes(sizes);
            mf.setPath(filePath);
            mf.setGuid(FileHelper.getFileMd5(f.getPath()));
            mf.setExtName(extName);
            mf.setSizes(FileHelper.sizeToMb(f.length()));
            mf.setPath(subPath + File.separator + fileName);
            // mf.setGuid(FileHelper.getFileMd5(f.getPath()))
            list.add(mf);
        }
@@ -194,31 +193,56 @@
    /**
     * 查询映射
     */
    public List<TabMapperEntity> selectMappers(String subPath) {
        String root = pathHelper.getConfig().getTempPath() + File.separator + subPath;
        File file = new File(root);
        if (!file.exists() && !file.isDirectory()) {
    public List<MetaFileEntity> selectMappers(UserEntity ue, String path, DirEntity dir, VerEntity ver, String epsgCode) {
        List<MetaFileEntity> metas = selectFiles(path, StaticData.ALL_EXTENSION);
        if (null == metas || metas.isEmpty()) {
            return null;
        }
        File[] files = file.listFiles();
        if (null == files || files.length == 0) {
            return null;
        List<MetaFileEntity> list = new ArrayList<>();
        for (MetaFileEntity meta : metas) {
            meta.setDirid(dir.getId());
            meta.setDepid(ue.getDepid());
            meta.setVerid(ver.getId());
            meta.setCreateUser(ue.getId());
            meta.setEpsgCode(epsgCode);
            if (StaticData.ZIP.equals(meta.getExtName())) {
                List<MetaFileEntity> subs = getMappers(path, meta.getPath(), meta);
                if (null != subs && subs.size() > 0) {
                    list.addAll(subs);
                    continue;
                }
            }
            meta.setEventid(StringHelper.getGuid());
            list.add(meta);
        }
        File zipFile = new File(root + "_zip");
        if (!zipFile.exists() || !zipFile.isDirectory()) {
            zipFile.mkdirs();
        }
        return getMappers(zipFile.getPath(), files);
        return list;
    }
    /**
     * 获取映射
     */
    private List<TabMapperEntity> getMappers(String zipPath, File[] files) {
    private List<MetaFileEntity> getMappers(String path, String zipPath, MetaFileEntity meta) {
        File file = new File(pathHelper.getConfig().getTempPath() + File.separator + zipPath);
        if (!file.exists() || file.isDirectory()) {
            return null;
        }
        File zipFolder = new File(pathHelper.getConfig().getTempPath() + File.separator + path + "_zip");
        if (!zipFolder.exists() || !zipFolder.isDirectory()) {
            zipFolder.mkdirs();
        }
        List<MetaFileEntity> list = new ArrayList<>();
        return list;
    }
    /*private List<TabMapperEntity> getMappers(String zipPath, File[] files) {
        String temp = pathHelper.getConfig().getTempPath();
        List<TabMapperEntity> list = new ArrayList<>();
@@ -257,9 +281,6 @@
        return list;
    }
    /**
     * 获取Shp文件
     */
    private void getShpFiles(String sourceName, String subPath, List<TabMapperEntity> list) {
        List<String> files = new ArrayList<>();
        getShpFiles(subPath, files);
@@ -272,9 +293,6 @@
        }
    }
    /**
     * 获取Shp文件
     */
    private void getShpFiles(String shpPath, List<String> list) {
        File file = new File(shpPath);
@@ -295,9 +313,6 @@
        }
    }
    /**
     * 获取Gdb文件
     */
    private void getGdbFiles(String sourceName, String subPath, List<TabMapperEntity> list) {
        List<String> files = new ArrayList<>();
        getGdbFiles(subPath, files);
@@ -312,9 +327,6 @@
        }
    }
    /**
     * 获取Gdb文件
     */
    private void getGdbFiles(String shpPath, List<String> list) {
        File file = new File(shpPath);
@@ -335,7 +347,7 @@
            getGdbFiles(f.getPath(), list);
        }
    }
    }*/
    private boolean isGdbFile(File f) {
        if (f.getName().toLowerCase().endsWith(GDB)) {