From 58dd3c49946f2960fbf5c20d55acbd162108eb2d Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期五, 24 三月 2023 18:08:18 +0800
Subject: [PATCH] 1

---
 src/main/java/com/lf/server/service/all/UploadAttachService.java |   46 ++++++++++++++++++++++++++++++----------------
 1 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/src/main/java/com/lf/server/service/all/UploadAttachService.java b/src/main/java/com/lf/server/service/all/UploadAttachService.java
index 53cb4b3..74a669d 100644
--- a/src/main/java/com/lf/server/service/all/UploadAttachService.java
+++ b/src/main/java/com/lf/server/service/all/UploadAttachService.java
@@ -16,6 +16,7 @@
 import net.lingala.zip4j.ZipFile;
 import net.lingala.zip4j.model.FileHeader;
 import net.lingala.zip4j.model.ZipParameters;
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -273,22 +274,33 @@
 
         int rows = 0;
         for (Object obj : list) {
-            String name = getAnnexName(obj, field);
-            if (StringHelper.isEmpty(name)) {
+            String[] names = getNames(getAnnexName(obj, field));
+            if (null == names || names.length == 0) {
                 continue;
             }
 
-            String file = findAnnexFile(name, folder, files);
-            if (null == file) {
-                continue;
-            }
+            for (String name : names) {
+                String file = findAnnexFile(name, folder, files);
+                if (null == file) {
+                    continue;
+                }
 
-            BaseEntity be = (BaseEntity) obj;
-            rows += insertXlsAnnex(ue, meta, be, file);
-            files.remove(file);
+                rows += insertXlsAnnex(ue, meta, (BaseEntity) obj, file);
+            }
         }
 
         return rows;
+    }
+
+    /**
+     * 鑾峰彇鍚嶇О
+     */
+    private String[] getNames(String str) {
+        if (StringHelper.isEmpty(str)) {
+            return null;
+        }
+
+        return str.replace("锛�", ",").replace("锛�", ",").split(",");
     }
 
     /**
@@ -375,7 +387,6 @@
         String md5 = FileHelper.getFileMd5(file);
         AttachEntity old = attachService.selectByTabAndGuid(meta.getTab(), be.getEventid(), md5);
         if (null != old) {
-            f.delete();
             return 0;
         }
 
@@ -385,10 +396,13 @@
         AttachEntity ae = getAttachEntity(ue, meta.getTab(), be.getEventid(), fileName, md5, sizes);
         String targetPath = pathHelper.getConfig().getUploadPath() + File.separator + ae.getPath();
 
-        f.renameTo(new File(targetPath));
-        int rows = attachService.insert(ae);
+        try {
+            FileUtils.copyFile(f, new File(targetPath));
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+        }
 
-        return rows > 0 ? 1 : 0;
+        return attachService.insert(ae);
     }
 
     /**
@@ -413,7 +427,7 @@
     /**
      * 璇锋眰涓嬭浇
      */
-    public String downloadReqForGuids(UserEntity ue, String[] guids) {
+    public String downloadReqForGuids(UserEntity ue, List<String> guids) {
         List<AttachEntity> list = attachService.selectByGuids(guids);
 
         return downloadReq(ue, list);
@@ -422,7 +436,7 @@
     /**
      * 璇锋眰涓嬭浇
      */
-    public String downloadReqForTabGuids(UserEntity ue, String tab, String[] guids) {
+    public String downloadReqForTabGuids(UserEntity ue, String tab, List<String> guids) {
         List<AttachEntity> list = attachService.selectByTabGuids(tab, guids);
 
         return downloadReq(ue, list);
@@ -440,7 +454,7 @@
         String zipFile = pathHelper.getDownloadFullPath() + File.separator + zipName;
 
         ZipFile zip = Zip4jHelper.createZipFile(zipFile, null);
-        ZipParameters params = Zip4jHelper.getZipParams();
+        ZipParameters params = Zip4jHelper.getZipParams(false);
         addZipFiles(zip, params, list);
 
         DownloadEntity downloadEntity = getDownloadEntity(ue, zipFile, null);

--
Gitblit v1.9.3