| | |
| | | /** |
| | | * 打包DB数据 |
| | | */ |
| | | public String zipDbData(UserEntity ue, BasicMapper baseMapper, String filter, String pwd) { |
| | | boolean flag = baseMapper instanceof GeomBaseMapper; |
| | | public String zipDbData(UserEntity ue, String name, String filter, String pwd) throws Exception { |
| | | BasicMapper baseMapper = ClassHelper.getBasicMapper(name); |
| | | if (baseMapper == null) { |
| | | return null; |
| | | } |
| | | |
| | | QueryWrapper wrapper = new QueryWrapper(); |
| | | baseQueryService.addFilterWrapper(wrapper, filter); |
| | | if (flag) { |
| | | if (baseMapper instanceof GeomBaseMapper) { |
| | | wrapper.select("ST_AsText(geom) as geom, *"); |
| | | } |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | return null; |
| | | Map<String, List<?>> map = new HashMap<>(1); |
| | | map.put(name, list); |
| | | |
| | | return zipData(ue, map, pwd); |
| | | } |
| | | |
| | | /** |
| | | * 打包数据 |
| | | */ |
| | | private String zipData(UserEntity ue, Map<String, List<?>> map, String pwd) throws Exception { |
| | | String tempName = StringHelper.YMDHMS2_FORMAT.format(new Date()); |
| | | String tempPath = pathHelper.getTempPath(tempName); |
| | | String filePath = tempPath + File.separator + tempName + ".gdb"; |
| | | |
| | | File file = new File(filePath); |
| | | if (file.exists() && file.isDirectory()) { |
| | | FileHelper.deleteDir(filePath); |
| | | } |
| | | GdbHelper.createGdb(filePath, map); |
| | | |
| | | String zipName = tempName + ".gdb.zip"; |
| | | String zipFile = pathHelper.getDownloadFullPath() + File.separator + zipName; |
| | | |
| | | ZipFile zip = Zip4jHelper.createZipFile(zipFile, pwd); |
| | | ZipParameters params = Zip4jHelper.getZipParams(); |
| | | addZipFiles(zip, params, file.listFiles()); |
| | | |
| | | String dbPwd = Md5Helper.reverse(Md5Helper.generate(pwd)); |
| | | DownloadEntity downloadEntity = getDownloadEntity(ue, zipFile, dbPwd); |
| | | int rows = downloadMapper.insert(downloadEntity); |
| | | |
| | | return rows > 0 ? downloadEntity.getGuid() : null; |
| | | } |
| | | } |