| | |
| | | */ |
| | | @Service |
| | | public class BaseUploadService { |
| | | private final static String XLS = ".xls"; |
| | | |
| | | private final static String MDB = ".mdb"; |
| | | |
| | | private final static String GDB = ".gdb"; |
| | | |
| | | private final static String SHP_ZIP = ".shp.zip"; |
| | | |
| | | private final static String GDB_ZIP = ".gdb.zip"; |
| | | |
| | | private final static String ZIP = ".zip"; |
| | | |
| | | @Autowired |
| | | public PathHelper pathHelper; |
| | | |
| | |
| | | mf.setExtName(extName); |
| | | mf.setSizes(FileHelper.sizeToMb(f.length())); |
| | | mf.setPath(subPath + File.separator + fileName); |
| | | // mf.setGuid(FileHelper.getFileMd5(f.getPath())) |
| | | if (!StaticData.ZIP.equals(extName)) { |
| | | mf.setGuid(FileHelper.getFileMd5(f.getPath())); |
| | | } |
| | | |
| | | list.add(mf); |
| | | } |
| | |
| | | meta.setEpsgCode(epsgCode); |
| | | |
| | | if (StaticData.ZIP.equals(meta.getExtName())) { |
| | | List<MetaFileEntity> subs = getMappers(path, meta); |
| | | List<MetaFileEntity> subs = getMapperFiles(path, meta); |
| | | if (null != subs && subs.size() > 0) { |
| | | list.addAll(subs); |
| | | continue; |
| | |
| | | */ |
| | | private List<MetaFileEntity> getMapperFiles(File[] files, MetaFileEntity meta) { |
| | | List<MetaFileEntity> list = new ArrayList<>(); |
| | | for (File f : files) { |
| | | |
| | | |
| | | String fileName = FileHelper.getFileName(f.getPath()); |
| | | String extName = FileHelper.getExtension(fileName); |
| | | if (!StaticData.ALL_EXTENSION.contains(extName)) { |
| | | continue; |
| | | } |
| | | |
| | | MetaFileEntity mf = createMetaFileEntity(meta); |
| | | mf.setName(fileName); |
| | | mf.setExtName(extName); |
| | | mf.setSizes(FileHelper.sizeToMb(f.length())); |
| | | //mf.setPath(subPath + File.separator + fileName); |
| | | mf.setGuid(FileHelper.getFileMd5(f.getPath())); |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 创建元数据文件实体类 |
| | | */ |
| | | private MetaFileEntity createMetaFileEntity(MetaFileEntity meta) { |
| | | MetaFileEntity mf = new MetaFileEntity(); |
| | | mf.setDirid(meta.getDirid()); |
| | | mf.setDepid(meta.getDepid()); |
| | | mf.setVerid(meta.getVerid()); |
| | | mf.setCreateUser(meta.getCreateUser()); |
| | | mf.setEpsgCode(meta.getEpsgCode()); |
| | | |
| | | return mf; |
| | | } |
| | | |
| | | /*private List<TabMapperEntity> getMappers(String zipPath, File[] files) { |
| | |
| | | }*/ |
| | | |
| | | private boolean isGdbFile(File f) { |
| | | if (f.getName().toLowerCase().endsWith(GDB)) { |
| | | if (f.isDirectory() && f.getName().toLowerCase().endsWith(StaticData.GDB)) { |
| | | File[] files = f.listFiles(); |
| | | if (null == files || files.length == 0) { |
| | | return false; |