管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-01-10 58a671a7c81c5bd71ebd1dbcb9b3f3aadb41aac4
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);