From ed8c7a5effd0d423ce1118b680ecdca6fe732609 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期三, 02 七月 2025 16:43:13 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.11.205:9000/r/P2022036_Service

---
 src/main/java/com/lf/server/service/data/DownloadService.java |  192 +++--------------------------------------------
 1 files changed, 14 insertions(+), 178 deletions(-)

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 708df7e..6d4e5f3 100644
--- a/src/main/java/com/lf/server/service/data/DownloadService.java
+++ b/src/main/java/com/lf/server/service/data/DownloadService.java
@@ -1,25 +1,17 @@
 package com.lf.server.service.data;
 
-import com.lf.server.entity.all.StaticData;
-import com.lf.server.entity.ctrl.DownloadReqEntity;
+import com.lf.server.entity.all.AbstractPwdEntity;
 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.UserEntity;
 import com.lf.server.helper.*;
 import com.lf.server.mapper.data.DownloadMapper;
-import net.lingala.zip4j.ZipFile;
-import net.lingala.zip4j.model.FileHeader;
-import net.lingala.zip4j.model.ZipParameters;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.io.File;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 /**
  * 涓嬭浇璁板綍
@@ -37,30 +29,30 @@
 
     @Override
     public Integer selectCount(String name) {
-        name = StringHelper.getLikeStr(name);
+        name = StringHelper.getLikeUpperStr(name);
 
         return downloadMapper.selectCount(name);
     }
 
     @Override
     public List<DownloadEntity> selectByPage(String name, Integer limit, Integer offset) {
-        name = StringHelper.getLikeStr(name);
+        name = StringHelper.getLikeUpperStr(name);
 
         return downloadMapper.selectByPage(name, limit, offset);
     }
 
     @Override
-    public Integer selectCountForUser(Integer createUser, Integer type, String name) {
-        name = StringHelper.getLikeStr(name);
+    public Integer selectCountForUser(Integer createUser, String types, String name) {
+        name = StringHelper.getLikeUpperStr(name);
 
-        return downloadMapper.selectCountForUser(createUser, type, name);
+        return downloadMapper.selectCountForUser(createUser, types, name);
     }
 
     @Override
-    public List<DownloadEntity> selectByPageForUser(Integer createUser, Integer type, String name, Integer limit, Integer offset) {
-        name = StringHelper.getLikeStr(name);
+    public List<DownloadEntity> selectByPageForUser(Integer createUser, String types, String name, Integer limit, Integer offset) {
+        name = StringHelper.getLikeUpperStr(name);
 
-        return downloadMapper.selectByPageForUser(createUser, type, name, limit, offset);
+        return downloadMapper.selectByPageForUser(createUser, types, name, limit, offset);
     }
 
     @Override
@@ -121,17 +113,17 @@
     /**
      * 瑙e瘑
      *
-     * @param reqEntity 璇锋眰涓嬭浇瀹炰綋绫�
+     * @param entity 瀵嗙爜鎶借薄绫�
      * @return 鏄�/鍚﹁В瀵嗘垚鍔�
      */
-    public static boolean decryptPwd(DownloadReqEntity reqEntity) {
+    public static boolean decryptPwd(AbstractPwdEntity entity) {
         try {
-            String pwd = RsaHelper.decrypt(reqEntity.getPwd());
+            String pwd = RsaHelper.decrypt(entity.getPwd());
             if (StringHelper.isEmpty(pwd)) {
                 return false;
             }
 
-            reqEntity.setPwd(pwd);
+            entity.setPwd(pwd);
 
             return true;
         } catch (Exception ex) {
@@ -175,161 +167,5 @@
             log.error(ex.getMessage(), ex);
             return null;
         }
-    }
-
-    /**
-     * 鎵撳寘鏂囦欢
-     *
-     * @param ue   鐢ㄦ埛瀹炰綋
-     * @param list 婧愭暟鎹枃浠堕泦鍚�
-     * @param pwd  瀵嗙爜
-     * @return 涓嬭浇鏂囦欢GUID
-     */
-    public String zipFiles(UserEntity ue, List<MetaEntity> list, String pwd) throws Exception {
-        rmRepeatMetaFiles(list);
-
-        String downloadPath = pathHelper.getDownloadFullPath();
-        String zipName = StringHelper.YMDHMS2_FORMAT.format(new Date()) + ".zip";
-        String zipFile = downloadPath + File.separator + zipName;
-
-        ZipFile zip = Zip4jHelper.createZipFile(zipFile, pwd);
-        ZipParameters params = Zip4jHelper.getZipParams();
-        addMetaFiles(zip, params, list);
-
-        String dbPwd = Md5Helper.reverse(Md5Helper.generate(pwd));
-        DownloadEntity downloadEntity = getDownloadEntity(ue, zipFile, dbPwd);
-        int rows = downloadMapper.insert(downloadEntity);
-
-        return rows > 0 ? downloadEntity.getGuid() : null;
-    }
-
-    /**
-     * 绉婚櫎閲嶅鐨勬簮鏁版嵁鏂囦欢
-     */
-    private void rmRepeatMetaFiles(List<MetaEntity> list) {
-        List<String> guidList = new ArrayList<>();
-
-        int i = 0;
-        while (i < list.size()) {
-            MetaEntity entity = list.get(i);
-            if (guidList.contains(entity.getGuid())) {
-                list.remove(i);
-                continue;
-            }
-
-            guidList.add(entity.getGuid());
-            i++;
-        }
-    }
-
-    /**
-     * 娣诲姞婧愭暟鎹枃浠惰嚦Zip鍖�
-     */
-    private void addMetaFiles(ZipFile zip, ZipParameters params, List<MetaEntity> list) {
-        int i = 1;
-        String uploadPath = pathHelper.getConfig().getUploadPath();
-        for (MetaEntity mf : list) {
-            try {
-                switch ("." + mf.getType()) {
-                    case StaticData.MPT:
-                        addMultiFile(i++, uploadPath, mf, zip, params, StaticData.MPT_EXT);
-                        break;
-                    case StaticData.IMG:
-                        addMultiFile(i++, uploadPath, mf, zip, params, StaticData.IMG_EXT);
-                        break;
-                    case StaticData.TIF:
-                        addMultiFile(i++, uploadPath, mf, zip, params, StaticData.TIF_EXT);
-                        break;
-                    case StaticData.TIFF:
-                        addMultiFile(i++, uploadPath, mf, zip, params, StaticData.TIFF_EXT);
-                        break;
-                    case StaticData.SHP:
-                        addMultiFile(i++, uploadPath, mf, zip, params, StaticData.SHP_EXT);
-                        break;
-                    case StaticData.GDB:
-                        addFolderFile(i++, uploadPath, mf, zip, params);
-                        break;
-                    default:
-                        addSingleFile(i++, uploadPath, mf, zip, params);
-                        break;
-                }
-
-            } catch (Exception ex) {
-                log.error(ex.getMessage(), ex);
-            }
-        }
-    }
-
-    /**
-     * 娣诲姞鐩綍鏂囦欢
-     */
-    private void addFolderFile(int i, String uploadPath, MetaEntity mf, ZipFile zip, ZipParameters params) throws Exception {
-        File file = new File(uploadPath + File.separator + mf.getPath());
-        if (!file.exists() || !file.isDirectory()) {
-            return;
-        }
-        zip.addFolder(file, params);
-
-        String fileName = FileHelper.getFileName(file.getPath());
-        FileHeader header = zip.getFileHeader(fileName);
-        if (null != header) {
-            zip.renameFile(header, i + "_" + mf.getName());
-        }
-    }
-
-    /**
-     * 娣诲姞澶氭枃浠�
-     */
-    private void addMultiFile(int i, String uploadPath, MetaEntity mf, ZipFile zip, ZipParameters params, List<String> extList) throws Exception {
-        addSingleFile(i, uploadPath, mf, zip, params);
-
-        for (String ext : extList) {
-            File file = new File(uploadPath + File.separator + mf.getPath().replace("." + mf.getType(), ext));
-            if (!file.exists() || file.isDirectory()) {
-                continue;
-            }
-            zip.addFile(file, params);
-
-            String fileName = FileHelper.getFileName(file.getPath());
-            FileHeader header = zip.getFileHeader(fileName);
-            if (null != header) {
-                zip.renameFile(header, i + "_" + mf.getName().replace("." + mf.getType(), ext));
-            }
-        }
-    }
-
-    /**
-     * 娣诲姞鍗曟枃浠�
-     */
-    private void addSingleFile(int i, String uploadPath, MetaEntity mf, ZipFile zip, ZipParameters params) throws Exception {
-        File file = new File(uploadPath + File.separator + mf.getPath());
-        zip.addFile(file, params);
-
-        String fileName = FileHelper.getFileName(file.getPath());
-        FileHeader header = zip.getFileHeader(fileName);
-        if (null != header) {
-            zip.renameFile(header, i + "_" + mf.getName());
-        }
-    }
-
-    /**
-     * 鑾峰彇涓嬭浇瀹炰綋绫�
-     */
-    private DownloadEntity getDownloadEntity(UserEntity ue, String file, String pwd) throws Exception {
-        DownloadEntity de = new DownloadEntity();
-        de.setName(FileHelper.getFileName(file));
-        // 1-Shp鏂囦欢锛�2-涓撻鍥撅紝3-婧愭暟鎹紝4-涓氬姟鏁版嵁锛�5-绠¢亾鍒嗘瀽锛�6-缁熻鎶ュ憡
-        de.setType(3);
-        de.setSizes(FileHelper.sizeToMb(new File(file).length()));
-        de.setDepid(ue.getDepid());
-        de.setDcount(0);
-        de.setPwd(pwd);
-        de.setUrl(FileHelper.getRelativePath(file));
-        de.setDescr("婧愭暟鎹枃浠�");
-        de.setGuid(FileHelper.getFileMd5(file));
-        de.setCreateUser(ue.getId());
-        // de.setGeom(null)
-
-        return de;
     }
 }

--
Gitblit v1.9.3