From effc7aa4c1006fc2874f47f34db3be13384014ea Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期四, 09 二月 2023 13:02:39 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/service/show/DataLibService.java | 42 ++++++++++++++++++++++++++++++++++++++---- 1 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/lf/server/service/show/DataLibService.java b/src/main/java/com/lf/server/service/show/DataLibService.java index 77cf21b..a0fb6bf 100644 --- a/src/main/java/com/lf/server/service/show/DataLibService.java +++ b/src/main/java/com/lf/server/service/show/DataLibService.java @@ -207,12 +207,15 @@ /** * 鎵撳寘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, *"); } @@ -221,6 +224,37 @@ 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; } } -- Gitblit v1.9.3