|
|
@@ -2842,16 +2842,16 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
2842
|
2842
|
return AjaxResult.error("请选择要上传的文件");
|
|
2843
|
2843
|
}
|
|
2844
|
2844
|
UUID uuid = UUID.randomUUID();
|
|
2845
|
|
- String targetPath = "\\home\\ruoyi\\uploadPath\\upload\\unzipFile\\";
|
|
2846
|
|
- //String targetPath = "D:\\home\\unzip\\" + uuid + "\\";
|
|
|
2845
|
+ String targetPath = "/home/ruoyi/uploadPath/upload/unzipFile/"+uuid+ "/";
|
|
|
2846
|
+ //String targetPath = "D:/home/unzip/" + uuid + "/";
|
|
2847
|
2847
|
File zipFile = null;
|
|
2848
|
2848
|
InputStream ins = null;
|
|
2849
|
2849
|
try {
|
|
2850
|
2850
|
ins = file.getInputStream();
|
|
2851
|
2851
|
//上传的压缩包保存的路径
|
|
2852
|
|
- //String savePath = "D:\\develop\\java\\";
|
|
2853
|
|
- String savePath = "\\home\\ruoyi\\uploadPath\\upload\\zipFile\\";
|
|
2854
|
|
- String saveName = uuid + file.getOriginalFilename();
|
|
|
2852
|
+ String savePath = "/home/ruoyi/uploadPath/upload/zipFile/";
|
|
|
2853
|
+ //String savePath = "D:/home/zipFile/";
|
|
|
2854
|
+ String saveName = uuid + "_" + file.getOriginalFilename();
|
|
2855
|
2855
|
zipFile = new File(savePath + saveName);
|
|
2856
|
2856
|
inputChangeToFile(ins, zipFile);
|
|
2857
|
2857
|
} catch (IOException e) {
|
|
|
@@ -2866,13 +2866,17 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
2866
|
2866
|
//遍历路径
|
|
2867
|
2867
|
for (String pdfUrl : andConvertPDF) {
|
|
2868
|
2868
|
//获取文件的页数
|
|
|
2869
|
+ System.out.println("这是查到的符合条件的文件路径====="+pdfUrl);
|
|
2869
|
2870
|
int fileNumPage = getFileNumPage(pdfUrl);
|
|
|
2871
|
+ //文件转成base64
|
|
|
2872
|
+ String base64 = OCRUtils.pdfConvertBase64(pdfUrl);
|
|
|
2873
|
+ if (base64 == null){
|
|
|
2874
|
+ return AjaxResult.error("文件转base64编码有误,请检查");
|
|
|
2875
|
+ }
|
|
2870
|
2876
|
StringBuilder stringBuilder = new StringBuilder(); // 创建一个StringBuilder对象
|
|
2871
|
2877
|
for (int i = 0; i < fileNumPage; i++) {
|
|
2872
|
2878
|
//对接腾讯云接口.识别里面的数据
|
|
2873
|
|
- //暂时写死
|
|
2874
|
|
- String pdfFilePath = "http://121.40.189.20:9000/API/uploadPath/upload/2023/11/14/ca2ca4697e5449ff9b9d23f95b221f58.pdf";
|
|
2875
|
|
- String text = OCRUtils.pdfIdentifyText(pdfUrl, i + 1);
|
|
|
2879
|
+ String text = OCRUtils.pdfIdentifyText(base64, i + 1);
|
|
2876
|
2880
|
if (stringBuilder.length() > 0) {
|
|
2877
|
2881
|
stringBuilder.append(","); // 在已有内容的情况下添加逗号分隔符
|
|
2878
|
2882
|
}
|
|
|
@@ -2880,56 +2884,69 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
2880
|
2884
|
}
|
|
2881
|
2885
|
// 将字符串按逗号分隔符切割
|
|
2882
|
2886
|
String[] fields = stringBuilder.toString().split(",");
|
|
2883
|
|
- JSONObject jsonObject = new JSONObject(); // 创建一个空的JSON对象
|
|
|
2887
|
+ Map<String, List<String>> map = new HashMap<>();
|
|
2884
|
2888
|
for (String field : fields) {
|
|
2885
|
2889
|
// 对于每个字段,再按冒号分隔符拆分出键和值
|
|
2886
|
2890
|
String[] keyValue = field.split(":");
|
|
2887
|
|
- if (keyValue.length == 2) { // 对于合法的键值对,将其添加到JSON对象中
|
|
2888
|
|
- jsonObject.put(keyValue[0], keyValue[1]);
|
|
|
2891
|
+ if (keyValue.length >= 2) {
|
|
|
2892
|
+ String key = keyValue[0];
|
|
|
2893
|
+ String value = keyValue[1];
|
|
|
2894
|
+ // 判断Map中是否已存在该键
|
|
|
2895
|
+ if (map.containsKey(key)) {
|
|
|
2896
|
+ // 如果已存在,获取该键对应的值,并将新的值添加到集合中
|
|
|
2897
|
+ List<String> values = map.get(key);
|
|
|
2898
|
+ values.add(value);
|
|
|
2899
|
+ } else {
|
|
|
2900
|
+ // 如果不存在,创建一个新的集合,并将值添加到集合中
|
|
|
2901
|
+ List<String> values = new ArrayList<>();
|
|
|
2902
|
+ values.add(value);
|
|
|
2903
|
+ map.put(key, values);
|
|
|
2904
|
+ }
|
|
2889
|
2905
|
}
|
|
2890
|
2906
|
}
|
|
2891
|
|
- //调用新增案件的接口
|
|
2892
|
|
- CaseApplication caseApplication = new CaseApplication();
|
|
2893
|
|
-
|
|
2894
|
|
- caseApplication.setApplicationOrganId(jsonObject.getString("统一社会信用代码"));
|
|
2895
|
|
- caseApplication.setCompLegalPerson(jsonObject.getString("法定代表人"));
|
|
2896
|
|
- caseApplication.setResidenAffiliAppli(jsonObject.getString("住所"));
|
|
2897
|
|
- caseApplication.setContactAddressAgent(jsonObject.getString("联系地址"));
|
|
2898
|
|
- caseApplication.setNameAgent(jsonObject.getString("委托代理人"));
|
|
2899
|
|
- caseApplication.setContactTelphoneAgent(jsonObject.getString("联系电话"));
|
|
2900
|
|
- caseApplication.setDebtorName(jsonObject.getString("被申请人"));
|
|
2901
|
|
- caseApplication.setDebtorIdentityNum(jsonObject.getString("居民身份证号码"));
|
|
2902
|
|
- caseApplication.setArbitratClaims(jsonObject.getString("仲裁请求"));
|
|
2903
|
|
- caseApplication.setCaseSubjectAmount(new BigDecimal(1));
|
|
2904
|
|
- List<CaseAffiliate> caseAffiliates = new ArrayList<>();
|
|
2905
|
|
- CaseAffiliate caseAffiliate = new CaseAffiliate();
|
|
2906
|
|
- caseAffiliate.setIdentityType(1);
|
|
2907
|
|
- caseAffiliate.setName(jsonObject.getString("申请人"));
|
|
2908
|
|
- caseAffiliate.setIdentityNum("");
|
|
2909
|
|
- caseAffiliate.setContactTelphone(jsonObject.getString("申请人联系电话"));
|
|
2910
|
|
- caseAffiliates.add(caseAffiliate);
|
|
2911
|
|
- CaseAffiliate caseAffiliate1 = new CaseAffiliate();
|
|
2912
|
|
- caseAffiliate1.setIdentityType(2);
|
|
2913
|
|
- caseAffiliate1.setName(jsonObject.getString("被申请人"));
|
|
2914
|
|
- caseAffiliate1.setIdentityNum("");
|
|
2915
|
|
- caseAffiliate1.setContactTelphone(jsonObject.getString("被申请人联系电话"));
|
|
2916
|
|
- caseAffiliates.add(caseAffiliate1);
|
|
2917
|
|
- caseApplication.setCaseAffiliates(caseAffiliates);
|
|
2918
|
|
- this.insertcaseApplication(caseApplication);
|
|
2919
|
|
- if (null != caseApplication.getId()) {
|
|
2920
|
|
- // 绑定案件与申请书
|
|
2921
|
|
- File file1 = new File(pdfUrl);
|
|
2922
|
|
- CaseAttach caseAttach = new CaseAttach();
|
|
2923
|
|
- caseAttach.setCaseAppliId(caseApplication.getId());
|
|
2924
|
|
- String saveName = "/profile/upload/" + file1.getName();
|
|
2925
|
|
- String savePath = "/home/ruoyi/uploadPath/upload";
|
|
2926
|
|
- caseAttach.setAnnexPath(savePath);
|
|
2927
|
|
- caseAttach.setAnnexName(saveName);
|
|
2928
|
|
- caseAttach.setAnnexType(1);
|
|
2929
|
|
- caseAttachMapper.save(caseAttach);
|
|
|
2907
|
+ if (map.size()>0){
|
|
|
2908
|
+ //调用新增案件的接口
|
|
|
2909
|
+ CaseApplication caseApplication = new CaseApplication();
|
|
|
2910
|
+ //默认案件标的
|
|
|
2911
|
+ caseApplication.setCaseSubjectAmount(new BigDecimal(1));
|
|
|
2912
|
+ caseApplication.setApplicationOrganId(map.get("统一社会信用代码").get(0));
|
|
|
2913
|
+ caseApplication.setCompLegalPerson(map.get("负责人").get(0));
|
|
|
2914
|
+ caseApplication.setNameAgent(map.get("委托代理人").get(0));
|
|
|
2915
|
+ caseApplication.setArbitratClaims(map.get("仲裁请求").get(0));
|
|
|
2916
|
+ List<CaseAffiliate> caseAffiliates = new ArrayList<>();
|
|
|
2917
|
+ CaseAffiliate caseAffiliate = new CaseAffiliate();
|
|
|
2918
|
+ caseAffiliate.setIdentityType(1);
|
|
|
2919
|
+ caseAffiliate.setName(map.get("申请人").get(0));
|
|
|
2920
|
+ caseAffiliate.setIdentityNum(map.get("统一社会信用代码").get(0));
|
|
|
2921
|
+ caseAffiliate.setContactTelphone(map.get("联系电话").get(0));
|
|
|
2922
|
+ caseAffiliate.setResidenAffili(map.get("住所").get(0));
|
|
|
2923
|
+ caseAffiliate.setContactAddress(map.get("联系地址").get(0));
|
|
|
2924
|
+ caseAffiliate.setSendEmail(map.get("电子邮件").get(0));
|
|
|
2925
|
+ caseAffiliates.add(caseAffiliate);
|
|
|
2926
|
+ CaseAffiliate caseAffiliate1 = new CaseAffiliate();
|
|
|
2927
|
+ caseAffiliate1.setIdentityType(2);
|
|
|
2928
|
+ caseAffiliate1.setName(map.get("被申请人").get(0));
|
|
|
2929
|
+ caseAffiliate1.setIdentityNum(map.get("居民身份证号码").get(0));
|
|
|
2930
|
+ caseAffiliate1.setContactTelphone(map.get("联系电话").get(1));
|
|
|
2931
|
+ caseAffiliate1.setResidenAffili(map.get("住所").get(1));
|
|
|
2932
|
+ caseAffiliates.add(caseAffiliate1);
|
|
|
2933
|
+ caseApplication.setCaseAffiliates(caseAffiliates);
|
|
|
2934
|
+ this.insertcaseApplication(caseApplication);
|
|
|
2935
|
+ if (null != caseApplication.getId()) {
|
|
|
2936
|
+ // 绑定案件与申请书
|
|
|
2937
|
+ File file1 = new File(pdfUrl);
|
|
|
2938
|
+ CaseAttach caseAttach = new CaseAttach();
|
|
|
2939
|
+ caseAttach.setCaseAppliId(caseApplication.getId());
|
|
|
2940
|
+ caseAttach.setAnnexPath(file1.getPath());
|
|
|
2941
|
+ caseAttach.setAnnexName(file1.getName());
|
|
|
2942
|
+ caseAttach.setAnnexType(1);
|
|
|
2943
|
+ caseAttachMapper.save(caseAttach);
|
|
|
2944
|
+ return AjaxResult.success("导入成功");
|
|
|
2945
|
+ }
|
|
|
2946
|
+ }else{
|
|
|
2947
|
+ return AjaxResult.error("文件识别内容失败,请检查");
|
|
2930
|
2948
|
}
|
|
2931
|
2949
|
}
|
|
2932
|
|
- return AjaxResult.success("导入成功");
|
|
2933
|
2950
|
} else {
|
|
2934
|
2951
|
// 没有找到符合条件的文件
|
|
2935
|
2952
|
return AjaxResult.error("未找到符合条件的文件");
|
|
|
@@ -2938,7 +2955,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
2938
|
2955
|
// 解压失败
|
|
2939
|
2956
|
return AjaxResult.error("解压失败");
|
|
2940
|
2957
|
}
|
|
2941
|
|
-
|
|
|
2958
|
+ return null;
|
|
2942
|
2959
|
}
|
|
2943
|
2960
|
|
|
2944
|
2961
|
/**
|
|
|
@@ -3023,8 +3040,8 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
3023
|
3040
|
|
|
3024
|
3041
|
private static String convertToPDF(File file) {
|
|
3025
|
3042
|
String wordFilePath = file.getAbsolutePath();
|
|
3026
|
|
- // String pdfSaveDirectory = "D:\\home\\unzip\\wordToPDF\\";
|
|
3027
|
|
- String pdfSaveDirectory = "\\home\\ruoyi\\uploadPath\\upload\\wordToPDF\\";
|
|
|
3043
|
+ //String pdfSaveDirectory = "D:\\home\\unzip\\wordToPDF\\";
|
|
|
3044
|
+ String pdfSaveDirectory = "/home/ruoyi/uploadPath/upload/wordToPDF/";
|
|
3028
|
3045
|
File directory = new File(pdfSaveDirectory);
|
|
3029
|
3046
|
if (!directory.exists()) {
|
|
3030
|
3047
|
directory.mkdirs();
|