From b885fe8d0c0f7c7053b998758f84da054e8cfc6a Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期一, 03 四月 2023 13:42:11 +0800
Subject: [PATCH] 1

---
 src/main/java/com/lf/server/service/show/DataLibService.java  |    8 ++++----
 data/db_cx.sql                                                |    7 ++-----
 src/main/java/com/lf/server/service/data/DownloadService.java |   42 ++++++++++++++++++++++++++++++++++++------
 3 files changed, 42 insertions(+), 15 deletions(-)

diff --git a/data/db_cx.sql b/data/db_cx.sql
index 142566a..541f67a 100644
--- a/data/db_cx.sql
+++ b/data/db_cx.sql
@@ -17,11 +17,8 @@
 select * from lf.sys_meta where name='鍕樻帰鐐瑰湴灞傝〃.xlsx' or type='fbx'
 --delete from bs.s_explorationpointstratum where parentid in (select eventid from lf.sys_meta where name='鍕樻帰鐐瑰湴灞傝〃.xlsx');
 --delete from lf.sys_meta where name='鍕樻帰鐐瑰湴灞傝〃.xlsx';
-
-select * from lf.sys_attach where tab = 'bs.s_explorationpoint' and tab_guid in (select eventid from bs.s_explorationpoint where gid > 1)
-select * from lf.sys_attach where tab != 'bd.b_borehole'
-select * from lf.sys_publish
-
+select * from lf.sys_meta where 
+type = 'tif' or type = 'tiff' or lower(name) in ('骞抽潰鍥剧储寮曟枃浠�.xlsx', '绌胯法瓒婂湴褰㈠浘.dwg', '涓嚎鎴愭灉琛�.xlsx', '绂绘暎鐐�.xlsx', '鎺у埗鐐�.xlsx', '鍦伴潰绾�.xlsx')
 
 
 
diff --git a/src/main/java/com/lf/server/service/data/DownloadService.java b/src/main/java/com/lf/server/service/data/DownloadService.java
index f86a857..8383fa7 100644
--- a/src/main/java/com/lf/server/service/data/DownloadService.java
+++ b/src/main/java/com/lf/server/service/data/DownloadService.java
@@ -5,10 +5,12 @@
 import com.lf.server.entity.data.DownloadEntity;
 import com.lf.server.entity.data.MetaEntity;
 import com.lf.server.entity.show.PipelineEntity;
+import com.lf.server.entity.sys.AttachEntity;
 import com.lf.server.entity.sys.MetaDownEntity;
 import com.lf.server.entity.sys.UserEntity;
 import com.lf.server.helper.*;
 import com.lf.server.mapper.data.DownloadMapper;
+import com.lf.server.service.show.DataLibService;
 import com.lf.server.service.sys.MetaDownService;
 import net.lingala.zip4j.ZipFile;
 import net.lingala.zip4j.model.FileHeader;
@@ -32,6 +34,9 @@
 
     @Autowired
     DownloadMapper downloadMapper;
+
+    @Autowired
+    DataLibService dataLibService;
 
     @Autowired
     MetaDownService metaDownService;
@@ -188,21 +193,39 @@
      * @param pwd  瀵嗙爜
      * @return 涓嬭浇鏂囦欢GUID
      */
-    public String zipFiles(UserEntity ue, List<MetaEntity> list, String pwd) {
+    public String zipFiles(UserEntity ue, List<MetaEntity> list, String pwd) throws Exception {
         Map<String, List<String>> tabs = getTabs(list);
         rmRepeatMetas(list);
 
-        String downloadPath = pathHelper.getDownloadFullPath();
-        String zipName = StringHelper.YMDHMS2_FORMAT.format(new Date()) + ".zip";
-        String zipFile = downloadPath + File.separator + zipName;
+        Map<String, List<?>> dataMap = new HashMap<>(2);
+        Map<String, List<AttachEntity>> annexMap = new HashMap<>(2);
+        queryData(tabs, dataMap, annexMap);
 
+        //String downloadPath = pathHelper.getDownloadFullPath();
+        //String zipName = StringHelper.YMDHMS2_FORMAT.format(new Date()) + ".zip";
+        //String zipFile = downloadPath + File.separator + zipName;
+
+        String tempName = StringHelper.YMDHMS2_FORMAT.format(new Date());
+        String tempPath = pathHelper.getTempPath(tempName);
+        String gdbPath = tempPath + File.separator + "tabs.gdb";
+
+        File gdbFile = new File(gdbPath);
+        if (gdbFile.exists() && gdbFile.isDirectory()) {
+            FileHelper.deleteDir(gdbPath);
+        }
+        if (dataMap.size() > 0) {
+            GdbHelper.createGdb(gdbPath, dataMap);
+        }
+
+        String zipFile = pathHelper.getDownloadFullPath() + File.separator + tempName + ".gdb.zip";
         ZipFile zip = Zip4jHelper.createZipFile(zipFile, pwd);
         ZipParameters params = Zip4jHelper.getZipParams(true);
-        addMetaFiles(zip, params, list);
+        //addMetaFiles(zip, params, list);
+        zip.addFolder(new File(gdbPath), params);
+        dataLibService.addAnnex(zip, params, annexMap);
 
         String dbPwd = Md5Helper.reverse(Md5Helper.generate(pwd));
         DownloadEntity de = getDownloadEntity(ue, zipFile, dbPwd);
-
         int rows = downloadMapper.insert(de);
         if (de.getId() > 0) {
             insertMetaDown(ue, list, de);
@@ -254,6 +277,13 @@
     }
 
     /**
+     * 鏌ヨ鏁版嵁
+     */
+    private void queryData(Map<String, List<String>> tabs, Map<String, List<?>> dataMap, Map<String, List<AttachEntity>> annexMap) {
+        //
+    }
+
+    /**
      * 娣诲姞鍏冩暟鎹枃浠惰嚦Zip鍖�
      */
     private void addMetaFiles(ZipFile zip, ZipParameters params, List<MetaEntity> list) {
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 0bdeb1c..11a542f 100644
--- a/src/main/java/com/lf/server/service/show/DataLibService.java
+++ b/src/main/java/com/lf/server/service/show/DataLibService.java
@@ -168,10 +168,10 @@
         addAnnex(zip, params, annexMap);
 
         String dbPwd = Md5Helper.reverse(Md5Helper.generate(dr.getPwd()));
-        DownloadEntity downloadEntity = getDownloadEntity(ue, zipFile, dbPwd);
-        int rows = downloadMapper.insert(downloadEntity);
+        DownloadEntity de = getDownloadEntity(ue, zipFile, dbPwd);
+        int rows = downloadMapper.insert(de);
 
-        return rows > 0 ? downloadEntity.getGuid() : null;
+        return rows > 0 ? de.getGuid() : null;
     }
 
     /**
@@ -289,7 +289,7 @@
     /**
      * 娣诲姞闄勪欢
      */
-    private void addAnnex(ZipFile zip, ZipParameters params, Map<String, List<AttachEntity>> annexMap) {
+    public void addAnnex(ZipFile zip, ZipParameters params, Map<String, List<AttachEntity>> annexMap) {
         List<String> files = new ArrayList<>();
         String uploadPath = pathHelper.getConfig().getUploadPath();
         for (String key : annexMap.keySet()) {

--
Gitblit v1.9.3