Quellcode durchsuchen

Merge branch 'wq' of SH-Arbitrate/Arbitrate-Backend into dev

wangqiong123 vor 2 Jahren
Ursprung
Commit
a87fdca103

+ 13
- 1
ruoyi-admin/src/main/resources/application.yml Datei anzeigen

@@ -182,4 +182,16 @@ imConfig:
182 182
   # 腾讯云账户 SecretId
183 183
   secretId: AKID3xfHgroY4MQHvLXUXMwIQL1UjmbBX1Tv
184 184
   # 腾讯云密钥
185
-  secretKey: INDrIXcT8YmomZBcsy0oNirnU0LTN4X7
185
+  secretKey: INDrIXcT8YmomZBcsy0oNirnU0LTN4X7
186
+jodconverter:
187
+  local:
188
+    #暂时关闭预览,启动时会有点慢
189
+    enabled: true
190
+    #设置libreoffice主目录 linux地址如:/usr/lib64/libreoffice
191
+    office-home: /usr/lib64/libreoffice
192
+#    office-home: D:/Program Files/LibreOffice
193
+#    office-home: D:\app\libreOffice
194
+    #开启多个libreoffice进程,每个端口对应一个进程
195
+    port-numbers: 8100
196
+    #libreoffice进程重启前的最大进程数
197
+    max-tasks-per-process: 100

+ 45
- 0
ruoyi-common/pom.xml Datei anzeigen

@@ -11,12 +11,57 @@
11 11
 
12 12
     <artifactId>ruoyi-common</artifactId>
13 13
 
14
+
14 15
     <description>
15 16
         common通用工具
16 17
     </description>
17 18
 
18 19
     <dependencies>
19 20
 
21
+
22
+        <dependency>
23
+            <groupId>org.jodconverter</groupId>
24
+            <artifactId>jodconverter-core</artifactId>
25
+            <version>4.2.0</version>
26
+        </dependency>
27
+        <dependency>
28
+            <groupId>org.jodconverter</groupId>
29
+            <artifactId>jodconverter-local</artifactId>
30
+            <version>4.2.0</version>
31
+        </dependency>
32
+        <dependency>
33
+            <groupId>org.jodconverter</groupId>
34
+            <artifactId>jodconverter-spring-boot-starter</artifactId>
35
+            <version>4.2.0</version>
36
+        </dependency>
37
+        <dependency>
38
+            <groupId>com.artofsolving</groupId>
39
+            <artifactId>jodconverter</artifactId>
40
+            <version>2.2.1</version>
41
+        </dependency>
42
+        <dependency>
43
+            <groupId>org.openoffice</groupId>
44
+            <artifactId>jurt</artifactId>
45
+            <version>3.0.1</version>
46
+        </dependency>
47
+        <dependency>
48
+            <groupId>org.openoffice</groupId>
49
+            <artifactId>ridl</artifactId>
50
+            <version>3.0.1</version>
51
+        </dependency>
52
+        <dependency>
53
+            <groupId>org.openoffice</groupId>
54
+            <artifactId>juh</artifactId>
55
+            <version>3.0.1</version>
56
+        </dependency>
57
+        <dependency>
58
+            <groupId>org.openoffice</groupId>
59
+            <artifactId>unoil</artifactId>
60
+            <version>3.0.1</version>
61
+        </dependency>
62
+
63
+
64
+
20 65
         <!-- Spring框架基本的核心工具 -->
21 66
         <dependency>
22 67
             <groupId>org.springframework</groupId>

+ 119
- 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/LibreOfficeUtil.java Datei anzeigen

@@ -0,0 +1,119 @@
1
+package com.ruoyi.common.utils;
2
+
3
+import cn.hutool.extra.spring.SpringUtil;
4
+
5
+import com.artofsolving.jodconverter.DocumentConverter;
6
+import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
7
+import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
8
+import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
9
+import com.ruoyi.common.exception.ServiceException;
10
+import lombok.extern.slf4j.Slf4j;
11
+import org.jodconverter.document.DocumentFormat;
12
+import org.jodconverter.office.OfficeException;
13
+import org.springframework.beans.factory.annotation.Value;
14
+import org.springframework.http.MediaType;
15
+
16
+
17
+import java.io.File;
18
+import java.io.IOException;
19
+import java.io.InputStream;
20
+import java.io.OutputStream;
21
+
22
+/**
23
+ * LibreOffice工具类,用于将word,excel,ppt等格式文件转为pdf预览
24
+ *
25
+ * @author xuyuxiang
26
+ * @date 2020/7/6 14:55
27
+ */
28
+@Slf4j
29
+public class LibreOfficeUtil {
30
+    @Value("${jodconverter.local.office-home}")
31
+    private long OpenOffice_HOME;
32
+
33
+    private static DocumentConverter documentConverter;
34
+
35
+    private static void init() {
36
+        try {
37
+            documentConverter = SpringUtil.getBean(DocumentConverter.class);
38
+        } catch (Exception e) {
39
+            throw new ServiceException();
40
+        }
41
+    }
42
+
43
+
44
+    public static boolean doc2pdf(File docFile, File pdfFile) {
45
+        boolean result = false;// 转换结果
46
+        if (docFile.exists()) {
47
+            if (!pdfFile.exists()) {
48
+                OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
49
+                try {
50
+                    connection.connect();
51
+                    DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
52
+                    converter.convert(docFile, pdfFile);
53
+                    // 关闭连接
54
+                    connection.disconnect();
55
+                    result = true;
56
+
57
+                    log.info("****pdf转换成功,PDF输出:" + pdfFile.getPath() + "****");
58
+                } catch (java.net.ConnectException e) {
59
+                    log.error("openoffice服务未启动", e);
60
+                } catch (com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException e) {
61
+                    log.error("读取转换文件失败", e);
62
+                } catch (Exception e) {
63
+                    log.error("转换失败", e);
64
+                }
65
+            } else {
66
+                result = true;
67
+                log.info("****已经转换为pdf,不需要再进行转化****");
68
+            }
69
+        } else {
70
+            log.info("****需要转换的文档不存在,无法转换****");
71
+        }
72
+        return result;
73
+    }
74
+    /**
75
+     * doc转pdf(程序启动openoffice)
76
+     *
77
+     * @param inputFile 输入文件
78
+     * @param outputFile 输出文件
79
+     * @return
80
+     */
81
+    public static boolean doc2pdf2(File inputFile, File outputFile) {
82
+        boolean result = false;
83
+        // OpenOffice的安装目录
84
+        String OpenOffice_HOME = "D:\\app\\libreOffice";
85
+        if (OpenOffice_HOME.charAt(OpenOffice_HOME.length() - 1) != '/') {
86
+            OpenOffice_HOME += "/";
87
+        }
88
+        Process process = null;
89
+        try {
90
+            // 启动OpenOffice的服务
91
+            String command = OpenOffice_HOME
92
+                    + "program/soffice.exe -headless -accept=\"socket,host=127.0.0.1,port=8100;urp;\"";
93
+            process = Runtime.getRuntime().exec(command);
94
+            // 连接 OpenOffice实例,运行在8100端口
95
+            OpenOfficeConnection connection = new SocketOpenOfficeConnection("127.0.0.1", 8100);
96
+            connection.connect();
97
+
98
+            // 转换
99
+            DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
100
+            converter.convert(inputFile, outputFile);
101
+
102
+            // 关闭连接
103
+            connection.disconnect();
104
+            // 销毁OpenOffice服务的进程
105
+            process.destroy();
106
+
107
+            log.info("****pdf转换成功,PDF输出:" + outputFile.getPath() + "****");
108
+            return true;
109
+        } catch (Exception e) {
110
+            log.error("pdf转换失败", e);
111
+        } finally {
112
+            if (process != null) {
113
+                process.destroy();
114
+            }
115
+        }
116
+        return result;
117
+    }
118
+
119
+}

+ 25
- 13
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/AdjudicationServiceImpl.java Datei anzeigen

@@ -180,7 +180,16 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
180 180
                 //
181 181
                 for (String bookmark : bookmarkList) {
182 182
                     if(columnValueMap.containsKey(bookmark)){
183
-                        datas.put(bookmark,columnValueMap.get(bookmark));
183
+                        if(bookmark.equals("resSex")){
184
+                            String responSex = columnValueMap.get(bookmark);
185
+                            if (responSex.equals("0")) {
186
+                                datas.put(bookmark, "男");
187
+                            } else {
188
+                                datas.put(bookmark, "女");
189
+                            }
190
+                        }else {
191
+                            datas.put(bookmark, columnValueMap.get(bookmark));
192
+                        }
184 193
                     }
185 194
                 }
186 195
             }else {
@@ -231,11 +240,11 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
231 240
                 // todo 线上仲裁/线下仲裁方式未选择
232 241
                 //线上开庭时
233 242
                 if (arbitratMethod == 1) {
234
-                    String replace = onLine.replace(onLineDate, hearDateStr);
243
+                    String replace = onLine.replace(onLineDate, Optional.ofNullable(hearDateStr).orElse(""));
235 244
                     datas.put("onLine", replace);
236 245
                 } else {
237 246
                     //书面仲裁时
238
-                    String replace = written.replace(writtenDate, hearDateStr);
247
+                    String replace = written.replace(writtenDate, Optional.ofNullable(hearDateStr).orElse(""));
239 248
                     datas.put("written", replace);
240 249
 
241 250
                 }
@@ -252,7 +261,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
252 261
             if (arbitratMethod == 1) {
253 262
                 if (isAbsence != null && isAbsence == 1) {
254 263
                     // 被申请人缺席
255
-                    String absentReplace = absent.replace("{{agentName}}", agentName);
264
+                    String absentReplace = absent.replace("{{agentName}}", Optional.ofNullable(agentName).orElse(""));
256 265
                     datas.put("absent",absentReplace);
257 266
                     // 被申请人缺席
258 267
                     String resAbsentReplace=resAbsent;
@@ -267,7 +276,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
267 276
                     datas.put("resAbsent",resAbsentReplace);
268 277
                 } else {
269 278
                     // 出席
270
-                    String attendReplace = attend.replace("{{agentName}}", agentName);
279
+                    String attendReplace = attend.replace("{{agentName}}", Optional.ofNullable(agentName).orElse(""));
271 280
                     datas.put("attend",attend);
272 281
                     // 被申请人证据
273 282
                     if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(6))){
@@ -281,7 +290,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
281 290
                             for (CaseAttach caseAttach : caseAttaches) {
282 291
                                 stringBuilder.append(caseAttach.getAnnexName()).append("\n");
283 292
                             }
284
-                            resFileRplace = resFile.replace("{{resFile}}", stringBuilder.toString()).replace("{{applicantOpinion}}", arbitrateRecordSelect.getApplicantOpinion());
293
+                            resFileRplace = resFile.replace("{{resFile}}", stringBuilder.toString()).replace("{{applicantOpinion}}", Optional.ofNullable(arbitrateRecordSelect.getApplicantOpinion()).orElse(""));
285 294
                         }
286 295
                         datas.put("resFile",resFileRplace);
287 296
                     }else {
@@ -296,7 +305,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
296 305
                         for (CaseAttach caseAttach : caseAttaches) {
297 306
                             stringBuilder.append(caseAttach.getAnnexName()).append("\n");
298 307
                         }
299
-                         resAttendOpinionReplace = resAttendOpinion.replace("{{applicantFile}}", stringBuilder.toString()).replace("{{respondentOpinion}}", arbitrateRecordSelect.getRespondentOpinion());
308
+                         resAttendOpinionReplace = resAttendOpinion.replace("{{applicantFile}}", stringBuilder.toString()).replace("{{respondentOpinion}}", arbitrateRecordSelect.getRespondentOpinion()==null?"":arbitrateRecordSelect.getRespondentOpinion());
300 309
                     }
301 310
 
302 311
                     datas.put("resAttendOpinion",resAttendOpinionReplace);
@@ -306,13 +315,16 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
306 315
 
307 316
             String month = String.format("%02d", now.getMonthValue());
308 317
             String day = String.format("%02d", now.getDayOfMonth());
309
-            String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx";
310
-//             String modalFilePath = "D:/新裁决书模板.docx";
311
-            // todo 服务器路径
312
-            String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
313
-//             String saveFolderPath = "D:/";
318
+            // todo
319
+//            String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx";
320
+             String modalFilePath = templatePath;
321
+            // todo
322
+//            String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
323
+            String saveFolderPath = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
314 324
             String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
315
-            String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
325
+            // todo
326
+//            String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
327
+            String saveName = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day + "/" + fileName;
316 328
             String resultFilePath = saveFolderPath + "/" + fileName;
317 329
             // 创建日期目录
318 330
             File saveFolder = new File(saveFolderPath);

+ 12
- 8
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java Datei anzeigen

@@ -3016,7 +3016,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3016 3016
         if (unzipSuccess) {
3017 3017
             // 查询抓取规则
3018 3018
             // todo 批次需要再上传压缩包时用户填写
3019
-            List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId(17L);
3019
+            List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId(18L);
3020 3020
             if (CollectionUtil.isEmpty(fatchRuleList)) {
3021 3021
               return   error("未设置抓取规则");
3022 3022
             }
@@ -3291,7 +3291,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3291 3291
             //文件转成base64
3292 3292
             String base64 = OCRUtils.pdfConvertBase64(pdfUrl);
3293 3293
             if (base64 == null) {
3294
-                throw new ServiceException("文件转成base64,转码失败");
3294
+                throw new ServiceException("文件转成base64,转码失败pdfUrl:"+pdfUrl);
3295 3295
                 //  return false;
3296 3296
             }
3297 3297
             StringBuilder ocrText = new StringBuilder(); // 创建一个StringBuilder对象
@@ -3468,12 +3468,16 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3468 3468
         File outputFile = new File(pdfFilePath);
3469 3469
 
3470 3470
         try {
3471
-            InputStream docxInputStream = new FileInputStream(inputWord);
3472
-            OutputStream outputStream = new FileOutputStream(outputFile);
3473
-            IConverter converter = LocalConverter.builder().build();
3474
-            converter.convert(docxInputStream).as(DocumentType.DOCX).to(outputStream).as(DocumentType.PDF).execute();
3475
-            docxInputStream.close();
3476
-            outputStream.close();
3471
+            LibreOfficeUtil.doc2pdf2(inputWord,outputFile);
3472
+
3473
+
3474
+//
3475
+//            InputStream docxInputStream = new FileInputStream(inputWord);
3476
+//            OutputStream outputStream = new FileOutputStream(outputFile);
3477
+//            IConverter converter = LocalConverter.builder().build();
3478
+//            converter.convert(docxInputStream).as(DocumentType.DOCX).to(outputStream).as(DocumentType.PDF).execute();
3479
+//            docxInputStream.close();
3480
+//            outputStream.close();
3477 3481
 
3478 3482
         } catch (Exception e) {
3479 3483
             throw new ServiceException(e.getMessage()+"wordFilePath:"+wordFilePath+"pdfFilePath:"+pdfFilePath);

+ 1
- 1
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseApplicationMapper.xml Datei anzeigen

@@ -1432,7 +1432,7 @@
1432 1432
         c.disputes,
1433 1433
         c.loan_type,
1434 1434
         c.loan_term,
1435
-        c.mediation_agreement
1435
+        c.mediation_agreement,c.template_id templateId
1436 1436
         from case_application c
1437 1437
         LEFT JOIN case_affiliate ca ON ca.case_appli_id = c.id and ca.identity_type=1
1438 1438