| | |
| | | |
| | | import com.lf.server.entity.all.BaseEntity; |
| | | import com.lf.server.entity.all.StaticData; |
| | | import com.lf.server.entity.data.CoordEntity; |
| | | import com.lf.server.entity.data.DirEntity; |
| | | import com.lf.server.entity.data.FmeLogEntity; |
| | | import com.lf.server.entity.data.MetaFileEntity; |
| | | import com.lf.server.entity.data.*; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.*; |
| | | import com.lf.server.mapper.all.BasicMapper; |
| | |
| | | |
| | | @Autowired |
| | | FmeService fmeService; |
| | | |
| | | @Autowired |
| | | MetaService metaService; |
| | | |
| | | @Override |
| | | public List<CoordEntity> selectCoords(String zoning) { |
| | |
| | | |
| | | File f = new File(mf.getPath()); |
| | | if (!f.exists()) { |
| | | mf.setMsg("文件丢失"); |
| | | mf.setRows(-1); |
| | | mf.setMsg("文件不存在"); |
| | | } |
| | | } |
| | | } |
| | |
| | | * 复制文件 |
| | | */ |
| | | private void copyFiles(List<MetaFileEntity> list) { |
| | | List<String> gdbList = new ArrayList<>(); |
| | | for (MetaFileEntity mf : list) { |
| | | switch (mf.getExtName()) { |
| | | case StaticData.MPT: |
| | |
| | | copyMultiFile(mf, StaticData.SHP_EXT); |
| | | break; |
| | | case StaticData.GDB: |
| | | if (gdbList.contains(mf.getPath())) { |
| | | MetaEntity meta = metaService.selectByGuid(mf.getGuid()); |
| | | if (null != meta) { |
| | | mf.setPath(meta.getPath()); |
| | | } |
| | | continue; |
| | | } |
| | | |
| | | gdbList.add(mf.getPath()); |
| | | copyFolderFile(mf); |
| | | break; |
| | | default: |
| | |
| | | /** |
| | | * 复制单个文件 |
| | | */ |
| | | private void copySingleFile(MetaFileEntity mf) { |
| | | private int copySingleFile(MetaFileEntity mf) { |
| | | File file = new File(mf.getPath()); |
| | | if (!file.exists()) { |
| | | mf.setMsg("文件丢失"); |
| | | return -1; |
| | | } |
| | | |
| | | MetaEntity old = metaService.selectByGuid(mf.getGuid()); |
| | | if (null != old) { |
| | | mf.setMsg("文件已存在"); |
| | | file.delete(); |
| | | return 0; |
| | | } |
| | | |
| | | String uploadPath = pathHelper.getUploadFullPath(); |
| | | String targetPath = uploadPath + File.separator + mf.getGuid() + mf.getExtName(); |
| | | |
| | | File newFile = new File(targetPath); |
| | | if (newFile.exists()) { |
| | | file.delete(); |
| | | return 0; |
| | | } |
| | | |
| | | file.renameTo(newFile); |
| | | |
| | | String subPath = FileHelper.getRelativePath(targetPath); |
| | | mf.setPath(subPath); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | /** |
| | | * 复制多个文件 |
| | | */ |
| | | private void copyMultiFile(MetaFileEntity mf, List<String> extList) { |
| | | String path = mf.getPath(); |
| | | |
| | | int status = copySingleFile(mf); |
| | | if (status < 1) { |
| | | for (int i = 0, c = extList.size(); i < c; i++) { |
| | | String subPath = path.replace(mf.getExtName(), extList.get(i)); |
| | | File file = new File(subPath); |
| | | if (file.exists()) { |
| | | file.delete(); |
| | | } |
| | | } |
| | | return; |
| | | } |
| | | |
| | | String uploadPath = pathHelper.getConfig().getUploadPath(); |
| | | for (int i = 0, c = extList.size(); i < c; i++) { |
| | | String sourcePath = path.replace(mf.getExtName(), extList.get(i)); |
| | | File file = new File(sourcePath); |
| | | if (!file.exists()) { |
| | | continue; |
| | | } |
| | | |
| | | String targetPath = uploadPath + File.separator + mf.getPath().replace(mf.getExtName(), extList.get(i)); |
| | | File newFile = new File(targetPath); |
| | | if (newFile.exists()) { |
| | | continue; |
| | | } |
| | | |
| | | file.renameTo(newFile); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 复制文件夹文件 |
| | | */ |
| | | private void copyFolderFile(MetaFileEntity mf) { |
| | | File file = new File(mf.getPath()); |
| | | if (!file.exists()) { |
| | | mf.setMsg("文件丢失"); |
| | | return; |
| | | } |
| | | |
| | | MetaEntity old = metaService.selectByGuid(mf.getGuid()); |
| | | if (null != old) { |
| | | mf.setMsg("文件已存在"); |
| | | FileHelper.deleteFiles(file); |
| | | return; |
| | | } |
| | | |
| | | String uploadPath = pathHelper.getUploadFullPath(); |
| | | String targetPath = uploadPath + File.separator + mf.getGuid() + mf.getExtName(); |
| | | |
| | | File newFile = new File(targetPath); |
| | | if (newFile.exists() && newFile.isDirectory()) { |
| | | FileHelper.deleteFiles(file); |
| | | return; |
| | | } |
| | | |
| | | newFile.mkdirs(); |
| | | File[] files = file.listFiles(); |
| | | if (null == files || files.length == 0) { |
| | | return; |
| | | } |
| | | |
| | | for (File f : files) { |
| | | String subPath = targetPath + File.separator + FileHelper.getFileName(f.getPath()); |
| | | f.renameTo(new File(subPath)); |
| | | } |
| | | |
| | | String subPath = FileHelper.getRelativePath(targetPath); |
| | | mf.setPath(subPath); |
| | | } |
| | | |
| | | /** |
| | | * 插入元数据 |
| | | * |
| | | * @param list |
| | | */ |
| | | private void insertMetas(List<MetaFileEntity> list) { |
| | | for (MetaFileEntity mf : list) { |