| | |
| | | |
| | | boolean isShp = StaticData.SHP.equals(extName); |
| | | if (isGdb) { |
| | | List<MetaFileEntity> rs = getGdbMappers(f, meta); |
| | | List<MetaFileEntity> rs = getGdbMappers(f, meta, subPath); |
| | | if (null != rs && rs.size() > 0) { |
| | | list.addAll(rs); |
| | | } |
| | |
| | | } |
| | | |
| | | MetaFileEntity mf = createMetaFileEntity(meta); |
| | | mf.setEventid(StringHelper.getGuid()); |
| | | mf.setName(fileName); |
| | | mf.setExtName(extName); |
| | | mf.setSizes(FileHelper.sizeToMb(f.length())); |
| | | mf.setPath(f.getPath().substring(subPath.length())); |
| | | |
| | | if (isShp) { |
| | | mf.setTab(fileName); |
| | | mf.setGuid(getShpMd5(f.getPath())); |
| | | List<String> shpFiles = getShpFiles(f.getPath()); |
| | | mf.setGuid(getFilesMd5(shpFiles)); |
| | | } else { |
| | | mf.setSizes(FileHelper.sizeToMb(f.length())); |
| | | mf.setGuid(FileHelper.getFileMd5(f.getPath())); |
| | | } |
| | | list.add(mf); |
| | |
| | | */ |
| | | private MetaFileEntity createMetaFileEntity(MetaFileEntity meta) { |
| | | MetaFileEntity mf = new MetaFileEntity(); |
| | | mf.setEventid(StringHelper.getGuid()); |
| | | mf.setDirid(meta.getDirid()); |
| | | mf.setDepid(meta.getDepid()); |
| | | mf.setVerid(meta.getVerid()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取SHP文件的MD5码 |
| | | * 获取SHP文件集合 |
| | | */ |
| | | private String getShpMd5(String shpPath) { |
| | | List<String> files = new ArrayList<>(); |
| | | files.add(shpPath); |
| | | private List<String> getShpFiles(String shpPath) { |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(shpPath); |
| | | |
| | | 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); |
| | | list.add(path); |
| | | } |
| | | } |
| | | |
| | | return getFilesMd5(files); |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取GDB文件的MD5码 |
| | | * 获取GDB文件集合 |
| | | */ |
| | | private String getGdbMd5(String path) { |
| | | private List<String> getGdbFiles(String path) { |
| | | File[] files = new File(path).listFiles(); |
| | | if (null == files || files.length == 0) { |
| | | return StringHelper.getGuid(); |
| | | return null; |
| | | } |
| | | |
| | | List<String> list = new ArrayList<>(); |
| | |
| | | list.add(f.getPath()); |
| | | } |
| | | |
| | | return getFilesMd5(list); |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取多文件的MD5 |
| | | */ |
| | | private String getFilesMd5(List<String> strs) { |
| | | private String getFilesMd5(List<String> files) { |
| | | List<String> list = new ArrayList<>(); |
| | | for (String str : strs) { |
| | | String md5 = FileHelper.getFileMd5(str); |
| | | for (String file : files) { |
| | | String md5 = FileHelper.getFileMd5(file); |
| | | if (null != md5) { |
| | | list.add(md5); |
| | | } |
| | |
| | | /** |
| | | * 获取GDB文件映射 |
| | | */ |
| | | private List<MetaFileEntity> getGdbMappers(File f,MetaFileEntity meta) { |
| | | private List<MetaFileEntity> getGdbMappers(File f, MetaFileEntity meta, String subPath) { |
| | | List<String> tabs = GdbHelper.getTabNames(f.getPath()); |
| | | if (null == tabs || tabs.size() == 0) { |
| | | return null; |
| | | } |
| | | |
| | | String md5 = getGdbMd5(f.getPath()); |
| | | String fileName = FileHelper.getFileName(f.getPath()); |
| | | String extName = FileHelper.getExtension(fileName); |
| | | List<String> gdbFiles = getGdbFiles(f.getPath()); |
| | | String md5 = getFilesMd5(gdbFiles); |
| | | |
| | | List<MetaFileEntity> list = new ArrayList<>(); |
| | | for (String tab : tabs) { |
| | | // |
| | | MetaFileEntity mf = createMetaFileEntity(meta); |
| | | mf.setEventid(StringHelper.getGuid()); |
| | | mf.setName(fileName); |
| | | mf.setExtName(extName); |
| | | mf.setSizes(FileHelper.sizeToMb(f.length())); |
| | | mf.setPath(f.getPath().substring(subPath.length())); |
| | | mf.setTab(tab); |
| | | mf.setGuid(md5); |
| | | } |
| | | |
| | | return null; |