管道基础大数据平台系统开发-【后端】-Server
3
13693261870
2023-01-10 3af5e8f2335b3d5cd4528f9ee9f326eef5fe2f9a
src/main/java/com/lf/server/service/all/BaseUploadService.java
@@ -259,7 +259,7 @@
            boolean isShp = StaticData.SHP.equals(extName);
            if (isGdb) {
                //
                String md5 = getGdbMd5(f.getPath());
                continue;
            }
@@ -270,7 +270,7 @@
            mf.setPath(f.getPath().substring(subPath.length()));
            if (isShp) {
                mf.setTab(fileName);
                //
                mf.setGuid(getShpMd5(f.getPath()));
            } else {
                mf.setGuid(FileHelper.getFileMd5(f.getPath()));
            }
@@ -295,89 +295,59 @@
        return mf;
    }
    /*private List<TabMapperEntity> getMappers(String zipPath, File[] files) {
        String temp = pathHelper.getConfig().getTempPath();
        List<TabMapperEntity> list = new ArrayList<>();
        for (File f : files) {
            String fileName = FileHelper.getFileName(f.getPath());
            if (fileName.contains(XLS)) {
                String path = f.getPath().replace(temp + File.separator, "");
                list.add(new TabMapperEntity(fileName, "xls", null, path));
                continue;
            }
            if (fileName.contains(MDB)) {
                String path = f.getPath().replace(temp + File.separator, "");
                List<String> tabs = MdbHelper.getTabNames(f.getPath());
                for (String tab : tabs) {
                    list.add(new TabMapperEntity(fileName, "mdb", tab, path));
                }
                continue;
            }
            if (fileName.contains(SHP_ZIP)) {
                String subPath = zipPath + File.separator + f.getName().toLowerCase().replace(".zip", "");
                ZipHelper.unzip(f.getPath(), subPath);
                getShpFiles(f.getName(), subPath, list);
                continue;
            }
            if (fileName.contains(GDB_ZIP)) {
                String subPath = zipPath + File.separator + f.getName().toLowerCase().replace(".zip", "");
                ZipHelper.unzip(f.getPath(), subPath);
                getGdbFiles(f.getName(), subPath, list);
                continue;
            }
            if (fileName.contains(ZIP)) {
                // 暂时不实现
            }
        }
        return list;
    }
    private void getShpFiles(String sourceName, String subPath, List<TabMapperEntity> list) {
    /**
     * 获取SHP文件的MD5码
     */
    private String getShpMd5(String shpPath) {
        List<String> files = new ArrayList<>();
        getShpFiles(subPath, files);
        files.add(shpPath);
        String root = pathHelper.getConfig().getTempPath() + File.separator;
        for (String file : files) {
            String name = FileHelper.getFileName(file);
            String path = file.replace(root, "");
            list.add(new TabMapperEntity(sourceName, "shp", name, path));
        for (int i = 1, c = StaticData.SHP_EXTENSION.size(); i < c; i++) {
            String path = shpPath.replace(".shp", StaticData.SHP_EXTENSION.get(i));
            File f = new File(path);
            if (f.exists() && !f.isDirectory()) {
                files.add(path);
        }
    }
    private void getGdbFiles(String sourceName, String subPath, List<TabMapperEntity> list) {
        List<String> files = new ArrayList<>();
        getGdbFiles(subPath, files);
        String root = pathHelper.getConfig().getTempPath() + File.separator;
        for (String file : files) {
            String path = file.replace(root, "");
            List<String> tabs = GdbHelper.getTabNames(file);
            for (String tab : tabs) {
                list.add(new TabMapperEntity(sourceName, "gdb", tab, path));
        return getFilesMd5(files);
            }
        }
    }*/
    private void getShpFiles(String shpPath, List<String> list) {
        File file = new File(shpPath);
        File[] files = file.listFiles();
    /**
     * 获取GDB文件的MD5码
     */
    private String getGdbMd5(String path) {
        File[] files = new File(path).listFiles();
        if (null == files || files.length == 0) {
            return;
            return StringHelper.getGuid();
        }
        List<String> list = new ArrayList<>();
        for (File f : files) {
            if (f.isDirectory()) {
                getShpFiles(f.getPath(), list);
                continue;
            }
            if (f.getName().toLowerCase().endsWith(".shp")) {
                list.add(f.getPath());
            }
        return getFilesMd5(list);
        }
    /**
     * 获取多文件的MD5
     */
    private String getFilesMd5(List<String> list) {
        StringBuilder sb = new StringBuilder();
        for (String str : list) {
            String md5 = FileHelper.getFileMd5(str);
            if (null != md5) {
                sb.append(sb + ",");
            }
        }
        if (sb.length() > 0) {
            return FileHelper.getStringMd5(sb.toString());
        }
        return StringHelper.getGuid();
    }
    private void getGdbFiles(String shpPath, List<String> list) {
@@ -423,7 +393,7 @@
    }
    /**
     * 获取参数
     * 获取参数 *
     * Enumeration<String> headers = req.getHeaderNames();
     * Enumeration<String> attributes = req.getAttributeNames();
     */