|
|
@@ -17,6 +17,7 @@ import com.google.gson.JsonObject;
|
|
17
|
17
|
import com.ruoyi.common.annotation.DataScope;
|
|
18
|
18
|
import com.ruoyi.common.config.RuoYiConfig;
|
|
19
|
19
|
import com.ruoyi.common.constant.CaseApplicationConstants;
|
|
|
20
|
+import com.ruoyi.common.constant.Constants;
|
|
20
|
21
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
21
|
22
|
import com.ruoyi.common.core.domain.entity.*;
|
|
22
|
23
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
|
@@ -66,11 +67,14 @@ import java.math.RoundingMode;
|
|
66
|
67
|
import java.nio.file.Files;
|
|
67
|
68
|
import java.nio.file.Path;
|
|
68
|
69
|
import java.nio.file.StandardCopyOption;
|
|
|
70
|
+import java.text.NumberFormat;
|
|
|
71
|
+import java.text.ParseException;
|
|
69
|
72
|
import java.text.SimpleDateFormat;
|
|
70
|
73
|
import java.time.LocalDate;
|
|
71
|
74
|
import java.time.ZoneId;
|
|
72
|
75
|
import java.util.*;
|
|
73
|
76
|
import java.util.function.Function;
|
|
|
77
|
+import java.util.regex.Matcher;
|
|
74
|
78
|
import java.util.regex.Pattern;
|
|
75
|
79
|
import java.util.stream.Collectors;
|
|
76
|
80
|
import java.util.zip.ZipEntry;
|
|
|
@@ -389,8 +393,9 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
389
|
393
|
if (file.isEmpty()) {
|
|
390
|
394
|
return AjaxResult.error("请选择要上传的文件");
|
|
391
|
395
|
}
|
|
392
|
|
- String targetPath = "/home/ruoyi/uploadPath/upload/unzipFile";
|
|
393
|
|
- // String targetPath = "D:\\home\\unzip\\";
|
|
|
396
|
+ // todo 服务器上要放开
|
|
|
397
|
+// String targetPath = "/home/ruoyi/uploadPath/upload/unzipFile";
|
|
|
398
|
+ String targetPath = "D:/zip";
|
|
394
|
399
|
File zipFile = null;
|
|
395
|
400
|
InputStream ins = null;
|
|
396
|
401
|
try {
|
|
|
@@ -407,7 +412,9 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
407
|
412
|
String zipName = file.getOriginalFilename();
|
|
408
|
413
|
String subzipName = zipName.substring(0, zipName.indexOf(".zip"));
|
|
409
|
414
|
// String zipPath = "F:\\testZip\\uploadPath\\upload\\upload1\\unzipFile\\"+subzipName;
|
|
410
|
|
- String zipPath = "/home/ruoyi/uploadPath/upload/unzipFile/" + subzipName;
|
|
|
415
|
+ // todo 服务器上要放开
|
|
|
416
|
+// String zipPath = "/home/ruoyi/uploadPath/upload/unzipFile/" + subzipName;
|
|
|
417
|
+ String zipPath = "D:/" + subzipName;
|
|
411
|
418
|
|
|
412
|
419
|
File dirUnzipPath = new File(zipPath);
|
|
413
|
420
|
List<File> allFiles = new ArrayList<>();
|
|
|
@@ -1360,7 +1367,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
1360
|
1367
|
public int deletecaseApplicationByIds(List<Long> ids) {
|
|
1361
|
1368
|
int rows = caseApplicationMapper.batchDeletecaseApplication(ids);
|
|
1362
|
1369
|
caseAffiliateMapper.batchDeletecaseAffiliate(ids);
|
|
1363
|
|
- caseApplicationLogMapper.batchDeleteLog(ids);
|
|
|
1370
|
+ // caseApplicationLogMapper.batchDeleteLog(ids);
|
|
1364
|
1371
|
return rows;
|
|
1365
|
1372
|
}
|
|
1366
|
1373
|
|
|
|
@@ -2296,14 +2303,15 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
2296
|
2303
|
if (createBy != null) {
|
|
2297
|
2304
|
arbitrateRecordselect.setCreateBy(createBy);
|
|
2298
|
2305
|
}
|
|
2299
|
|
-
|
|
|
2306
|
+ //
|
|
2300
|
2307
|
CaseApplication caseApplicationupdate = new CaseApplication();
|
|
2301
|
2308
|
caseApplicationupdate.setId(arbitrateRecordselect.getCaseAppliId());
|
|
2302
|
2309
|
caseApplicationupdate.setIsAbsence(arbitrateRecordselect.getIsAbsence());
|
|
2303
|
2310
|
caseApplicationupdate.setAppliIsAbsen(arbitrateRecordselect.getAppliIsAbsen());
|
|
2304
|
|
- caseApplicationupdate.setResponCrossOpin(arbitrateRecordselect.getResponCrossOpin());
|
|
2305
|
|
- caseApplicationupdate.setApplicaCrossOpin(arbitrateRecordselect.getApplicaCrossOpin());
|
|
2306
|
|
- caseApplicationupdate.setResponDefenOpini(arbitrateRecordselect.getResponDefenOpini());
|
|
|
2311
|
+ caseApplicationupdate.setRespondentOpinion(arbitrateRecordselect.getRespondentOpinion());
|
|
|
2312
|
+ caseApplicationupdate.setApplicantOpinion(arbitrateRecordselect.getApplicantOpinion());
|
|
|
2313
|
+ caseApplicationupdate.setCaseFacts(arbitrateRecordselect.getCaseFacts());
|
|
|
2314
|
+ caseApplicationupdate.setCaseFocus(arbitrateRecordselect.getCaseFocus());
|
|
2307
|
2315
|
caseApplicationMapper.submitCaseApplication(caseApplicationupdate);
|
|
2308
|
2316
|
|
|
2309
|
2317
|
//先判断案件是否已经提交过仲裁结果
|
|
|
@@ -2914,15 +2922,17 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
2914
|
2922
|
return AjaxResult.error("请选择要上传的文件");
|
|
2915
|
2923
|
}
|
|
2916
|
2924
|
UUID uuid = UUID.randomUUID();
|
|
2917
|
|
- String targetPath = "/home/ruoyi/uploadPath/upload/unzipFile/"+uuid+ "/";
|
|
2918
|
|
- //String targetPath = "D:/home/unzip/" + uuid + "/";
|
|
|
2925
|
+ // todo 服务器上要放开
|
|
|
2926
|
+// String targetPath = "/home/ruoyi/uploadPath/upload/unzipFile/"+uuid+ "/";
|
|
|
2927
|
+ String targetPath = "D:/zip";
|
|
2919
|
2928
|
File zipFile = null;
|
|
2920
|
2929
|
InputStream ins = null;
|
|
2921
|
2930
|
try {
|
|
2922
|
2931
|
ins = file.getInputStream();
|
|
2923
|
2932
|
//上传的压缩包保存的路径
|
|
2924
|
|
- String savePath = "/home/ruoyi/uploadPath/upload/zipFile/";
|
|
2925
|
|
- //String savePath = "D:/home/zipFile/";
|
|
|
2933
|
+ // todo 服务器上要放开
|
|
|
2934
|
+// String savePath = "/home/ruoyi/uploadPath/upload/zipFile/";
|
|
|
2935
|
+ String savePath = "D:/zip/";
|
|
2926
|
2936
|
String saveName = uuid + "_" + file.getOriginalFilename();
|
|
2927
|
2937
|
zipFile = new File(savePath + saveName);
|
|
2928
|
2938
|
inputChangeToFile(ins, zipFile);
|
|
|
@@ -2933,96 +2943,204 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
2933
|
2943
|
boolean unzipSuccess = UnZipFileUtils.unZipFile(zipFile, targetPath);
|
|
2934
|
2944
|
if (unzipSuccess) {
|
|
2935
|
2945
|
File directory = new File(targetPath);
|
|
2936
|
|
- List<String> andConvertPDF = findAndConvertPDF(directory);
|
|
|
2946
|
+ Map<String,String> andConvertPDF = findAndConvertPDF(directory);
|
|
2937
|
2947
|
if (andConvertPDF != null && andConvertPDF.size() > 0) {
|
|
2938
|
|
- //遍历路径
|
|
2939
|
|
- for (String pdfUrl : andConvertPDF) {
|
|
2940
|
|
- //获取文件的页数
|
|
2941
|
|
- System.out.println("这是查到的符合条件的文件路径====="+pdfUrl);
|
|
2942
|
|
- int fileNumPage = getFileNumPage(pdfUrl);
|
|
2943
|
|
- //文件转成base64
|
|
2944
|
|
- String base64 = OCRUtils.pdfConvertBase64(pdfUrl);
|
|
2945
|
|
- if (base64 == null){
|
|
|
2948
|
+ Map<String, List<String>> map = new HashMap<>();
|
|
|
2949
|
+ // oc识别pdf并组装数据
|
|
|
2950
|
+ // 抓取申请书
|
|
|
2951
|
+ if(!OCRAndBuildInfo(andConvertPDF, "仲裁申请书", map)){
|
|
2946
|
2952
|
return AjaxResult.error("文件转base64编码有误,请检查");
|
|
2947
|
2953
|
}
|
|
2948
|
|
- StringBuilder stringBuilder = new StringBuilder(); // 创建一个StringBuilder对象
|
|
2949
|
|
- for (int i = 0; i < fileNumPage; i++) {
|
|
2950
|
|
- //对接腾讯云接口.识别里面的数据
|
|
2951
|
|
- String text = OCRUtils.pdfIdentifyText(base64, i + 1);
|
|
2952
|
|
- if (stringBuilder.length() > 0) {
|
|
2953
|
|
- stringBuilder.append(","); // 在已有内容的情况下添加逗号分隔符
|
|
2954
|
|
- }
|
|
2955
|
|
- stringBuilder.append(text); // 拼接当前的字符串
|
|
2956
|
|
- }
|
|
2957
|
|
- // 将字符串按逗号分隔符切割
|
|
2958
|
|
- String[] fields = stringBuilder.toString().split(",");
|
|
2959
|
|
- Map<String, List<String>> map = new HashMap<>();
|
|
2960
|
|
- for (String field : fields) {
|
|
2961
|
|
- // 对于每个字段,再按冒号分隔符拆分出键和值
|
|
2962
|
|
- String[] keyValue = field.split(":");
|
|
2963
|
|
- if (keyValue.length >= 2) {
|
|
2964
|
|
- String key = keyValue[0];
|
|
2965
|
|
- String value = keyValue[1];
|
|
2966
|
|
- // 判断Map中是否已存在该键
|
|
2967
|
|
- if (map.containsKey(key)) {
|
|
2968
|
|
- // 如果已存在,获取该键对应的值,并将新的值添加到集合中
|
|
2969
|
|
- List<String> values = map.get(key);
|
|
2970
|
|
- values.add(value);
|
|
2971
|
|
- } else {
|
|
2972
|
|
- // 如果不存在,创建一个新的集合,并将值添加到集合中
|
|
2973
|
|
- List<String> values = new ArrayList<>();
|
|
2974
|
|
- values.add(value);
|
|
2975
|
|
- map.put(key, values);
|
|
2976
|
|
- }
|
|
2977
|
|
- }
|
|
2978
|
|
- }
|
|
2979
|
|
- if (map.size()>0){
|
|
|
2954
|
+ // 抓取调节协议书
|
|
|
2955
|
+ if(!OCRAndBuildInfo(andConvertPDF, "调解协议", map)){
|
|
|
2956
|
+ return AjaxResult.error("文件转base64编码有误,请检查");
|
|
|
2957
|
+ }
|
|
|
2958
|
+ // 抓取合同
|
|
|
2959
|
+ if(!OCRAndBuildInfo(andConvertPDF, "合同", map)){
|
|
|
2960
|
+ return AjaxResult.error("文件转base64编码有误,请检查");
|
|
|
2961
|
+ }
|
|
|
2962
|
+ if(!OCRAndBuildInfo(andConvertPDF, "授权委托书", map)){
|
|
|
2963
|
+ return AjaxResult.error("文件转base64编码有误,请检查");
|
|
|
2964
|
+ }
|
|
|
2965
|
+
|
|
|
2966
|
+ if (map.size()>0){
|
|
|
2967
|
+ // todo 从压缩包中识别各字段填充到数据库
|
|
2980
|
2968
|
//调用新增案件的接口
|
|
2981
|
2969
|
CaseApplication caseApplication = new CaseApplication();
|
|
2982
|
|
- //默认案件标的
|
|
|
2970
|
+ //默认案件标的 todo 案件标的是什么
|
|
2983
|
2971
|
caseApplication.setCaseSubjectAmount(new BigDecimal(1));
|
|
2984
|
2972
|
caseApplication.setApplicationOrganId(map.get("统一社会信用代码").get(0));
|
|
2985
|
2973
|
caseApplication.setArbitratClaims(map.get("仲裁请求").get(0));
|
|
|
2974
|
+ caseApplication.setFacts(map.get("事实和理由").get(0));
|
|
|
2975
|
+ String contractNumber = map.get("合同编号").get(0);
|
|
|
2976
|
+ // 提取字母和数字
|
|
|
2977
|
+ String regx="[^a-zA-Z0-9]";
|
|
|
2978
|
+ String replaceAll = contractNumber.replaceAll(regx, "");
|
|
|
2979
|
+
|
|
|
2980
|
+ caseApplication.setContractNumber(replaceAll.toUpperCase());
|
|
|
2981
|
+ String lonStartDate = map.get("或委托代理人签字:").get(0);
|
|
|
2982
|
+ SimpleDateFormat sdf = new SimpleDateFormat();
|
|
|
2983
|
+ sdf.applyPattern("yyyy年MM月dd日");
|
|
|
2984
|
+ try {
|
|
|
2985
|
+ caseApplication.setLoanStartDate( sdf.parse(lonStartDate));
|
|
|
2986
|
+ } catch (ParseException e) {
|
|
|
2987
|
+ e.printStackTrace();
|
|
|
2988
|
+ }
|
|
|
2989
|
+ // todo 查询同一批号的模板
|
|
|
2990
|
+ // 金融消费纠纷基本情况
|
|
|
2991
|
+ String disputes = map.get("金融消费纠纷基本情况").get(0);
|
|
|
2992
|
+ String disputesTemplate="本案当事人甲{1}(下称“甲方”)于{2}向本案当事人乙{3}(下称“乙方”)申请{3}贷款,贷款金额人民币{4}元,贷款期限{5}期。截至{6},甲方尚欠乙方金额总计人民币{7}元。因甲方诉求与乙方进行协商还款。乙方为妥善解决纠纷,故申请调解中心进行调解。";
|
|
|
2993
|
+ List<String> disputeList = getReplaceList(disputesTemplate, disputes);
|
|
|
2994
|
+ if(CollectionUtil.isNotEmpty(disputeList)){
|
|
|
2995
|
+ if(disputeList.size()>3){
|
|
|
2996
|
+ caseApplication.setLoanType(disputeList.get(3));
|
|
|
2997
|
+ }
|
|
|
2998
|
+ if(disputeList.size()>4) {
|
|
|
2999
|
+ String claimPrinciOwed = disputeList.get(4);
|
|
|
3000
|
+ // 金额格式化
|
|
|
3001
|
+ try {
|
|
|
3002
|
+ Double.parseDouble(claimPrinciOwed);
|
|
|
3003
|
+
|
|
|
3004
|
+ caseApplication.setClaimPrinciOwed(new BigDecimal(claimPrinciOwed));
|
|
|
3005
|
+ } catch (NumberFormatException e) {
|
|
|
3006
|
+
|
|
|
3007
|
+ String regEx = "[^0-9]";
|
|
|
3008
|
+ Pattern p = Pattern.compile(regEx);
|
|
|
3009
|
+ Matcher m = p.matcher(claimPrinciOwed);
|
|
|
3010
|
+ String result = m.replaceAll("").trim();
|
|
|
3011
|
+ BigDecimal bigDecimal = null;
|
|
|
3012
|
+ if (claimPrinciOwed.contains("百")) {
|
|
|
3013
|
+ bigDecimal = new BigDecimal(result).multiply(new BigDecimal("100"));
|
|
|
3014
|
+ } else if (claimPrinciOwed.contains("千")) {
|
|
|
3015
|
+ bigDecimal = new BigDecimal(result).multiply(new BigDecimal("1000"));
|
|
|
3016
|
+ } else if (claimPrinciOwed.contains("万")) {
|
|
|
3017
|
+ bigDecimal = new BigDecimal(result).multiply(new BigDecimal("10000"));
|
|
|
3018
|
+ } else if (claimPrinciOwed.contains("百万")) {
|
|
|
3019
|
+ bigDecimal = new BigDecimal(result).multiply(new BigDecimal("1000000"));
|
|
|
3020
|
+ } else if (claimPrinciOwed.contains("千万")) {
|
|
|
3021
|
+ bigDecimal = new BigDecimal(result).multiply(new BigDecimal("10000000"));
|
|
|
3022
|
+ } else if (claimPrinciOwed.contains("亿")) {
|
|
|
3023
|
+ bigDecimal = new BigDecimal(result).multiply(new BigDecimal("100000000"));
|
|
|
3024
|
+ }
|
|
|
3025
|
+ // todo 生产裁决书时金额格式增加千分位
|
|
|
3026
|
+ // NumberFormat format = NumberFormat.getInstance();
|
|
|
3027
|
+ // String format1 = format.format(bigDecimal);
|
|
|
3028
|
+
|
|
|
3029
|
+ caseApplication.setClaimPrinciOwed(bigDecimal);
|
|
|
3030
|
+ }
|
|
|
3031
|
+ }
|
|
|
3032
|
+
|
|
|
3033
|
+ if(disputeList.size()>5){
|
|
|
3034
|
+ caseApplication.setLoanTerm(disputeList.get(5));
|
|
|
3035
|
+ }
|
|
|
3036
|
+ }
|
|
|
3037
|
+ // 调解协议
|
|
|
3038
|
+ String mediationAgreement = map.get("经调解,双方自愿达成如下协议").get(0);
|
|
|
3039
|
+ caseApplication.setMediationAgreement(mediationAgreement);
|
|
|
3040
|
+ String mediationAgreementTemplate="1、乙方从维系客户的角度出发,同意为甲方申请停催至{1},停催期间正常计息,且征信影响由甲方自行承担。2、甲方应于{2}停催到期前向乙方申请费息减免业务,并按人民币{3}元一次性结清剩余贷款。3、今后双方无涉,就此结案。";
|
|
|
3041
|
+ // 对比模板和pdf识别的内容,取出占位符对应的值
|
|
|
3042
|
+ List<String> mediationAgreementList = getReplaceList(mediationAgreementTemplate, mediationAgreement);
|
|
|
3043
|
+ if(CollectionUtil.isNotEmpty(mediationAgreementList)){
|
|
|
3044
|
+ // 截止日期
|
|
|
3045
|
+ String lonEndDate = mediationAgreementList.get(0);
|
|
|
3046
|
+ try {
|
|
|
3047
|
+ caseApplication.setLoanEndDate( sdf.parse(lonEndDate));
|
|
|
3048
|
+ } catch (ParseException e) {
|
|
|
3049
|
+ e.printStackTrace();
|
|
|
3050
|
+ }
|
|
|
3051
|
+ if(mediationAgreementList.size()>2){
|
|
|
3052
|
+ // 待还金额
|
|
|
3053
|
+ caseApplication.setOutstandingMoney(mediationAgreementList.get(2));
|
|
|
3054
|
+ }
|
|
|
3055
|
+ }
|
|
|
3056
|
+ // 合同甲方
|
|
|
3057
|
+ caseApplication.setPartyA(map.get("甲方(贷款人)").get(0));
|
|
2986
|
3058
|
List<CaseAffiliate> caseAffiliates = new ArrayList<>();
|
|
2987
|
3059
|
CaseAffiliate caseAffiliate = new CaseAffiliate();
|
|
2988
|
3060
|
caseAffiliate.setIdentityType(1);
|
|
2989
|
3061
|
caseAffiliate.setName(map.get("申请人").get(0));
|
|
2990
|
3062
|
caseAffiliate.setIdentityNum(map.get("统一社会信用代码").get(0));
|
|
2991
|
3063
|
caseAffiliate.setCompLegalPerson(map.get("负责人").get(0));
|
|
|
3064
|
+ if(map.get("职务").size()>0) {
|
|
|
3065
|
+ // 法定代表人职务
|
|
|
3066
|
+ caseAffiliate.setCompLegalperPost(map.get("职务").get(0));
|
|
|
3067
|
+ if(map.get("职务").size()>1) {
|
|
|
3068
|
+ // 代理人职务
|
|
|
3069
|
+ caseAffiliate.setAppliAgentTitle(map.get("职务").get(1));
|
|
|
3070
|
+ }
|
|
|
3071
|
+ }
|
|
2992
|
3072
|
caseAffiliate.setNameAgent(map.get("委托代理人").get(0));
|
|
2993
|
3073
|
caseAffiliate.setContactTelphoneAgent(map.get("联系电话").get(0));
|
|
2994
|
3074
|
caseAffiliate.setResidenAffili(map.get("住所").get(0));
|
|
2995
|
3075
|
caseAffiliate.setContactAddress(map.get("联系地址").get(0));
|
|
2996
|
|
- caseAffiliate.setEmail(map.get("电子邮件").get(0).replaceAll("\\s", ""));
|
|
|
3076
|
+ caseAffiliate.setAgentEmail(map.get("电子邮件").get(0).replaceAll("\\s", ""));
|
|
|
3077
|
+
|
|
|
3078
|
+
|
|
2997
|
3079
|
//设置默认代理人的身份证号码,暂时写死 要不然新增方法报错
|
|
2998
|
3080
|
// caseAffiliate.setIdentityNumAgent("610423199603171716");
|
|
2999
|
3081
|
caseAffiliates.add(caseAffiliate);
|
|
3000
|
3082
|
CaseAffiliate caseAffiliate1 = new CaseAffiliate();
|
|
3001
|
3083
|
caseAffiliate1.setIdentityType(2);
|
|
3002
|
3084
|
caseAffiliate1.setName(map.get("被申请人").get(0));
|
|
3003
|
|
- caseAffiliate1.setIdentityNum(map.get("居民身份证号码").get(0));
|
|
|
3085
|
+ // 被申请人身份证
|
|
|
3086
|
+ String identityNum = map.get("居民身份证号码").get(0);
|
|
|
3087
|
+ caseAffiliate1.setIdentityNum(identityNum);
|
|
|
3088
|
+ // 被申请人电子邮件
|
|
|
3089
|
+ if(map.get("乙方确认有效的电子信箱地址为").size()>1) {
|
|
|
3090
|
+ if(map.get("乙方确认有效的电子信箱地址为").get(0).contains("/")) {
|
|
|
3091
|
+ caseAffiliate1.setEmail(map.get("乙方确认有效的电子信箱地址为").get(1).replaceAll("\\s", ""));
|
|
|
3092
|
+ }else {
|
|
|
3093
|
+ caseAffiliate1.setEmail(map.get("乙方确认有效的电子信箱地址为").get(0).replaceAll("\\s", ""));
|
|
|
3094
|
+ }
|
|
|
3095
|
+ }
|
|
|
3096
|
+ // 出生年月日,从身份证抓取
|
|
|
3097
|
+ if(StrUtil.isNotEmpty(identityNum)) {
|
|
|
3098
|
+ Map<String, String> identityNumMap = getBirAgeSex(identityNum);
|
|
|
3099
|
+ String birthday = identityNumMap.get("birthday");
|
|
|
3100
|
+ if(StrUtil.isNotEmpty(birthday)) {
|
|
|
3101
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
3102
|
+ Date birthdayDate = null;
|
|
|
3103
|
+ try {
|
|
|
3104
|
+ birthdayDate = simpleDateFormat.parse(birthday);
|
|
|
3105
|
+ } catch (Exception e) {
|
|
|
3106
|
+ e.printStackTrace();
|
|
|
3107
|
+ }
|
|
|
3108
|
+ caseAffiliate1.setResponBirth(birthdayDate);
|
|
|
3109
|
+ }
|
|
|
3110
|
+ //从身份证抓取性别
|
|
|
3111
|
+ caseAffiliate1.setResponSex(identityNumMap.get("sexCode"));
|
|
|
3112
|
+ }
|
|
3004
|
3113
|
caseAffiliate1.setContactTelphone(map.get("联系电话").get(1));
|
|
3005
|
3114
|
caseAffiliate1.setResidenAffili(map.get("住所").get(1));
|
|
3006
|
|
- //设置默认的性别 2代表未知
|
|
3007
|
|
- caseAffiliate1.setResponSex("2");
|
|
|
3115
|
+
|
|
3008
|
3116
|
caseAffiliates.add(caseAffiliate1);
|
|
3009
|
3117
|
caseApplication.setCaseAffiliates(caseAffiliates);
|
|
3010
|
3118
|
this.insertcaseApplication(caseApplication);
|
|
3011
|
3119
|
if (null != caseApplication.getId()) {
|
|
3012
|
|
- // 绑定案件与申请书
|
|
3013
|
|
- File file1 = new File(pdfUrl);
|
|
3014
|
|
- CaseAttach caseAttach = new CaseAttach();
|
|
3015
|
|
- caseAttach.setCaseAppliId(caseApplication.getId());
|
|
3016
|
|
- caseAttach.setAnnexPath(file1.getPath());
|
|
3017
|
|
- caseAttach.setAnnexName(file1.getName());
|
|
3018
|
|
- caseAttach.setAnnexType(1);
|
|
3019
|
|
- caseAttachMapper.save(caseAttach);
|
|
|
3120
|
+ List<CaseAttach> caseAttachs=new ArrayList<>();
|
|
|
3121
|
+ for (Map.Entry<String, String> entry : andConvertPDF.entrySet()) {
|
|
|
3122
|
+ if(entry.getValue().contains("证据材料")){
|
|
|
3123
|
+ String pdfUrl = entry.getValue();
|
|
|
3124
|
+ File file1 = new File(pdfUrl);
|
|
|
3125
|
+ CaseAttach caseAttach = new CaseAttach();
|
|
|
3126
|
+ caseAttach.setCaseAppliId(caseApplication.getId());
|
|
|
3127
|
+ caseAttach.setAnnexPath(file1.getPath());
|
|
|
3128
|
+ caseAttach.setAnnexName(file1.getName());
|
|
|
3129
|
+ // 申请人提供的证据材料
|
|
|
3130
|
+ caseAttach.setAnnexType(2);
|
|
|
3131
|
+ caseAttachs.add(caseAttach);
|
|
|
3132
|
+ }
|
|
|
3133
|
+ }
|
|
|
3134
|
+ if(CollectionUtil.isNotEmpty(caseAttachs)) {
|
|
|
3135
|
+ // 新增申请人证据材料
|
|
|
3136
|
+ caseAttachMapper.batchSave(caseAttachs);
|
|
|
3137
|
+ }
|
|
3020
|
3138
|
return AjaxResult.success("导入成功");
|
|
3021
|
3139
|
}
|
|
3022
|
3140
|
}else{
|
|
3023
|
3141
|
return AjaxResult.error("文件识别内容失败,请检查");
|
|
3024
|
3142
|
}
|
|
3025
|
|
- }
|
|
|
3143
|
+
|
|
3026
|
3144
|
} else {
|
|
3027
|
3145
|
// 没有找到符合条件的文件
|
|
3028
|
3146
|
return AjaxResult.error("未找到符合条件的文件");
|
|
|
@@ -3034,6 +3152,95 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
3034
|
3152
|
return null;
|
|
3035
|
3153
|
}
|
|
3036
|
3154
|
|
|
|
3155
|
+ private boolean OCRAndBuildInfo( Map<String, String> andConvertPDF, String mapKey, Map<String, List<String>> map) {
|
|
|
3156
|
+ String pdfUrl = andConvertPDF.get(mapKey);
|
|
|
3157
|
+ if(StrUtil.isEmpty(pdfUrl)){
|
|
|
3158
|
+ return false;
|
|
|
3159
|
+ }
|
|
|
3160
|
+ //获取文件的页数
|
|
|
3161
|
+ int fileNumPage = getFileNumPage(pdfUrl);
|
|
|
3162
|
+ //文件转成base64
|
|
|
3163
|
+ String base64 = OCRUtils.pdfConvertBase64(pdfUrl);
|
|
|
3164
|
+ if (base64 == null){
|
|
|
3165
|
+ return false;
|
|
|
3166
|
+ }
|
|
|
3167
|
+ StringBuilder stringBuilder = new StringBuilder(); // 创建一个StringBuilder对象
|
|
|
3168
|
+ for (int i = 0; i < fileNumPage; i++) {
|
|
|
3169
|
+ //对接腾讯云接口.识别里面的数据
|
|
|
3170
|
+ String text = OCRUtils.pdfIdentifyText(base64, i + 1,mapKey);
|
|
|
3171
|
+ if (stringBuilder.length() > 0) {
|
|
|
3172
|
+ stringBuilder.append(Constants.BR); // 在已有内容的情况下添加逗号分隔符
|
|
|
3173
|
+ }
|
|
|
3174
|
+ stringBuilder.append(text); // 拼接当前的字符串
|
|
|
3175
|
+ }
|
|
|
3176
|
+ // 将字符串按逗号分隔符切割
|
|
|
3177
|
+ String[] fields = stringBuilder.toString().split(Constants.BR);
|
|
|
3178
|
+ for (String field : fields) {
|
|
|
3179
|
+ // 对于每个字段,再按冒号分隔符拆分出键和值
|
|
|
3180
|
+ String[] keyValue = field.split(Constants.PDFSTR);
|
|
|
3181
|
+ if (keyValue.length >= 2) {
|
|
|
3182
|
+ String key = keyValue[0];
|
|
|
3183
|
+ String value = keyValue[1];
|
|
|
3184
|
+ // 判断Map中是否已存在该键
|
|
|
3185
|
+ if (map.containsKey(key)) {
|
|
|
3186
|
+ // 如果已存在,获取该键对应的值,并将新的值添加到集合中
|
|
|
3187
|
+ List<String> values = map.get(key);
|
|
|
3188
|
+ values.add(value);
|
|
|
3189
|
+ } else {
|
|
|
3190
|
+ // 如果不存在,创建一个新的集合,并将值添加到集合中
|
|
|
3191
|
+ List<String> values = new ArrayList<>();
|
|
|
3192
|
+ values.add(value);
|
|
|
3193
|
+ map.put(key, values);
|
|
|
3194
|
+ }
|
|
|
3195
|
+ }
|
|
|
3196
|
+ }
|
|
|
3197
|
+ return true;
|
|
|
3198
|
+ }
|
|
|
3199
|
+
|
|
|
3200
|
+ /**
|
|
|
3201
|
+ * 通过身份证号码获取出生日期、性别、年龄
|
|
|
3202
|
+ * @param certificateNo
|
|
|
3203
|
+ * @return 返回的出生日期格式:1990-01-01 性别格式:1-女,0-男
|
|
|
3204
|
+ */
|
|
|
3205
|
+ public static Map<String, String> getBirAgeSex(String certificateNo) {
|
|
|
3206
|
+ String birthday = "";
|
|
|
3207
|
+ String age = "";
|
|
|
3208
|
+ String sexCode = "";
|
|
|
3209
|
+
|
|
|
3210
|
+ int year = Calendar.getInstance().get(Calendar.YEAR);
|
|
|
3211
|
+ char[] number = certificateNo.toCharArray();
|
|
|
3212
|
+ boolean flag = true;
|
|
|
3213
|
+ if (number.length == 15) {
|
|
|
3214
|
+ for (int x = 0; x < number.length; x++) {
|
|
|
3215
|
+ if (!flag) return new HashMap<String, String>();
|
|
|
3216
|
+ flag = Character.isDigit(number[x]);
|
|
|
3217
|
+ }
|
|
|
3218
|
+ } else if (number.length == 18) {
|
|
|
3219
|
+ for (int x = 0; x < number.length - 1; x++) {
|
|
|
3220
|
+ if (!flag) return new HashMap<String, String>();
|
|
|
3221
|
+ flag = Character.isDigit(number[x]);
|
|
|
3222
|
+ }
|
|
|
3223
|
+ }
|
|
|
3224
|
+ if (flag && certificateNo.length() == 15) {
|
|
|
3225
|
+ birthday = "19" + certificateNo.substring(6, 8) + "-"
|
|
|
3226
|
+ + certificateNo.substring(8, 10) + "-"
|
|
|
3227
|
+ + certificateNo.substring(10, 12);
|
|
|
3228
|
+ sexCode = Integer.parseInt(certificateNo.substring(certificateNo.length() - 3, certificateNo.length())) % 2 == 0 ? "1" : "0";
|
|
|
3229
|
+ age = (year - Integer.parseInt("19" + certificateNo.substring(6, 8))) + "";
|
|
|
3230
|
+ } else if (flag && certificateNo.length() == 18) {
|
|
|
3231
|
+ birthday = certificateNo.substring(6, 10) + "-"
|
|
|
3232
|
+ + certificateNo.substring(10, 12) + "-"
|
|
|
3233
|
+ + certificateNo.substring(12, 14);
|
|
|
3234
|
+ sexCode = Integer.parseInt(certificateNo.substring(certificateNo.length() - 4, certificateNo.length() - 1)) % 2 == 0 ? "1" : "0";
|
|
|
3235
|
+ age = (year - Integer.parseInt(certificateNo.substring(6, 10))) + "";
|
|
|
3236
|
+ }
|
|
|
3237
|
+ Map<String, String> map = new HashMap<String, String>();
|
|
|
3238
|
+ map.put("birthday", birthday);
|
|
|
3239
|
+ map.put("age", age);
|
|
|
3240
|
+ map.put("sexCode", sexCode);
|
|
|
3241
|
+ return map;
|
|
|
3242
|
+ }
|
|
|
3243
|
+
|
|
3037
|
3244
|
/**
|
|
3038
|
3245
|
* 根据附件id修改案件id
|
|
3039
|
3246
|
* @param caseAttach
|
|
|
@@ -3045,12 +3252,13 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
3045
|
3252
|
return success();
|
|
3046
|
3253
|
}
|
|
3047
|
3254
|
|
|
3048
|
|
- public static List<String> findAndConvertPDF(File directory) {
|
|
3049
|
|
- List<String> pdfPaths = new ArrayList<>();
|
|
|
3255
|
+ public static Map<String,String> findAndConvertPDF(File directory) {
|
|
|
3256
|
+ Map<String,String> pdfPathMap= new HashMap<>();
|
|
3050
|
3257
|
if (directory.isFile()) {
|
|
3051
|
3258
|
String path = "";
|
|
|
3259
|
+ String fileName = "";
|
|
3052
|
3260
|
// 如果传入的参数是一个文件
|
|
3053
|
|
- if (directory.getName().contains("仲裁申请书")) {
|
|
|
3261
|
+ // if (directory.getName().contains("仲裁申请书")) {
|
|
3054
|
3262
|
if (isPDF(directory)) {
|
|
3055
|
3263
|
// 如果文件名包含"仲裁申请书"且是PDF格式,直接返回路径
|
|
3056
|
3264
|
path = directory.getAbsolutePath();
|
|
|
@@ -3062,17 +3270,53 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
3062
|
3270
|
}
|
|
3063
|
3271
|
}
|
|
3064
|
3272
|
if (path != null) {
|
|
3065
|
|
- pdfPaths.add(path);
|
|
|
3273
|
+ // 如果文件名包含"仲裁申请书"且是PDF格式,直接返回路径
|
|
|
3274
|
+ // 如果是PDF格式,直接添加到列表中
|
|
|
3275
|
+ String name="";
|
|
|
3276
|
+ if (directory.getName().contains("仲裁申请书")) {
|
|
|
3277
|
+ name="仲裁申请书";
|
|
|
3278
|
+ }
|
|
|
3279
|
+ if (directory.getName().contains("调解协议")) {
|
|
|
3280
|
+ name="调解协议";
|
|
|
3281
|
+ }
|
|
|
3282
|
+ if (directory.getName().contains("情况说明")) {
|
|
|
3283
|
+ name="情况说明";
|
|
|
3284
|
+ }
|
|
|
3285
|
+ if (directory.getName().contains("贷款合同")) {
|
|
|
3286
|
+ name="贷款合同";
|
|
|
3287
|
+ }
|
|
|
3288
|
+ if (directory.getName().contains("营业执照")) {
|
|
|
3289
|
+ name="营业执照";
|
|
|
3290
|
+ }
|
|
|
3291
|
+ if (directory.getName().contains("负责人证明")) {
|
|
|
3292
|
+ name="负责人证明";
|
|
|
3293
|
+ }
|
|
|
3294
|
+ if (directory.getName().contains("负责人身份证")) {
|
|
|
3295
|
+ name="负责人身份证";
|
|
|
3296
|
+ }
|
|
|
3297
|
+ if (directory.getName().contains("授权委托书")) {
|
|
|
3298
|
+ name="授权委托书";
|
|
|
3299
|
+ }
|
|
|
3300
|
+ if (directory.getName().contains("经办人员的劳动合同")) {
|
|
|
3301
|
+ name="经办人员的劳动合同";
|
|
|
3302
|
+ }
|
|
|
3303
|
+ if (directory.getName().contains("经办人员身份证")) {
|
|
|
3304
|
+ name="经办人员的身份证";
|
|
|
3305
|
+ }
|
|
|
3306
|
+ if (directory.getName().contains("自然人身份证")) {
|
|
|
3307
|
+ name="自然人身份证";
|
|
|
3308
|
+ }
|
|
|
3309
|
+
|
|
|
3310
|
+ pdfPathMap.put(name,path);
|
|
3066
|
3311
|
}
|
|
3067
|
|
- }
|
|
|
3312
|
+ // }
|
|
3068
|
3313
|
} else if (directory.isDirectory()) {
|
|
3069
|
|
- searchAndConvertPDF(directory, pdfPaths);
|
|
|
3314
|
+ searchAndConvertPDF(directory, pdfPathMap);
|
|
3070
|
3315
|
} else {
|
|
3071
|
3316
|
return null;
|
|
3072
|
3317
|
}
|
|
3073
|
|
- return pdfPaths;
|
|
|
3318
|
+ return pdfPathMap;
|
|
3074
|
3319
|
}
|
|
3075
|
|
-
|
|
3076
|
3320
|
public static boolean isPDF(File file) {
|
|
3077
|
3321
|
String extension = getFileExtension(file);
|
|
3078
|
3322
|
return extension.equalsIgnoreCase("pdf");
|
|
|
@@ -3088,27 +3332,66 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
3088
|
3332
|
}
|
|
3089
|
3333
|
}
|
|
3090
|
3334
|
|
|
3091
|
|
- public static void searchAndConvertPDF(File directory, List<String> pdfPaths) {
|
|
|
3335
|
+ public static void searchAndConvertPDF(File directory, Map<String,String> pdfPathMap) {
|
|
3092
|
3336
|
File[] files = directory.listFiles();
|
|
3093
|
3337
|
if (files != null) {
|
|
3094
|
3338
|
for (File file : files) {
|
|
|
3339
|
+ if(file.getName().contains("zip")|| file.getName().contains("rar")){
|
|
|
3340
|
+ continue;
|
|
|
3341
|
+ }
|
|
3095
|
3342
|
if (file.isFile()) {
|
|
3096
|
|
- // 如果是文件且文件名包含"仲裁申请书"
|
|
|
3343
|
+ String name="";
|
|
3097
|
3344
|
if (file.getName().contains("仲裁申请书")) {
|
|
|
3345
|
+ name="仲裁申请书";
|
|
|
3346
|
+ }
|
|
|
3347
|
+ if (file.getName().contains("调解协议")) {
|
|
|
3348
|
+ name="调解协议";
|
|
|
3349
|
+ }
|
|
|
3350
|
+ if (file.getName().contains("情况说明")) {
|
|
|
3351
|
+ name="情况说明";
|
|
|
3352
|
+ }
|
|
|
3353
|
+ if (file.getName().contains("贷款合同")) {
|
|
|
3354
|
+ name="贷款合同";
|
|
|
3355
|
+ }
|
|
|
3356
|
+ if (file.getName().contains("营业执照")) {
|
|
|
3357
|
+ name="营业执照";
|
|
|
3358
|
+ }
|
|
|
3359
|
+ if (file.getName().contains("负责人证明")) {
|
|
|
3360
|
+ name="负责人证明";
|
|
|
3361
|
+ }
|
|
|
3362
|
+ if (file.getName().contains("负责人身份证")) {
|
|
|
3363
|
+ name="负责人身份证";
|
|
|
3364
|
+ }
|
|
|
3365
|
+ if (file.getName().contains("授权委托书")) {
|
|
|
3366
|
+ name="授权委托书";
|
|
|
3367
|
+ }
|
|
|
3368
|
+ if (file.getName().contains("经办人员的劳动合同")) {
|
|
|
3369
|
+ name="经办人员的劳动合同";
|
|
|
3370
|
+ }
|
|
|
3371
|
+ if (file.getName().contains("经办人员的身份证")) {
|
|
|
3372
|
+ name="经办人员身份证";
|
|
|
3373
|
+ }
|
|
|
3374
|
+ if (file.getName().contains("自然人身份证")) {
|
|
|
3375
|
+ name="自然人身份证";
|
|
|
3376
|
+ }
|
|
|
3377
|
+ // 如果是文件且文件名包含"仲裁申请书"
|
|
|
3378
|
+ // if (file.getName().contains("仲裁申请书")) {
|
|
3098
|
3379
|
if (isPDF(file)) {
|
|
3099
|
3380
|
// 如果是PDF格式,直接添加到列表中
|
|
3100
|
|
- pdfPaths.add(file.getAbsolutePath());
|
|
|
3381
|
+ pdfPathMap.put(name,file.getAbsolutePath());
|
|
3101
|
3382
|
} else {
|
|
3102
|
3383
|
// 如果不是PDF格式,进行转换成PDF并添加转换后的路径到列表中
|
|
3103
|
|
- String pdfPath = convertToPDF(file);
|
|
|
3384
|
+ String pdfPath = convertToPDF(file);
|
|
3104
|
3385
|
if (pdfPath != null) {
|
|
3105
|
|
- pdfPaths.add(pdfPath);
|
|
|
3386
|
+ // 如果是PDF格式,直接添加到列表中
|
|
|
3387
|
+ pdfPathMap.put(name,pdfPath);
|
|
3106
|
3388
|
}
|
|
3107
|
3389
|
}
|
|
3108
|
|
- }
|
|
|
3390
|
+
|
|
|
3391
|
+ // }
|
|
3109
|
3392
|
} else if (file.isDirectory()) {
|
|
3110
|
3393
|
// 如果是目录,递归查找
|
|
3111
|
|
- searchAndConvertPDF(file, pdfPaths);
|
|
|
3394
|
+ searchAndConvertPDF(file, pdfPathMap);
|
|
3112
|
3395
|
}
|
|
3113
|
3396
|
}
|
|
3114
|
3397
|
}
|
|
|
@@ -3151,6 +3434,66 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
3151
|
3434
|
}
|
|
3152
|
3435
|
return pageCount;
|
|
3153
|
3436
|
}
|
|
|
3437
|
+
|
|
|
3438
|
+ /**
|
|
|
3439
|
+ * 获取模板和正文中替换符的内容
|
|
|
3440
|
+ * @param a
|
|
|
3441
|
+ * @param b
|
|
|
3442
|
+ * @return
|
|
|
3443
|
+ */
|
|
|
3444
|
+ public static List<String> getReplaceList(String a,String b){
|
|
|
3445
|
+ String aTmpe = filterString(a);
|
|
|
3446
|
+ String bTmpe = filterString(b);
|
|
|
3447
|
+ String regex = "(\\{[^}}]*})";
|
|
|
3448
|
+ String[] ptTemplate = aTmpe.replaceAll(regex, "@=").split("@=");
|
|
|
3449
|
+ String replace = "";
|
|
|
3450
|
+ for (int i = 0; i < ptTemplate.length; i++) {
|
|
|
3451
|
+ if(ptTemplate[i]==null || ptTemplate[i].equals(" "))continue;
|
|
|
3452
|
+ if(replace.equals("")){
|
|
|
3453
|
+ replace = bTmpe.replace(ptTemplate[i], "@=");
|
|
|
3454
|
+ }else {
|
|
|
3455
|
+ replace = replace.replace(ptTemplate[i], "@=");
|
|
|
3456
|
+ }
|
|
|
3457
|
+ }
|
|
|
3458
|
+ List<String> aList = new ArrayList<>();
|
|
|
3459
|
+ String[] split = replace.split("@=");
|
|
|
3460
|
+ for (int i =0; i<split.length; i++){
|
|
|
3461
|
+ if(split[i] == "" || split[i].equals("")) continue;
|
|
|
3462
|
+ aList.add(split[i]);
|
|
|
3463
|
+ }
|
|
|
3464
|
+ return aList;
|
|
|
3465
|
+ }
|
|
|
3466
|
+
|
|
|
3467
|
+ // 去掉内容中的换行符
|
|
|
3468
|
+ public static String filterString(String str){
|
|
|
3469
|
+ if(str == null || str.equals("")) return null;
|
|
|
3470
|
+ String regEx= "[\\r\\n]";
|
|
|
3471
|
+ Pattern p = Pattern.compile(regEx);
|
|
|
3472
|
+ Matcher m = p.matcher(str);
|
|
|
3473
|
+ return m.replaceAll(" ").trim();
|
|
|
3474
|
+ }
|
|
|
3475
|
+
|
|
|
3476
|
+ // 检索时,转换特殊字符
|
|
|
3477
|
+ public static String escapeQueryChars(String s) {
|
|
|
3478
|
+ if (StringUtils.isBlank(s)) {
|
|
|
3479
|
+ return s;
|
|
|
3480
|
+ }
|
|
|
3481
|
+ StringBuilder sb = new StringBuilder();
|
|
|
3482
|
+ for (int i = 0; i < s.length(); i++) {
|
|
|
3483
|
+ char c = s.charAt(i);
|
|
|
3484
|
+ // These characters are part of the query syntax and must be escaped
|
|
|
3485
|
+ if (c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')'
|
|
|
3486
|
+ || c == ':' || c == '^' || c == '[' || c == ']' || c == '\"'
|
|
|
3487
|
+ || c == '{' || c == '}' || c == '~' || c == '*' || c == '?'
|
|
|
3488
|
+ || c == '|' || c == '&' || c == ';' || c == '/' || c == '.'
|
|
|
3489
|
+ || c == '$' || Character.isWhitespace(c)) {
|
|
|
3490
|
+ sb.append('\\');
|
|
|
3491
|
+ }
|
|
|
3492
|
+ sb.append(c);
|
|
|
3493
|
+ }
|
|
|
3494
|
+ return sb.toString();
|
|
|
3495
|
+ }
|
|
|
3496
|
+
|
|
3154
|
3497
|
}
|
|
3155
|
3498
|
|
|
3156
|
3499
|
|