From d6e936e3dcb645658fa7e0c3e02c1daa30bfeb68 Mon Sep 17 00:00:00 2001
From: sinake <sinake1@qq.com>
Date: 星期二, 13 十月 2026 15:55:56 +0800
Subject: [PATCH] 上传命名规则调整

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java |   47 ++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 36 insertions(+), 11 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
index d361a51..16be382 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
@@ -3,13 +3,17 @@
 import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.file.FileUploadUtils;
 import com.ruoyi.common.utils.file.FileUtils;
 import com.ruoyi.framework.config.ServerConfig;
+import io.swagger.annotations.ApiOperation;
 import org.apache.catalina.connector.Connector;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.coyote.AbstractProtocol;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.text.PDFTextStripper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -82,19 +86,23 @@
             String filename = file.getOriginalFilename().trim();
             String felinamePath = FileUploadUtils.extractFilename(file);
 //            String pathFileName = FileUploadUtils.getPathFileName(filePath, s);
-            File file1 = new File(filePath + "/" + felinamePath);
-            boolean exists = file1.exists();
-            if (exists) {
-                int i = filename.lastIndexOf(".");
-                String startStr = filename.substring(0, i);
-                String endStr = filename.substring(i, filename.length());
+            for (int i=1;i<500;i++) {
+                File file1 = new File(filePath + "/" + felinamePath);
+                boolean exists = file1.exists();
+                if (exists) {
+                    int index = filename.lastIndexOf(".");
+                    String startStr = filename.substring(0, index);
+                    String endStr = filename.substring(index, filename.length());
 
-                String newFilename = startStr + System.currentTimeMillis() + endStr; // your new filename
-                String contentType = file.getContentType();
-                byte[] bytes = file.getBytes();
-                file = new MockMultipartFile(newFilename, newFilename, contentType, bytes);
+                    String newFilename = startStr + "-" + i + endStr; // your new filename
+                    felinamePath = DateUtils.datePath() + "/" + newFilename;
+                    String contentType = file.getContentType();
+                    byte[] bytes = file.getBytes();
+                    file = new MockMultipartFile(newFilename, newFilename, contentType, bytes);
+                }else{
+                    break;
+                }
             }
-
             // 涓婁紶骞惰繑鍥炴柊鏂囦欢鍚嶇О
             String fileName = FileUploadUtils.upload(filePath, file);
             String url1 = serverConfig.getUrl();
@@ -177,4 +185,21 @@
         }
         return 0;
     }
+
+    @ApiOperation("pdf璇嗗埆")
+    @GetMapping("/common/pdfBox")
+    public String pdfBox(String filePath) throws Exception {
+        try (PDDocument document = PDDocument.load(new File(filePath))) {
+            PDFTextStripper stripper = new PDFTextStripper();
+            stripper.setSortByPosition(true); // 鎸夐〉闈㈡帓鐗堥『搴忚緭鍑烘枃瀛楋紝鍙戠エ蹇呴』寮�杩欎釜
+            // 鍙戠エ浠g爜
+            String codeReg = "鍙戠エ浠g爜[:锛歖(\\d{10,12})";
+            // 鍙戠エ鍙风爜
+            String noReg = "鍙戠エ鍙风爜[:锛歖(\\d{8})";
+            // 浠风◣鍚堣
+            String amountReg = "浠风◣鍚堣.*?楼([0-9.]+)";
+            String text=stripper.getText(document);
+            return text;
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3