管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-01-10 58a671a7c81c5bd71ebd1dbcb9b3f3aadb41aac4
1
已修改3个文件
40 ■■■■ 文件已修改
src/main/java/com/lf/server/controller/data/upload/UploadController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/helper/ZipHelper.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/all/BaseUploadService.java 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/data/upload/UploadController.java
@@ -108,8 +108,8 @@
    @SysLog()
    @ApiOperation(value = "查询映射")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query", example = "20230109010101"),
            @ApiImplicitParam(name = "dirid", value = "目录ID", dataType = "Integer", paramType = "query", example = "1"),
            @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query", example = "20230110010101"),
            @ApiImplicitParam(name = "dirid", value = "目录ID", dataType = "Integer", paramType = "query", example = "163"),
            @ApiImplicitParam(name = "verid", value = "版本ID", dataType = "Integer", paramType = "query", example = "0"),
            @ApiImplicitParam(name = "epsgCode", value = "坐标编码", dataType = "String", paramType = "query", example = "EPSG:4490")
    })
src/main/java/com/lf/server/helper/ZipHelper.java
@@ -4,6 +4,7 @@
import org.apache.commons.logging.LogFactory;
import java.io.*;
import java.nio.charset.Charset;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -36,7 +37,7 @@
            }
            int count;
            zipFile = new ZipFile(filePath);
            zipFile = new ZipFile(filePath, Charset.forName("GBK"));
            Enumeration e = zipFile.entries();
            while (e.hasMoreElements()) {
                ZipEntry entry = (ZipEntry) e.nextElement();
src/main/java/com/lf/server/service/all/BaseUploadService.java
@@ -194,6 +194,7 @@
        }
        List<MetaFileEntity> list = new ArrayList<>();
        List<DirEntity> dirs = dirService.selectDirRecursive(dir.getName());
        for (MetaFileEntity meta : metas) {
            meta.setEventid(StringHelper.getGuid());
            meta.setDirid(dir.getId());
@@ -203,7 +204,7 @@
            meta.setEpsgCode(epsgCode);
            if (StaticData.ZIP.equals(meta.getExtName())) {
                List<MetaFileEntity> subs = getMapperFiles(path, dir, meta);
                List<MetaFileEntity> subs = getMapperFiles(path, dir, dirs, meta);
                if (null != subs && subs.size() > 0) {
                    list.addAll(subs);
                    continue;
@@ -219,8 +220,9 @@
    /**
     * 获取映射文件
     */
    private List<MetaFileEntity> getMapperFiles(String path, DirEntity dir, MetaFileEntity meta) {
        String zipFile = pathHelper.getConfig().getTempPath() + File.separator + meta.getPath();
    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();
        File file = new File(zipFile);
        if (!file.exists() || file.isDirectory()) {
            return null;
@@ -240,13 +242,13 @@
            return null;
        }
        return getMapperFiles(files, dir, meta, subPath);
        return getMapperFiles(files, dir, dirs, meta, tempPath.length() + 1);
    }
    /**
     * 获取映射文件
     */
    private List<MetaFileEntity> getMapperFiles(File[] files, DirEntity dir, MetaFileEntity meta, String subPath) {
    private List<MetaFileEntity> getMapperFiles(File[] files, DirEntity dir, List<DirEntity> dirs, MetaFileEntity meta, int start) {
        List<MetaFileEntity> list = new ArrayList<>();
        for (File f : files) {
            boolean isGdb = isGdbFile(f);
@@ -260,10 +262,10 @@
                continue;
            }
            int dirid = getDirByPath(f.getPath(), dir);
            int dirid = getDirByPath(f.getPath(), dir, dirs);
            boolean isShp = StaticData.SHP.equals(extName);
            if (isGdb) {
                List<MetaFileEntity> rs = getGdbMappers(f, meta, dirid, subPath);
                List<MetaFileEntity> rs = getGdbMappers(f, meta, dirid, start);
                if (null != rs && rs.size() > 0) {
                    list.addAll(rs);
                }
@@ -275,7 +277,7 @@
            mf.setEventid(StringHelper.getGuid());
            mf.setName(fileName);
            mf.setExtName(extName);
            mf.setPath(f.getPath().substring(subPath.length()));
            mf.setPath(f.getPath().substring(start));
            if (isShp) {
                List<String> shpFiles = getShpFiles(f.getPath());
@@ -309,20 +311,15 @@
    /**
     * 根据文件路径获取目录ID
     */
    private int getDirByPath(String filePath, DirEntity dir) {
        if (0 != dir.getPid()) {
            return dir.getId();
        }
        List<DirEntity> list = dirService.selectDirRecursive(dir.getName());
        if (null == list || list.isEmpty()) {
    private int getDirByPath(String filePath, DirEntity dir, List<DirEntity> dirs) {
        if (0 != dir.getPid() || null == dirs || dirs.isEmpty()) {
            return dir.getId();
        }
        if ("/".equals(File.separator)) {
            filePath = filePath.replace("/", "\\");
        }
        for (DirEntity entity : list) {
        for (DirEntity entity : dirs) {
            if (filePath.contains(entity.getFullName())) {
                return entity.getId();
            }
@@ -405,7 +402,7 @@
    /**
     * 获取GDB文件映射
     */
    private List<MetaFileEntity> getGdbMappers(File f, MetaFileEntity meta, int dirid, String subPath) {
    private List<MetaFileEntity> getGdbMappers(File f, MetaFileEntity meta, int dirid, int start) {
        List<String> tabs = GdbHelper.getTabNames(f.getPath());
        if (null == tabs || tabs.size() == 0) {
            return null;
@@ -426,7 +423,7 @@
            mf.setName(fileName);
            mf.setExtName(extName);
            mf.setSizes(FileHelper.sizeToMb(f.length()));
            mf.setPath(f.getPath().substring(subPath.length()));
            mf.setPath(f.getPath().substring(start));
            mf.setTab(tab);
            mf.setSizes(sizes);
            mf.setGuid(md5);