生成裁决书修改
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.wisdomarbitrate.utils;
|
||||
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.tencentcloudapi.bsca.v20210811.models.LicenseSummary;
|
||||
import com.tencentcloudapi.common.Credential;
|
||||
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
||||
@@ -23,8 +24,26 @@ public class OCRUtils {
|
||||
private static final String SECRET_ID = "AKIDeEf2A8uX1HSainvvnXAc3X9ZlhtyvkMp";
|
||||
//API的SecretKey
|
||||
private static final String SECRET_KEY = "QjphKo8zkHZigT8j9PVtFPJyfIvO3d6V";
|
||||
// 仲裁申请书识别字段
|
||||
private static final String[] applicantName = {"申请人", "统一社会信用代码", "负责人", "住所", "联系地址"
|
||||
, "委托代理人", "联系电话", "电子邮件", "被申请人", "居民身份证号码", "仲裁请求", "事实和理由"};
|
||||
// 贷款合同识别字段
|
||||
private static final String[] contractName = {
|
||||
"合同编号","甲方(贷款人)" ,"或委托代理人签字:","本合同的初始贷款年利率为","乙方确认有效的电子信箱地址为"};
|
||||
// 调解协议识别字段
|
||||
private static final String[] accordName = {"金融消费纠纷基本情况","经调解,双方自愿达成如下协议"};
|
||||
// 授权委托书识别字段
|
||||
private static final String[] powerAttorneyName = {"职务"};
|
||||
|
||||
public static String pdfIdentifyText(String imageBase64, Integer pageNumber) {
|
||||
|
||||
/**
|
||||
* pdf识别成文字
|
||||
* @param imageBase64
|
||||
* @param pageNumber
|
||||
* @param type pdf类型
|
||||
* @return
|
||||
*/
|
||||
public static String pdfIdentifyText(String imageBase64, Integer pageNumber,String type) {
|
||||
try {
|
||||
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
|
||||
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
|
||||
@@ -43,9 +62,16 @@ public class OCRUtils {
|
||||
req.setImageBase64(imageBase64);
|
||||
req.setIsPdf(true);
|
||||
req.setPdfPageNumber(pageNumber.longValue());
|
||||
String[] itemNames1 = {"申请人", "统一社会信用代码", "负责人", "住所", "联系地址"
|
||||
, "委托代理人", "联系电话", "电子邮件", "被申请人", "居民身份证号码", "仲裁请求", "事实和理由"};
|
||||
req.setItemNames(itemNames1);
|
||||
if(type.contains("申请书")){
|
||||
req.setItemNames(applicantName);
|
||||
}else if(type.contains("调解协议")){
|
||||
// req.setItemNames(accordName);
|
||||
}else if(type.contains("合同")){
|
||||
req.setItemNames(contractName);
|
||||
}else if(type.contains("授权委托书")){
|
||||
req.setItemNames(powerAttorneyName);
|
||||
}
|
||||
|
||||
// 返回的resp是一个SmartStructuralOCRV2Response的实例,与请求对象对应
|
||||
SmartStructuralOCRV2Response resp = client.SmartStructuralOCRV2(req);
|
||||
// 输出json格式的字符串回包
|
||||
@@ -67,9 +93,9 @@ public class OCRUtils {
|
||||
JSONObject value = line.getJSONObject("Value");
|
||||
String autoName = key.getString("AutoName");
|
||||
String autoContent = value.getString("AutoContent");
|
||||
String text = autoName + ":" + autoContent;
|
||||
String text = autoName + Constants.PDFSTR + autoContent;
|
||||
if (stringBuilder.length() > 0) {
|
||||
stringBuilder.append(","); // 在已有内容的情况下添加逗号分隔符
|
||||
stringBuilder.append(Constants.BR); // 在已有内容的情况下添加逗号分隔符
|
||||
}
|
||||
stringBuilder.append(text); // 拼接当前的字符串
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user