| | |
| | | import com.lf.server.entity.data.VerEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.*; |
| | | import com.lf.server.service.data.DirService; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @Service |
| | | public class BaseUploadService { |
| | | @Autowired |
| | | public PathHelper pathHelper; |
| | | private DirService dirService; |
| | | |
| | | @Autowired |
| | | private PathHelper pathHelper; |
| | | |
| | | public final Log log = LogFactory.getLog(getClass()); |
| | | |
| | |
| | | meta.setEpsgCode(epsgCode); |
| | | |
| | | if (StaticData.ZIP.equals(meta.getExtName())) { |
| | | List<MetaFileEntity> subs = getMapperFiles(path, meta); |
| | | List<MetaFileEntity> subs = getMapperFiles(path, dir, meta); |
| | | if (null != subs && subs.size() > 0) { |
| | | list.addAll(subs); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | meta.setEventid(StringHelper.getGuid()); |
| | | list.add(meta); |
| | | } |
| | | |
| | |
| | | /** |
| | | * 获取映射文件 |
| | | */ |
| | | private List<MetaFileEntity> getMapperFiles(String path, MetaFileEntity meta) { |
| | | private List<MetaFileEntity> getMapperFiles(String path, DirEntity dir, MetaFileEntity meta) { |
| | | String zipFile = pathHelper.getConfig().getTempPath() + File.separator + meta.getPath(); |
| | | File file = new File(zipFile); |
| | | if (!file.exists() || file.isDirectory()) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | return getMapperFiles(files, meta, subPath); |
| | | return getMapperFiles(files, dir, meta, subPath); |
| | | } |
| | | |
| | | /** |
| | | * 获取映射文件 |
| | | */ |
| | | private List<MetaFileEntity> getMapperFiles(File[] files, MetaFileEntity meta,String subPath) { |
| | | private List<MetaFileEntity> getMapperFiles(File[] files, DirEntity dir, MetaFileEntity meta, String subPath) { |
| | | List<MetaFileEntity> list = new ArrayList<>(); |
| | | for (File f : files) { |
| | | boolean isGdb = isGdbFile(f); |
| | |
| | | continue; |
| | | } |
| | | |
| | | int dirid = getDirByPath(f.getPath(), dir); |
| | | boolean isShp = StaticData.SHP.equals(extName); |
| | | if (isGdb) { |
| | | List<MetaFileEntity> rs = getGdbMappers(f, meta, subPath); |
| | | List<MetaFileEntity> rs = getGdbMappers(f, meta, dirid, subPath); |
| | | if (null != rs && rs.size() > 0) { |
| | | list.addAll(rs); |
| | | } |
| | |
| | | } |
| | | |
| | | MetaFileEntity mf = createMetaFileEntity(meta); |
| | | mf.setDirid(dirid); |
| | | mf.setEventid(StringHelper.getGuid()); |
| | | mf.setName(fileName); |
| | | mf.setExtName(extName); |
| | |
| | | mf.setEpsgCode(meta.getEpsgCode()); |
| | | |
| | | return mf; |
| | | } |
| | | |
| | | /** |
| | | * 根据文件路径获取目录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()) { |
| | | return dir.getId(); |
| | | } |
| | | if ("/".equals(File.separator)) { |
| | | filePath = filePath.replace("/", "\\"); |
| | | } |
| | | |
| | | for (DirEntity entity : list) { |
| | | if (filePath.contains(entity.getFullName())) { |
| | | return entity.getId(); |
| | | } |
| | | } |
| | | |
| | | return dir.getId(); |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 获取GDB文件映射 |
| | | */ |
| | | private List<MetaFileEntity> getGdbMappers(File f, MetaFileEntity meta, String subPath) { |
| | | private List<MetaFileEntity> getGdbMappers(File f, MetaFileEntity meta, int dirid, String subPath) { |
| | | List<String> tabs = GdbHelper.getTabNames(f.getPath()); |
| | | if (null == tabs || tabs.size() == 0) { |
| | | return null; |
| | |
| | | List<MetaFileEntity> list = new ArrayList<>(); |
| | | for (String tab : tabs) { |
| | | MetaFileEntity mf = createMetaFileEntity(meta); |
| | | mf.setDirid(dirid); |
| | | mf.setEventid(StringHelper.getGuid()); |
| | | mf.setName(fileName); |
| | | mf.setExtName(extName); |