Procházet zdrojové kódy

案件压缩包导入

18792927508 před 2 roky
rodič
revize
a525fd6a16

+ 1
- 1
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/FatchRuleMapper.java Zobrazit soubor

@@ -15,7 +15,7 @@ public interface FatchRuleMapper {
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 20
    List<FatchRule> selectFatchRuleList(FatchRule fatchRule);
21 21
 

+ 116
- 112
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java Zobrazit soubor

@@ -14,6 +14,7 @@ import com.documents4j.job.LocalConverter;
14 14
 import com.google.gson.Gson;
15 15
 import com.google.gson.JsonArray;
16 16
 import com.google.gson.JsonObject;
17
+
17 18
 import com.ruoyi.common.annotation.DataScope;
18 19
 import com.ruoyi.common.config.RuoYiConfig;
19 20
 import com.ruoyi.common.constant.CaseApplicationConstants;
@@ -37,7 +38,6 @@ import com.ruoyi.system.mapper.SysUserRoleMapper;
37 38
 import com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue;
38 39
 import com.ruoyi.wisdomarbitrate.domain.vo.ReservedConferenceVO;
39 40
 import com.ruoyi.wisdomarbitrate.domain.vo.ToDoCount;
40
-import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
41 41
 import com.ruoyi.wisdomarbitrate.domain.*;
42 42
 import com.ruoyi.wisdomarbitrate.domain.vo.SendRoomNoMessageVO;
43 43
 import com.ruoyi.wisdomarbitrate.mapper.*;
@@ -46,41 +46,33 @@ import com.ruoyi.wisdomarbitrate.utils.OCRUtils;
46 46
 import com.ruoyi.wisdomarbitrate.utils.SignAward;
47 47
 import com.ruoyi.wisdomarbitrate.utils.UnZipFileUtils;
48 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 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 52
 import org.springframework.beans.factory.annotation.Autowired;
60 53
 import org.springframework.beans.factory.annotation.Value;
61 54
 import org.springframework.stereotype.Service;
62 55
 import org.springframework.transaction.annotation.Transactional;
63 56
 import org.springframework.web.multipart.MultipartFile;
64
-
65 57
 import java.io.*;
66 58
 import java.math.BigDecimal;
67 59
 import java.math.RoundingMode;
68 60
 import java.nio.file.Files;
69 61
 import java.nio.file.Path;
70 62
 import java.nio.file.StandardCopyOption;
71
-import java.text.NumberFormat;
72 63
 import java.text.ParseException;
73 64
 import java.text.SimpleDateFormat;
74 65
 import java.time.LocalDate;
75 66
 import java.time.ZoneId;
76 67
 import java.util.*;
68
+import java.util.List;
69
+import java.util.concurrent.TimeUnit;
77 70
 import java.util.function.Function;
78 71
 import java.util.regex.Matcher;
79 72
 import java.util.regex.Pattern;
80 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 76
 import static com.ruoyi.common.core.domain.AjaxResult.success;
85 77
 import static com.ruoyi.common.utils.PageUtils.startPage;
86 78
 import static com.ruoyi.common.utils.SecurityUtils.getLoginUser;
@@ -253,6 +245,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
253 245
 
254 246
     }
255 247
 
248
+
256 249
     @Override
257 250
     public ToDoCount selectToDoCount() {
258 251
 
@@ -398,9 +391,8 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
398 391
         if (file.isEmpty()) {
399 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 396
         File zipFile = null;
405 397
         InputStream ins = null;
406 398
         try {
@@ -416,10 +408,9 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
416 408
         //得到解压缩的所有文件
417 409
         String zipName = file.getOriginalFilename();
418 410
         String subzipName = zipName.substring(0, zipName.indexOf(".zip"));
419
-//        String zipPath = "F:\\testZip\\uploadPath\\upload\\upload1\\unzipFile\\"+subzipName;
420
-        // todo 服务器路径需要改
411
+        // todo
421 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 415
         File dirUnzipPath = new File(zipPath);
425 416
         List<File> allFiles = new ArrayList<>();
@@ -511,9 +502,9 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
511 502
                     String year = Integer.toString(now.getYear());
512 503
                     String month = String.format("%02d", now.getMonthValue());
513 504
                     String day = String.format("%02d", now.getDayOfMonth());
514
-                    //  // todo 服务器路径需要改
505
+                   // todo
515 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 508
                     String fileName = UUID.randomUUID().toString().replace("-", "") + "_" + substrfile;
518 509
                     String resultFilePath = saveFolderPath + "/" + fileName;
519 510
                     try {
@@ -3003,17 +2994,17 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3003 2994
             return AjaxResult.error("请选择要上传的文件");
3004 2995
         }
3005 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 3000
         File zipFile = null;
3010 3001
         InputStream ins = null;
3011 3002
         try {
3012 3003
             ins = file.getInputStream();
3013 3004
             //上传的压缩包保存的路径
3014
-            // todo 服务器路径需要改
3005
+            // todo
3015 3006
             String savePath = "/home/ruoyi/uploadPath/upload/zipFile/";
3016
-//           String savePath = "D:/zip/";
3007
+//           String savePath = "D:/home/ruoyi/uploadPath/upload/zipFile/";
3017 3008
             String saveName = uuid + "_" + file.getOriginalFilename();
3018 3009
             zipFile = new File(savePath + saveName);
3019 3010
             inputChangeToFile(ins, zipFile);
@@ -3025,34 +3016,39 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3025 3016
         if (unzipSuccess) {
3026 3017
             // 查询抓取规则
3027 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 3023
             File directory = new File(targetPath);
3030
-           Map<String,String>  andConvertPDF = findAndConvertPDF(directory,fatchRuleList);
3024
+            Map<String, String> andConvertPDF = findAndConvertPDF(directory, fatchRuleList);
3031 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 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 3046
                     caseApplication.setArbitratClaims(fatchMap.get("arbitrationClaims"));
3051 3047
                     // 事实和理由
3052 3048
                     caseApplication.setFacts(fatchMap.get("factsAndReason"));
3053 3049
                     // 合同编号
3054 3050
                     String contractNumber = fatchMap.get("contractNumber");
3055
-                    if(StrUtil.isNotEmpty(contractNumber)) {
3051
+                    if (StrUtil.isNotEmpty(contractNumber)) {
3056 3052
                         // 提取字母和数字
3057 3053
                         String regx = "[^a-zA-Z0-9]";
3058 3054
                         String replaceAll = contractNumber.replaceAll(regx, "");
@@ -3063,7 +3059,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3063 3059
                     String lonStartDate = fatchMap.get("lonStartDate:");
3064 3060
                     SimpleDateFormat sdf = new SimpleDateFormat();
3065 3061
                     sdf.applyPattern("yyyy年MM月dd日");
3066
-                    if(StrUtil.isNotEmpty(lonStartDate)) {
3062
+                    if (StrUtil.isNotEmpty(lonStartDate)) {
3067 3063
                         try {
3068 3064
                             caseApplication.setLoanStartDate(sdf.parse(lonStartDate));
3069 3065
                         } catch (ParseException e) {
@@ -3138,19 +3134,19 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3138 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 3151
                     caseAffiliate.setResidenAffili(fatchMap.get("applicantHome"));
3156 3152
                     // 申请人联系地址
@@ -3163,30 +3159,30 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3163 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 3176
                     respondentAffiliate.setIdentityType(2);
3181 3177
                     // 被申请人名称
3182 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 3183
                         Map<String, String> identityNumMap = getBirAgeSex(identityNum);
3188 3184
                         String birthday = identityNumMap.get("birthday");
3189
-                        if(StrUtil.isNotEmpty(birthday)) {
3185
+                        if (StrUtil.isNotEmpty(birthday)) {
3190 3186
                             SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
3191 3187
                             Date birthdayDate = null;
3192 3188
                             try {
@@ -3198,11 +3194,11 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3198 3194
                             respondentAffiliate.setResponBirth(birthdayDate);
3199 3195
                         }
3200 3196
                         //从身份证抓取性别
3201
-                        fatchMap.put("resSex",identityNumMap.get("sexCode"));
3197
+                        fatchMap.put("resSex", identityNumMap.get("sexCode"));
3202 3198
                         respondentAffiliate.setResponSex(identityNumMap.get("sexCode"));
3203 3199
                     }
3204 3200
                     respondentAffiliate.setIdentityNum(identityNum);
3205
-                        // 被申请人电子邮件
3201
+                    // 被申请人电子邮件
3206 3202
 //                    if(map.get("乙方确认有效的电子信箱地址为").size()>1) {
3207 3203
 //                        if(map.get("乙方确认有效的电子信箱地址为").get(0).contains("/")) {
3208 3204
 //                            respondentAffiliate.setEmail(map.get("乙方确认有效的电子信箱地址为").get(1).replaceAll("\\s", ""));
@@ -3211,40 +3207,40 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
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 3212
                     respondentAffiliate.setContactTelphone(fatchMap.get("respondentPhone"));
3217 3213
                     // 被申请人住所
3218 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 3245
             } else {
3250 3246
                 // 没有找到符合条件的文件
@@ -3298,9 +3294,9 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3298 3294
                 //  return false;
3299 3295
             }
3300 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 3300
                 ocrText.append(text); // 拼接当前的字符串
3305 3301
             }
3306 3302
             if(StrUtil.isNotEmpty(ocrText)){
@@ -3377,10 +3373,13 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3377 3373
                     // 如果文件名包含"仲裁申请书"且是PDF格式,直接返回路径
3378 3374
                     path = directory.getAbsolutePath();
3379 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 3385
                     // 如果文件名包含"仲裁申请书"且是PDF格式,直接返回路径
@@ -3432,7 +3431,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3432 3431
                             pdfPathMap.put(file.getName(),file.getAbsolutePath());
3433 3432
                         } else {
3434 3433
                             // 如果不是PDF格式,进行转换成PDF并添加转换后的路径到列表中
3435
-                        String   pdfPath = convertToPDF(file);
3434
+                             String   pdfPath = convertToPDF(file);
3436 3435
                             if (pdfPath != null) {
3437 3436
                                 // 如果是PDF格式,直接添加到列表中
3438 3437
                                 pdfPathMap.put(file.getName(),pdfPath);
@@ -3450,19 +3449,23 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3450 3449
 
3451 3450
     private static String convertToPDF(File file) {
3452 3451
         String wordFilePath = file.getAbsolutePath();
3453
-        //String pdfSaveDirectory = "D:\\home\\unzip\\wordToPDF\\";
3454
-        // todo 服务器路径需要改
3452
+        // todo
3455 3453
         String pdfSaveDirectory = "/home/ruoyi/uploadPath/upload/wordToPDF/";
3456
-//        String pdfSaveDirectory = "D:/";
3454
+//        String pdfSaveDirectory = "D:/home/ruoyi/uploadPath/upload/wordToPDF/";
3457 3455
         File directory = new File(pdfSaveDirectory);
3458 3456
         if (!directory.exists()) {
3459 3457
             directory.mkdirs();
3460 3458
         }
3461 3459
         String name = file.getName();
3462 3460
         String nameWithoutExtension = name.substring(0, name.lastIndexOf("."));
3461
+
3463 3462
         String pdfFilePath = pdfSaveDirectory + nameWithoutExtension + ".pdf";
3464 3463
         File inputWord = new File(wordFilePath);
3464
+        if(!inputWord.exists()){
3465
+            throw new ServiceException("文件不存在wordFilePath:"+wordFilePath);
3466
+        }
3465 3467
         File outputFile = new File(pdfFilePath);
3468
+
3466 3469
         try {
3467 3470
             InputStream docxInputStream = new FileInputStream(inputWord);
3468 3471
             OutputStream outputStream = new FileOutputStream(outputFile);
@@ -3472,7 +3475,8 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3472 3475
             outputStream.close();
3473 3476
 
3474 3477
         } catch (Exception e) {
3475
-            e.printStackTrace();
3478
+            throw new ServiceException(e.getMessage()+"wordFilePath:"+wordFilePath+"pdfFilePath:"+pdfFilePath);
3479
+           // e.printStackTrace();
3476 3480
         }
3477 3481
         return pdfFilePath;
3478 3482
     }

+ 2
- 6
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java Zobrazit soubor

@@ -555,12 +555,8 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
555 555
     public AjaxResult saveFatchRules(TemplateManage templateManage) {
556 556
         TemplateFatchRule templateFatchRule = new TemplateFatchRule();
557 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 560
         List<FatchRule> fatchRules = templateManage.getFatchRules();
565 561
         if(fatchRules!=null&&fatchRules.size()>0){
566 562
             for (FatchRule fatchRule : fatchRules) {

+ 9
- 4
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/OCRUtils.java Zobrazit soubor

@@ -221,15 +221,20 @@ public class OCRUtils {
221 221
                 // 开始截取字符串 申请人:赵会
222 222
                 //   String[] startContentSplit = ocrText.split(fatchRule.getStartContent());
223 223
                 int startFirstIndex = ocrText.indexOf(fatchRule.getStartContent()) + fatchRule.getStartContent().length();
224
+                if(startFirstIndex<0){
225
+                    continue;
226
+                }
224 227
                 if (ocrText.length() >= startFirstIndex) {
225 228
                     ocrText = ocrText.substring(startFirstIndex);
226 229
                 }
227 230
 
228 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 Zobrazit soubor

@@ -129,12 +129,15 @@
129 129
                     <!--根据角色和状态过滤-->
130 130
                     <!--被申请人-->
131 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 135
                     </if>
134 136
                     <!--仲裁员-->
135 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 141
                         and
139 142
                         instr (t.arbitrator_id,#{userId})>0)
140 143
                     </if>
@@ -147,14 +150,17 @@
147 150
                     <!--                    </if>-->
148 151
                     <!--部门长-->
149 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 155
                         <foreach item="caseStatus" collection="deptHeadStatus" open="(" separator="," close=")">
152 156
                             #{caseStatus}
153
-                        </foreach>)
157
+                        </foreach>)-->
154 158
                     </if>
155 159
                     <!--财务-->
156 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 166
                     </if>
@@ -165,7 +171,8 @@
165 171
                         <foreach item="deptId" collection="agentDeptIds" open="(" separator="," close=")">#{deptId}
166 172
                         </foreach>
167 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 177
                     </if>
171 178
                 </where>
@@ -205,7 +212,8 @@
205 212
                 JOIN case_affiliate ca ON ca.case_appli_id =c.id AND ca.identity_type = 1
206 213
 
207 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 218
                     <if test="applicationOrganId != null and applicationOrganId != ''">
211 219
                         AND ca.application_organ_id = #{applicationOrganId}
@@ -295,7 +303,7 @@
295 303
                 WHERE
296 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 308
           <!--      <if test="deptIds != null and deptIds.size() > 0">
301 309
                     and ca.application_organ_id in