Просмотр исходного кода

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

wangqiong123 2 лет назад
Родитель
Сommit
3a831e31ad

+ 1
- 1
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/FatchRuleMapper.java Просмотреть файл

15
 /**
15
 /**
16
  * 根据批次查询
16
  * 根据批次查询
17
  */
17
  */
18
-   List<FatchRule> listByTemplateId(@Param("templateId")String templateId);
18
+   List<FatchRule> listByTemplateId(@Param("templateId")Long templateId);
19
 
19
 
20
    List<FatchRule> selectFatchRuleList(FatchRule fatchRule);
20
    List<FatchRule> selectFatchRuleList(FatchRule fatchRule);
21
 
21
 

+ 116
- 112
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java Просмотреть файл

14
 import com.google.gson.Gson;
14
 import com.google.gson.Gson;
15
 import com.google.gson.JsonArray;
15
 import com.google.gson.JsonArray;
16
 import com.google.gson.JsonObject;
16
 import com.google.gson.JsonObject;
17
+
17
 import com.ruoyi.common.annotation.DataScope;
18
 import com.ruoyi.common.annotation.DataScope;
18
 import com.ruoyi.common.config.RuoYiConfig;
19
 import com.ruoyi.common.config.RuoYiConfig;
19
 import com.ruoyi.common.constant.CaseApplicationConstants;
20
 import com.ruoyi.common.constant.CaseApplicationConstants;
37
 import com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue;
38
 import com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue;
38
 import com.ruoyi.wisdomarbitrate.domain.vo.ReservedConferenceVO;
39
 import com.ruoyi.wisdomarbitrate.domain.vo.ReservedConferenceVO;
39
 import com.ruoyi.wisdomarbitrate.domain.vo.ToDoCount;
40
 import com.ruoyi.wisdomarbitrate.domain.vo.ToDoCount;
40
-import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
41
 import com.ruoyi.wisdomarbitrate.domain.*;
41
 import com.ruoyi.wisdomarbitrate.domain.*;
42
 import com.ruoyi.wisdomarbitrate.domain.vo.SendRoomNoMessageVO;
42
 import com.ruoyi.wisdomarbitrate.domain.vo.SendRoomNoMessageVO;
43
 import com.ruoyi.wisdomarbitrate.mapper.*;
43
 import com.ruoyi.wisdomarbitrate.mapper.*;
46
 import com.ruoyi.wisdomarbitrate.utils.SignAward;
46
 import com.ruoyi.wisdomarbitrate.utils.SignAward;
47
 import com.ruoyi.wisdomarbitrate.utils.UnZipFileUtils;
47
 import com.ruoyi.wisdomarbitrate.utils.UnZipFileUtils;
48
 import com.tencentyun.TLSSigAPIv2;
48
 import com.tencentyun.TLSSigAPIv2;
49
-import org.apache.http.HttpEntity;
50
-import org.apache.http.client.methods.CloseableHttpResponse;
51
-import org.apache.http.client.methods.HttpPost;
52
-import org.apache.http.entity.StringEntity;
53
-import org.apache.http.impl.client.CloseableHttpClient;
54
-import org.apache.http.impl.client.HttpClients;
55
-import org.apache.http.util.EntityUtils;
49
+
56
 import org.apache.pdfbox.pdmodel.PDDocument;
50
 import org.apache.pdfbox.pdmodel.PDDocument;
57
-import org.apache.poi.xwpf.usermodel.Document;
58
-import org.apache.poi.xwpf.usermodel.XWPFDocument;
51
+
59
 import org.springframework.beans.factory.annotation.Autowired;
52
 import org.springframework.beans.factory.annotation.Autowired;
60
 import org.springframework.beans.factory.annotation.Value;
53
 import org.springframework.beans.factory.annotation.Value;
61
 import org.springframework.stereotype.Service;
54
 import org.springframework.stereotype.Service;
62
 import org.springframework.transaction.annotation.Transactional;
55
 import org.springframework.transaction.annotation.Transactional;
63
 import org.springframework.web.multipart.MultipartFile;
56
 import org.springframework.web.multipart.MultipartFile;
64
-
65
 import java.io.*;
57
 import java.io.*;
66
 import java.math.BigDecimal;
58
 import java.math.BigDecimal;
67
 import java.math.RoundingMode;
59
 import java.math.RoundingMode;
68
 import java.nio.file.Files;
60
 import java.nio.file.Files;
69
 import java.nio.file.Path;
61
 import java.nio.file.Path;
70
 import java.nio.file.StandardCopyOption;
62
 import java.nio.file.StandardCopyOption;
71
-import java.text.NumberFormat;
72
 import java.text.ParseException;
63
 import java.text.ParseException;
73
 import java.text.SimpleDateFormat;
64
 import java.text.SimpleDateFormat;
74
 import java.time.LocalDate;
65
 import java.time.LocalDate;
75
 import java.time.ZoneId;
66
 import java.time.ZoneId;
76
 import java.util.*;
67
 import java.util.*;
68
+import java.util.List;
69
+import java.util.concurrent.TimeUnit;
77
 import java.util.function.Function;
70
 import java.util.function.Function;
78
 import java.util.regex.Matcher;
71
 import java.util.regex.Matcher;
79
 import java.util.regex.Pattern;
72
 import java.util.regex.Pattern;
80
 import java.util.stream.Collectors;
73
 import java.util.stream.Collectors;
81
-import java.util.zip.ZipEntry;
82
-import java.util.zip.ZipInputStream;
83
 
74
 
75
+import static com.ruoyi.common.core.domain.AjaxResult.error;
84
 import static com.ruoyi.common.core.domain.AjaxResult.success;
76
 import static com.ruoyi.common.core.domain.AjaxResult.success;
85
 import static com.ruoyi.common.utils.PageUtils.startPage;
77
 import static com.ruoyi.common.utils.PageUtils.startPage;
86
 import static com.ruoyi.common.utils.SecurityUtils.getLoginUser;
78
 import static com.ruoyi.common.utils.SecurityUtils.getLoginUser;
253
 
245
 
254
     }
246
     }
255
 
247
 
248
+
256
     @Override
249
     @Override
257
     public ToDoCount selectToDoCount() {
250
     public ToDoCount selectToDoCount() {
258
 
251
 
398
         if (file.isEmpty()) {
391
         if (file.isEmpty()) {
399
             return AjaxResult.error("请选择要上传的文件");
392
             return AjaxResult.error("请选择要上传的文件");
400
         }
393
         }
401
-        // todo 服务器路径需要改
402
-        String targetPath = "/home/ruoyi/uploadPath/upload/unzipFile";
403
-//         String targetPath = "D:/";
394
+
395
+         String targetPath = "/home/ruoyi/uploadPath/upload/unzipFile";
404
         File zipFile = null;
396
         File zipFile = null;
405
         InputStream ins = null;
397
         InputStream ins = null;
406
         try {
398
         try {
416
         //得到解压缩的所有文件
408
         //得到解压缩的所有文件
417
         String zipName = file.getOriginalFilename();
409
         String zipName = file.getOriginalFilename();
418
         String subzipName = zipName.substring(0, zipName.indexOf(".zip"));
410
         String subzipName = zipName.substring(0, zipName.indexOf(".zip"));
419
-//        String zipPath = "F:\\testZip\\uploadPath\\upload\\upload1\\unzipFile\\"+subzipName;
420
-        // todo 服务器路径需要改
411
+        // todo
421
         String zipPath = "/home/ruoyi/uploadPath/upload/unzipFile/" + subzipName;
412
         String zipPath = "/home/ruoyi/uploadPath/upload/unzipFile/" + subzipName;
422
-//        String zipPath = "D:/" + subzipName;
413
+//        String zipPath = "D:/home/ruoyi/uploadPath/upload/unzipFile/" + subzipName;
423
 
414
 
424
         File dirUnzipPath = new File(zipPath);
415
         File dirUnzipPath = new File(zipPath);
425
         List<File> allFiles = new ArrayList<>();
416
         List<File> allFiles = new ArrayList<>();
511
                     String year = Integer.toString(now.getYear());
502
                     String year = Integer.toString(now.getYear());
512
                     String month = String.format("%02d", now.getMonthValue());
503
                     String month = String.format("%02d", now.getMonthValue());
513
                     String day = String.format("%02d", now.getDayOfMonth());
504
                     String day = String.format("%02d", now.getDayOfMonth());
514
-                    //  // todo 服务器路径需要改
505
+                   // todo
515
                     String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
506
                     String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
516
-//                    String saveFolderPath = "D:/" + year + "/" + month + "/" + day;
507
+//                    String saveFolderPath = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
517
                     String fileName = UUID.randomUUID().toString().replace("-", "") + "_" + substrfile;
508
                     String fileName = UUID.randomUUID().toString().replace("-", "") + "_" + substrfile;
518
                     String resultFilePath = saveFolderPath + "/" + fileName;
509
                     String resultFilePath = saveFolderPath + "/" + fileName;
519
                     try {
510
                     try {
3003
             return AjaxResult.error("请选择要上传的文件");
2994
             return AjaxResult.error("请选择要上传的文件");
3004
         }
2995
         }
3005
         UUID uuid = UUID.randomUUID();
2996
         UUID uuid = UUID.randomUUID();
3006
-        // todo 服务器路径需要改
3007
-        String targetPath = "/home/ruoyi/uploadPath/upload/unzipFile/"+uuid+ "/";
3008
-//        String targetPath = "D:/zip";
2997
+        // todo
2998
+        String targetPath = "/home/ruoyi/uploadPath/upload/unzipFile/" + uuid + "/";
2999
+//        String targetPath = "D:/home/ruoyi/uploadPath/upload/unzipFile/"+uuid+ "/";
3009
         File zipFile = null;
3000
         File zipFile = null;
3010
         InputStream ins = null;
3001
         InputStream ins = null;
3011
         try {
3002
         try {
3012
             ins = file.getInputStream();
3003
             ins = file.getInputStream();
3013
             //上传的压缩包保存的路径
3004
             //上传的压缩包保存的路径
3014
-            // todo 服务器路径需要改
3005
+            // todo
3015
             String savePath = "/home/ruoyi/uploadPath/upload/zipFile/";
3006
             String savePath = "/home/ruoyi/uploadPath/upload/zipFile/";
3016
-//           String savePath = "D:/zip/";
3007
+//           String savePath = "D:/home/ruoyi/uploadPath/upload/zipFile/";
3017
             String saveName = uuid + "_" + file.getOriginalFilename();
3008
             String saveName = uuid + "_" + file.getOriginalFilename();
3018
             zipFile = new File(savePath + saveName);
3009
             zipFile = new File(savePath + saveName);
3019
             inputChangeToFile(ins, zipFile);
3010
             inputChangeToFile(ins, zipFile);
3025
         if (unzipSuccess) {
3016
         if (unzipSuccess) {
3026
             // 查询抓取规则
3017
             // 查询抓取规则
3027
             // todo 批次需要再上传压缩包时用户填写
3018
             // todo 批次需要再上传压缩包时用户填写
3028
-            List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId("9");
3019
+            List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId(17L);
3020
+            if (CollectionUtil.isEmpty(fatchRuleList)) {
3021
+              return   error("未设置抓取规则");
3022
+            }
3029
             File directory = new File(targetPath);
3023
             File directory = new File(targetPath);
3030
-           Map<String,String>  andConvertPDF = findAndConvertPDF(directory,fatchRuleList);
3024
+            Map<String, String> andConvertPDF = findAndConvertPDF(directory, fatchRuleList);
3031
             if (andConvertPDF != null && andConvertPDF.size() > 0) {
3025
             if (andConvertPDF != null && andConvertPDF.size() > 0) {
3032
-                   Map<String,String> fatchMap = new HashMap<>();
3033
-                    if(CollectionUtil.isNotEmpty(fatchRuleList)){
3034
-                        Map<String, List<FatchRule>> fatchRuleMap = fatchRuleList.stream().collect(Collectors.groupingBy(FatchRule::getFileName));
3035
-                        // 根据抓取规则循环抓取
3036
-                        for (Map.Entry<String, List<FatchRule>> entry : fatchRuleMap.entrySet()) {
3037
-                            OCRAndBuildInfo(andConvertPDF,entry.getKey(),fatchMap,entry.getValue());
3038
-                        }
3026
+                Map<String, String> fatchMap = new HashMap<>();
3027
+                if (CollectionUtil.isNotEmpty(fatchRuleList)) {
3028
+                    Map<String, List<FatchRule>> fatchRuleMap = fatchRuleList.stream().collect(Collectors.groupingBy(FatchRule::getFileName));
3029
+                    // 根据抓取规则循环抓取
3030
+                    for (Map.Entry<String, List<FatchRule>> entry : fatchRuleMap.entrySet()) {
3031
+                        OCRAndBuildInfo(andConvertPDF, entry.getKey(), fatchMap, entry.getValue());
3039
                     }
3032
                     }
3040
-
3041
-                if (fatchMap.size()>0){
3033
+                }
3034
+                if (fatchMap.size() <= 0) {
3035
+                  return   error("从压缩包中未抓取到内容,请检查抓取字段配置");
3036
+                }
3037
+                if (fatchMap.size() > 0) {
3042
 
3038
 
3043
                     // todo 从压缩包中识别各字段填充到数据库
3039
                     // todo 从压缩包中识别各字段填充到数据库
3044
-                        //调用新增案件的接口
3045
-                        CaseApplication caseApplication = new CaseApplication();
3046
-                        //默认案件标的 todo 案件标的是什么
3047
-                        caseApplication.setCaseSubjectAmount(new BigDecimal(1));
3048
-                        // todo 这些以后要去掉,不在案件基本信息表维护,现在往基本信息表设置字段是因为修改以及查询详情的时候页面中字段是固定的,以后也要动态维护字段
3040
+                    //调用新增案件的接口
3041
+                    CaseApplication caseApplication = new CaseApplication();
3042
+                    //默认案件标的 todo 案件标的是什么
3043
+                    caseApplication.setCaseSubjectAmount(new BigDecimal(1));
3044
+                    // todo 这些以后要去掉,不在案件基本信息表维护,现在往基本信息表设置字段是因为修改以及查询详情的时候页面中字段是固定的,以后也要动态维护字段
3049
                     // 仲裁请求
3045
                     // 仲裁请求
3050
                     caseApplication.setArbitratClaims(fatchMap.get("arbitrationClaims"));
3046
                     caseApplication.setArbitratClaims(fatchMap.get("arbitrationClaims"));
3051
                     // 事实和理由
3047
                     // 事实和理由
3052
                     caseApplication.setFacts(fatchMap.get("factsAndReason"));
3048
                     caseApplication.setFacts(fatchMap.get("factsAndReason"));
3053
                     // 合同编号
3049
                     // 合同编号
3054
                     String contractNumber = fatchMap.get("contractNumber");
3050
                     String contractNumber = fatchMap.get("contractNumber");
3055
-                    if(StrUtil.isNotEmpty(contractNumber)) {
3051
+                    if (StrUtil.isNotEmpty(contractNumber)) {
3056
                         // 提取字母和数字
3052
                         // 提取字母和数字
3057
                         String regx = "[^a-zA-Z0-9]";
3053
                         String regx = "[^a-zA-Z0-9]";
3058
                         String replaceAll = contractNumber.replaceAll(regx, "");
3054
                         String replaceAll = contractNumber.replaceAll(regx, "");
3063
                     String lonStartDate = fatchMap.get("lonStartDate:");
3059
                     String lonStartDate = fatchMap.get("lonStartDate:");
3064
                     SimpleDateFormat sdf = new SimpleDateFormat();
3060
                     SimpleDateFormat sdf = new SimpleDateFormat();
3065
                     sdf.applyPattern("yyyy年MM月dd日");
3061
                     sdf.applyPattern("yyyy年MM月dd日");
3066
-                    if(StrUtil.isNotEmpty(lonStartDate)) {
3062
+                    if (StrUtil.isNotEmpty(lonStartDate)) {
3067
                         try {
3063
                         try {
3068
                             caseApplication.setLoanStartDate(sdf.parse(lonStartDate));
3064
                             caseApplication.setLoanStartDate(sdf.parse(lonStartDate));
3069
                         } catch (ParseException e) {
3065
                         } catch (ParseException e) {
3138
 //                            caseApplication.setOutstandingMoney(mediationAgreementList.get(2));
3134
 //                            caseApplication.setOutstandingMoney(mediationAgreementList.get(2));
3139
 //                        }
3135
 //                        }
3140
 //                    }
3136
 //                    }
3141
-                        // 合同甲方(贷款人)
3142
-                        caseApplication.setPartyA(fatchMap.get("partyA"));
3143
-                        List<CaseAffiliate> caseAffiliates = new ArrayList<>();
3144
-                        CaseAffiliate caseAffiliate = new CaseAffiliate();
3145
-                        caseAffiliate.setIdentityType(1);
3146
-                        // 申请人
3147
-                        caseAffiliate.setName(fatchMap.get("applicantName"));
3148
-                        // 统一社会信用代码
3149
-                        caseAffiliate.setIdentityNum(fatchMap.get("creditCode"));
3150
-                        // 法定代表人
3151
-                        caseAffiliate.setCompLegalPerson(fatchMap.get("legalRepresentative"));
3152
-                        // 申请人联系电话
3153
-                        caseAffiliate.setContactTelphone(fatchMap.get("applicantPhone"));
3137
+                    // 合同甲方(贷款人)
3138
+                    caseApplication.setPartyA(fatchMap.get("partyA"));
3139
+                    List<CaseAffiliate> caseAffiliates = new ArrayList<>();
3140
+                    CaseAffiliate caseAffiliate = new CaseAffiliate();
3141
+                    caseAffiliate.setIdentityType(1);
3142
+                    // 申请人
3143
+                    caseAffiliate.setName(fatchMap.get("applicantName"));
3144
+                    // 统一社会信用代码
3145
+                    caseAffiliate.setIdentityNum(fatchMap.get("creditCode"));
3146
+                    // 法定代表人
3147
+                    caseAffiliate.setCompLegalPerson(fatchMap.get("legalRepresentative"));
3148
+                    // 申请人联系电话
3149
+                    caseAffiliate.setContactTelphone(fatchMap.get("applicantPhone"));
3154
                     // 申请人住所
3150
                     // 申请人住所
3155
                     caseAffiliate.setResidenAffili(fatchMap.get("applicantHome"));
3151
                     caseAffiliate.setResidenAffili(fatchMap.get("applicantHome"));
3156
                     // 申请人联系地址
3152
                     // 申请人联系地址
3163
 //                                caseAffiliate.setAppliAgentTitle(map.get("职务").get(1));
3159
 //                                caseAffiliate.setAppliAgentTitle(map.get("职务").get(1));
3164
 //                            }
3160
 //                            }
3165
 //                        }
3161
 //                        }
3166
-                        // 委托代理人
3167
-                        caseAffiliate.setNameAgent(fatchMap.get("agentName"));
3168
-                        // 委托代理人联系电话
3169
-                        caseAffiliate.setContactTelphoneAgent(fatchMap.get("agentPhone"));
3162
+                    // 委托代理人
3163
+                    caseAffiliate.setNameAgent(fatchMap.get("agentName"));
3164
+                    // 委托代理人联系电话
3165
+                    caseAffiliate.setContactTelphoneAgent(fatchMap.get("agentPhone"));
3170
 
3166
 
3171
-                        // 代理人电子邮件
3172
-                        caseAffiliate.setAgentEmail(fatchMap.get("agentEmail").replaceAll("\\s", ""));
3167
+                    // 代理人电子邮件
3168
+                    caseAffiliate.setAgentEmail(StrUtil.isNotEmpty(fatchMap.get("agentEmail")) ? fatchMap.get("agentEmail").replaceAll("\\s", "") : null);
3173
 
3169
 
3174
 
3170
 
3175
-                        //设置默认代理人的身份证号码,暂时写死 要不然新增方法报错
3176
-                  //      caseAffiliate.setIdentityNumAgent("610423199603171716");
3177
-                        caseAffiliates.add(caseAffiliate);
3178
-                        // 被申请人信息
3179
-                        CaseAffiliate respondentAffiliate = new CaseAffiliate();
3171
+                    //设置默认代理人的身份证号码,暂时写死 要不然新增方法报错
3172
+                    //      caseAffiliate.setIdentityNumAgent("610423199603171716");
3173
+                    caseAffiliates.add(caseAffiliate);
3174
+                    // 被申请人信息
3175
+                    CaseAffiliate respondentAffiliate = new CaseAffiliate();
3180
                     respondentAffiliate.setIdentityType(2);
3176
                     respondentAffiliate.setIdentityType(2);
3181
                     // 被申请人名称
3177
                     // 被申请人名称
3182
                     respondentAffiliate.setName(fatchMap.get("respondentName"));
3178
                     respondentAffiliate.setName(fatchMap.get("respondentName"));
3183
-                        // 被申请人身份证
3184
-                        String identityNum = fatchMap.get("respondentCard");
3179
+                    // 被申请人身份证
3180
+                    String identityNum = fatchMap.get("respondentCard");
3185
                     // 出生年月日,从身份证抓取
3181
                     // 出生年月日,从身份证抓取
3186
-                    if(StrUtil.isNotEmpty(identityNum)) {
3182
+                    if (StrUtil.isNotEmpty(identityNum)) {
3187
                         Map<String, String> identityNumMap = getBirAgeSex(identityNum);
3183
                         Map<String, String> identityNumMap = getBirAgeSex(identityNum);
3188
                         String birthday = identityNumMap.get("birthday");
3184
                         String birthday = identityNumMap.get("birthday");
3189
-                        if(StrUtil.isNotEmpty(birthday)) {
3185
+                        if (StrUtil.isNotEmpty(birthday)) {
3190
                             SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
3186
                             SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
3191
                             Date birthdayDate = null;
3187
                             Date birthdayDate = null;
3192
                             try {
3188
                             try {
3198
                             respondentAffiliate.setResponBirth(birthdayDate);
3194
                             respondentAffiliate.setResponBirth(birthdayDate);
3199
                         }
3195
                         }
3200
                         //从身份证抓取性别
3196
                         //从身份证抓取性别
3201
-                        fatchMap.put("resSex",identityNumMap.get("sexCode"));
3197
+                        fatchMap.put("resSex", identityNumMap.get("sexCode"));
3202
                         respondentAffiliate.setResponSex(identityNumMap.get("sexCode"));
3198
                         respondentAffiliate.setResponSex(identityNumMap.get("sexCode"));
3203
                     }
3199
                     }
3204
                     respondentAffiliate.setIdentityNum(identityNum);
3200
                     respondentAffiliate.setIdentityNum(identityNum);
3205
-                        // 被申请人电子邮件
3201
+                    // 被申请人电子邮件
3206
 //                    if(map.get("乙方确认有效的电子信箱地址为").size()>1) {
3202
 //                    if(map.get("乙方确认有效的电子信箱地址为").size()>1) {
3207
 //                        if(map.get("乙方确认有效的电子信箱地址为").get(0).contains("/")) {
3203
 //                        if(map.get("乙方确认有效的电子信箱地址为").get(0).contains("/")) {
3208
 //                            respondentAffiliate.setEmail(map.get("乙方确认有效的电子信箱地址为").get(1).replaceAll("\\s", ""));
3204
 //                            respondentAffiliate.setEmail(map.get("乙方确认有效的电子信箱地址为").get(1).replaceAll("\\s", ""));
3211
 //                        }
3207
 //                        }
3212
 //                    }
3208
 //                    }
3213
                     // 被申请人电子邮件
3209
                     // 被申请人电子邮件
3214
-                    respondentAffiliate.setEmail(fatchMap.get("respondentEmail").replaceAll("\\s", ""));
3210
+                    respondentAffiliate.setEmail(StrUtil.isNotEmpty(fatchMap.get("respondentEmail")) ? fatchMap.get("respondentEmail").replaceAll("\\s", "") : null);
3215
                     // 被申请人联系电话
3211
                     // 被申请人联系电话
3216
                     respondentAffiliate.setContactTelphone(fatchMap.get("respondentPhone"));
3212
                     respondentAffiliate.setContactTelphone(fatchMap.get("respondentPhone"));
3217
                     // 被申请人住所
3213
                     // 被申请人住所
3218
                     respondentAffiliate.setResidenAffili(fatchMap.get("respondentHome"));
3214
                     respondentAffiliate.setResidenAffili(fatchMap.get("respondentHome"));
3219
 
3215
 
3220
-                        caseAffiliates.add(respondentAffiliate);
3221
-                        caseApplication.setCaseAffiliates(caseAffiliates);
3222
-                        // 新增案件基本信息表
3223
-                        this.insertcaseApplication(caseApplication,fatchMap);
3224
-                        if (null != caseApplication.getId()) {
3225
-                            List<CaseAttach> caseAttachs=new ArrayList<>();
3226
-                            for (Map.Entry<String, String> entry : andConvertPDF.entrySet()) {
3227
-                                if(entry.getValue().contains("证据材料")||entry.getValue().contains("申请书")||entry.getValue().contains("调解协议")||entry.getValue().contains("情况说明")){
3228
-                                    String pdfUrl = entry.getValue();
3229
-                                    File file1 = new File(pdfUrl);
3230
-                                    CaseAttach caseAttach = new CaseAttach();
3231
-                                    caseAttach.setCaseAppliId(caseApplication.getId());
3232
-                                    caseAttach.setAnnexPath(file1.getPath());
3233
-                                    caseAttach.setAnnexName(file1.getName());
3234
-                                    // 申请人提供的证据材料
3235
-                                    caseAttach.setAnnexType(2);
3236
-                                    caseAttachs.add(caseAttach);
3237
-                                }
3238
-                            }
3239
-                            if(CollectionUtil.isNotEmpty(caseAttachs)) {
3240
-                                // 新增申请人证据材料
3241
-                                caseAttachMapper.batchSave(caseAttachs);
3216
+                    caseAffiliates.add(respondentAffiliate);
3217
+                    caseApplication.setCaseAffiliates(caseAffiliates);
3218
+                    // 新增案件基本信息表
3219
+                    this.insertcaseApplication(caseApplication, fatchMap);
3220
+                    if (null != caseApplication.getId()) {
3221
+                        List<CaseAttach> caseAttachs = new ArrayList<>();
3222
+                        for (Map.Entry<String, String> entry : andConvertPDF.entrySet()) {
3223
+                            if (entry.getValue().contains("证据材料") || entry.getValue().contains("申请书") || entry.getValue().contains("调解协议") || entry.getValue().contains("情况说明")) {
3224
+                                String pdfUrl = entry.getValue();
3225
+                                File file1 = new File(pdfUrl);
3226
+                                CaseAttach caseAttach = new CaseAttach();
3227
+                                caseAttach.setCaseAppliId(caseApplication.getId());
3228
+                                caseAttach.setAnnexPath(file1.getPath());
3229
+                                caseAttach.setAnnexName(file1.getName());
3230
+                                // 申请人提供的证据材料
3231
+                                caseAttach.setAnnexType(2);
3232
+                                caseAttachs.add(caseAttach);
3242
                             }
3233
                             }
3243
-                            return AjaxResult.success("导入成功");
3244
                         }
3234
                         }
3245
-                    }else{
3246
-                        return AjaxResult.error("文件识别内容失败,请检查");
3235
+                        if (CollectionUtil.isNotEmpty(caseAttachs)) {
3236
+                            // 新增申请人证据材料
3237
+                            caseAttachMapper.batchSave(caseAttachs);
3238
+                        }
3239
+                        return AjaxResult.success("导入成功");
3247
                     }
3240
                     }
3241
+                } else {
3242
+                    return AjaxResult.error("文件识别内容失败,请检查");
3243
+                }
3248
 
3244
 
3249
             } else {
3245
             } else {
3250
                 // 没有找到符合条件的文件
3246
                 // 没有找到符合条件的文件
3298
                 //  return false;
3294
                 //  return false;
3299
             }
3295
             }
3300
             StringBuilder ocrText = new StringBuilder(); // 创建一个StringBuilder对象
3296
             StringBuilder ocrText = new StringBuilder(); // 创建一个StringBuilder对象
3301
-            for (int i = 0; i < fileNumPage; i++) {
3297
+            for (int i = 1; i <= fileNumPage; i++) {
3302
                 //对接腾讯云接口.识别里面的数据
3298
                 //对接腾讯云接口.识别里面的数据
3303
-                String text = OCRUtils.pdfIdentifyText(base64, i + 1, fatchRules);
3299
+                String text = OCRUtils.pdfIdentifyText(base64, i , fatchRules);
3304
                 ocrText.append(text); // 拼接当前的字符串
3300
                 ocrText.append(text); // 拼接当前的字符串
3305
             }
3301
             }
3306
             if(StrUtil.isNotEmpty(ocrText)){
3302
             if(StrUtil.isNotEmpty(ocrText)){
3377
                     // 如果文件名包含"仲裁申请书"且是PDF格式,直接返回路径
3373
                     // 如果文件名包含"仲裁申请书"且是PDF格式,直接返回路径
3378
                     path = directory.getAbsolutePath();
3374
                     path = directory.getAbsolutePath();
3379
                 } else {
3375
                 } else {
3380
-                    // 如果不是PDF格式,进行转换成PDF并返回路径
3381
-                    String pdfPath = convertToPDF(directory);
3382
-                    if (pdfPath != null) {
3383
-                        path = pdfPath;
3376
+                    String extension = getFileExtension(directory);
3377
+                    if( extension.contains("doc")|| extension.contains("docx")) {
3378
+                        // 如果不是PDF格式,进行转换成PDF并返回路径
3379
+                        String pdfPath = convertToPDF(directory);
3380
+                        if (pdfPath != null) {
3381
+                            path = pdfPath;
3382
+                        }
3384
                     }
3383
                     }
3385
                 }
3384
                 }
3386
                     // 如果文件名包含"仲裁申请书"且是PDF格式,直接返回路径
3385
                     // 如果文件名包含"仲裁申请书"且是PDF格式,直接返回路径
3432
                             pdfPathMap.put(file.getName(),file.getAbsolutePath());
3431
                             pdfPathMap.put(file.getName(),file.getAbsolutePath());
3433
                         } else {
3432
                         } else {
3434
                             // 如果不是PDF格式,进行转换成PDF并添加转换后的路径到列表中
3433
                             // 如果不是PDF格式,进行转换成PDF并添加转换后的路径到列表中
3435
-                        String   pdfPath = convertToPDF(file);
3434
+                             String   pdfPath = convertToPDF(file);
3436
                             if (pdfPath != null) {
3435
                             if (pdfPath != null) {
3437
                                 // 如果是PDF格式,直接添加到列表中
3436
                                 // 如果是PDF格式,直接添加到列表中
3438
                                 pdfPathMap.put(file.getName(),pdfPath);
3437
                                 pdfPathMap.put(file.getName(),pdfPath);
3450
 
3449
 
3451
     private static String convertToPDF(File file) {
3450
     private static String convertToPDF(File file) {
3452
         String wordFilePath = file.getAbsolutePath();
3451
         String wordFilePath = file.getAbsolutePath();
3453
-        //String pdfSaveDirectory = "D:\\home\\unzip\\wordToPDF\\";
3454
-        // todo 服务器路径需要改
3452
+        // todo
3455
         String pdfSaveDirectory = "/home/ruoyi/uploadPath/upload/wordToPDF/";
3453
         String pdfSaveDirectory = "/home/ruoyi/uploadPath/upload/wordToPDF/";
3456
-//        String pdfSaveDirectory = "D:/";
3454
+//        String pdfSaveDirectory = "D:/home/ruoyi/uploadPath/upload/wordToPDF/";
3457
         File directory = new File(pdfSaveDirectory);
3455
         File directory = new File(pdfSaveDirectory);
3458
         if (!directory.exists()) {
3456
         if (!directory.exists()) {
3459
             directory.mkdirs();
3457
             directory.mkdirs();
3460
         }
3458
         }
3461
         String name = file.getName();
3459
         String name = file.getName();
3462
         String nameWithoutExtension = name.substring(0, name.lastIndexOf("."));
3460
         String nameWithoutExtension = name.substring(0, name.lastIndexOf("."));
3461
+
3463
         String pdfFilePath = pdfSaveDirectory + nameWithoutExtension + ".pdf";
3462
         String pdfFilePath = pdfSaveDirectory + nameWithoutExtension + ".pdf";
3464
         File inputWord = new File(wordFilePath);
3463
         File inputWord = new File(wordFilePath);
3464
+        if(!inputWord.exists()){
3465
+            throw new ServiceException("文件不存在wordFilePath:"+wordFilePath);
3466
+        }
3465
         File outputFile = new File(pdfFilePath);
3467
         File outputFile = new File(pdfFilePath);
3468
+
3466
         try {
3469
         try {
3467
             InputStream docxInputStream = new FileInputStream(inputWord);
3470
             InputStream docxInputStream = new FileInputStream(inputWord);
3468
             OutputStream outputStream = new FileOutputStream(outputFile);
3471
             OutputStream outputStream = new FileOutputStream(outputFile);
3472
             outputStream.close();
3475
             outputStream.close();
3473
 
3476
 
3474
         } catch (Exception e) {
3477
         } catch (Exception e) {
3475
-            e.printStackTrace();
3478
+            throw new ServiceException(e.getMessage()+"wordFilePath:"+wordFilePath+"pdfFilePath:"+pdfFilePath);
3479
+           // e.printStackTrace();
3476
         }
3480
         }
3477
         return pdfFilePath;
3481
         return pdfFilePath;
3478
     }
3482
     }

+ 2
- 6
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java Просмотреть файл

555
     public AjaxResult saveFatchRules(TemplateManage templateManage) {
555
     public AjaxResult saveFatchRules(TemplateManage templateManage) {
556
         TemplateFatchRule templateFatchRule = new TemplateFatchRule();
556
         TemplateFatchRule templateFatchRule = new TemplateFatchRule();
557
         templateFatchRule.setTemplateId(templateManage.getId());
557
         templateFatchRule.setTemplateId(templateManage.getId());
558
-        List<TemplateFatchRule> templateFatchRulelist = templateFatchRuleMapper.selectTemplateFatchRuleList(templateFatchRule);
559
-        if(templateFatchRulelist!=null&&templateFatchRulelist.size()>0){
560
-            List<Long> fatchRuleIds   = templateFatchRulelist.stream().map(TemplateFatchRule::getFatchRuleId).collect(Collectors.toList());
561
-            fatchRuleMapper.deletebatchFatchRule(fatchRuleIds);
562
-            templateFatchRuleMapper.deleteTemplateFatchRule(templateManage.getId());
563
-        }
558
+        templateFatchRuleMapper.deleteTemplateFatchRule(templateManage.getId());
559
+
564
         List<FatchRule> fatchRules = templateManage.getFatchRules();
560
         List<FatchRule> fatchRules = templateManage.getFatchRules();
565
         if(fatchRules!=null&&fatchRules.size()>0){
561
         if(fatchRules!=null&&fatchRules.size()>0){
566
             for (FatchRule fatchRule : fatchRules) {
562
             for (FatchRule fatchRule : fatchRules) {

+ 9
- 4
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/OCRUtils.java Просмотреть файл

221
                 // 开始截取字符串 申请人:赵会
221
                 // 开始截取字符串 申请人:赵会
222
                 //   String[] startContentSplit = ocrText.split(fatchRule.getStartContent());
222
                 //   String[] startContentSplit = ocrText.split(fatchRule.getStartContent());
223
                 int startFirstIndex = ocrText.indexOf(fatchRule.getStartContent()) + fatchRule.getStartContent().length();
223
                 int startFirstIndex = ocrText.indexOf(fatchRule.getStartContent()) + fatchRule.getStartContent().length();
224
+                if(startFirstIndex<0){
225
+                    continue;
226
+                }
224
                 if (ocrText.length() >= startFirstIndex) {
227
                 if (ocrText.length() >= startFirstIndex) {
225
                     ocrText = ocrText.substring(startFirstIndex);
228
                     ocrText = ocrText.substring(startFirstIndex);
226
                 }
229
                 }
227
 
230
 
228
                 if (StrUtil.isNotEmpty(fatchRule.getEndContent())) {
231
                 if (StrUtil.isNotEmpty(fatchRule.getEndContent())) {
229
-                    int endFirstIndex = ocrText.indexOf(fatchRule.getEndContent()) + fatchRule.getEndContent().length();
230
-                    if (ocrText.length() >= (endFirstIndex-fatchRule.getEndContent().length())) {
231
-                        fatchMap.put(fatchRule.getColumn(), ocrText.substring(0, endFirstIndex-fatchRule.getEndContent().length()));
232
-                        ocrText = ocrText.substring(endFirstIndex-fatchRule.getEndContent().length());
232
+                    if(ocrText.indexOf(fatchRule.getEndContent())>=0) {
233
+                        int endFirstIndex = ocrText.indexOf(fatchRule.getEndContent()) + fatchRule.getEndContent().length();
234
+                        if (ocrText.length() >= (endFirstIndex - fatchRule.getEndContent().length())) {
235
+                            fatchMap.put(fatchRule.getColumn(), ocrText.substring(0, endFirstIndex - fatchRule.getEndContent().length()));
236
+                            ocrText = ocrText.substring(endFirstIndex - fatchRule.getEndContent().length());
237
+                        }
233
                     }
238
                     }
234
                 }
239
                 }
235
             }
240
             }

+ 17
- 9
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseApplicationMapper.xml Просмотреть файл

129
                     <!--根据角色和状态过滤-->
129
                     <!--根据角色和状态过滤-->
130
                     <!--被申请人-->
130
                     <!--被申请人-->
131
                     <if test="idCard != null and idCard != ''">
131
                     <if test="idCard != null and idCard != ''">
132
-                        or (t.identity_num=#{idCard} AND t.identity_type=2 and (t.case_status=4 or t.case_status=17))
132
+                        or (t.identity_num=#{idCard} AND t.identity_type=2
133
+<!--                         and (t.case_status=4 or t.case_status=17) -->
134
+                        )
133
                     </if>
135
                     </if>
134
                     <!--仲裁员-->
136
                     <!--仲裁员-->
135
                     <if test="userId != null and userId != ''">
137
                     <if test="userId != null and userId != ''">
136
-                        or ( t.identity_type=1 and
137
-                        t.case_status in (7,13,17,18)
138
+                <!--        or ( t.identity_type=1 and
139
+                        t.case_status in (7,13,17,18) -->
140
+                        or (t.identity_type=1
138
                         and
141
                         and
139
                         instr (t.arbitrator_id,#{userId})>0)
142
                         instr (t.arbitrator_id,#{userId})>0)
140
                     </if>
143
                     </if>
147
                     <!--                    </if>-->
150
                     <!--                    </if>-->
148
                     <!--部门长-->
151
                     <!--部门长-->
149
                     <if test="deptHeadStatus != null and deptHeadStatus.size() > 0">
152
                     <if test="deptHeadStatus != null and deptHeadStatus.size() > 0">
150
-                        or (t.identity_type=1 and t.case_status in
153
+                        or (t.identity_type=1)
154
+                        <!--and t.case_status in
151
                         <foreach item="caseStatus" collection="deptHeadStatus" open="(" separator="," close=")">
155
                         <foreach item="caseStatus" collection="deptHeadStatus" open="(" separator="," close=")">
152
                             #{caseStatus}
156
                             #{caseStatus}
153
-                        </foreach>)
157
+                        </foreach>)-->
154
                     </if>
158
                     </if>
155
                     <!--财务-->
159
                     <!--财务-->
156
                     <if test="financeStatus != null and financeStatus != ''">
160
                     <if test="financeStatus != null and financeStatus != ''">
157
-                        or (t.identity_type=1 and t.case_status =#{financeStatus})
161
+                        or (t.identity_type=1
162
+                        <!-- and t.case_status =#{financeStatus}-->
163
+                        )
158
 
164
 
159
 
165
 
160
                     </if>
166
                     </if>
165
                         <foreach item="deptId" collection="agentDeptIds" open="(" separator="," close=")">#{deptId}
171
                         <foreach item="deptId" collection="agentDeptIds" open="(" separator="," close=")">#{deptId}
166
                         </foreach>
172
                         </foreach>
167
                         AND t.identity_type=1
173
                         AND t.identity_type=1
168
-                        and t.case_status in (0,9))
174
+                      <!--  and t.case_status in (0,9)-->
175
+                        )
169
 
176
 
170
                     </if>
177
                     </if>
171
                 </where>
178
                 </where>
205
                 JOIN case_affiliate ca ON ca.case_appli_id =c.id AND ca.identity_type = 1
212
                 JOIN case_affiliate ca ON ca.case_appli_id =c.id AND ca.identity_type = 1
206
 
213
 
207
                 <where>
214
                 <where>
208
-                    (c.case_status &lt;= 10 or c.case_status=31) AND ca.identity_type=1
215
+                    <!--(c.case_status &lt;= 10 or c.case_status=31) AND-->
216
+                     ca.identity_type=1
209
 
217
 
210
                     <if test="applicationOrganId != null and applicationOrganId != ''">
218
                     <if test="applicationOrganId != null and applicationOrganId != ''">
211
                         AND ca.application_organ_id = #{applicationOrganId}
219
                         AND ca.application_organ_id = #{applicationOrganId}
295
                 WHERE
303
                 WHERE
296
                 ca.identity_type=1
304
                 ca.identity_type=1
297
 
305
 
298
-                and c.case_status in (1,5,8,9,11,14,15,16,17,31)
306
+              <!--  and c.case_status in (1,5,8,9,11,14,15,16,17,31)-->
299
 
307
 
300
           <!--      <if test="deptIds != null and deptIds.size() > 0">
308
           <!--      <if test="deptIds != null and deptIds.size() > 0">
301
                     and ca.application_organ_id in
309
                     and ca.application_organ_id in