| | |
| | | |
| | | boolean isShp = StaticData.SHP.equals(extName); |
| | | if (isGdb) { |
| | | // |
| | | String md5 = getGdbMd5(f.getPath()); |
| | | continue; |
| | | } |
| | | |
| | |
| | | mf.setPath(f.getPath().substring(subPath.length())); |
| | | if (isShp) { |
| | | mf.setTab(fileName); |
| | | // |
| | | mf.setGuid(getShpMd5(f.getPath())); |
| | | } else { |
| | | mf.setGuid(FileHelper.getFileMd5(f.getPath())); |
| | | } |
| | |
| | | return mf; |
| | | } |
| | | |
| | | /*private List<TabMapperEntity> getMappers(String zipPath, File[] files) { |
| | | String temp = pathHelper.getConfig().getTempPath(); |
| | | /** |
| | | * 获取SHP文件的MD5码 |
| | | */ |
| | | private String getShpMd5(String shpPath) { |
| | | List<String> files = new ArrayList<>(); |
| | | files.add(shpPath); |
| | | |
| | | 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)) { |
| | | // 暂时不实现 |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | return list; |
| | | return getFilesMd5(files); |
| | | } |
| | | |
| | | private void getShpFiles(String sourceName, String subPath, List<TabMapperEntity> list) { |
| | | List<String> files = new ArrayList<>(); |
| | | getShpFiles(subPath, files); |
| | | |
| | | 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)); |
| | | } |
| | | } |
| | | |
| | | 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)); |
| | | } |
| | | } |
| | | }*/ |
| | | |
| | | 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; |
| | | } |
| | | list.add(f.getPath()); |
| | | } |
| | | |
| | | 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) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取参数 |
| | | * 获取参数 * |
| | | * Enumeration<String> headers = req.getHeaderNames(); |
| | | * Enumeration<String> attributes = req.getAttributeNames(); |
| | | */ |