From 542a030a93de7dbc39e185d4ce355c5894e3cd5b Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期二, 22 七月 2025 13:45:06 +0800
Subject: [PATCH] 解决切面日志插入失败

---
 se-common/src/main/java/com/terra/common/helper/FileHelper.java |   46 +++++++++++++++-------------------------------
 1 files changed, 15 insertions(+), 31 deletions(-)

diff --git a/se-system/src/main/java/com/terra/system/helper/FileHelper.java b/se-common/src/main/java/com/terra/common/helper/FileHelper.java
similarity index 92%
rename from se-system/src/main/java/com/terra/system/helper/FileHelper.java
rename to se-common/src/main/java/com/terra/common/helper/FileHelper.java
index fd36596..8279050 100644
--- a/se-system/src/main/java/com/terra/system/helper/FileHelper.java
+++ b/se-common/src/main/java/com/terra/common/helper/FileHelper.java
@@ -1,9 +1,8 @@
-package com.terra.system.helper;
+package com.terra.common.helper;
 
 import com.terra.common.entity.all.StaticData;
-import com.terra.system.entity.data.MetaFileEntity;
 //import com.twmacinta.util.MD5;
-import org.apache.commons.codec.digest.DigestUtils;
+//import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -11,6 +10,7 @@
 import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
 import java.security.MessageDigest;
 import java.text.DecimalFormat;
 import java.util.List;
@@ -236,43 +236,27 @@
     /**
      * 3.鑾峰彇鏂囦欢MD5鐮侊紙JDK锛�
      */
-    public static String getMd5ByJdk(String filePath) throws IOException {
+    /*public static String getMd5ByJdk(String filePath) throws IOException {
         FileInputStream fileStream = new FileInputStream(filePath);
         String md5 = DigestUtils.md5Hex(fileStream);
         fileStream.close();
 
         return md5;
-    }
+    }*/
 
     /**
      * 2.鑾峰彇蹇�� MD5 鐮�
      */
-    public static String getFastMd5(String filePath) throws IOException {
-        /*String hash = MD5.asHex(MD5.getHash(new File(filePath)));
+    /*public static String getFastMd5(String filePath) throws IOException {
+        String hash = MD5.asHex(MD5.getHash(new File(filePath)));
 
         MD5 md5 = new MD5();
         md5.Update(hash, null);
 
-        return md5.asHex();*/
+        return md5.asHex();
 
         return null;
-    }
-
-    /**
-     * 鍒犻櫎鏂囦欢
-     */
-    public static void deleteFiles(List<MetaFileEntity> list) {
-        try {
-            for (MetaFileEntity mf : list) {
-                File f = new File(mf.getPath());
-                if (f.exists()) {
-                    f.delete();
-                }
-            }
-        } catch (Exception ex) {
-            log.error(ex.getMessage(), ex);
-        }
-    }
+    }*/
 
     /**
      * 鍒犻櫎鏂囦欢澶�
@@ -366,7 +350,7 @@
 
             return byteToHexString(b);
         } catch (Exception ex) {
-            ex.printStackTrace();
+            log.error(ex.getMessage(), ex);
             return null;
         } finally {
             try {
@@ -374,7 +358,7 @@
                     fis.close();
                 }
             } catch (IOException ex) {
-                ex.printStackTrace();
+                log.error(ex.getMessage(), ex);
             }
         }
     }
@@ -453,8 +437,8 @@
         InputStream is = null;
         OutputStream os = null;
         try {
-            is = new FileInputStream(src);
-            os = new FileOutputStream(dest);
+            is = Files.newInputStream(src.toPath());
+            os = Files.newOutputStream(dest.toPath());
 
             byte[] buffer = new byte[1024];
 
@@ -463,8 +447,8 @@
                 os.write(buffer, 0, length);
             }
         } finally {
-            os.close();
-            is.close();
+            if (os != null) os.close();
+            if (is != null) is.close();
         }
     }
 }

--
Gitblit v1.9.3