Parcourir la source

Merge branch 'dev' of http://git.xayunmei.com/SH-Arbitrate/Arbitrate-Backend into qtz3

qitz il y a 2 ans
Parent
révision
0755325701

+ 13
- 1
ruoyi-admin/src/main/resources/application.yml Voir le fichier

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

+ 64
- 0
ruoyi-common/pom.xml Voir le fichier

11
 
11
 
12
     <artifactId>ruoyi-common</artifactId>
12
     <artifactId>ruoyi-common</artifactId>
13
 
13
 
14
+
14
     <description>
15
     <description>
15
         common通用工具
16
         common通用工具
16
     </description>
17
     </description>
17
 
18
 
18
     <dependencies>
19
     <dependencies>
19
 
20
 
21
+        <!--docx文件下载问题-->
22
+        <dependency>
23
+            <groupId>org.apache.poi</groupId>
24
+            <artifactId>poi-ooxml</artifactId>
25
+            <version>4.1.2</version>
26
+        </dependency>
27
+
28
+        <!-- POI依赖,读取.doc型文档-->
29
+        <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-scratchpad -->
30
+        <dependency>
31
+            <groupId>org.apache.poi</groupId>
32
+            <artifactId>poi-scratchpad</artifactId>
33
+            <version>4.1.1</version>
34
+        </dependency>
35
+
36
+        <dependency>
37
+            <groupId>commons-io</groupId>
38
+            <artifactId>commons-io</artifactId>
39
+            <version>2.6</version>
40
+        </dependency>
41
+        <dependency>
42
+            <groupId>org.jodconverter</groupId>
43
+            <artifactId>jodconverter-core</artifactId>
44
+            <version>4.2.0</version>
45
+        </dependency>
46
+        <dependency>
47
+            <groupId>org.jodconverter</groupId>
48
+            <artifactId>jodconverter-local</artifactId>
49
+            <version>4.2.0</version>
50
+        </dependency>
51
+        <dependency>
52
+            <groupId>org.jodconverter</groupId>
53
+            <artifactId>jodconverter-spring-boot-starter</artifactId>
54
+            <version>4.2.0</version>
55
+        </dependency>
56
+        <dependency>
57
+            <groupId>com.artofsolving</groupId>
58
+            <artifactId>jodconverter</artifactId>
59
+            <version>2.2.1</version>
60
+        </dependency>
61
+        <dependency>
62
+            <groupId>org.openoffice</groupId>
63
+            <artifactId>jurt</artifactId>
64
+            <version>3.0.1</version>
65
+        </dependency>
66
+        <dependency>
67
+            <groupId>org.openoffice</groupId>
68
+            <artifactId>ridl</artifactId>
69
+            <version>3.0.1</version>
70
+        </dependency>
71
+        <dependency>
72
+            <groupId>org.openoffice</groupId>
73
+            <artifactId>juh</artifactId>
74
+            <version>3.0.1</version>
75
+        </dependency>
76
+        <dependency>
77
+            <groupId>org.openoffice</groupId>
78
+            <artifactId>unoil</artifactId>
79
+            <version>3.0.1</version>
80
+        </dependency>
81
+
82
+
83
+
20
         <!-- Spring框架基本的核心工具 -->
84
         <!-- Spring框架基本的核心工具 -->
21
         <dependency>
85
         <dependency>
22
             <groupId>org.springframework</groupId>
86
             <groupId>org.springframework</groupId>

+ 45
- 13
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/AdjudicationServiceImpl.java Voir le fichier

176
                 Map<String, String> columnValueMap = columnValueList.stream().collect(Collectors.toMap(ColumnValue::getColumn, ColumnValue::getValue));
176
                 Map<String, String> columnValueMap = columnValueList.stream().collect(Collectors.toMap(ColumnValue::getColumn, ColumnValue::getValue));
177
                 agentName=columnValueMap.get("agentName");
177
                 agentName=columnValueMap.get("agentName");
178
                 resName=columnValueMap.get("respondentName");
178
                 resName=columnValueMap.get("respondentName");
179
+                resName=columnValueMap.get("respondentName");
179
                 // 懒得if,暂时这样
180
                 // 懒得if,暂时这样
180
                 //
181
                 //
181
                 for (String bookmark : bookmarkList) {
182
                 for (String bookmark : bookmarkList) {
182
                     if(columnValueMap.containsKey(bookmark)){
183
                     if(columnValueMap.containsKey(bookmark)){
183
-                        datas.put(bookmark,columnValueMap.get(bookmark));
184
+                        if(bookmark.equals("resSex")){
185
+                            String responSex = columnValueMap.get(bookmark);
186
+                            if (responSex.equals("0")) {
187
+                                datas.put(bookmark, "男");
188
+                            } else {
189
+                                datas.put(bookmark, "女");
190
+                            }
191
+                        }else {
192
+                            datas.put(bookmark, columnValueMap.get(bookmark));
193
+                        }
184
                     }
194
                     }
185
                 }
195
                 }
186
             }else {
196
             }else {
220
             if (objectiJuris!=null&&objectiJuris == 1) {
230
             if (objectiJuris!=null&&objectiJuris == 1) {
221
                 datas.put("jurisdictionalObjection", jurisdictionalObjection);
231
                 datas.put("jurisdictionalObjection", jurisdictionalObjection);
222
             }
232
             }
233
+
234
+            // 出席庭审人员角色名称
235
+            String attendName="秘书、";
236
+            boolean isAbsenceFlag = caseApplicationById.getIsAbsence() != null && caseApplicationById.getIsAbsence().equals(0);
237
+            boolean appIsAbsenceFlag = caseApplicationById.getAppliIsAbsen() != null && caseApplicationById.getAppliIsAbsen().equals(0);
238
+            if(isAbsenceFlag||appIsAbsenceFlag){
239
+                if(isAbsenceFlag) {
240
+                    attendName += "申请代理人" + agentName+"、";
241
+                }
242
+                if(appIsAbsenceFlag) {
243
+                    attendName += "被申请人" + resName;
244
+                }
245
+                if(attendName.endsWith("、")){
246
+                    agentName=attendName.replace("、","");
247
+                }
248
+            }
249
+
223
             // 仲裁员名称
250
             // 仲裁员名称
224
             datas.put("arbitratorName", caseApplicationById.getArbitratorName());
251
             datas.put("arbitratorName", caseApplicationById.getArbitratorName());
225
             // 审理方式
252
             // 审理方式
228
             if (hearDate != null) {
255
             if (hearDate != null) {
229
                 // 审理日期
256
                 // 审理日期
230
                 String hearDateStr = sdf.format(hearDate);
257
                 String hearDateStr = sdf.format(hearDate);
258
+                datas.put("hearDate",hearDateStr);
231
                 // todo 线上仲裁/线下仲裁方式未选择
259
                 // todo 线上仲裁/线下仲裁方式未选择
232
                 //线上开庭时
260
                 //线上开庭时
233
                 if (arbitratMethod == 1) {
261
                 if (arbitratMethod == 1) {
234
-                    String replace = onLine.replace(onLineDate, hearDateStr);
262
+                    String replace = onLine.replace(onLineDate, Optional.ofNullable(hearDateStr).orElse(""));
235
                     datas.put("onLine", replace);
263
                     datas.put("onLine", replace);
264
+
236
                 } else {
265
                 } else {
237
                     //书面仲裁时
266
                     //书面仲裁时
238
-                    String replace = written.replace(writtenDate, hearDateStr);
267
+                    String replace = written.replace(writtenDate, Optional.ofNullable(hearDateStr).orElse(""));
239
                     datas.put("written", replace);
268
                     datas.put("written", replace);
240
 
269
 
241
                 }
270
                 }
252
             if (arbitratMethod == 1) {
281
             if (arbitratMethod == 1) {
253
                 if (isAbsence != null && isAbsence == 1) {
282
                 if (isAbsence != null && isAbsence == 1) {
254
                     // 被申请人缺席
283
                     // 被申请人缺席
255
-                    String absentReplace = absent.replace("{{agentName}}", agentName);
284
+                    String absentReplace = absent.replace("{{agentName}}", Optional.ofNullable(agentName).orElse(""));
256
                     datas.put("absent",absentReplace);
285
                     datas.put("absent",absentReplace);
257
                     // 被申请人缺席
286
                     // 被申请人缺席
258
                     String resAbsentReplace=resAbsent;
287
                     String resAbsentReplace=resAbsent;
267
                     datas.put("resAbsent",resAbsentReplace);
296
                     datas.put("resAbsent",resAbsentReplace);
268
                 } else {
297
                 } else {
269
                     // 出席
298
                     // 出席
270
-                    String attendReplace = attend.replace("{{agentName}}", agentName);
299
+                    String attendReplace = attend.replace("{{agentName}}", Optional.ofNullable(agentName).orElse(""));
271
                     datas.put("attend",attend);
300
                     datas.put("attend",attend);
272
                     // 被申请人证据
301
                     // 被申请人证据
273
                     if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(6))){
302
                     if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(6))){
281
                             for (CaseAttach caseAttach : caseAttaches) {
310
                             for (CaseAttach caseAttach : caseAttaches) {
282
                                 stringBuilder.append(caseAttach.getAnnexName()).append("\n");
311
                                 stringBuilder.append(caseAttach.getAnnexName()).append("\n");
283
                             }
312
                             }
284
-                            resFileRplace = resFile.replace("{{resFile}}", stringBuilder.toString()).replace("{{applicantOpinion}}", arbitrateRecordSelect.getApplicantOpinion());
313
+                            resFileRplace = resFile.replace("{{resFile}}", stringBuilder.toString()).replace("{{applicantOpinion}}", Optional.ofNullable(arbitrateRecordSelect.getApplicantOpinion()).orElse(""));
285
                         }
314
                         }
286
                         datas.put("resFile",resFileRplace);
315
                         datas.put("resFile",resFileRplace);
287
                     }else {
316
                     }else {
296
                         for (CaseAttach caseAttach : caseAttaches) {
325
                         for (CaseAttach caseAttach : caseAttaches) {
297
                             stringBuilder.append(caseAttach.getAnnexName()).append("\n");
326
                             stringBuilder.append(caseAttach.getAnnexName()).append("\n");
298
                         }
327
                         }
299
-                         resAttendOpinionReplace = resAttendOpinion.replace("{{applicantFile}}", stringBuilder.toString()).replace("{{respondentOpinion}}", arbitrateRecordSelect.getRespondentOpinion());
328
+                         resAttendOpinionReplace = resAttendOpinion.replace("{{applicantFile}}", stringBuilder.toString()).replace("{{respondentOpinion}}", arbitrateRecordSelect.getRespondentOpinion()==null?"":arbitrateRecordSelect.getRespondentOpinion());
300
                     }
329
                     }
301
 
330
 
302
                     datas.put("resAttendOpinion",resAttendOpinionReplace);
331
                     datas.put("resAttendOpinion",resAttendOpinionReplace);
306
 
335
 
307
             String month = String.format("%02d", now.getMonthValue());
336
             String month = String.format("%02d", now.getMonthValue());
308
             String day = String.format("%02d", now.getDayOfMonth());
337
             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:/";
338
+            // todo
339
+//            String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx";
340
+             String modalFilePath = templatePath;
341
+            // todo
342
+//            String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
343
+            String saveFolderPath = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
314
             String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
344
             String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
315
-            String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
345
+            // todo
346
+//            String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
347
+            String saveName = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day + "/" + fileName;
316
             String resultFilePath = saveFolderPath + "/" + fileName;
348
             String resultFilePath = saveFolderPath + "/" + fileName;
317
             // 创建日期目录
349
             // 创建日期目录
318
             File saveFolder = new File(saveFolderPath);
350
             File saveFolder = new File(saveFolderPath);

+ 123
- 110
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java Voir le fichier

49
 
49
 
50
 import org.apache.pdfbox.pdmodel.PDDocument;
50
 import org.apache.pdfbox.pdmodel.PDDocument;
51
 
51
 
52
+
53
+import org.apache.poi.hwpf.extractor.WordExtractor;
54
+import org.apache.poi.ooxml.POIXMLDocument;
55
+import org.apache.poi.ooxml.extractor.POIXMLTextExtractor;
56
+import org.apache.poi.openxml4j.opc.OPCPackage;
57
+import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
58
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
52
 import org.springframework.beans.factory.annotation.Autowired;
59
 import org.springframework.beans.factory.annotation.Autowired;
53
 import org.springframework.beans.factory.annotation.Value;
60
 import org.springframework.beans.factory.annotation.Value;
54
 import org.springframework.stereotype.Service;
61
 import org.springframework.stereotype.Service;
1162
             maxVersion = 1;
1169
             maxVersion = 1;
1163
         }
1170
         }
1164
         caseApplication.setVersion(maxVersion + 1);
1171
         caseApplication.setVersion(maxVersion + 1);
1165
-        // 将修改提交状态改为未提交
1166
-        // caseApplication.setUpdateSubmitStatus(UpdateSubmitStatus.UNCOMMITTED.getCode());
1167
-        // 修改案件表的版本号
1168
-        //   caseApplicationMapper.updateVersionById(caseApplication.getId(),caseApplication.getVersion());
1169
-
1170
         // 异步新增案件日志
1172
         // 异步新增案件日志
1171
         ThreadPoolUtil.execute(() -> {
1173
         ThreadPoolUtil.execute(() -> {
1172
             try {
1174
             try {
2882
      * @param userId
2884
      * @param userId
2883
      * @return
2885
      * @return
2884
      */
2886
      */
2887
+    @Override
2885
     public String generateUserSign(String userId) {
2888
     public String generateUserSign(String userId) {
2886
         TLSSigAPIv2 tlsSigAPIv2 = new TLSSigAPIv2(sdkAppId, sdkSecretKey);
2889
         TLSSigAPIv2 tlsSigAPIv2 = new TLSSigAPIv2(sdkAppId, sdkSecretKey);
2887
         return tlsSigAPIv2.genUserSig(userId, 60 * 60 * 10);
2890
         return tlsSigAPIv2.genUserSig(userId, 60 * 60 * 10);
3023
         if (unzipSuccess) {
3026
         if (unzipSuccess) {
3024
             // 查询抓取规则
3027
             // 查询抓取规则
3025
             // todo 批次需要再上传压缩包时用户填写
3028
             // todo 批次需要再上传压缩包时用户填写
3026
-            List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId(17L);
3029
+            List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId(templateId);
3027
             if (CollectionUtil.isEmpty(fatchRuleList)) {
3030
             if (CollectionUtil.isEmpty(fatchRuleList)) {
3028
               return   error("未设置抓取规则");
3031
               return   error("未设置抓取规则");
3029
             }
3032
             }
3041
                 if (fatchMap.size() <= 0) {
3044
                 if (fatchMap.size() <= 0) {
3042
                   return   error("从压缩包中未抓取到内容,请检查抓取字段配置");
3045
                   return   error("从压缩包中未抓取到内容,请检查抓取字段配置");
3043
                 }
3046
                 }
3044
-                if (fatchMap.size() > 0) {
3045
 
3047
 
3046
                     // todo 从压缩包中识别各字段填充到数据库
3048
                     // todo 从压缩包中识别各字段填充到数据库
3047
                     //调用新增案件的接口
3049
                     //调用新增案件的接口
3048
                     CaseApplication caseApplication = new CaseApplication();
3050
                     CaseApplication caseApplication = new CaseApplication();
3049
                     caseApplication.setTemplateId(templateId);
3051
                     caseApplication.setTemplateId(templateId);
3050
-                    //默认案件标的 todo 案件标的是什么
3051
-                    caseApplication.setCaseSubjectAmount(new BigDecimal(1));
3052
+                    //默认案件标的 todo 案件标的是什么,默认写死
3053
+                    caseApplication.setCaseSubjectAmount(new BigDecimal(10000));
3052
                     // todo 这些以后要去掉,不在案件基本信息表维护,现在往基本信息表设置字段是因为修改以及查询详情的时候页面中字段是固定的,以后也要动态维护字段
3054
                     // todo 这些以后要去掉,不在案件基本信息表维护,现在往基本信息表设置字段是因为修改以及查询详情的时候页面中字段是固定的,以后也要动态维护字段
3053
                     // 仲裁请求
3055
                     // 仲裁请求
3054
                     caseApplication.setArbitratClaims(fatchMap.get("arbitrationClaims"));
3056
                     caseApplication.setArbitratClaims(fatchMap.get("arbitrationClaims"));
3159
                     caseAffiliate.setResidenAffili(fatchMap.get("applicantHome"));
3161
                     caseAffiliate.setResidenAffili(fatchMap.get("applicantHome"));
3160
                     // 申请人联系地址
3162
                     // 申请人联系地址
3161
                     caseAffiliate.setContactAddress(fatchMap.get("applicantAddress"));
3163
                     caseAffiliate.setContactAddress(fatchMap.get("applicantAddress"));
3162
-//                        if(map.get("职务").size()>0) {
3163
 //                            // 法定代表人职务
3164
 //                            // 法定代表人职务
3164
-//                            caseAffiliate.setCompLegalperPost(map.get("职务").get(0));
3165
-//                            if(map.get("职务").size()>1) {
3166
-//                                // 代理人职务
3167
-//                                caseAffiliate.setAppliAgentTitle(map.get("职务").get(1));
3168
-//                            }
3169
-//                        }
3165
+                   caseAffiliate.setCompLegalperPost(fatchMap.get("compLegalperPost"));
3170
                     // 委托代理人
3166
                     // 委托代理人
3171
                     caseAffiliate.setNameAgent(fatchMap.get("agentName"));
3167
                     caseAffiliate.setNameAgent(fatchMap.get("agentName"));
3172
                     // 委托代理人联系电话
3168
                     // 委托代理人联系电话
3228
                     if (null != caseApplication.getId()) {
3224
                     if (null != caseApplication.getId()) {
3229
                         List<CaseAttach> caseAttachs = new ArrayList<>();
3225
                         List<CaseAttach> caseAttachs = new ArrayList<>();
3230
                         for (Map.Entry<String, String> entry : andConvertPDF.entrySet()) {
3226
                         for (Map.Entry<String, String> entry : andConvertPDF.entrySet()) {
3231
-                            if (entry.getValue().contains("证据材料") || entry.getValue().contains("申请书") || entry.getValue().contains("调解协议") || entry.getValue().contains("情况说明")) {
3232
                                 String pdfUrl = entry.getValue();
3227
                                 String pdfUrl = entry.getValue();
3233
                                 File file1 = new File(pdfUrl);
3228
                                 File file1 = new File(pdfUrl);
3234
                                 CaseAttach caseAttach = new CaseAttach();
3229
                                 CaseAttach caseAttach = new CaseAttach();
3238
                                 // 申请人提供的证据材料
3233
                                 // 申请人提供的证据材料
3239
                                 caseAttach.setAnnexType(2);
3234
                                 caseAttach.setAnnexType(2);
3240
                                 caseAttachs.add(caseAttach);
3235
                                 caseAttachs.add(caseAttach);
3241
-                            }
3236
+
3242
                         }
3237
                         }
3243
                         if (CollectionUtil.isNotEmpty(caseAttachs)) {
3238
                         if (CollectionUtil.isNotEmpty(caseAttachs)) {
3244
                             // 新增申请人证据材料
3239
                             // 新增申请人证据材料
3246
                         }
3241
                         }
3247
                         return AjaxResult.success("导入成功");
3242
                         return AjaxResult.success("导入成功");
3248
                     }
3243
                     }
3249
-                } else {
3250
-                    return AjaxResult.error("文件识别内容失败,请检查");
3251
-                }
3244
+
3252
 
3245
 
3253
             } else {
3246
             } else {
3254
                 // 没有找到符合条件的文件
3247
                 // 没有找到符合条件的文件
3289
         }
3282
         }
3290
     }
3283
     }
3291
 
3284
 
3285
+    public static String readerTxtFile(String filePath){
3286
+        BufferedReader br=null;
3287
+        StringBuilder result=new StringBuilder();
3288
+        try {
3289
+            br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(filePath)),"GBK"));
3290
+            String line=null;
3291
+            while ((line=br.readLine())!=null) {
3292
+                result.append(line).append("\n");
3293
+            }
3294
+        } catch (IOException e) {
3295
+          e.printStackTrace();
3296
+        } finally {
3297
+            if (null!=br){
3298
+                try {
3299
+                    br.close();
3300
+                } catch (IOException e) {
3301
+                    e.printStackTrace();
3302
+                }
3303
+            }
3304
+        }
3305
+        return result.toString();
3306
+    }
3307
+    public static String readWord(String filePath) throws Exception{
3308
+
3309
+        File file = new File(filePath);
3310
+        if(file.length()==0) return ""; // 需要操作原因是可能会空文件问题,如果不做处理,在下面读取中会报错
3311
+        StringBuffer sb = new StringBuffer();
3312
+        String buffer = "";
3313
+        try {
3314
+            if (filePath.endsWith(".doc")) {
3315
+                InputStream is = new FileInputStream(file);
3316
+                WordExtractor ex = new WordExtractor(is);
3317
+                buffer = ex.getText();
3318
+                if(buffer.length() > 0){
3319
+                    //使用回车换行符分割字符串
3320
+                    String [] arry = buffer.split("r\\n");
3321
+                    for (String string : arry) {
3322
+                        sb.append(string.trim());
3323
+                    }
3324
+                }
3325
+            } else if (filePath.endsWith(".docx")) {
3326
+                FileInputStream fis = new FileInputStream(file);
3327
+                XWPFDocument xdoc = new XWPFDocument(fis);
3328
+                XWPFWordExtractor extractor = new XWPFWordExtractor(xdoc);
3329
+                buffer = extractor.getText();
3330
+
3331
+
3332
+
3333
+//                OPCPackage opcPackage = POIXMLDocument.openPackage(filePath);
3334
+//                XWPFWordExtractor extractor = new XWPFWordExtractor(opcPackage);
3335
+//                buffer = extractor.getText();
3336
+                if(buffer.length() > 0){
3337
+                    //使用换行符分割字符串
3338
+                    String [] arry = buffer.split("\r\n");
3339
+                    for (String string : arry) {
3340
+                        sb.append(string.trim());
3341
+                    }
3342
+                }
3343
+            } else {
3344
+                return null;
3345
+            }
3346
+            return sb.toString();
3347
+        } catch (Exception e) {
3348
+            System.out.print("error---->"+filePath);
3349
+            e.printStackTrace();
3350
+            return null;
3351
+        }
3352
+    }
3353
+
3292
     private boolean OCRAndBuildInfo( Map<String, String> andConvertPDF,String mapKey,  Map<String, String> map, List<FatchRule> fatchRules) {
3354
     private boolean OCRAndBuildInfo( Map<String, String> andConvertPDF,String mapKey,  Map<String, String> map, List<FatchRule> fatchRules) {
3293
         String pdfUrl = andConvertPDF.get(mapKey);
3355
         String pdfUrl = andConvertPDF.get(mapKey);
3294
 
3356
 
3295
         if(StrUtil.isNotEmpty(pdfUrl)) {
3357
         if(StrUtil.isNotEmpty(pdfUrl)) {
3296
-            //获取文件的页数
3297
-            int fileNumPage = getFileNumPage(pdfUrl);
3298
-            //文件转成base64
3299
-            String base64 = OCRUtils.pdfConvertBase64(pdfUrl);
3300
-            if (base64 == null) {
3301
-                throw new ServiceException("文件转成base64,转码失败");
3302
-                //  return false;
3303
-            }
3304
-            StringBuilder ocrText = new StringBuilder(); // 创建一个StringBuilder对象
3305
-            for (int i = 1; i <= fileNumPage; i++) {
3306
-                //对接腾讯云接口.识别里面的数据
3307
-                String text = OCRUtils.pdfIdentifyText(base64, i , fatchRules);
3308
-                ocrText.append(text); // 拼接当前的字符串
3309
-            }
3310
-            if(StrUtil.isNotEmpty(ocrText)){
3311
-               OCRUtils.fatchRuleGetContent(ocrText.toString(), fatchRules,map);
3358
+            if(pdfUrl.endsWith("txt")){
3359
+                String readerFile = readerTxtFile(pdfUrl);
3360
+                if(StrUtil.isNotEmpty(readerFile)){
3361
+                    OCRUtils.fatchRuleGetContent(readerFile, fatchRules,map);
3362
+                }
3363
+
3364
+            }else if(pdfUrl.endsWith("doc")||pdfUrl.endsWith("docx")){
3365
+                // doc,docx,text识别内容
3366
+                String readerFile = null;
3367
+                try {
3368
+                    readerFile = readWord(pdfUrl);
3369
+                } catch (Exception e) {
3370
+                    e.printStackTrace();
3371
+                }
3372
+                if(StrUtil.isNotEmpty(readerFile)){
3373
+                    OCRUtils.fatchRuleGetContent(readerFile, fatchRules,map);
3374
+                }
3375
+
3376
+            }else if(pdfUrl.endsWith("pdf")){
3377
+                //获取文件的页数
3378
+                int fileNumPage = getFileNumPage(pdfUrl);
3379
+                //文件转成base64
3380
+                String base64 = OCRUtils.pdfConvertBase64(pdfUrl);
3381
+                if (base64 == null) {
3382
+                    throw new ServiceException("文件转成base64,转码失败");
3383
+                    //  return false;
3384
+                }
3385
+                StringBuilder ocrText = new StringBuilder(); // 创建一个StringBuilder对象
3386
+                for (int i = 1; i <= fileNumPage; i++) {
3387
+                    //对接腾讯云接口.识别里面的数据
3388
+                    String text = OCRUtils.pdfIdentifyText(base64, i, fatchRules);
3389
+                    ocrText.append(text); // 拼接当前的字符串
3390
+                    if(StrUtil.isNotEmpty(ocrText)){
3391
+                        OCRUtils.fatchRuleGetContent(ocrText.toString(), fatchRules,map);
3392
+                    }
3393
+                }
3312
             }
3394
             }
3395
+
3313
         }
3396
         }
3314
         return true;
3397
         return true;
3315
     }
3398
     }
3374
        Map<String,String> pdfPathMap= new HashMap<>();
3457
        Map<String,String> pdfPathMap= new HashMap<>();
3375
         if (directory.isFile()) {
3458
         if (directory.isFile()) {
3376
             String path = "";
3459
             String path = "";
3377
-            String fileName = "";
3378
             // 如果传入的参数是一个文件
3460
             // 如果传入的参数是一个文件
3379
-     //       if (directory.getName().contains("仲裁申请书")) {
3380
-                if (isPDF(directory)) {
3381
-                    // 如果文件名包含"仲裁申请书"且是PDF格式,直接返回路径
3382
                     path = directory.getAbsolutePath();
3461
                     path = directory.getAbsolutePath();
3383
-                } else {
3384
-                    String extension = getFileExtension(directory);
3385
-                    if( extension.contains("doc")|| extension.contains("docx")) {
3386
-                        // 如果不是PDF格式,进行转换成PDF并返回路径
3387
-                        String pdfPath = convertToPDF(directory);
3388
-                        if (pdfPath != null) {
3389
-                            path = pdfPath;
3390
-                        }
3391
-                    }
3392
-                }
3393
-                    // 如果文件名包含"仲裁申请书"且是PDF格式,直接返回路径
3394
-                    // 如果是PDF格式,直接添加到列表中
3395
-//                    if(CollectionUtil.isNotEmpty(fatchRuleList)) {
3396
-//                        for (FatchRule fatchRule : fatchRuleList) {
3397
-//                            if(fatchRule.getFileName().contains(directory.getName())){
3398
-                                pdfPathMap.put(directory.getName(), path);
3399
-//                            }
3400
-//                        }
3401
-//
3402
-//                    }
3403
-         //   }
3462
+                    pdfPathMap.put(directory.getName(), path);
3463
+
3404
         } else if (directory.isDirectory()) {
3464
         } else if (directory.isDirectory()) {
3405
             searchAndConvertPDF(directory, pdfPathMap);
3465
             searchAndConvertPDF(directory, pdfPathMap);
3406
         } else {
3466
         } else {
3432
                 }
3492
                 }
3433
                 if (file.isFile()) {
3493
                 if (file.isFile()) {
3434
 
3494
 
3435
-                    // 如果是文件且文件名包含"仲裁申请书"
3436
-                //    if (file.getName().contains("仲裁申请书")) {
3437
-                        if (isPDF(file)) {
3438
-                            // 如果是PDF格式,直接添加到列表中
3439
-                            pdfPathMap.put(file.getName(),file.getAbsolutePath());
3440
-                        } else {
3441
-                            // 如果不是PDF格式,进行转换成PDF并添加转换后的路径到列表中
3442
-                             String   pdfPath = convertToPDF(file);
3443
-                            if (pdfPath != null) {
3444
-                                // 如果是PDF格式,直接添加到列表中
3445
-                                pdfPathMap.put(file.getName(),pdfPath);
3446
-                            }
3447
-                        }
3448
-
3449
-                //    }
3495
+                    pdfPathMap.put(file.getName(),file.getAbsolutePath());
3450
                 } else if (file.isDirectory()) {
3496
                 } else if (file.isDirectory()) {
3451
                     // 如果是目录,递归查找
3497
                     // 如果是目录,递归查找
3452
                     searchAndConvertPDF(file, pdfPathMap);
3498
                     searchAndConvertPDF(file, pdfPathMap);
3455
         }
3501
         }
3456
     }
3502
     }
3457
 
3503
 
3458
-    private static String convertToPDF(File file) {
3459
-        String wordFilePath = file.getAbsolutePath();
3460
-        // todo
3461
-        String pdfSaveDirectory = "/home/ruoyi/uploadPath/upload/wordToPDF/";
3462
-//        String pdfSaveDirectory = "D:/home/ruoyi/uploadPath/upload/wordToPDF/";
3463
-        File directory = new File(pdfSaveDirectory);
3464
-        if (!directory.exists()) {
3465
-            directory.mkdirs();
3466
-        }
3467
-        String name = file.getName();
3468
-        String nameWithoutExtension = name.substring(0, name.lastIndexOf("."));
3469
-
3470
-        String pdfFilePath = pdfSaveDirectory + nameWithoutExtension + ".pdf";
3471
-        File inputWord = new File(wordFilePath);
3472
-        if(!inputWord.exists()){
3473
-            throw new ServiceException("文件不存在wordFilePath:"+wordFilePath);
3474
-        }
3475
-        File outputFile = new File(pdfFilePath);
3476
-
3477
-        try {
3478
-            InputStream docxInputStream = new FileInputStream(inputWord);
3479
-            OutputStream outputStream = new FileOutputStream(outputFile);
3480
-            IConverter converter = LocalConverter.builder().build();
3481
-            converter.convert(docxInputStream).as(DocumentType.DOCX).to(outputStream).as(DocumentType.PDF).execute();
3482
-            docxInputStream.close();
3483
-            outputStream.close();
3484
-
3485
-        } catch (Exception e) {
3486
-            throw new ServiceException(e.getMessage()+"wordFilePath:"+wordFilePath+"pdfFilePath:"+pdfFilePath);
3487
-           // e.printStackTrace();
3488
-        }
3489
-        return pdfFilePath;
3490
-    }
3491
 
3504
 
3492
     private static int getFileNumPage(String pdfUrl) {
3505
     private static int getFileNumPage(String pdfUrl) {
3493
         File pdfFile = new File(pdfUrl);
3506
         File pdfFile = new File(pdfUrl);

+ 1
- 1
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseApplicationMapper.xml Voir le fichier

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

+ 3
- 3
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/FatchRuleMapper.xml Voir le fichier

19
 
19
 
20
     <select id="selectFatchRuleList" parameterType="FatchRule" resultMap="BaseResultMap">
20
     <select id="selectFatchRuleList" parameterType="FatchRule" resultMap="BaseResultMap">
21
         SELECT f.id ,f.file_name ,f.start_content ,f.end_content ,
21
         SELECT f.id ,f.file_name ,f.start_content ,f.end_content ,
22
-        f.`column` ,f.is_default ,f.columnName
22
+        f.`column` ,f.is_default ,f.`column_name`
23
         FROM template_fatch_rule tf
23
         FROM template_fatch_rule tf
24
         left join template_manage t on tf.template_id  = t.id
24
         left join template_manage t on tf.template_id  = t.id
25
         LEFT JOIN fatch_rule f on tf.fatch_rule_id  = f.id
25
         LEFT JOIN fatch_rule f on tf.fatch_rule_id  = f.id
65
 
65
 
66
     <select id="selectFatchRuleListIsDefault" parameterType="FatchRule" resultMap="BaseResultMap">
66
     <select id="selectFatchRuleListIsDefault" parameterType="FatchRule" resultMap="BaseResultMap">
67
         SELECT f.id ,f.file_name ,f.start_content ,f.end_content ,
67
         SELECT f.id ,f.file_name ,f.start_content ,f.end_content ,
68
-        f.`column` ,f.is_default ,f.columnName
68
+        f.`column` ,f.is_default ,f.`column_name`
69
         FROM fatch_rule f
69
         FROM fatch_rule f
70
         <where>
70
         <where>
71
             <if test="isDefault != null">
71
             <if test="isDefault != null">
87
         <if test="startContent != null and startContent != ''">start_content,</if>
87
         <if test="startContent != null and startContent != ''">start_content,</if>
88
         <if test="endContent != null and endContent != ''">end_content,</if>
88
         <if test="endContent != null and endContent != ''">end_content,</if>
89
         <if test="column != null and column != ''">`column`,</if>
89
         <if test="column != null and column != ''">`column`,</if>
90
-        <if test="columnName != null and columnName != ''">columnName,</if>
90
+        <if test="columnName != null and columnName != ''">`column_name`,</if>
91
         <if test="isDefault != null">is_default</if>
91
         <if test="isDefault != null">is_default</if>
92
         )values(
92
         )values(
93
         <if test="fileName != null and fileName != ''">#{fileName},</if>
93
         <if test="fileName != null and fileName != ''">#{fileName},</if>