Quellcode durchsuchen

Merge remote-tracking branch 'origin/dify'

# Conflicts:
#	src/main/java/cn/cslg/pas/controller/outApi/DifyController.java
#	src/main/java/cn/cslg/pas/service/common/DifyService.java
#	src/main/resources/application-dev.yml
lrj vor 4 Monaten
Ursprung
Commit
3b440918c5

+ 23 - 11
pom.xml

@@ -23,7 +23,7 @@
         <google.code.gson.version>2.7</google.code.gson.version>
         <hutool.version>5.6.5</hutool.version>
         <okhttps.version>4.10.0</okhttps.version>
-        <poi.version>4.1.2</poi.version>
+        <poi.version>5.2.5</poi.version>
         <poi-tl.version>1.10.3</poi-tl.version>
         <druid.version>1.1.20</druid.version>
         <fastjson.version>2.0.12</fastjson.version>
@@ -68,16 +68,16 @@
             <artifactId>fastjson</artifactId>
             <version>${fastjson.version}</version>
         </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-compress</artifactId>
-            <version>1.21</version>
-        </dependency>
-        <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-            <version>2.6</version>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>org.apache.commons</groupId>-->
+<!--            <artifactId>commons-compress</artifactId>-->
+<!--            <version>1.21</version>-->
+<!--        </dependency>-->
+<!--        <dependency>-->
+<!--            <groupId>commons-io</groupId>-->
+<!--            <artifactId>commons-io</artifactId>-->
+<!--            <version>2.6</version>-->
+<!--        </dependency>-->
         <dependency>
             <groupId>io.jsonwebtoken</groupId>
             <artifactId>jjwt</artifactId>
@@ -289,6 +289,13 @@
             <artifactId>flexmark-all</artifactId>
             <version>0.64.8</version>
         </dependency>
+
+        <dependency>
+            <groupId>com.aspose</groupId>
+            <artifactId>aspose-words</artifactId>
+            <version>22.10</version> <!-- 替换为最新版本 -->
+            <classifier>jdk17</classifier>
+        </dependency>
     </dependencies>
 
     <build>
@@ -339,6 +346,11 @@
     <!--阿里云镜像源(因需要提交到GithubActions,会引起依赖下载过慢的问题)-->
     <repositories>
         <repository>
+            <id>AsposeJavaAPI</id>
+            <name>Aspose Java API Repository</name>
+            <url>https://repository.aspose.com/repo/</url>
+        </repository>
+        <repository>
             <id>nexus-aliyun</id>
             <name>nexus-aliyun</name>
             <url>http://maven.aliyun.com/nexus/content/groups/public/</url>

+ 15 - 0
src/main/java/cn/cslg/pas/common/model/poi/PoiRemarkVO.java

@@ -0,0 +1,15 @@
+package cn.cslg.pas.common.model.poi;
+
+import lombok.Data;
+
+import java.math.BigInteger;
+
+@Data
+public class PoiRemarkVO {
+    private BigInteger commentId;
+    private Integer index;
+    private String trueContent;
+    private Integer remarkType;
+    private String type;
+    private String reason;
+}

+ 17 - 0
src/main/java/cn/cslg/pas/common/model/poi/PoiWordRunVO.java

@@ -0,0 +1,17 @@
+package cn.cslg.pas.common.model.poi;
+
+import lombok.Data;
+
+@Data
+public class PoiWordRunVO {
+    private Integer index;
+
+    private Integer lastIndex;
+    private String content;//原文内容
+
+    private String trueContent;
+
+    private Boolean ifRemark;
+    private String type;
+    private String reason;
+}

+ 1 - 1
src/main/java/cn/cslg/pas/common/utils/ExcelUtils.java

@@ -167,7 +167,7 @@ public class ExcelUtils {
 
     public static String getValue(Cell cell) {
         if (cell != null) {
-            if (cell.getCellType() == CellType.NUMERIC && HSSFDateUtil.isCellDateFormatted(cell)) {
+            if (cell.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell)) {
                 Date date = cell.getDateCellValue();
                 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
                 String dateString = dateFormat.format(date);

+ 1 - 1
src/main/java/cn/cslg/pas/common/utils/ReadExcelUtils.java

@@ -220,7 +220,7 @@ public class ReadExcelUtils {
 
     public static String getValue(Cell cell) {
         if (cell != null) {
-            if (cell.getCellType() == CellType.NUMERIC && HSSFDateUtil.isCellDateFormatted(cell)) {
+            if (cell.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell)) {
                 Date date = cell.getDateCellValue();
                 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
                 String dateString = dateFormat.format(date);

+ 34 - 0
src/main/java/cn/cslg/pas/common/utils/StringUtils.java

@@ -526,4 +526,38 @@ public class StringUtils {
     public static <T> String join(String[] list, String separator) {
         return org.apache.commons.lang3.StringUtils.join(list, separator);
     }
+
+
+    public static List<String> splitChineseText(String text,Integer textNum) {
+        List<String> chunks = new ArrayList<>();
+        int start = 0;
+        int textLength = text.length();
+        if (text.length() < textNum) {
+            chunks.add(text);
+            return chunks;
+        }
+        while (start < textLength) {
+            // 计算当前块的最大可能结束位置
+            int end = Math.min(start + textNum, textLength);
+            int lastSentenceEnd = -1;
+
+            // 从后向前查找最后一个句号
+            for (int i = end - 1; i >= start; i--) {
+                if (text.charAt(i) == '。') {
+                    lastSentenceEnd = i;
+                    break;
+                }
+            }
+
+            if (lastSentenceEnd != -1) {
+                // 切割文本并添加到结果集
+                chunks.add(text.substring(start, lastSentenceEnd + 1));
+                start = lastSentenceEnd + 1;
+            } else {
+                // 异常处理:当前2000字符范围内没有句号
+                throw new RuntimeException("文本位置 " + start + " 至 " + end + " 之间未找到句号,请检查输入文本格式");
+            }
+        }
+        return chunks;
+    }
 }

Datei-Diff unterdrückt, da er zu groß ist
+ 1417 - 0
src/main/java/cn/cslg/pas/service/TemplateExportService.java


Datei-Diff unterdrückt, da er zu groß ist
+ 391 - 0
src/main/java/cn/cslg/pas/service/common/POIService.java


+ 3 - 3
src/main/java/cn/cslg/pas/service/common/PatentStarApiService.java

@@ -195,9 +195,9 @@ public class PatentStarApiService {
         String signMd5 = FormatUtil.MD5(Sign);
         // 创建一个OkHttpClient对象
         OkHttpClient okHttpClient = new OkHttpClient.Builder()
-                .connectTimeout(5, TimeUnit.SECONDS)
-                .writeTimeout(5, TimeUnit.SECONDS)
-                .readTimeout(5, TimeUnit.SECONDS)
+                .connectTimeout(10, TimeUnit.SECONDS)
+                .writeTimeout(10, TimeUnit.SECONDS)
+                .readTimeout(10, TimeUnit.SECONDS)
                 .addInterceptor(new PatentStarApiService.OkhttpInterceptor(3))
                 .build();
 

+ 28 - 0
src/test/java/cn/cslg/pas/DifyTest.java

@@ -0,0 +1,28 @@
+package cn.cslg.pas;
+
+import cn.cslg.pas.common.utils.FileUtils;
+import cn.cslg.pas.service.common.POIService;
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.io.File;
+import java.io.FileOutputStream;
+@SpringBootTest
+public class DifyTest {
+@Autowired
+private POIService poiService;
+
+    @Test
+    public void checkFile() throws Exception {
+//        String path = "E:\\temfile\\poi\\test1.docx";
+//        File file=new File(path);
+//
+//        XWPFDocument doc = poiService.checkPatentFile(path);
+//        FileOutputStream out = new FileOutputStream("E:\\temfile\\poi\\output2.docx");
+//        doc.write(out);
+//        out.close();
+//        doc.close();
+    }
+}