Kaynağa Gözat

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

wangqiong123 2 yıl önce
ebeveyn
işleme
a832a8281a

+ 14
- 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/DeptIdentifyController.java Dosyayı Görüntüle

@@ -1,4 +1,5 @@
1 1
 package com.ruoyi.web.controller.wisdomarbitrate;
2
+import cn.hutool.core.util.StrUtil;
2 3
 import com.ruoyi.common.core.controller.BaseController;
3 4
 import com.ruoyi.common.core.domain.AjaxResult;
4 5
 import com.ruoyi.common.core.page.TableDataInfo;
@@ -219,7 +220,19 @@ public class DeptIdentifyController extends BaseController {
219 220
         return AjaxResult.success(fatchRulesel);
220 221
     }
221 222
 
222
-
223
+    /**
224
+     * 根据模板id查询模板字段列表
225
+     * @param templateManage
226
+     * @return
227
+     */
228
+    @GetMapping("/getTemplateInfoById")
229
+    public AjaxResult getTemplateInfoById(@RequestBody  TemplateManage templateManage){
230
+        if(templateManage.getId()==null){
231
+            return error("参数校验错误");
232
+        }
233
+        List<FatchRule> fatchRuleList = deptIdentifyService.getTemplateInfoById(templateManage);
234
+        return AjaxResult.success(fatchRuleList);
235
+    }
223 236
 
224 237
 
225 238
 }

+ 7
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IDeptIdentifyService.java Dosyayı Görüntüle

@@ -59,4 +59,11 @@ public interface IDeptIdentifyService {
59 59
     List<FatchRule> selectColumnandComment();
60 60
 
61 61
     FatchRule selectColumnbycomment(FatchRule fatchRule);
62
+
63
+    /**
64
+     * 根据模板id查询模板字段列表
65
+     * @param templateManage
66
+     * @return
67
+     */
68
+    List<FatchRule> getTemplateInfoById(TemplateManage templateManage);
62 69
 }

+ 10
- 5
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/AdjudicationServiceImpl.java Dosyayı Görüntüle

@@ -158,10 +158,19 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
158 158
                 return AjaxResult.error("请先指定裁决书模板");
159 159
             }
160 160
             templatePath = templateManages.get(0).getTemOrigPath();
161
+            if(StrUtil.isEmpty(templatePath)){
162
+                return AjaxResult.error("未找到该模板");
163
+            }
164
+
161 165
             // todo 部署放开
162 166
             if(templatePath!=null){
163 167
                 templatePath="/home/ruoyi/" +templatePath;
164 168
             }
169
+            try {
170
+                File file = new File(templatePath);
171
+            } catch (Exception e) {
172
+                return AjaxResult.error("未找到该模板");
173
+            }
165 174
             templateName = templateManages.get(0).getFileName();
166 175
             // 查询案件相关表信息
167 176
             CaseAffiliate caseAffiliate = new CaseAffiliate();
@@ -199,9 +208,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
199 208
             // 获取模板中的占位符key
200 209
             List<String> bookmarkList = getBookmarkByDocx(templatePath);
201 210
             if (CollectionUtil.isEmpty(bookmarkList)) {
202
-                // 直接保存模板为裁决书
203
-                saveArbitorFile(id, templateName, templatePath, caseApplicationById, arbitrateRecordSelect);
204
-                return AjaxResult.success("生成裁决书成功");
211
+                return AjaxResult.success("请检查模板是否配置正确,未获取到占位符");
205 212
             }
206 213
             // 遍历书签,给书签赋值
207 214
             replaceBookmark(bookmarkList,datas,valueMap);
@@ -231,8 +238,6 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
231 238
             String month = String.format("%02d", now.getMonthValue());
232 239
             String day = String.format("%02d", now.getDayOfMonth());
233 240
             // todo
234
-//            String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx";
235
-            // todo
236 241
             String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
237 242
 //            String saveFolderPath = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
238 243
             String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";

+ 161
- 153
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java Dosyayı Görüntüle

@@ -1,6 +1,7 @@
1 1
 package com.ruoyi.wisdomarbitrate.service.impl;
2 2
 
3 3
 
4
+import cn.hutool.core.bean.BeanUtil;
4 5
 import cn.hutool.core.collection.CollectionUtil;
5 6
 import cn.hutool.core.util.IdcardUtil;
6 7
 import cn.hutool.core.util.ObjectUtil;
@@ -1016,11 +1017,21 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
1016 1017
         }
1017 1018
 
1018 1019
         List<CaseAttach> caseAttachList = caseApplication.getCaseAttachList();
1019
-        if (caseAttachList != null && caseAttachList.size() > 0) {
1020
-            for (CaseAttach caseAttach : caseAttachList) {
1021
-                caseAttach.setCaseAppliId(caseApplication.getId());
1022
-                // 修改案件附件
1023
-                caseAttachMapper.updateCaseAttach(caseAttach);
1020
+        // 是否是压缩包导入,压缩包导入则不更新附件
1021
+        boolean isZipImport = caseApplication.getImportFlag() == null || caseApplication.getImportFlag() != 2;
1022
+        if (caseAttachList != null && caseAttachList.size() > 0  ) {
1023
+            if(isZipImport) {
1024
+                for (CaseAttach caseAttach : caseAttachList) {
1025
+                    caseAttach.setCaseAppliId(caseApplication.getId());
1026
+                    // 修改案件附件
1027
+                    caseAttachMapper.updateCaseAttach(caseAttach);
1028
+                }
1029
+            }else {
1030
+                // 压缩包导入
1031
+                for (CaseAttach caseAttach : caseAttachList) {
1032
+                    caseAttach.setCaseAppliId(caseApplication.getId());
1033
+                }
1034
+                caseAttachMapper.batchSave(caseAttachList);
1024 1035
             }
1025 1036
         }
1026 1037
         // 新增日志
@@ -1254,7 +1265,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
1254 1265
                 agentUser.setNickName(caseAffiliate.getNameAgent());
1255 1266
                 agentUser.setUserName(caseAffiliate.getContactTelphoneAgent());
1256 1267
                 agentUser.setPhonenumber(caseAffiliate.getContactTelphoneAgent());
1257
-                //   agentUser.setPassword(SecurityUtils.encryptPassword(Constants.DEFAULT_PASSWORD));
1268
+                agentUser.setPassword(SecurityUtils.encryptPassword("abc123456"));
1258 1269
                 agentUser.setDeptId(Long.valueOf(caseAffiliate.getApplicationOrganId()));
1259 1270
                 int insertUserRow = sysUserMapper.insertUser(agentUser);
1260 1271
                 // 新增角色为申请人
@@ -3049,9 +3060,9 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3049 3060
 
3050 3061
         return success(reservedConferenceMapper.deleteByRoomId(roomId));
3051 3062
     }
3052
-
3063
+    @Transactional
3053 3064
     @Override
3054
-    public AjaxResult uploadCaseZipFile(MultipartFile file,Long templateId) {
3065
+    public AjaxResult uploadCaseZipFile(MultipartFile file, Long templateId) {
3055 3066
         if (file.isEmpty()) {
3056 3067
             return AjaxResult.error("请选择要上传的文件");
3057 3068
         }
@@ -3075,113 +3086,107 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3075 3086
         }
3076 3087
         //解压缩上传的压缩包
3077 3088
         boolean unzipSuccess = UnZipFileUtils.unZipFile(zipFile, targetPath);
3078
-        if (unzipSuccess) {
3079
-            // 查询抓取规则
3080
-            // todo 批次需要再上传压缩包时用户填写
3081
-            List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId(templateId);
3082
-            if (CollectionUtil.isEmpty(fatchRuleList)) {
3083
-              return   error("未设置抓取规则");
3084
-            }
3085
-            File directory = new File(targetPath);
3086
-            Map<String, String> andConvertPDF = findAndConvertPDF(directory, fatchRuleList);
3087
-            if (andConvertPDF != null && andConvertPDF.size() > 0) {
3088
-                Map<String, String> fatchMap = new HashMap<>();
3089
-                if (CollectionUtil.isNotEmpty(fatchRuleList)) {
3090
-                    Map<String, List<FatchRule>> fatchRuleMap = fatchRuleList.stream().collect(Collectors.groupingBy(FatchRule::getFileName));
3091
-                    // 根据抓取规则循环抓取
3092
-                    for (Map.Entry<String, List<FatchRule>> entry : fatchRuleMap.entrySet()) {
3093
-                        OCRAndBuildInfo(andConvertPDF, entry.getKey(), fatchMap, entry.getValue());
3094
-                    }
3095
-                }
3096
-                if (fatchMap.size() <= 0) {
3097
-                  return  error("从压缩包中未抓取到内容,请检查抓取字段配置");
3098
-                }
3099
-                  // 组装案件内置字段主表内容
3100
-                    CaseApplication caseApplication = new CaseApplication();
3101
-                    caseApplication.setTemplateId(templateId);
3102
-                    //默认案件标的 todo 案件标的是什么,默认写死
3103
-                    caseApplication.setCaseSubjectAmount(new BigDecimal(100000));
3104
-                // todo 从抓取规则表取字段和字典表取基本字段,字典表的字段名塞到基本表,is_default=1自定义字段塞到columnValue
3105
-                // 抓取规则,0-内置字段,1-自定义字段
3106
-                Map<Integer, List<FatchRule>> fatchRuleMap = fatchRuleList.stream().collect(Collectors.groupingBy(FatchRule::getIsDefault));
3107
-                // 自定义字段,组装columnValue表
3108
-                List<ColumnValue> columnValueList = new ArrayList<>();
3109
-                if (fatchRuleMap.size() > 0 && fatchRuleMap.containsKey(1)) {
3110
-                    List<FatchRule> columnRules = fatchRuleMap.get(1);
3111
-                    columnRules.forEach(columnRule -> {
3112
-                        ColumnValue columnValue = new ColumnValue();
3113
-                        columnValue.setColumn(columnRule.getColumn());
3114
-                        columnValue.setName(columnRule.getColumnName());
3115
-                        columnValue.setValue(fatchMap.get(columnRule.getColumnName()));
3116
-                        columnValue.setIsDefault(1);
3117
-                        columnValueList.add(columnValue);
3118
-                    });
3119
-                }
3120
-                // 在系统表中查询案件内置字段
3121
-                SysDictData sysDictData = new SysDictData();
3122
-                sysDictData.setDictType("case_built_type");
3123
-                List<SysDictData> dictDataList = dictDataMapper.selectDictDataList(sysDictData);
3124
-                // 组装内置字段
3125
-                buildDefaultColumn(caseApplication,dictDataList,fatchMap);
3126
-                    // 借款开始日期
3127
-//                    String lonStartDate = fatchMap.get("借款开始日期:");
3128
-//                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
3129
-//                    if (StrUtil.isNotEmpty(lonStartDate)) {
3130
-//                        try {
3131
-//                            caseApplication.setLoanStartDate(sdf.parse(lonStartDate));
3132
-//                        } catch (ParseException e) {
3133
-//                            e.printStackTrace();
3134
-//                        }
3135
-//                    }
3136
-                // 设置批号
3137
-                if(StrUtil.isEmpty(caseApplication.getBatchNumber())){
3138
-                    Integer maxBatchNumber = caseApplicationMapper.selectBatchNumberLike();
3139
-                    if(maxBatchNumber==null){
3140
-                        caseApplication.setBatchNumber("1");
3141
-                    }else {
3142
-                        caseApplication.setBatchNumber(maxBatchNumber+1+"");
3143
-                    }
3144
-                }
3145
-                    // 新增案件基本信息表
3146
-                    this.insertcaseApplication(caseApplication, columnValueList);
3147
-                    if (null != caseApplication.getId()) {
3148
-                        List<CaseAttach> caseAttachs = new ArrayList<>();
3149
-                        for (Map.Entry<String, String> entry : andConvertPDF.entrySet()) {
3150
-                                String fileUrl = entry.getValue();
3151
-                            // 上传
3152
-                            String filePath = RuoYiConfig.getUploadPath();
3153
-
3154
-                            CaseAttach caseAttach = new CaseAttach();
3155
-                                caseAttach.setCaseAppliId(caseApplication.getId());
3156
-                                caseAttach.setAnnexPath(filePath);
3157
-                                if(StrUtil.isNotEmpty(fileUrl)) {
3158
-                                    String fileName = fileUrl.replace(filePath, "/profile/upload");
3159
-                                    caseAttach.setAnnexName(fileName);
3160
-                                }
3161
-                                // 申请人提供的证据材料
3162
-                                caseAttach.setAnnexType(2);
3163
-                                caseAttachs.add(caseAttach);
3164
-
3165
-                        }
3166
-                        if (CollectionUtil.isNotEmpty(caseAttachs)) {
3167
-                            // 新增申请人证据材料
3168
-                            caseAttachMapper.batchSave(caseAttachs);
3169
-                        }
3170
-                        return AjaxResult.success("导入成功");
3171
-                    }
3172
-
3173
-
3174
-            } else {
3175
-                // 没有找到符合条件的文件
3176
-                return AjaxResult.error("未找到符合条件的文件");
3177
-            }
3178
-        } else {
3089
+        if (!unzipSuccess) {
3179 3090
             // 解压失败
3180 3091
             return AjaxResult.error("解压失败");
3181 3092
         }
3182
-        return null;
3093
+        // 查询抓取规则
3094
+        // todo 批次需要再上传压缩包时用户填写
3095
+        List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId(templateId);
3096
+        if (CollectionUtil.isEmpty(fatchRuleList)) {
3097
+            return error("未设置抓取规则");
3098
+        }
3099
+        File directory = new File(targetPath);
3100
+        Map<String, String> andConvertPDF = findAndConvertPDF(directory, fatchRuleList);
3101
+        if (andConvertPDF == null || andConvertPDF.size() <= 0) {
3102
+            // 解压失败
3103
+            return AjaxResult.error("未获取到文件");
3104
+        }
3105
+        Map<String, String> fatchMap = new HashMap<>();
3106
+        if (CollectionUtil.isNotEmpty(fatchRuleList)) {
3107
+            Map<String, List<FatchRule>> fatchRuleMap = fatchRuleList.stream().collect(Collectors.groupingBy(FatchRule::getFileName));
3108
+            // 根据抓取规则循环抓取
3109
+            for (Map.Entry<String, List<FatchRule>> entry : fatchRuleMap.entrySet()) {
3110
+                getFatchContent(andConvertPDF, entry.getKey(), fatchMap, entry.getValue());
3111
+            }
3112
+        }
3113
+        if (fatchMap.size() <= 0) {
3114
+            return error("从压缩包中未抓取到内容,请检查抓取字段配置");
3115
+        }
3116
+        // 组装案件内置字段主表内容
3117
+        CaseApplication caseApplication = new CaseApplication();
3118
+        caseApplication.setTemplateId(templateId);
3119
+        //默认案件标的 todo 案件标的是什么,默认写死
3120
+        caseApplication.setCaseSubjectAmount(new BigDecimal(100000));
3121
+        //  从抓取规则表取字段和字典表取基本字段,字典表的字段名塞到基本表,is_default=1自定义字段塞到columnValue
3122
+        // 抓取规则,0-内置字段,1-自定义字段
3123
+        Map<Integer, List<FatchRule>> fatchRuleMap = fatchRuleList.stream().collect(Collectors.groupingBy(FatchRule::getIsDefault));
3124
+        // 自定义字段,组装columnValue表
3125
+        List<ColumnValue> columnValueList = new ArrayList<>();
3126
+        if (fatchRuleMap.size() > 0 && fatchRuleMap.containsKey(1)) {
3127
+            List<FatchRule> columnRules = fatchRuleMap.get(1);
3128
+            columnRules.forEach(columnRule -> {
3129
+                ColumnValue columnValue = new ColumnValue();
3130
+                columnValue.setColumn(columnRule.getColumn());
3131
+                columnValue.setName(columnRule.getColumnName());
3132
+                columnValue.setValue(fatchMap.get(columnRule.getColumnName()));
3133
+                columnValue.setIsDefault(1);
3134
+                columnValueList.add(columnValue);
3135
+            });
3136
+        }
3137
+        // 在系统表中查询案件内置字段
3138
+        SysDictData sysDictData = new SysDictData();
3139
+        sysDictData.setDictType("case_built_type");
3140
+        List<SysDictData> dictDataList = dictDataMapper.selectDictDataList(sysDictData);
3141
+        // 组装内置字段
3142
+        buildDefaultColumn(caseApplication, dictDataList, fatchMap);
3143
+        // 设置批号
3144
+        if (StrUtil.isEmpty(caseApplication.getBatchNumber())) {
3145
+            Integer maxBatchNumber = caseApplicationMapper.selectBatchNumberLike();
3146
+            if (maxBatchNumber == null) {
3147
+                caseApplication.setBatchNumber("1");
3148
+            } else {
3149
+                caseApplication.setBatchNumber(maxBatchNumber + 1 + "");
3150
+            }
3151
+        }
3152
+        List<CaseAttach> caseAttachs = new ArrayList<>();
3153
+        for (Map.Entry<String, String> entry : andConvertPDF.entrySet()) {
3154
+            String fileUrl = entry.getValue();
3155
+            if(StrUtil.isEmpty(fileUrl)){
3156
+                continue;
3157
+            }
3158
+            // 上传
3159
+            String filePath = RuoYiConfig.getUploadPath();
3160
+
3161
+            CaseAttach caseAttach = new CaseAttach();
3162
+            caseAttach.setCaseAppliId(caseApplication.getId());
3163
+            caseAttach.setAnnexPath(filePath);
3164
+            if (StrUtil.isNotEmpty(fileUrl)) {
3165
+                String fileName = fileUrl.replace(filePath, "/profile/upload");
3166
+                caseAttach.setAnnexName(fileName);
3167
+            }
3168
+            // 申请人提供的证据材料
3169
+            caseAttach.setAnnexType(2);
3170
+            caseAttachs.add(caseAttach);
3171
+            if(fileUrl.contains("仲裁申请书")){
3172
+                CaseAttach applyFile = new CaseAttach();
3173
+                BeanUtil.copyProperties(caseAttach,applyFile);
3174
+                applyFile.setAnnexType(1);
3175
+                caseAttachs.add(applyFile);
3176
+            }
3177
+
3178
+        }
3179
+        caseApplication.setCaseAttachList(caseAttachs);
3180
+        // 案件压缩包导入
3181
+        caseApplication.setImportFlag(2);
3182
+        // 新增案件基本信息表
3183
+        this.insertcaseApplication(caseApplication, columnValueList);
3184
+
3185
+        return AjaxResult.success("导入成功");
3186
+
3183 3187
     }
3184 3188
 
3189
+
3185 3190
     /**
3186 3191
      * 组装内置字段
3187 3192
      * @param caseApplication  案件信息
@@ -3224,12 +3229,13 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3224 3229
             }
3225 3230
 
3226 3231
         }
3227
-        if(ObjectUtil.isNotEmpty(debtorAffiliate)){
3228
-            caseAffiliates.add(debtorAffiliate);
3229
-        }
3230 3232
         if(ObjectUtil.isNotEmpty(affiliate)){
3231 3233
             caseAffiliates.add(affiliate);
3232 3234
         }
3235
+        if(ObjectUtil.isNotEmpty(debtorAffiliate)){
3236
+            caseAffiliates.add(debtorAffiliate);
3237
+        }
3238
+
3233 3239
         caseApplication.setCaseAffiliates(caseAffiliates);
3234 3240
 
3235 3241
     }
@@ -3468,50 +3474,52 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3468 3474
         }
3469 3475
     }
3470 3476
 
3471
-    private boolean OCRAndBuildInfo( Map<String, String> andConvertPDF,String mapKey,  Map<String, String> map, List<FatchRule> fatchRules) {
3472
-        String pdfUrl = andConvertPDF.get(mapKey);
3473
-
3474
-        if(StrUtil.isNotEmpty(pdfUrl)) {
3475
-            if(pdfUrl.endsWith("txt")){
3476
-                String readerFile = readerTxtFile(pdfUrl);
3477
-                if(StrUtil.isNotEmpty(readerFile)){
3478
-                    OCRUtils.fatchRuleGetContent(readerFile, fatchRules,map);
3479
-                }
3480
-
3481
-            }else if(pdfUrl.endsWith("doc")||pdfUrl.endsWith("docx")){
3482
-                // doc,docx,text识别内容
3483
-                String readerFile = null;
3484
-                try {
3485
-                    readerFile = readWord(pdfUrl);
3486
-                } catch (Exception e) {
3487
-                    e.printStackTrace();
3488
-                }
3489
-                if(StrUtil.isNotEmpty(readerFile)){
3490
-                    OCRUtils.fatchRuleGetContent(readerFile, fatchRules,map);
3491
-                }
3477
+    /**
3478
+     * 获取抓取内容
3479
+     * @param andConvertPDF 文件路径map
3480
+     * @param mapKey 文件名
3481
+     * @param map 抓取内容map
3482
+     * @param fatchRules 抓取规则
3483
+     */
3484
+    private void getFatchContent(Map<String, String> andConvertPDF, String mapKey, Map<String, String> map, List<FatchRule> fatchRules) {
3485
+        String fileURL = andConvertPDF.get(mapKey);
3486
+        if (StrUtil.isEmpty(fileURL)) {
3487
+            return;
3488
+        }
3489
+        if (fileURL.endsWith("txt")) {
3490
+            String readerFile = readerTxtFile(fileURL);
3491
+            OCRUtils.fatchRuleGetContent(readerFile, fatchRules, map);
3492
+        } else if (fileURL.endsWith("doc") || fileURL.endsWith("docx")) {
3493
+            // doc,docx,text识别内容
3494
+            String readerFile = null;
3495
+            try {
3496
+                readerFile = readWord(fileURL);
3497
+            } catch (Exception e) {
3498
+                e.printStackTrace();
3499
+            }
3500
+            OCRUtils.fatchRuleGetContent(readerFile, fatchRules, map);
3492 3501
 
3493
-            }else if(pdfUrl.endsWith("pdf")){
3494
-                //获取文件的页数
3495
-                int fileNumPage = getFileNumPage(pdfUrl);
3496
-                //文件转成base64
3497
-                String base64 = OCRUtils.pdfConvertBase64(pdfUrl);
3498
-                if (base64 == null) {
3499
-                    throw new ServiceException("pdf转base64失败");
3500
-                    //  return false;
3501
-                }
3502
-                StringBuilder ocrText = new StringBuilder(); // 创建一个StringBuilder对象
3503
-                for (int i = 1; i <= fileNumPage; i++) {
3504
-                    //对接腾讯云接口.识别里面的数据
3505
-                    String text = OCRUtils.pdfIdentifyText(base64, i, fatchRules);
3506
-                    ocrText.append(text); // 拼接当前的字符串
3507
-                    if(StrUtil.isNotEmpty(ocrText)){
3508
-                        OCRUtils.fatchRuleGetContent(ocrText.toString(), fatchRules,map);
3509
-                    }
3510
-                }
3502
+        } else if (fileURL.endsWith("pdf")) {
3503
+            //获取文件的页数
3504
+            int fileNumPage = getFileNumPage(fileURL);
3505
+            //文件转成base64
3506
+            String base64 = OCRUtils.pdfConvertBase64(fileURL);
3507
+            if (base64 == null) {
3508
+                throw new ServiceException("pdf转base64失败");
3509
+                //  return false;
3511 3510
             }
3511
+            StringBuilder ocrText = new StringBuilder(); // 创建一个StringBuilder对象
3512
+            for (int i = 1; i <= fileNumPage; i++) {
3513
+                //对接腾讯云接口.识别里面的数据
3514
+                String text = OCRUtils.pdfIdentifyText(base64, i, fatchRules);
3515
+                ocrText.append(text); // 拼接当前的字符串
3516
+                // 根据抓取规则截取内容
3517
+                OCRUtils.fatchRuleGetContent(ocrText.toString(), fatchRules, map);
3512 3518
 
3519
+            }
3513 3520
         }
3514
-        return true;
3521
+
3522
+
3515 3523
     }
3516 3524
 
3517 3525
     /**

+ 39
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java Dosyayı Görüntüle

@@ -1,5 +1,7 @@
1 1
 package com.ruoyi.wisdomarbitrate.service.impl;
2 2
 
3
+import cn.hutool.core.collection.CollectionUtil;
4
+import cn.hutool.core.util.StrUtil;
3 5
 import com.alibaba.fastjson.JSONObject;
4 6
 import com.github.pagehelper.PageHelper;
5 7
 import com.github.pagehelper.PageInfo;
@@ -10,6 +12,7 @@ import com.ruoyi.common.constant.FileTransformation;
10 12
 import com.ruoyi.common.core.domain.AjaxResult;
11 13
 import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
12 14
 import com.ruoyi.common.core.domain.entity.SysDept;
15
+import com.ruoyi.common.core.domain.entity.SysDictData;
13 16
 import com.ruoyi.common.core.domain.entity.SysUser;
14 17
 import com.ruoyi.common.exception.EsignDemoException;
15 18
 import com.ruoyi.common.exception.ServiceException;
@@ -17,6 +20,7 @@ import com.ruoyi.common.utils.SealUtil;
17 20
 import com.ruoyi.common.utils.file.FileUploadUtils;
18 21
 import com.ruoyi.system.domain.SysUserPost;
19 22
 import com.ruoyi.system.mapper.SysDeptMapper;
23
+import com.ruoyi.system.mapper.SysDictDataMapper;
20 24
 import com.ruoyi.system.mapper.SysUserMapper;
21 25
 import com.ruoyi.system.mapper.SysUserPostMapper;
22 26
 import com.ruoyi.wisdomarbitrate.domain.*;
@@ -63,6 +67,8 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
63 67
     private TemplateFatchRuleMapper templateFatchRuleMapper;
64 68
     @Autowired
65 69
     private  FatchRuleMapper fatchRuleMapper;
70
+    @Autowired
71
+    private SysDictDataMapper dictDataMapper;
66 72
 
67 73
 
68 74
     @Override
@@ -603,6 +609,39 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
603 609
         return fatchRulesel;
604 610
     }
605 611
 
612
+    /**
613
+     * 根据模板id查询模板字段列表
614
+     * @param templateManage
615
+     * @return
616
+     */
617
+    @Override
618
+    public List<FatchRule> getTemplateInfoById(TemplateManage templateManage) {
619
+        FatchRule fatchRule = new FatchRule();
620
+        fatchRule.setTemplateId(templateManage.getId());
621
+        List<FatchRule> fatchRuleList = fatchRuleMapper.selectFatchRuleList(fatchRule);
622
+        if(CollectionUtil.isEmpty(fatchRuleList)){
623
+            fatchRuleList=new ArrayList<>();
624
+        }
625
+        List<String> columnNameList = fatchRuleList.stream().map(FatchRule::getColumnName).collect(Collectors.toList());
626
+        // 在系统表中查询案件内置字段
627
+        SysDictData sysDictData = new SysDictData();
628
+        sysDictData.setDictType("case_built_type");
629
+        List<SysDictData> dictDataList = dictDataMapper.selectDictDataList(sysDictData);
630
+        if(CollectionUtil.isNotEmpty(dictDataList)){
631
+            for (SysDictData dictData : dictDataList) {
632
+                if(StrUtil.isEmpty(dictData.getDictLabel())||columnNameList.contains(dictData.getDictLabel())){
633
+                    continue;
634
+                }
635
+                FatchRule rule=new FatchRule();
636
+                rule.setColumn(dictData.getDictValue());
637
+                rule.setColumnName(dictData.getDictLabel());
638
+                fatchRuleList.add(rule);
639
+            }
640
+        }
641
+
642
+        return fatchRuleList;
643
+    }
644
+
606 645
     private String getFileExtension(String fileName) {
607 646
         int lastDotIndex = fileName.lastIndexOf(".");
608 647
         if (lastDotIndex > 0 && lastDotIndex < fileName.length() - 1) {

+ 136
- 239
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/OCRUtils.java Dosyayı Görüntüle

@@ -86,112 +86,8 @@ public class OCRUtils {
86 86
             return respStr.toString().substring(0, lastIndexOf);
87 87
         }
88 88
         return respStr.toString();
89
-
90
-
91
-//
92
-//            //解析数据
93
-//            String s = GeneralAccurateOCRResponse.toJsonString(resp);
94
-//            // 解析JSON数据
95
-//            JSONObject jsonObject = new JSONObject(s);
96
-//            JSONArray structuralList = jsonObject.getJSONArray("TextDetections");
97
-//            // 遍历StructuralList中的Groups,获取Key对应的AutoName和Value对应的AutoConten
98
-//            StringBuilder stringBuilder = new StringBuilder(); // 创建一个StringBuilder对象
99
-//            for (int i = 0; i < structuralList.length(); i++) {
100
-//                JSONArray groups = structuralList.getJSONObject(i).getJSONArray("Groups");
101
-//                for (int j = 0; j < groups.length(); j++) {
102
-//                    JSONArray lines = groups.getJSONObject(j).getJSONArray("Lines");
103
-//                    for (int k = 0; k < lines.length(); k++) {
104
-//                        JSONObject line = lines.getJSONObject(k);
105
-//                        JSONObject key = line.getJSONObject("Key");
106
-//                        JSONObject value = line.getJSONObject("Value");
107
-//                        String autoName = key.getString("AutoName");
108
-//                        String autoContent = value.getString("AutoContent");
109
-//                        String text = autoName + Constants.PDFSTR + autoContent;
110
-//                        if (stringBuilder.length() > 0) {
111
-//                            stringBuilder.append(Constants.BR); // 在已有内容的情况下添加逗号分隔符
112
-//                        }
113
-//                        stringBuilder.append(text); // 拼接当前的字符串
114
-//                    }
115
-//                }
116
-//            }
117
-//            return stringBuilder.toString(); // 获取最终的拼接结果
118
-//        } catch (TencentCloudSDKException e) {
119
-//            System.out.println(e.toString());
120
-//        }
121 89
     }
122 90
 
123
-    /**
124
-     * pdf识别成文字
125
-     *
126
-     * @param imageBase64
127
-     * @param pageNumber
128
-     * @param type        pdf类型
129
-     * @return
130
-     */
131
-    public static String pdfIdentifyText1(String imageBase64, Integer pageNumber, String type) {
132
-        try {
133
-            // 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
134
-            // 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
135
-            // 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
136
-            Credential cred = new Credential(SECRET_ID, SECRET_KEY);
137
-            // 实例化一个http选项,可选的,没有特殊需求可以跳过
138
-            HttpProfile httpProfile = new HttpProfile();
139
-            httpProfile.setEndpoint("ocr.tencentcloudapi.com");
140
-            // 实例化一个client选项,可选的,没有特殊需求可以跳过
141
-            ClientProfile clientProfile = new ClientProfile();
142
-            clientProfile.setHttpProfile(httpProfile);
143
-            // 实例化要请求产品的client对象,clientProfile是可选的
144
-            OcrClient client = new OcrClient(cred, "ap-beijing", clientProfile);
145
-            // 实例化一个请求对象,每个接口都会对应一个request对象
146
-            SmartStructuralOCRV2Request req = new SmartStructuralOCRV2Request();
147
-            req.setImageBase64(imageBase64);
148
-            req.setIsPdf(true);
149
-            req.setPdfPageNumber(pageNumber.longValue());
150
-            if (type.contains("申请书")) {
151
-                req.setItemNames(applicantName);
152
-            } else if (type.contains("调解协议")) {
153
-                req.setItemNames(accordName);
154
-            } else if (type.contains("合同")) {
155
-                req.setItemNames(contractName);
156
-            } else if (type.contains("授权委托书")) {
157
-                req.setItemNames(powerAttorneyName);
158
-            }
159
-
160
-            // 返回的resp是一个SmartStructuralOCRV2Response的实例,与请求对象对应
161
-            SmartStructuralOCRV2Response resp = client.SmartStructuralOCRV2(req);
162
-            // 输出json格式的字符串回包
163
-            System.out.println(SmartStructuralOCRV2Response.toJsonString(resp));
164
-            //解析数据
165
-            String s = SmartStructuralOCRV2Response.toJsonString(resp);
166
-            // 解析JSON数据
167
-            JSONObject jsonObject = new JSONObject(s);
168
-            JSONArray structuralList = jsonObject.getJSONArray("StructuralList");
169
-            // 遍历StructuralList中的Groups,获取Key对应的AutoName和Value对应的AutoConten
170
-            StringBuilder stringBuilder = new StringBuilder(); // 创建一个StringBuilder对象
171
-            for (int i = 0; i < structuralList.length(); i++) {
172
-                JSONArray groups = structuralList.getJSONObject(i).getJSONArray("Groups");
173
-                for (int j = 0; j < groups.length(); j++) {
174
-                    JSONArray lines = groups.getJSONObject(j).getJSONArray("Lines");
175
-                    for (int k = 0; k < lines.length(); k++) {
176
-                        JSONObject line = lines.getJSONObject(k);
177
-                        JSONObject key = line.getJSONObject("Key");
178
-                        JSONObject value = line.getJSONObject("Value");
179
-                        String autoName = key.getString("AutoName");
180
-                        String autoContent = value.getString("AutoContent");
181
-                        String text = autoName + Constants.PDFSTR + autoContent;
182
-                        if (stringBuilder.length() > 0) {
183
-                            stringBuilder.append(Constants.BR); // 在已有内容的情况下添加逗号分隔符
184
-                        }
185
-                        stringBuilder.append(text); // 拼接当前的字符串
186
-                    }
187
-                }
188
-            }
189
-            return stringBuilder.toString(); // 获取最终的拼接结果
190
-        } catch (TencentCloudSDKException e) {
191
-            System.out.println(e.toString());
192
-        }
193
-        return null;
194
-    }
195 91
 
196 92
     public static String pdfConvertBase64(String pathUrl) {
197 93
         try {
@@ -216,91 +112,100 @@ public class OCRUtils {
216 112
      * @return
217 113
      */
218 114
     public static void fatchRuleGetContent(String ocrText, List<FatchRule> fatchRules, Map<String, String> fatchMap) {
219
-        String text = ocrText;
220
-        if (CollectionUtil.isNotEmpty(fatchRules)) {
115
+        if (StrUtil.isEmpty(ocrText) || CollectionUtil.isEmpty(fatchRules)) {
116
+            return;
117
+        }
118
+        for (FatchRule fatchRule : fatchRules) {
119
+            // 从后往前抓取
120
+            if (fatchRule.getFatchOrder() != null && fatchRule.getFatchOrder() == 1) {
121
+                reverseSubstringText(ocrText, fatchRule, fatchMap);
122
+            } else {
123
+                // 从前往后抓取
124
+                substringText(ocrText, fatchRule, fatchMap);
221 125
 
222
-            for (FatchRule fatchRule : fatchRules) {
223
-                // 从后往前抓取
224
-                if (fatchRule.getFatchOrder() != null && fatchRule.getFatchOrder() == 1) {
225
-                    String reverseText = StrUtil.reverse(ocrText);
226
-                    if (StrUtil.isEmpty(fatchRule.getStartContent()) && StrUtil.isEmpty(fatchRule.getEndContent())) {
227
-                        fatchMap.put(fatchRule.getColumnName(), trimStr(text));
228
-                    } else if(StrUtil.isEmpty(fatchRule.getStartContent())&&StrUtil.isNotEmpty(fatchRule.getEndContent())) {
229
-                        // 开始字段为空,结束字段不为空
230
-                        String endReverseText = StrUtil.reverse(fatchRule.getEndContent());
231
-                        int endContIndex = StrUtil.ordinalIndexOf(reverseText, endReverseText, fatchRule.getEndContentRepeatOrder());
232
-                        if (endContIndex != -1) {
233
-                            String substring = text.substring(0, endContIndex);
234
-                            fatchMap.put(fatchRule.getColumnName(), trimStr(StrUtil.reverse(substring)));
235
-                        }
236
-                    }
237
-//
238
-//
239
-//                    }else if(StrUtil.isNotEmpty(fatchRule.getStartContent())&&StrUtil.isEmpty(fatchRule.getEndContent())){
240
-//                        // 开始字段不为空,结束字段为空
241
-//                        // 开始字段为空,结束字段不为空
242
-//                        String startReverseText = StrUtil.reverse(fatchRule.getStartContent());
243
-//                        int startContIndex = StrUtil.ordinalIndexOf(reverseText, startReverseText, fatchRule.getStartContentRepeatOrder());
244
-//                        if (startContIndex != -1) {
245
-//                            String substring = text.substring(0, startContIndex);
246
-//                            fatchMap.put(fatchRule.getColumnName(), trimStr(StrUtil.reverse(substring)));
247
-//                        }
248
-//
249
-//                    }else if(StrUtil.isNotEmpty(fatchRule.getStartContent())&&StrUtil.isNotEmpty(fatchRule.getEndContent())){
250
-//                        String startReverseText = StrUtil.reverse(fatchRule.getStartContent());
251
-//                        String endReverseText = StrUtil.reverse(fatchRule.getEndContent());
252
-//                        int startContIndex = StrUtil.ordinalIndexOf(reverseText, startReverseText, fatchRule.getStartContentRepeatOrder());
253
-//                        if (startContIndex != -1) {
254
-//                        // 结束字段不为空
255
-//                        int endContIndex = StrUtil.ordinalIndexOf(reverseText, endReverseText, fatchRule.getEndContentRepeatOrder());
256
-//                        if (endContIndex != -1 && (startContIndex + fatchRule.getStartContent().length()) <= text.length()) {
257
-//                            String substring = text.substring(startContIndex + fatchRule.getStartContent().length(), endContIndex);
258
-//                            // 去除\n
259
-//                            fatchMap.put(fatchRule.getColumnName(),trimStr(StrUtil.reverse(substring)));
260
-//                        }
261
-//                        }
262
-//                    }
263
-                } else {
264
-                    // 开始为空结束为空
265
-                    if (StrUtil.isEmpty(fatchRule.getStartContent()) && StrUtil.isEmpty(fatchRule.getEndContent())) {
266
-                        fatchMap.put(fatchRule.getColumnName(), trimStr(text));
267
-                    } else if (StrUtil.isNotEmpty(fatchRule.getStartContent())) {
268
-                        int startContIndex = StrUtil.ordinalIndexOf(text, fatchRule.getStartContent(), fatchRule.getStartContentRepeatOrder());
269
-                        if (startContIndex != -1) {
270
-                            // 开始不为空结束为空
271
-                            if (StrUtil.isEmpty(fatchRule.getEndContent())) {
272
-                                if ((startContIndex + fatchRule.getStartContent().length()) <= text.length()) {
273
-                                    String substring = text.substring(startContIndex + fatchRule.getStartContent().length());
274
-                                    // 去除\n
275
-                                    fatchMap.put(fatchRule.getColumnName(), trimStr(substring));
276
-                                }
126
+            }
127
+        }
277 128
 
278
-                            } else {
279
-                                // 开始不为空结束不为空
280
-                                int endContIndex = StrUtil.ordinalIndexOf(text, fatchRule.getEndContent(), fatchRule.getEndContentRepeatOrder());
281
-                                if (endContIndex != -1 && (startContIndex + fatchRule.getStartContent().length()) <= text.length()&&(startContIndex + fatchRule.getStartContent().length())<=endContIndex ) {
282
-                                    String substring = text.substring(startContIndex + fatchRule.getStartContent().length(), endContIndex);
283
-                                    // 去除\n
284
-                                    fatchMap.put(fatchRule.getColumnName(), trimStr(substring));
285
-                                }
286 129
 
287
-                            }
288
-//
289
-                        }
130
+    }
131
+
132
+    public static void sub1(String text, FatchRule fatchRule, Map<String, String> fatchMap) {
133
+        if (StrUtil.isEmpty(fatchRule.getStartContent()) && StrUtil.isEmpty(fatchRule.getEndContent())) {
134
+            fatchMap.put(fatchRule.getColumnName(), trimStr(text));
135
+        } else if (StrUtil.isNotEmpty(fatchRule.getStartContent())) {
136
+            int startContIndex = StrUtil.ordinalIndexOf(text, fatchRule.getStartContent(), fatchRule.getStartContentRepeatOrder());
137
+            if (startContIndex != -1) {
138
+                // 开始不为空结束为空
139
+                if (StrUtil.isEmpty(fatchRule.getEndContent())) {
140
+                    if ((startContIndex + fatchRule.getStartContent().length()) <= text.length()) {
141
+                        String substring = text.substring(startContIndex + fatchRule.getStartContent().length());
142
+                        // 去除\n
143
+                        fatchMap.put(fatchRule.getColumnName(), trimStr(substring));
144
+                    }
290 145
 
291
-                    } else if (StrUtil.isEmpty(fatchRule.getStartContent()) && StrUtil.isNotEmpty(fatchRule.getEndContent())) {
292
-                        // 开始为空结束不为空
293
-                        int endContIndex = StrUtil.ordinalIndexOf(text, fatchRule.getEndContent(), fatchRule.getEndContentRepeatOrder());
294
-                        if (endContIndex != -1) {
295
-                            String substring = text.substring(0, endContIndex);
296
-                            fatchMap.put(fatchRule.getColumnName(), trimStr(substring));
297
-                        }
146
+                } else {
147
+                    // 开始不为空结束不为空
148
+                    int endContIndex = StrUtil.ordinalIndexOf(text, fatchRule.getEndContent(), fatchRule.getEndContentRepeatOrder());
149
+                    if (endContIndex != -1 && endContIndex <= text.length() && (startContIndex + fatchRule.getStartContent().length()) <= endContIndex) {
150
+                        String substring = text.substring(startContIndex + fatchRule.getStartContent().length(), endContIndex);
151
+                        // 去除\n
152
+                        fatchMap.put(fatchRule.getColumnName(), trimStr(substring));
298 153
                     }
154
+
299 155
                 }
156
+//
157
+            }
158
+
159
+        } else if (StrUtil.isEmpty(fatchRule.getStartContent()) && StrUtil.isNotEmpty(fatchRule.getEndContent())) {
160
+            // 开始为空结束不为空
161
+            int endContIndex = StrUtil.ordinalIndexOf(text, fatchRule.getEndContent(), fatchRule.getEndContentRepeatOrder());
162
+            if (endContIndex != -1) {
163
+                String substring = text.substring(0, endContIndex);
164
+                fatchMap.put(fatchRule.getColumnName(), trimStr(substring));
300 165
             }
301 166
         }
167
+    }
302 168
 
169
+    /**
170
+     * 正向截取字段
171
+     *
172
+     * @param text
173
+     * @param fatchRule
174
+     * @param fatchMap
175
+     */
176
+    private static void substringText(String text, FatchRule fatchRule, Map<String, String> fatchMap) {
177
+        String startContent = fatchRule.getStartContent();
178
+        String endContent = fatchRule.getEndContent();
179
+        // 开始为空结束为空
180
+        if (StrUtil.isEmpty(startContent) && StrUtil.isEmpty(endContent)) {
181
+            fatchMap.put(fatchRule.getColumnName(), trimStr(text));
182
+        } else if (StrUtil.isNotEmpty(startContent) && StrUtil.isEmpty(endContent)) {
183
+            // 开始不为空结束为空
184
+            int startContIndex = StrUtil.ordinalIndexOf(text, startContent, fatchRule.getStartContentRepeatOrder());
185
+            if (startContIndex != -1 && text.length() >= (startContIndex + startContent.length())) {
186
+                String substring = text.substring(startContIndex + startContent.length());
187
+                // 去除\n
188
+                fatchMap.put(fatchRule.getColumnName(), trimStr(substring));
189
+            }
303 190
 
191
+        } else if (StrUtil.isEmpty(startContent) && StrUtil.isNotEmpty(endContent)) {
192
+            // 开始为空结束不为空
193
+            int endContIndex = StrUtil.ordinalIndexOf(text, endContent, fatchRule.getEndContentRepeatOrder());
194
+            if (endContIndex != -1) {
195
+                String substring = text.substring(0, endContIndex);
196
+                fatchMap.put(fatchRule.getColumnName(), trimStr(substring));
197
+            }
198
+        } else if (StrUtil.isNotEmpty(startContent) && StrUtil.isNotEmpty(endContent)) {
199
+            // 开始结束不为空
200
+            int startIndexOf = StrUtil.ordinalIndexOf(text, startContent, fatchRule.getStartContentRepeatOrder());
201
+            int endIndexOf = StrUtil.ordinalIndexOf(text, endContent, fatchRule.getEndContentRepeatOrder());
202
+            if (startIndexOf != -1 && endIndexOf != -1 && endIndexOf >= (startIndexOf + startContent.length()) && text.length() >= endIndexOf) {
203
+                String substring = text.substring(startIndexOf + startContent.length(), endIndexOf);
204
+
205
+                fatchMap.put(fatchRule.getColumnName(), trimStr(substring));
206
+
207
+            }
208
+        }
304 209
     }
305 210
 
306 211
     /**
@@ -318,71 +223,63 @@ public class OCRUtils {
318 223
 
319 224
     }
320 225
 
321
-    public static void main(String[] args) {
322
-        String text="和 解 协 议\n" +
323
-                "\n" +
324
-                "\n" +
325
-                "甲方:上海维信荟智金融科技有限公司\n" +
326
-                "地址:上海市虹口区乍浦路89号办公楼1幢2801室\n" +
327
-                "电子邮箱【shaoyijie01@vcredit.com】\n" +
328
-                "\n" +
329
-                "乙方:【马旭】\n" +
330
-                "地址:【重庆市城口县蓼子乡长元路109号】\n" +
331
-                "手机号:【13585580076】\n" +
332
-                "身份证号:【500229198908244338】\n" +
333
-                "电子邮箱:【feiwen@vcredit.com】\n" +
334
-                "\n" +
335
-                "鉴于:\n" +
336
-                "乙方于【2023】年【3】月【1】日至【2023】年【4】月【26】日通过甲方旗下平台申请总计【2】笔贷款,本金合计【18000】元。乙方已于2023年4月31日结清上述2笔贷款。2023年10月6日,乙方称其对上述2笔贷款的担保合同、担保咨询服务合同(个人贷款委托担保合同:DD181b16j22010315099-1、担保服务合同:DD18qe30023020066644-1、担保咨询服务合同:DD18qe30023020066644-7)中约定的担保费、担保服务费不知情,向甲方要求退还上述担保费、担保服务费。甲方认为甲乙双方之间的上述合同真实有效,其中明确约定了上述担保费、担保服务费。双方因此产生纠纷。现甲方出于业务考虑,同意乙方履行保密义务的前提下,甲方给予特殊和解方案;乙方确认其充分知晓并理解本《和解协议》(下称“本协议”)中全部条款的实质含义及其相应的法律后果,并基于此种理解,履行相应义务,签署本协议。本协议于签署当日生效,对甲、乙双方具有同等法律拘束力。\n" +
337
-                "\n" +
338
-                "一、仲裁条款\n" +
339
-                "1、为了确保本协议的充分履行,甲乙双方达成一致:将本协议共同提交上海仲裁委员会予以立案确认其效力并作出裁决。由甲方作为仲裁案件申请人,乙方作为仲裁案件的被申请人。双方同意由甲方承担全部仲裁费。仲裁费以上海仲裁委员会实际出具的缴费通知书为准。双方均同意,上海仲裁委员会受理案件后,可通过电话或邮件的方式告知双方案件已受理的情况,无需再发送其他纸质书面的材料。(包括但不限于仲裁通知书、规则、名册、其他程序性文件以及本案仲裁申请书、证据材料等)。本案仲裁申请书、证据材料双方已经于提起仲裁前确认收到。\n" +
340
-                "\n" +
341
-                "双方同意本案适用快速程序,确认委托上海仲裁委员会主任指定一名仲裁员成立仲裁庭进行书面审理,并依法根据本协议作出裁决书,事实与理由从简。双方均同意放弃相应的答辩、举证等期限权利。双方同意由仲裁庭决定以其认为合适的方式,从简、从速处理本案。\n" +
342
-                "\n" +
343
-                "双方同意上海仲裁委员会通过电子送达方式向双方送达包括裁决书在内的各类仲裁法律文书,裁决书及各类仲裁法律文书发送至双方当事人所确认之电子邮箱的日期即为送达日期。双方确认本协议首部所载电子邮箱、联系地址和联系电话均为有效的送达信息。\n" +
344
-                "\n" +
345
-                "二、甲方郑重承诺\n" +
346
-                "1、甲方是独立线上消费金融服务提供商,合作方均为持牌金融机构。旗下各平台所经营的所有产品均合法合规,不存在任何违法、违规经营情形。\n" +
347
-                "2、甲方出于业务考虑,在乙方履行保密义务的前提下,给予乙方以下方案:【甲方于签署本协议之日起5日内给予乙方1000元补偿金】。\n" +
348
-                "\n" +
349
-                "三、乙方郑重承诺\n" +
350
-                "1、乙方接受甲方在本协议第二条项下所给予的和解方案,并在【3】个工作日内撤销对甲方及在甲方平台办理贷款涉及的所有资金方、担保方和其他相关方(上述公司的关联公司)的一切投诉,再无其他任何异议或主张,包括但不限于诉讼、信访、投诉、媒体平台举报等任何不利于甲方、资金方、担保方和其他相关方的言行或举动等。\n" +
351
-                "2、乙方承诺对本协议承担无限期保密义务,任何情况下不得将本协议内容泄露给任意第三方。\n" +
352
-                "3、若乙方违反上述任一承诺,则构成根本违约,应当退还甲方给予的全部补偿金,并承担违约责任。\n" +
353
-                "\n" +
354
-                "四、违约责任\n" +
355
-                "如果乙方违反本协议第三条项下任一承诺内容,则应当退还甲方给予的全部补偿金【1000】元,并向甲方一次性支付违约金【1000】元,上述金额共计【2000】元。同时,乙方应立即纠正违约行为并采取一切必要手段消除/挽回/弥补甲方因此遭受的损失或影响。\n" +
356
-                "\n" +
357
-                "\n" +
358
-                "\n" +
359
-                "甲方(盖章):                           乙方(签字):\n" +
360
-                "\n" +
361
-                "日期:2023年11月3日                                  日期:\n" +
362
-                "\n";
363
-        String[] split = text.split("日期:");
364
-        int order=1;
365
-        String s1 = spiltRtoL(text);
366
-        String substring = s1.substring(0, StrUtil.ordinalIndexOf(s1, StrUtil.reverse("日期:"), 2) + "日期:".length());
226
+    /**
227
+     * 从后往前截取字符串
228
+     *
229
+     * @param text
230
+     * @param fatchRule
231
+     * @param fatchMap
232
+     */
233
+    public static void reverseSubstringText(String text, FatchRule fatchRule, Map<String, String> fatchMap) {
367 234
 
368
-        if(split.length>0){
369
-            String s = split[split.length - order];
235
+        // 反正字符串
236
+        String reverseText = StrUtil.reverse(text);
237
+        // 结束截取字段
238
+        String reverseEndContent = "";
239
+        // 开始截取字段
240
+        String reverseStartContent = "";
241
+        if (StrUtil.isNotEmpty(fatchRule.getEndContent())) {
242
+            reverseEndContent = StrUtil.reverse(fatchRule.getEndContent());
370 243
         }
371
-
372
-    }
373
-    public static String spiltRtoL(String s) {
374
-
375
-        StringBuffer sb = new StringBuffer();
376
-        int length = s.length();
377
-        char[] c = new char[length];
378
-        for (int i = 0; i < length; i++) {
379
-            c[i] = s.charAt(i);
244
+        if (StrUtil.isNotEmpty(fatchRule.getStartContent())) {
245
+            reverseStartContent = StrUtil.reverse(fatchRule.getStartContent());
380 246
         }
381
-        for (int i = length - 1; i >= 0; i--) {
382
-            sb.append(c[i]);
247
+        // 开始和结束截取都为空
248
+        if (StrUtil.isEmpty(reverseStartContent) && StrUtil.isEmpty(reverseEndContent)) {
249
+            fatchMap.put(fatchRule.getColumnName(), trimStr(text));
250
+        } else if (StrUtil.isEmpty(reverseStartContent) && StrUtil.isNotEmpty(reverseEndContent)) {
251
+            // 开始为空,结束不为空
252
+            // 根据截取的序号查找出位置
253
+            int indexOf = StrUtil.ordinalIndexOf(reverseText, reverseEndContent, fatchRule.getEndContentRepeatOrder());
254
+            if (indexOf != -1) {
255
+                String substring = reverseText.substring(0, indexOf);
256
+                if (StrUtil.isNotEmpty(substring)) {
257
+                    fatchMap.put(fatchRule.getColumnName(), trimStr(StrUtil.reverse(substring)));
258
+                }
259
+            }
260
+        } else if (StrUtil.isNotEmpty(reverseStartContent) && StrUtil.isEmpty(reverseEndContent)) {
261
+            // 开始不为空,结束为空
262
+            int indexOf = StrUtil.ordinalIndexOf(reverseText, reverseStartContent, fatchRule.getStartContentRepeatOrder());
263
+            if (indexOf != -1 && (indexOf + reverseStartContent.length() <= text.length())) {
264
+                String substring = reverseText.substring(indexOf + reverseStartContent.length());
265
+                if (StrUtil.isNotEmpty(substring)) {
266
+                    fatchMap.put(fatchRule.getColumnName(), trimStr(StrUtil.reverse(substring)));
267
+                }
268
+            }
269
+
270
+        } else if (StrUtil.isNotEmpty(reverseStartContent) && StrUtil.isNotEmpty(reverseEndContent)) {
271
+            // 开始结束都不为空
272
+            int endIndexOf = StrUtil.ordinalIndexOf(reverseText, reverseEndContent, fatchRule.getEndContentRepeatOrder());
273
+            int startIndexOf = StrUtil.ordinalIndexOf(reverseText, reverseStartContent, fatchRule.getStartContentRepeatOrder());
274
+            if (startIndexOf != -1 && endIndexOf != -1 && endIndexOf >= (startIndexOf + reverseStartContent.length()) && text.length() >= endIndexOf) {
275
+                String substring = reverseText.substring(startIndexOf + reverseStartContent.length(), endIndexOf);
276
+                if (StrUtil.isNotEmpty(substring)) {
277
+                    fatchMap.put(fatchRule.getColumnName(), trimStr(StrUtil.reverse(substring)));
278
+                }
279
+            }
383 280
         }
384 281
 
385
-        return sb.toString();
282
+
386 283
     }
387 284
 
388 285
 }