| | |
| | | } |
| | | |
| | | List<MetaFileEntity> list = new ArrayList<>(); |
| | | List<DirEntity> dirs = dirService.selectDirRecursive(dir.getName()); |
| | | for (MetaFileEntity meta : metas) { |
| | | meta.setEventid(StringHelper.getGuid()); |
| | | meta.setDirid(dir.getId()); |
| | |
| | | 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; |
| | |
| | | /** |
| | | * 获取映射文件 |
| | | */ |
| | | 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; |
| | |
| | | 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); |
| | |
| | | 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); |
| | | } |
| | |
| | | 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()); |
| | |
| | | /** |
| | | * 根据文件路径获取目录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(); |
| | | } |
| | |
| | | /** |
| | | * 获取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; |
| | |
| | | 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); |