案件压缩包上传修改 #281

Merged
wangqiong123 merged 1 commits from wq into dev 2023-12-07 01:36:32 +00:00
12 changed files with 736 additions and 540 deletions
@@ -78,7 +78,7 @@ public class CaseApplicationController extends BaseController {
{ {
caseApplication.setCreateBy(getUsername()); caseApplication.setCreateBy(getUsername());
return toAjax(caseApplicationService.insertcaseApplication(caseApplication)); return toAjax(caseApplicationService.insertcaseApplication(caseApplication,null));
} }
/** /**
@@ -25,6 +25,10 @@ public class CaseApplication extends BaseEntity {
/** 案件标的 */ /** 案件标的 */
@Excel(name = "案件标的") @Excel(name = "案件标的")
private BigDecimal caseSubjectAmount; private BigDecimal caseSubjectAmount;
/**
* 模板id
*/
private Long templateId;
/** 立案日期 */ /** 立案日期 */
@@ -37,6 +41,14 @@ public class CaseApplication extends BaseEntity {
*/ */
private Integer importFlag; private Integer importFlag;
public Long getTemplateId() {
return templateId;
}
public void setTemplateId(Long templateId) {
this.templateId = templateId;
}
public Integer getImportFlag() { public Integer getImportFlag() {
return importFlag; return importFlag;
} }
@@ -19,6 +19,9 @@ public class FatchRule extends BaseEntity {
private String fileName; private String fileName;
private String startContent; private String startContent;
private String endContent; private String endContent;
private String column;
private String columnName;
private String column; private String column;
private String columnName; private String columnName;
@@ -0,0 +1,37 @@
package com.ruoyi.wisdomarbitrate.domain.vo;
import lombok.Data;
/**
* 动态配置字段表
*/
@Data
public class ColumnValue {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Long id;
/**
* 字段,同一个批号,column不可重复
*/
private String column;
/**
* 字段名
*/
private String name;
/**
* 字段值
*/
private String value;
/**
* 案件id
*/
private Long caseId;
}
@@ -0,0 +1,28 @@
package com.ruoyi.wisdomarbitrate.mapper;
import com.ruoyi.wisdomarbitrate.domain.FatchRule;
import com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 动态配置字段表
*/
@Repository
public interface ColumnValueMapper {
/**
* 批量新增
*/
void batchSave(@Param("list") List<ColumnValue> list);
/**
* 根据案件id查询字段及值
* @param caseId
* @return
*/
List<ColumnValue> listByCaseId(@Param("caseId") Long caseId);
}
@@ -15,7 +15,7 @@ public interface FatchRuleMapper {
/** /**
* 根据批次查询 * 根据批次查询
*/ */
List<FatchRule> list(@Param("batchNumber")String batchNumber); List<FatchRule> listByTemplateId(@Param("templateId")String templateId);
List<FatchRule> selectFatchRuleList(FatchRule fatchRule); List<FatchRule> selectFatchRuleList(FatchRule fatchRule);
@@ -11,13 +11,14 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map;
public interface ICaseApplicationService { public interface ICaseApplicationService {
List<CaseApplication> selectCaseApplicationList(CaseApplication caseApplication); List<CaseApplication> selectCaseApplicationList(CaseApplication caseApplication);
List<CaseApplication> selectCaseApplicationListByRole(CaseApplication caseApplication); List<CaseApplication> selectCaseApplicationListByRole(CaseApplication caseApplication);
int insertcaseApplication(CaseApplication caseApplication); int insertcaseApplication(CaseApplication caseApplication, Map<String,String> fatchMap);
int selectCaseApplicationCount(CaseApplication caseApplication); int selectCaseApplicationCount(CaseApplication caseApplication);
@@ -11,6 +11,7 @@ import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SmsUtils; import com.ruoyi.common.utils.SmsUtils;
import com.ruoyi.wisdomarbitrate.domain.vo.BookSendVO; import com.ruoyi.wisdomarbitrate.domain.vo.BookSendVO;
import com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue;
import com.ruoyi.wisdomarbitrate.mapper.*; import com.ruoyi.wisdomarbitrate.mapper.*;
import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils; import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
import com.ruoyi.common.utils.EmailOutUtil; import com.ruoyi.common.utils.EmailOutUtil;
@@ -25,11 +26,16 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBookmark;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailSendException; import org.springframework.mail.MailSendException;
import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.io.*; import java.io.*;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -43,7 +49,9 @@ import java.text.NumberFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.*; import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static com.ruoyi.common.utils.SecurityUtils.getUsername; import static com.ruoyi.common.utils.SecurityUtils.getUsername;
@@ -72,284 +80,230 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
private SendMailRecordMapper sendMailRecordMapper; private SendMailRecordMapper sendMailRecordMapper;
@Autowired @Autowired
private SmsRecordMapper smsRecordMapper; private SmsRecordMapper smsRecordMapper;
@Autowired
private TemplateManageMapper templateManageMapper;
@Autowired
private ColumnValueMapper columnValueMapper;
// 仲裁反请求模板内容
private final String counterclaim= "在《2022年版仲裁规则》第十八条第(一)项规定的期限内,被申请人向秘书处提交了" +
"《仲裁反请求申请书》及证据材料。仲裁委依据《2022年版仲裁规则》第十八条的规定受理了该仲裁反请求案申请。" +
"仲裁反请求案件受理后,秘书处向被申请人发送了仲裁反请求通知书及附件,向申请人发送了仲裁反请求通知书及附件、仲裁反请求申请书及附件。";
// 财产保全内容
String preservation = "本案受理后,申请人向仲裁委提交了财产保全申请,仲裁委根据《中华人民共和国仲裁法》" +
"第二十八条之规定,将该申请提交至法院。";
// 管辖权异议
String jurisdictionalObjection = "本案受理后,被申请人向仲裁委提交了《管辖异议申请书》,认为" +
",仲裁委经审理,当庭驳回了被申请人的管辖异议申请,并告知被申请人具体的事实和理由将在裁决书中一并列明。";
// 线上开庭时+线上仲裁
String onLineDate="{{onLineDate}}";
String onLine = "仲裁庭审阅了申请人提交的仲裁申请书、证据材料后,于"+onLineDate+"通过仲裁委智慧仲裁平台开庭审理了本案。";
// 开庭+线下仲裁
String offLineDate="{{offLineDate}}";
String offLine = "仲裁庭审阅了申请人提交的仲裁申请书、证据材料后,于 "+offLineDate+"在仲裁委所在地开庭审理了本案。";
//书面仲裁时
String writtenDate="{{writtenDate}}";
String written = "仲裁庭审阅了申请人提交的仲裁申请书、证据材料后,于"+writtenDate+"在仲裁委所在地开庭审理了本案。";
//开庭+缺席审理
String absent = "申请人的特别授权委托代理人{{agentName}}"+"出席了庭审。被申请人经依法送达开庭通知,无正当理由未出席庭审,故仲裁庭依据" +
"《2022年版仲裁规则》第四十条第(二)项的规定,对本案进行了缺席审理。庭审中,申请人陈述了仲裁请求事项及事实与理由,出示了证据材料并进行了说明,\" +\n" +
" \"发表了意见,回答了仲裁庭的提问,并作了最后陈述。因被申请人缺席庭审,故仲裁庭无法组织调解。"+"综上,仲裁庭依据《上海仲裁委员会仲裁规则》(2022年7月1日起施行的版本)" +
"第四十条第(二)项、第五十一条的规定,缺席裁决如下:";
// 开庭+出席
String attend="申请人的特别授权委托代理人{{agentName}}和被申请人本人出席了庭审。 ";
// 开庭+出席+被申提供证据
String onLineAttendFile="庭审中,申请人陈述了仲裁请求事项及所依据的事实与理由,被申请人进行了答辩;双方当事人均出示了证据材料并对对方的证据材料进行了质证;双方当事人均回答了仲裁庭的提问,进行了辩论,并分别作了最后陈述。双方当事人在仲裁庭的主持下进行了调解,但未能达成调解协议。 ";
// 开庭+出席+被申未提供证据
String onLineAttend="庭审中,申请人陈述了仲裁请求事项及所依据的事实与理由,被申请人进行了答辩;申请人出示了证据材料,被申请人对对方的证据材料进行了质证; 双方当事人均回答了仲裁庭的提问,进行了辩论,并分别作了最后陈述。双方当事人在仲裁庭的主持下进行了调解,但未能达成调解协议。 ";
// 被申请人出席答辩意见
String resAttendOpinion="\n(二)被申请人的答辩意见 \n(三)当事人提供的证据材料及对方的质证意见\n" +
"申请人为证明其主张的事实和理由,向仲裁庭提交了如下证据材料:\n{{applicantFile}}\n被申请人对上述材料的质证意见为:{{respondentOpinion}}\n";
// 被申请人出席+被申请人提供了资料
String resFile="被申请人向仲裁庭提交了如下证据材料:\n{{resFile}}" +
"申请人对上述材料的质证意见为:{{applicantOpinion}}";
// 被申请人缺席
String resAbsent="(二)当事人提供的证据材料\n" +
"申请人为证明其主张的事实和理由,向仲裁庭提交了如下证据材料:\n{{applicantFile}}";
@Override @Override
@Transactional @Transactional
public AjaxResult createDocument(CaseApplication caseApplication) { public AjaxResult createDocument(CaseApplication caseApplicationReq) {
String templatePath="";
String templateName="";
String agentName="";
String resName="";
try { try {
Map<String, Object> datas = new HashMap<>(); Map<String, Object> datas = new HashMap<>();
Long id = caseApplication.getId(); Long id = caseApplicationReq.getId();
if (id == null) { if (id == null) {
return null; return AjaxResult.error("案件id不能为空");
} }
//获取案件详细信息 //获取案件详细信息
CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication); CaseApplication caseApplicationById = caseApplicationService.selectCaseApplication(caseApplicationReq);
//生成编码
String equipmentNo = getNewEquipmentNo(); if(caseApplicationById==null){
datas.put("num", equipmentNo); return AjaxResult.error("案件不存在");
}
// 根据模板id查找对应的模板
if(caseApplicationById.getTemplateId()!=null) {
TemplateManage templateManage = new TemplateManage();
templateManage.setId(caseApplicationById.getTemplateId());
List<TemplateManage> templateManages = templateManageMapper.selectTemplateList(templateManage);
if(CollectionUtil.isEmpty(templateManages)){
return AjaxResult.error("请先指定裁决书模板");
}
templatePath=templateManages.get(0).getTemOrigPath();
templateName=templateManages.get(0).getFileName();
}
//获取仲裁记录表里的相关信息 //获取仲裁记录表里的相关信息
ArbitrateRecord arbitrateRecord = new ArbitrateRecord(); ArbitrateRecord arbitrateRecord = new ArbitrateRecord();
arbitrateRecord.setCaseAppliId(id); arbitrateRecord.setCaseAppliId(id);
ArbitrateRecord arbitrateRecord1 = arbitrateRecordMapper.selectArbitrateRecord(arbitrateRecord); ArbitrateRecord arbitrateRecordSelect = arbitrateRecordMapper.selectArbitrateRecord(arbitrateRecord);
//获取案件关联人信息
CaseAffiliate caseAffiliate = new CaseAffiliate(); // todo 获取模板中的所有占位符,该占位符字段必须和抓取字段一致,暂时写死
caseAffiliate.setCaseAppliId(id); // todo 生成裁决书的内容从key-value表中取,不从案件基本信息表取,会有问题,如果修改的话会有问题,暂不考虑该情况
List<CaseAffiliate> caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
String applicantName=""; // 根据案件id查询key-value表
String debtorName = ""; List<ColumnValue> columnValueList = columnValueMapper.listByCaseId(caseApplicationReq.getId());
List<String> nameAgentList = new ArrayList<>(); // 获取模板中的占位符key
if (caseAffiliates != null && caseAffiliates.size() > 0) { List<String> bookmarkList = getBookmarkByDocx(templatePath);
for (CaseAffiliate affiliate : caseAffiliates) { if(CollectionUtil.isEmpty(bookmarkList)){
//获取身份类型 // 直接保存模板为裁决书
int identityType = affiliate.getIdentityType(); saveArbitorFile(id,templateName,templatePath,caseApplicationById,arbitrateRecordSelect);
if (identityType == 1) { //申请人 return AjaxResult.success("生成裁决书成功");
applicantName=affiliate.getName(); }
datas.put("appName", affiliate.getName()); // 如果该表没值,在从主表填充裁决书模板
datas.put("appAddress", affiliate.getResidenAffili()); if(CollectionUtil.isNotEmpty(columnValueList)){
datas.put("appContactAddress", affiliate.getContactAddress()); Map<String, String> columnValueMap = columnValueList.stream().collect(Collectors.toMap(ColumnValue::getColumn, ColumnValue::getValue));
datas.put("appLegalPerson", affiliate.getCompLegalPerson()); agentName=columnValueMap.get("agentName");
datas.put("appLegalPersonTitle", affiliate.getCompLegalperPost()); resName=columnValueMap.get("respondentName");
datas.put("appAgentName", affiliate.getNameAgent()); // 懒得if,暂时这样
datas.put("appAgentTitle", affiliate.getAppliAgentTitle()); //
nameAgentList.add(affiliate.getNameAgent()); for (String bookmark : bookmarkList) {
} else if (identityType == 2) { //被申请人 if(columnValueMap.containsKey(bookmark)){
debtorName=affiliate.getName(); datas.put(bookmark,columnValueMap.get(bookmark));
datas.put("resName", affiliate.getName());
datas.put("resAddress", affiliate.getResidenAffili());
String responSex = affiliate.getResponSex();
if (responSex.equals("0")) {
datas.put("resSex", "男");
} else if (responSex.equals("1")){
datas.put("resSex", "女");
}else {
datas.put("resSex", "未知");
}
Date responBirth = affiliate.getResponBirth();
if (responBirth != null) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
String responBirthStr = sdf.format(responBirth);
datas.put("resDateOfBirth", responBirthStr);
}
datas.put("resContactAddress", affiliate.getContactAddress());
nameAgentList.add(affiliate.getNameAgent());
} }
} }
}else {
} }
Date createTime = caseApplication1.getCreateTime(); // 裁决书生成时间
LocalDate now = LocalDate.now();
String year = Integer.toString(now.getYear());
datas.put("year", year);
//生成编码
String equipmentNo = getNewEquipmentNo();
// 裁决书编号
datas.put("num", equipmentNo);
// 案件创建时间
Date createTime = caseApplicationById.getCreateTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
// 将日期格式化为字符串 // 将日期格式化为字符串
String createTimeStr = sdf.format(createTime); String createTimeStr = sdf.format(createTime);
datas.put("submissionDate", createTimeStr); datas.put("submissionDate", createTimeStr);
Date registerDate = caseApplication1.getRegisterDate(); // 立案日期
Date registerDate = caseApplicationById.getRegisterDate();
String registerDateStr = sdf.format(registerDate); String registerDateStr = sdf.format(registerDate);
datas.put("acceptDate", registerDateStr); datas.put("acceptDate", registerDateStr);
//反请求
Integer adjudicaCounter = caseApplication1.getAdjudicaCounter(); // 如果有仲裁反请求,该字段设置值
String counterclaim = "在《2022年版仲裁规则》第十八条第(一)项规定的期限内,被申请人向秘书处提交了" + Integer adjudicaCounter = caseApplicationById.getAdjudicaCounter();
"《仲裁反请求申请书》及证据材料。仲裁委依据《2022年版仲裁规则》第十八条的规定受理了该仲裁反请求案申请。" + if (adjudicaCounter!=null&&adjudicaCounter == 1) {
"仲裁反请求案件受理后,秘书处向被申请人发送了仲裁反请求通知书及附件,向申请人发送了仲裁反请求通知书及附件、仲裁反请求申请书及附件。";
if (adjudicaCounter == null) {
datas.put("counterclaim", null);
} else if (adjudicaCounter == 1) {
datas.put("counterclaim", counterclaim); datas.put("counterclaim", counterclaim);
} else {
datas.put("counterclaim", null);
} }
//财产保全 //财产保全
Integer properPreser = caseApplication1.getProperPreser(); Integer properPreser = caseApplicationById.getProperPreser();
String preservation = "本案受理后,申请人向仲裁委提交了财产保全申请,仲裁委根据《中华人民共和国仲裁法》" + if (properPreser!=null&&properPreser == 1) {
"第二十八条之规定,将该申请提交至法院。";
if (properPreser == null) {
datas.put("preservation", null);
} else if (properPreser == 1) {
datas.put("preservation", preservation); datas.put("preservation", preservation);
} else {
datas.put("preservation", null);
} }
//管辖权异议 //管辖权异议
Integer objectiJuris = caseApplication1.getObjectiJuris(); Integer objectiJuris = caseApplicationById.getObjectiJuris();
String jurisdictionalObjection = "本案受理后,被申请人向仲裁委提交了《管辖异议申请书》,认为" + if (objectiJuris!=null&&objectiJuris == 1) {
",仲裁委经审理,当庭驳回了被申请人的管辖异议申请,并告知被申请人具体的事实和理由将在裁决书中一并列明。";
if (objectiJuris == null) {
datas.put("jurisdictionalObjection", null);
} else if (objectiJuris == 1) {
datas.put("jurisdictionalObjection", jurisdictionalObjection); datas.put("jurisdictionalObjection", jurisdictionalObjection);
} else {
datas.put("jurisdictionalObjection", null);
} }
String arbitratorName = caseApplication1.getArbitratorName(); // 仲裁员名称
datas.put("arbitratorName", arbitratorName); datas.put("arbitratorName", caseApplicationById.getArbitratorName());
Integer arbitratMethod = caseApplication1.getArbitratMethod(); // 审理方式
Date hearDate = caseApplication1.getHearDate(); Integer arbitratMethod = caseApplicationById.getArbitratMethod();
Date hearDate = caseApplicationById.getHearDate();
if (hearDate != null) { if (hearDate != null) {
// 审理日期
String hearDateStr = sdf.format(hearDate); String hearDateStr = sdf.format(hearDate);
// todo 线上仲裁/线下仲裁方式未选择
//线上开庭时 //线上开庭时
if (arbitratMethod == 1) { if (arbitratMethod == 1) {
String onLine1 = "仲裁庭审阅了申请人提交的仲裁申请书、证据材料后,于"; String replace = onLine.replace(onLineDate, hearDateStr);
String onLine2 = "通过仲裁委智慧仲裁平台开庭审理了本案。"; datas.put("onLine", replace);
datas.put("onLine1", onLine1);
datas.put("hearDate", hearDateStr);
datas.put("onLine2", onLine2);
} else { } else {
//书面仲裁时 //书面仲裁时
String written1 = "仲裁庭审阅了申请人提交的仲裁申请书、证据材料后,于"; String replace = written.replace(writtenDate, hearDateStr);
String written2 = "在仲裁委所在地开庭审理了本案。"; datas.put("written", replace);
datas.put("written1", written1);
datas.put("hearDate1", hearDateStr);
datas.put("written2", written2);
} }
} }
// 所有附件
Integer isAbsence = caseApplication1.getIsAbsence(); List<CaseAttach> caseAttachList = caseApplicationById.getCaseAttachList();
if (isAbsence == null) { Map<Integer, List<CaseAttach>> caseAttachMap=new HashMap<>();
datas.put("absent1", null); if(caseAttachList!=null&&caseAttachList.size()>0){
datas.put("absent2", null); caseAttachMap = caseAttachList.stream().collect(Collectors.groupingBy(CaseAttach::getAnnexType));
datas.put("absent3", null);
datas.put("absent4", null);
datas.put("absent5", null);
datas.put("attend1", null);
datas.put("attend2", null);
datas.put("attend3", null);
datas.put("attend4", null);
datas.put("attend5", null);
datas.put("attend6", null);
datas.put("attend7", null);
datas.put("appAgentName1", null);
datas.put("appAgentName2", null);
datas.put("resAgentName", null);
} else if (isAbsence == 1) {
//缺席审理
String absent1 = "申请人的特别授权委托代理人";
String absent2 = "出席了庭审。被申请人经依法送达开庭通知,无正当理由未出席庭审,故仲裁庭依据" +
"《2022年版仲裁规则》第四十条第(二)项的规定,对本案进行了缺席审理。";
String absent3 = "庭审中,申请人陈述了仲裁请求事项及事实与理由,出示了证据材料并进行了说明," +
"发表了意见,回答了仲裁庭的提问,并作了最后陈述。因被申请人缺席庭审,故仲裁庭无法组织调解。";
String absent4 = "(二/三)当事人提供的证据材料\n" +
"申请人为证明其主张的事实和理由,向仲裁庭提交了如下证据材料:";
String absent5 = "综上,仲裁庭依据《上海仲裁委员会仲裁规则》(2022年7月1日起施行的版本)" +
"第四十条第(二)项、第五十一条的规定,缺席裁决如下:";
datas.put("absent1", absent1);
datas.put("absent2", absent2);
datas.put("absent3", absent3);
datas.put("absent4", absent4);
datas.put("absent5", absent5);
datas.put("appAgentName1", nameAgentList.get(0));
} else {
//出席审理
String attend1 = "申请人的特别授权委托代理人";
String attend2 = "和被申请人本人/的特别授权委托代理人";
String attend3 = "出席了庭审。";
String attend4 = "庭审中,申请人陈述了仲裁请求事项及所依据的事实与理由,被申请人进行了答辩;" +
"双方当事人均出示了证据材料并对对方的证据材料进行了质证;申请人出示了证据材料," +
"被申请人对对方的证据材料进行了质证;双方当事人均回答了仲裁庭的提问,进行了辩论," +
"并分别作了最后陈述。双方当事人在仲裁庭的主持下进行了调解,但未能达成调解协议。";
String attend5 = "(二)被申请人的答辩意见";
String attend6 = "(二/三)当事人提供的证据材料及对方的质证意见\n" +
"申请人为证明其主张的事实和理由,向仲裁庭提交了如下证据材料:";
String attend7 = "被申请人对上述材料的质证意见为:";
datas.put("attend1", attend1);
datas.put("attend2", attend2);
datas.put("attend3", attend3);
datas.put("attend4", attend4);
datas.put("attend5", attend5);
datas.put("attend6", attend6);
datas.put("attend7", attend7);
datas.put("responCrossOpin", arbitrateRecord1.getRespondentOpinion());
datas.put("appAgentName2", nameAgentList.get(0));
datas.put("resAgentName", nameAgentList.get(1));
if (arbitratMethod == 1) {
//被申出席+开庭
String attend8 = "综上,仲裁庭依据《上海仲裁委员会仲裁规则》(2022年7月1日起施行的版本)" +
"第五十一条的规定,裁决如下:";
datas.put("attend8", attend8);
} else {
//被申出席+书面
String attend9 = "综上,仲裁庭依据《上海仲裁委员会仲裁规则》(2022年7月1日起施行的版本)" +
"第五十一条、第五十八条的规定,裁决如下:";
datas.put("attend9", attend9);
}
} }
// 申请人的仲裁请求及事实和理由 申请人称 在事实与理由抓取 // 被申请人是否缺席
datas.put("claims", caseApplication1.getFacts()); Integer isAbsence = caseApplicationById.getIsAbsence();
// datas.put("request", caseApplication1.getRequestRule()); // 线上开庭
CaseApplication caseApplication2 = caseApplicationService.selectCaseApplication(caseApplication); if (arbitratMethod == 1) {
// todo 合同编号 if (isAbsence != null && isAbsence == 1) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日"); // 被申请人缺席
// datas.put("partyA", caseApplication2.getContractNumber()); String absentReplace = absent.replace("{{agentName}}", agentName);
// Date loanStartDate = caseApplication2.getLoanStartDate(); datas.put("absent",absentReplace);
// datas.put("lonStartDate",simpleDateFormat.format(loanStartDate)); // 被申请人缺席
// datas.put("contractNumber",caseApplication2.getContractNumber()); String resAbsentReplace=resAbsent;
// 合同名称 if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(2))){
// datas.put("contractName",caseApplication2.getContractName()); List<CaseAttach> caseAttaches = caseAttachMap.get(2);
// todo 查询该批号的裁决内容模板 StringBuilder stringBuilder = new StringBuilder();
String template="一、被申请人{1}应于{2}前向申请人{3}一次性支付剩余贷款{4}元。\n" + for (CaseAttach caseAttach : caseAttaches) {
"二、本案仲裁费人民币{5}元(已由申请人预缴),由申请人{6}承担\n"; stringBuilder.append(caseAttach.getAnnexName()).append("\n");
Date loanEndDate = caseApplication2.getLoanEndDate(); }
resAbsentReplace = resAttendOpinion.replace("{{applicantFile}}", stringBuilder.toString());
String outstandingMoney = caseApplication2.getOutstandingMoney(); }
NumberFormat format = NumberFormat.getInstance(); datas.put("resAbsent",resAbsentReplace);
String outstandingMoneyFormat=""; } else {
// 出席
if(StrUtil.isNotEmpty(outstandingMoney)) { String attendReplace = attend.replace("{{agentName}}", agentName);
outstandingMoneyFormat = format.format(new BigDecimal(outstandingMoney)); datas.put("attend",attend);
} // 被申请人证据
String rulingFollows = template.replace("{1}", debtorName).replace("{2}", simpleDateFormat.format(loanEndDate)) if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(6))){
.replace("{3}", applicantName).replace("{4}", outstandingMoneyFormat) // 开庭+出席+被申提供证据
.replace("{5}", String.valueOf(caseApplication2.getFeePayable())) datas.put("onLineAttendFile",onLineAttendFile);
.replace("{6}", applicantName); // 被申请人出席+被申请人提供了资料
// 请求仲裁庭裁决 String resFileRplace=resFile;
datas.put("request", caseApplication1.getArbitratClaims()); if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(6))){
List<CaseAttach> caseAttachList1 = caseApplication2.getCaseAttachList(); List<CaseAttach> caseAttaches = caseAttachMap.get(6);
if (caseAttachList1 != null && caseAttachList1.size() > 0) { StringBuilder stringBuilder = new StringBuilder();
StringBuilder debtorFiles=new StringBuilder(); for (CaseAttach caseAttach : caseAttaches) {
StringBuilder applicantFiles=new StringBuilder(); stringBuilder.append(caseAttach.getAnnexName()).append("\n");
for (CaseAttach caseAttach : caseAttachList1) { }
if (caseAttach.getAnnexType() == 6) { //被申请人证据材料 resFileRplace = resFile.replace("{{resFile}}", stringBuilder.toString()).replace("{{applicantOpinion}}", arbitrateRecordSelect.getApplicantOpinion());
debtorFiles.append(caseAttach.getAnnexName()).append("\r\n"); }
// boolean isImageFile = Pattern.matches(".*\\.(jpg|png|gif|bmp)$", annexName); datas.put("resFile",resFileRplace);
// if (isImageFile) { }else {
// String annexPath = "/home/ruoyi" + caseAttach.getAnnexPath(); // 开庭+出席+被申未提供证据
// System.out.println("路径是===========" + annexPath); datas.put("onLineAttend",onLineAttend);
// PictureRenderData pictureRenderData = WordUtil }
// .rebuildImageContent(100, 100, null, annexPath); // 被申请人出席答辩意见
// datas.put("resEvidenceMaterial", pictureRenderData); String resAttendOpinionReplace=resAttendOpinion;
// } if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(2))){
List<CaseAttach> caseAttaches = caseAttachMap.get(2);
} else if (caseAttach.getAnnexType() == 2) { //申请人证据材料 StringBuilder stringBuilder = new StringBuilder();
// String annexName = caseAttach.getAnnexName(); for (CaseAttach caseAttach : caseAttaches) {
// boolean isImageFile = Pattern.matches(".*\\.(jpg|png|gif|bmp)$", annexName); stringBuilder.append(caseAttach.getAnnexName()).append("\n");
// if (isImageFile) { }
// String annexPath = "/home/ruoyi" + caseAttach.getAnnexPath(); resAttendOpinionReplace = resAttendOpinion.replace("{{applicantFile}}", stringBuilder.toString()).replace("{{respondentOpinion}}", arbitrateRecordSelect.getRespondentOpinion());
// System.out.println("路径是===========" + annexPath);
// PictureRenderData pictureRenderData = WordUtil
// .rebuildImageContent(100, 100, null, annexPath);
// //申请人证据材料
// datas.put("appEvidenceMaterial", pictureRenderData);
// }
applicantFiles.append(caseAttach.getAnnexName()).append("\r\n");
} }
}
// //被申请人证据材料
datas.put("resEvidenceMaterial", debtorFiles.toString());
//申请人证据材料
datas.put("appEvidenceMaterial", applicantFiles.toString());
}
// 申请人对上述材料的质证意见为
datas.put("applicaCrossOpin", arbitrateRecord1.getApplicantOpinion());
// 仲裁庭经审理,查明本案事实如下:
datas.put("factDetermi", arbitrateRecord1.getCaseFacts());
// 关于本案争议焦点
datas.put("arbitrateThink", arbitrateRecord1.getCaseFocus());
// datas.put("rulingFollows", "被申请人依法偿还申请人欠款");
// 最终裁决
datas.put("rulingFollows", rulingFollows);
LocalDate now = LocalDate.now(); datas.put("resAttendOpinion",resAttendOpinionReplace);
String year = Integer.toString(now.getYear()); }
datas.put("year", year); }
String month = String.format("%02d", now.getMonthValue()); String month = String.format("%02d", now.getMonthValue());
String day = String.format("%02d", now.getDayOfMonth()); String day = String.format("%02d", now.getDayOfMonth());
String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx"; String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx";
@@ -376,38 +330,52 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
WordUtil.changeText(xwpfDocument); WordUtil.changeText(xwpfDocument);
} }
String savePath = docFilePath.substring(0, docFilePath.indexOf("/upload/") + 8); String savePath = docFilePath.substring(0, docFilePath.indexOf("/upload/") + 8);
CaseAttach caseAttach = CaseAttach.builder() // 保存裁决书附件
.caseAppliId(id) saveArbitorFile(id,saveName,savePath,caseApplicationById,arbitrateRecordSelect);
.annexName(saveName)
.annexPath(savePath)
.annexType(3)
.build();
//保存到附件表里,先判断之前有没有,有的话更新,没有的话新增
List<CaseAttach> caseAttachList = caseAttachMapper.getCaseAttachByCaseIdAndType(caseAttach);
if (caseAttachList != null && caseAttachList.size() > 0) {
//之前已经生成过了,更新
int i = caseAttachMapper.updateCaseAttachBycaseid(caseAttach);
} else {
//之前没生成过,新增
int i = caseAttachMapper.save(caseAttach);
if (i > 0) {
if (arbitrateRecord1 != null) {
Integer annexId = caseAttach.getAnnexId();
//将附件id保存到仲裁记录表里面
arbitrateRecord1.setAnnexId(annexId);
arbitrateRecordMapper.updataArbitrateRecord(arbitrateRecord1);
}
}
}
//修改案件状态
caseApplication1.setCaseStatus(CaseApplicationConstants.VERPRIF_ARBITRATION);
caseApplicationMapper.submitCaseApplication(caseApplication1);
return AjaxResult.success("裁决书已生成"); return AjaxResult.success("裁决书已生成");
} catch (IOException e) { } catch (IOException e) {
return AjaxResult.error(e + "请检查文件路径是否有误"); return AjaxResult.error(e + "请检查文件路径是否有误");
} }
} }
/**
* 保存裁决书附件
* @param id 案件id
* @param saveName 保存的文件名
* @param savePath 保存路径
* @param caseApplicationById 案件基本信息
* @param arbitrateRecordSelect 出裁决书生成记录
*/
private void saveArbitorFile(Long id, String saveName, String savePath, CaseApplication caseApplicationById, ArbitrateRecord arbitrateRecordSelect) {
CaseAttach caseAttach = CaseAttach.builder()
.caseAppliId(id)
.annexName(saveName)
.annexPath(savePath)
.annexType(3)
.build();
//保存到附件表里,先判断之前有没有,有的话更新,没有的话新增
List<CaseAttach> caseAttachList = caseAttachMapper.getCaseAttachByCaseIdAndType(caseAttach);
if (caseAttachList != null && caseAttachList.size() > 0) {
//之前已经生成过了,更新
int i = caseAttachMapper.updateCaseAttachBycaseid(caseAttach);
} else {
//之前没生成过,新增
int i = caseAttachMapper.save(caseAttach);
if (i > 0) {
if (arbitrateRecordSelect != null) {
Integer annexId = caseAttach.getAnnexId();
//将附件id保存到仲裁记录表里面
arbitrateRecordSelect.setAnnexId(annexId);
arbitrateRecordMapper.updataArbitrateRecord(arbitrateRecordSelect);
}
}
}
//修改案件状态
caseApplicationById.setCaseStatus(CaseApplicationConstants.VERPRIF_ARBITRATION);
caseApplicationMapper.submitCaseApplication(caseApplicationById);
}
@Override @Override
@Transactional @Transactional
public AjaxResult sendDocumentByEmail(Long id, String appEmail, String resEmail, String apptrackingNum, String restrackingNum) { public AjaxResult sendDocumentByEmail(Long id, String appEmail, String resEmail, String apptrackingNum, String restrackingNum) {
@@ -1097,5 +1065,37 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
} }
} }
/**
* 根据裁决书模板获取所有的占位符,占位符必须是{{name}}格式
* @param path
* @return
*/
public List<String> getBookmarkByDocx(String path){
XWPFDocument xwpfDocument = null;
try {
FileInputStream fileInputStream = new FileInputStream(path);
xwpfDocument = new XWPFDocument(fileInputStream);
} catch (IOException e) {
e.printStackTrace();
}
List<XWPFParagraph> paragraphs = xwpfDocument.getParagraphs();
String regex = "\\{\\{.*?\\}\\}"; // 定义占位符的正则表达式
Pattern pattern = Pattern.compile(regex);
List<String> bookmarkList=new ArrayList<>();
for (XWPFParagraph paragraph : paragraphs) {
String text = paragraph.getText();
Matcher matcher = pattern.matcher(text);
while (matcher.find()) {
String placeholder = matcher.group();
String keyword = placeholder.substring(2, placeholder.length() - 2);
bookmarkList.add(keyword);
}
}
return bookmarkList;
}
} }
@@ -34,6 +34,7 @@ import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysRoleMapper; import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.mapper.SysUserRoleMapper; import com.ruoyi.system.mapper.SysUserRoleMapper;
import com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue;
import com.ruoyi.wisdomarbitrate.domain.vo.ReservedConferenceVO; import com.ruoyi.wisdomarbitrate.domain.vo.ReservedConferenceVO;
import com.ruoyi.wisdomarbitrate.domain.vo.ToDoCount; import com.ruoyi.wisdomarbitrate.domain.vo.ToDoCount;
import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils; import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
@@ -136,6 +137,10 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
private CaseAffiliateLogMapper caseAffiliateLogMapper; private CaseAffiliateLogMapper caseAffiliateLogMapper;
@Autowired @Autowired
private CaseAttachLogMapper caseAttachLogMapper; private CaseAttachLogMapper caseAttachLogMapper;
@Autowired
private FatchRuleMapper fatchRuleMapper;
@Autowired
private ColumnValueMapper columnValueMapper;
// 手机号正则 // 手机号正则
private static final Pattern TELEPHONE_REGX = Pattern.compile("^1(3\\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\\d|9[0-35-9])\\d{8}$"); private static final Pattern TELEPHONE_REGX = Pattern.compile("^1(3\\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\\d|9[0-35-9])\\d{8}$");
@@ -412,6 +417,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
String zipName = file.getOriginalFilename(); String zipName = file.getOriginalFilename();
String subzipName = zipName.substring(0, zipName.indexOf(".zip")); String subzipName = zipName.substring(0, zipName.indexOf(".zip"));
// String zipPath = "F:\\testZip\\uploadPath\\upload\\upload1\\unzipFile\\"+subzipName; // String zipPath = "F:\\testZip\\uploadPath\\upload\\upload1\\unzipFile\\"+subzipName;
// todo 服务器路径需要改
String zipPath = "/home/ruoyi/uploadPath/upload/unzipFile/" + subzipName; String zipPath = "/home/ruoyi/uploadPath/upload/unzipFile/" + subzipName;
// String zipPath = "D:/" + subzipName; // String zipPath = "D:/" + subzipName;
@@ -934,7 +940,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
*/ */
@Override @Override
@Transactional @Transactional
public int insertcaseApplication(CaseApplication caseApplication) { public int insertcaseApplication(CaseApplication caseApplication,Map<String,String> fatchMap) {
caseApplication.setCaseStatus(CaseApplicationConstants.CASE_APPLICATION); caseApplication.setCaseStatus(CaseApplicationConstants.CASE_APPLICATION);
//根据仲裁费用计费规则计算应缴费用 //根据仲裁费用计费规则计算应缴费用
@@ -1033,6 +1039,9 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
} }
caseAffiliateLogMapper.batchCaseAffiliate(caseAffiliates); caseAffiliateLogMapper.batchCaseAffiliate(caseAffiliates);
} }
// 新增动态配置字段值表
insertColumnValue(fatchMap,caseApplication.getCaseAppliId());
}); });
return rows; return rows;
@@ -2989,180 +2998,204 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
//解压缩上传的压缩包 //解压缩上传的压缩包
boolean unzipSuccess = UnZipFileUtils.unZipFile(zipFile, targetPath); boolean unzipSuccess = UnZipFileUtils.unZipFile(zipFile, targetPath);
if (unzipSuccess) { if (unzipSuccess) {
// 查询抓取规则
// todo 批次需要再上传压缩包时用户填写
List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId("9");
File directory = new File(targetPath); File directory = new File(targetPath);
Map<String,String> andConvertPDF = findAndConvertPDF(directory); Map<String,String> andConvertPDF = findAndConvertPDF(directory,fatchRuleList);
if (andConvertPDF != null && andConvertPDF.size() > 0) { if (andConvertPDF != null && andConvertPDF.size() > 0) {
Map<String, List<String>> map = new HashMap<>(); Map<String,String> fatchMap = new HashMap<>();
// oc识别pdf并组装数据 if(CollectionUtil.isNotEmpty(fatchRuleList)){
// 抓取申请书 Map<String, List<FatchRule>> fatchRuleMap = fatchRuleList.stream().collect(Collectors.groupingBy(FatchRule::getFileName));
if(!OCRAndBuildInfo(andConvertPDF, "仲裁申请书", map)){ // 根据抓取规则循环抓取
return AjaxResult.error("未找到该路径:"+andConvertPDF); for (Map.Entry<String, List<FatchRule>> entry : fatchRuleMap.entrySet()) {
OCRAndBuildInfo(andConvertPDF,entry.getKey(),fatchMap,entry.getValue());
}
} }
// 抓取调节协议书
if(!OCRAndBuildInfo(andConvertPDF, "调解协议", map)){
return AjaxResult.error("未找到该路径:"+andConvertPDF);
}
// 抓取合同
if(!OCRAndBuildInfo(andConvertPDF, "贷款合同", map)){
return AjaxResult.error("未找到该路径:"+andConvertPDF);
}
if(!OCRAndBuildInfo(andConvertPDF, "授权委托书", map)){
return AjaxResult.error("未找到该路径:"+andConvertPDF);
}
if (map.size()>0){ if (fatchMap.size()>0){
// todo 从压缩包中识别各字段填充到数据库 // todo 从压缩包中识别各字段填充到数据库
//调用新增案件的接口 //调用新增案件的接口
CaseApplication caseApplication = new CaseApplication(); CaseApplication caseApplication = new CaseApplication();
//默认案件标的 todo 案件标的是什么 //默认案件标的 todo 案件标的是什么
caseApplication.setCaseSubjectAmount(new BigDecimal(1)); caseApplication.setCaseSubjectAmount(new BigDecimal(1));
caseApplication.setApplicationOrganId(map.get("统一社会信用代码").get(0)); // todo 这些以后要去掉,不在案件基本信息表维护,现在往基本信息表设置字段是因为修改以及查询详情的时候页面中字段是固定的,以后也要动态维护字段
caseApplication.setArbitratClaims(map.get("仲裁请求").get(0)); // 仲裁请求
caseApplication.setFacts(map.get("事实和理由").get(0)); caseApplication.setArbitratClaims(fatchMap.get("arbitrationClaims"));
String contractNumber = map.get("合同编号").get(0); // 事实和理由
// 提取字母和数字 caseApplication.setFacts(fatchMap.get("factsAndReason"));
String regx="[^a-zA-Z0-9]"; // 合同编号
String replaceAll = contractNumber.replaceAll(regx, ""); String contractNumber = fatchMap.get("contractNumber");
if(StrUtil.isNotEmpty(contractNumber)) {
// 提取字母和数字
String regx = "[^a-zA-Z0-9]";
String replaceAll = contractNumber.replaceAll(regx, "");
caseApplication.setContractNumber(replaceAll.toUpperCase()); caseApplication.setContractNumber(replaceAll.toUpperCase());
String lonStartDate = map.get("或委托代理人签字:").get(0); }
// 借款开始日期
String lonStartDate = fatchMap.get("lonStartDate:");
SimpleDateFormat sdf = new SimpleDateFormat(); SimpleDateFormat sdf = new SimpleDateFormat();
sdf.applyPattern("yyyy年MM月dd日"); sdf.applyPattern("yyyy年MM月dd日");
try { if(StrUtil.isNotEmpty(lonStartDate)) {
caseApplication.setLoanStartDate( sdf.parse(lonStartDate));
} catch (ParseException e) {
e.printStackTrace();
}
// todo 查询同一批号的模板
// 金融消费纠纷基本情况
String disputes = map.get("金融消费纠纷基本情况").get(0);
String disputesTemplate="本案当事人甲{1}(下称“甲方”)于{2}向本案当事人乙{3}(下称“乙方”)申请{3}贷款,贷款金额人民币{4}元,贷款期限{5}期。截至{6},甲方尚欠乙方金额总计人民币{7}元。因甲方诉求与乙方进行协商还款。乙方为妥善解决纠纷,故申请调解中心进行调解。";
List<String> disputeList = getReplaceList(disputesTemplate, disputes);
if(CollectionUtil.isNotEmpty(disputeList)){
if(disputeList.size()>3){
caseApplication.setLoanType(disputeList.get(3));
}
if(disputeList.size()>4) {
String claimPrinciOwed = disputeList.get(4);
// 金额格式化
try {
Double.parseDouble(claimPrinciOwed);
caseApplication.setClaimPrinciOwed(new BigDecimal(claimPrinciOwed));
} catch (NumberFormatException e) {
String regEx = "[^0-9]";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(claimPrinciOwed);
String result = m.replaceAll("").trim();
BigDecimal bigDecimal = null;
if (claimPrinciOwed.contains("百")) {
bigDecimal = new BigDecimal(result).multiply(new BigDecimal("100"));
} else if (claimPrinciOwed.contains("千")) {
bigDecimal = new BigDecimal(result).multiply(new BigDecimal("1000"));
} else if (claimPrinciOwed.contains("万")) {
bigDecimal = new BigDecimal(result).multiply(new BigDecimal("10000"));
} else if (claimPrinciOwed.contains("百万")) {
bigDecimal = new BigDecimal(result).multiply(new BigDecimal("1000000"));
} else if (claimPrinciOwed.contains("千万")) {
bigDecimal = new BigDecimal(result).multiply(new BigDecimal("10000000"));
} else if (claimPrinciOwed.contains("亿")) {
bigDecimal = new BigDecimal(result).multiply(new BigDecimal("100000000"));
}
// todo 生产裁决书时金额格式增加千分位
// NumberFormat format = NumberFormat.getInstance();
// String format1 = format.format(bigDecimal);
caseApplication.setClaimPrinciOwed(bigDecimal);
}
}
if(disputeList.size()>5){
caseApplication.setLoanTerm(disputeList.get(5));
}
}
// 调解协议
String mediationAgreement = map.get("经调解,双方自愿达成如下协议").get(0);
caseApplication.setMediationAgreement(mediationAgreement);
String mediationAgreementTemplate="1、乙方从维系客户的角度出发,同意为甲方申请停催至{1},停催期间正常计息,且征信影响由甲方自行承担。2、甲方应于{2}停催到期前向乙方申请费息减免业务,并按人民币{3}元一次性结清剩余贷款。3、今后双方无涉,就此结案。";
// 对比模板和pdf识别的内容,取出占位符对应的值
List<String> mediationAgreementList = getReplaceList(mediationAgreementTemplate, mediationAgreement);
if(CollectionUtil.isNotEmpty(mediationAgreementList)){
// 截止日期
String lonEndDate = mediationAgreementList.get(0);
try { try {
caseApplication.setLoanEndDate( sdf.parse(lonEndDate)); caseApplication.setLoanStartDate(sdf.parse(lonStartDate));
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
if(mediationAgreementList.size()>2){
// 待还金额
caseApplication.setOutstandingMoney(mediationAgreementList.get(2));
}
} }
// 合同甲方 // todo 查询同一批号的模板
caseApplication.setPartyA(map.get("甲方(贷款人)").get(0)); // 金融消费纠纷基本情况
String disputes = fatchMap.get("disputes");
caseApplication.setDisputes(disputes);
// String disputesTemplate="本案当事人甲{1}(下称“甲方”)于{2}向本案当事人乙{3}(下称“乙方”)申请{3}贷款,贷款金额人民币{4}元,贷款期限{5}期。截至{6},甲方尚欠乙方金额总计人民币{7}元。因甲方诉求与乙方进行协商还款。乙方为妥善解决纠纷,故申请调解中心进行调解。";
// List<String> disputeList = getReplaceList(disputesTemplate, disputes);
// if(CollectionUtil.isNotEmpty(disputeList)){
// if(disputeList.size()>3){
// caseApplication.setLoanType(disputeList.get(3));
// }
// if(disputeList.size()>4) {
// String claimPrinciOwed = disputeList.get(4);
// // 金额格式化
// try {
// Double.parseDouble(claimPrinciOwed);
//
// caseApplication.setClaimPrinciOwed(new BigDecimal(claimPrinciOwed));
// } catch (NumberFormatException e) {
//
// String regEx = "[^0-9]";
// Pattern p = Pattern.compile(regEx);
// Matcher m = p.matcher(claimPrinciOwed);
// String result = m.replaceAll("").trim();
// BigDecimal bigDecimal = null;
// if (claimPrinciOwed.contains("百")) {
// bigDecimal = new BigDecimal(result).multiply(new BigDecimal("100"));
// } else if (claimPrinciOwed.contains("千")) {
// bigDecimal = new BigDecimal(result).multiply(new BigDecimal("1000"));
// } else if (claimPrinciOwed.contains("万")) {
// bigDecimal = new BigDecimal(result).multiply(new BigDecimal("10000"));
// } else if (claimPrinciOwed.contains("百万")) {
// bigDecimal = new BigDecimal(result).multiply(new BigDecimal("1000000"));
// } else if (claimPrinciOwed.contains("千万")) {
// bigDecimal = new BigDecimal(result).multiply(new BigDecimal("10000000"));
// } else if (claimPrinciOwed.contains("亿")) {
// bigDecimal = new BigDecimal(result).multiply(new BigDecimal("100000000"));
// }
// // todo 生产裁决书时金额格式增加千分位
// // NumberFormat format = NumberFormat.getInstance();
// // String format1 = format.format(bigDecimal);
//
// caseApplication.setClaimPrinciOwed(bigDecimal);
// }
// }
//
// if(disputeList.size()>5){
// caseApplication.setLoanTerm(disputeList.get(5));
// }
// }
// 调解协议内容
String mediationAgreement = fatchMap.get("mediationAgreement");
caseApplication.setMediationAgreement(mediationAgreement);
// String mediationAgreementTemplate="1、乙方从维系客户的角度出发,同意为甲方申请停催至{1},停催期间正常计息,且征信影响由甲方自行承担。2、甲方应于{2}停催到期前向乙方申请费息减免业务,并按人民币{3}元一次性结清剩余贷款。3、今后双方无涉,就此结案。";
// // 对比模板和pdf识别的内容,取出占位符对应的值
// List<String> mediationAgreementList = getReplaceList(mediationAgreementTemplate, mediationAgreement);
// if(CollectionUtil.isNotEmpty(mediationAgreementList)){
// // 截止日期
// String lonEndDate = mediationAgreementList.get(0);
// try {
// caseApplication.setLoanEndDate( sdf.parse(lonEndDate));
// } catch (ParseException e) {
// e.printStackTrace();
// }
// if(mediationAgreementList.size()>2){
// // 待还金额
// caseApplication.setOutstandingMoney(mediationAgreementList.get(2));
// }
// }
// 合同甲方(贷款人)
caseApplication.setPartyA(fatchMap.get("partyA"));
List<CaseAffiliate> caseAffiliates = new ArrayList<>(); List<CaseAffiliate> caseAffiliates = new ArrayList<>();
CaseAffiliate caseAffiliate = new CaseAffiliate(); CaseAffiliate caseAffiliate = new CaseAffiliate();
caseAffiliate.setIdentityType(1); caseAffiliate.setIdentityType(1);
caseAffiliate.setName(map.get("申请人").get(0)); // 申请人
caseAffiliate.setIdentityNum(map.get("统一社会信用代码").get(0)); caseAffiliate.setName(fatchMap.get("applicantName"));
caseAffiliate.setCompLegalPerson(map.get("负责人").get(0)); // 统一社会信用代码
if(map.get("职务").size()>0) { caseAffiliate.setIdentityNum(fatchMap.get("creditCode"));
// 法定代表人职务 // 法定代表人
caseAffiliate.setCompLegalperPost(map.get("职务").get(0)); caseAffiliate.setCompLegalPerson(fatchMap.get("legalRepresentative"));
if(map.get("职务").size()>1) { // 申请人联系电话
// 代理人职务 caseAffiliate.setContactTelphone(fatchMap.get("applicantPhone"));
caseAffiliate.setAppliAgentTitle(map.get("职务").get(1)); // 申请人住所
} caseAffiliate.setResidenAffili(fatchMap.get("applicantHome"));
} // 申请人联系地址
caseAffiliate.setNameAgent(map.get("委托代理人").get(0)); caseAffiliate.setContactAddress(fatchMap.get("applicantAddress"));
caseAffiliate.setContactTelphoneAgent(map.get("联系电话").get(0)); // if(map.get("职务").size()>0) {
caseAffiliate.setResidenAffili(map.get("住所").get(0)); // // 法定代表人职务
caseAffiliate.setContactAddress(map.get("联系地址").get(0)); // caseAffiliate.setCompLegalperPost(map.get("职务").get(0));
caseAffiliate.setAgentEmail(map.get("电子邮件").get(0).replaceAll("\\s", "")); // if(map.get("职务").size()>1) {
// // 代理人职务
// caseAffiliate.setAppliAgentTitle(map.get("职务").get(1));
// }
// }
// 委托代理人
caseAffiliate.setNameAgent(fatchMap.get("agentName"));
// 委托代理人联系电话
caseAffiliate.setContactTelphoneAgent(fatchMap.get("agentPhone"));
// 代理人电子邮件
caseAffiliate.setAgentEmail(fatchMap.get("agentEmail").replaceAll("\\s", ""));
//设置默认代理人的身份证号码,暂时写死 要不然新增方法报错 //设置默认代理人的身份证号码,暂时写死 要不然新增方法报错
// caseAffiliate.setIdentityNumAgent("610423199603171716"); // caseAffiliate.setIdentityNumAgent("610423199603171716");
caseAffiliates.add(caseAffiliate); caseAffiliates.add(caseAffiliate);
CaseAffiliate caseAffiliate1 = new CaseAffiliate(); // 被申请人信息
caseAffiliate1.setIdentityType(2); CaseAffiliate respondentAffiliate = new CaseAffiliate();
caseAffiliate1.setName(map.get("被申请人").get(0)); respondentAffiliate.setIdentityType(2);
// 被申请人名称
respondentAffiliate.setName(fatchMap.get("respondentName"));
// 被申请人身份证 // 被申请人身份证
String identityNum = map.get("居民身份证号码").get(0); String identityNum = fatchMap.get("respondentCard");
caseAffiliate1.setIdentityNum(identityNum); // 出生年月日,从身份证抓取
// 被申请人电子邮件 if(StrUtil.isNotEmpty(identityNum)) {
if(map.get("乙方确认有效的电子信箱地址为").size()>1) { Map<String, String> identityNumMap = getBirAgeSex(identityNum);
if(map.get("乙方确认有效的电子信箱地址为").get(0).contains("/")) { String birthday = identityNumMap.get("birthday");
caseAffiliate1.setEmail(map.get("乙方确认有效的电子信箱地址为").get(1).replaceAll("\\s", "")); if(StrUtil.isNotEmpty(birthday)) {
}else { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
caseAffiliate1.setEmail(map.get("乙方确认有效的电子信箱地址为").get(0).replaceAll("\\s", "")); Date birthdayDate = null;
} try {
} birthdayDate = simpleDateFormat.parse(birthday);
// 出生年月日,从身份证抓取 } catch (Exception e) {
if(StrUtil.isNotEmpty(identityNum)) { e.printStackTrace();
Map<String, String> identityNumMap = getBirAgeSex(identityNum);
String birthday = identityNumMap.get("birthday");
if(StrUtil.isNotEmpty(birthday)) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date birthdayDate = null;
try {
birthdayDate = simpleDateFormat.parse(birthday);
} catch (Exception e) {
e.printStackTrace();
}
caseAffiliate1.setResponBirth(birthdayDate);
} }
//从身份证抓取性别 fatchMap.put("resDateOfBirth", sdf.format(birthdayDate));
caseAffiliate1.setResponSex(identityNumMap.get("sexCode")); respondentAffiliate.setResponBirth(birthdayDate);
} }
caseAffiliate1.setContactTelphone(map.get("联系电话").get(1)); //从身份证抓取性别
caseAffiliate1.setResidenAffili(map.get("住所").get(1)); fatchMap.put("resSex",identityNumMap.get("sexCode"));
respondentAffiliate.setResponSex(identityNumMap.get("sexCode"));
}
respondentAffiliate.setIdentityNum(identityNum);
// 被申请人电子邮件
// if(map.get("乙方确认有效的电子信箱地址为").size()>1) {
// if(map.get("乙方确认有效的电子信箱地址为").get(0).contains("/")) {
// respondentAffiliate.setEmail(map.get("乙方确认有效的电子信箱地址为").get(1).replaceAll("\\s", ""));
// }else {
// respondentAffiliate.setEmail(map.get("乙方确认有效的电子信箱地址为").get(0).replaceAll("\\s", ""));
// }
// }
// 被申请人电子邮件
respondentAffiliate.setEmail(fatchMap.get("respondentEmail").replaceAll("\\s", ""));
// 被申请人联系电话
respondentAffiliate.setContactTelphone(fatchMap.get("respondentPhone"));
// 被申请人住所
respondentAffiliate.setResidenAffili(fatchMap.get("respondentHome"));
caseAffiliates.add(caseAffiliate1); caseAffiliates.add(respondentAffiliate);
caseApplication.setCaseAffiliates(caseAffiliates); caseApplication.setCaseAffiliates(caseAffiliates);
this.insertcaseApplication(caseApplication); // 新增案件基本信息表
this.insertcaseApplication(caseApplication,fatchMap);
if (null != caseApplication.getId()) { if (null != caseApplication.getId()) {
List<CaseAttach> caseAttachs=new ArrayList<>(); List<CaseAttach> caseAttachs=new ArrayList<>();
for (Map.Entry<String, String> entry : andConvertPDF.entrySet()) { for (Map.Entry<String, String> entry : andConvertPDF.entrySet()) {
@@ -3199,49 +3232,54 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
return null; return null;
} }
private boolean OCRAndBuildInfo( Map<String, String> andConvertPDF, String mapKey, Map<String, List<String>> map) { /**
* 新增动态配置字段值表
* @param fatchMap
* @param caseApplicId
*/
private void insertColumnValue(Map<String, String> fatchMap, Long caseApplicId) {
if(fatchMap==null){
return;
}
// 新增到动态配置字段表
List<ColumnValue> columnValueList=new ArrayList<>();
// todo 新增完案件信息表后这样改
fatchMap.forEach((key,value)->{
ColumnValue columnValue = new ColumnValue();
columnValue.setCaseId(caseApplicId);
columnValue.setColumn(key);
columnValue.setValue(value);
// todo 组装的map中的key需要column+@+columnName拼接
columnValue.setName("");
columnValueList.add(columnValue);
});
if(CollectionUtil.isNotEmpty(columnValueList)){
// 批量新增
columnValueMapper.batchSave(columnValueList);
}
}
private boolean OCRAndBuildInfo( Map<String, String> andConvertPDF,String mapKey, Map<String, String> map, List<FatchRule> fatchRules) {
String pdfUrl = andConvertPDF.get(mapKey); String pdfUrl = andConvertPDF.get(mapKey);
if(StrUtil.isEmpty(pdfUrl)){ if(StrUtil.isNotEmpty(pdfUrl)) {
throw new ServiceException("pdfUrl:"+pdfUrl+"===mapKey:"+mapKey); //获取文件的页数
// return false; int fileNumPage = getFileNumPage(pdfUrl);
} //文件转成base64
//获取文件的页数 String base64 = OCRUtils.pdfConvertBase64(pdfUrl);
int fileNumPage = getFileNumPage(pdfUrl); if (base64 == null) {
//文件转成base64 throw new ServiceException("文件转成base64,转码失败");
String base64 = OCRUtils.pdfConvertBase64(pdfUrl); // return false;
if (base64 == null){
throw new ServiceException("文件转成base64 pdfUrl:"+pdfUrl+"===mapKey:"+mapKey);
// return false;
}
StringBuilder stringBuilder = new StringBuilder(); // 创建一个StringBuilder对象
for (int i = 0; i < fileNumPage; i++) {
//对接腾讯云接口.识别里面的数据
String text = OCRUtils.pdfIdentifyText(base64, i + 1,mapKey);
if (stringBuilder.length() > 0) {
stringBuilder.append(Constants.BR); // 在已有内容的情况下添加逗号分隔符
} }
stringBuilder.append(text); // 拼接当前的字符串 StringBuilder ocrText = new StringBuilder(); // 创建一个StringBuilder对象
} for (int i = 0; i < fileNumPage; i++) {
// 将字符串按逗号分隔符切割 //对接腾讯云接口.识别里面的数据
String[] fields = stringBuilder.toString().split(Constants.BR); String text = OCRUtils.pdfIdentifyText(base64, i + 1, fatchRules);
for (String field : fields) { ocrText.append(text); // 拼接当前的字符串
// 对于每个字段,再按冒号分隔符拆分出键和值 }
String[] keyValue = field.split(Constants.PDFSTR); if(StrUtil.isNotEmpty(ocrText)){
if (keyValue.length >= 2) { OCRUtils.fatchRuleGetContent(ocrText.toString(), fatchRules,map);
String key = keyValue[0];
String value = keyValue[1];
// 判断Map中是否已存在该键
if (map.containsKey(key)) {
// 如果已存在,获取该键对应的值,并将新的值添加到集合中
List<String> values = map.get(key);
values.add(value);
} else {
// 如果不存在,创建一个新的集合,并将值添加到集合中
List<String> values = new ArrayList<>();
values.add(value);
map.put(key, values);
}
} }
} }
return true; return true;
@@ -3303,7 +3341,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
} }
public static Map<String,String> findAndConvertPDF(File directory) { public static Map<String,String> findAndConvertPDF(File directory, List<FatchRule> fatchRuleList ) {
Map<String,String> pdfPathMap= new HashMap<>(); Map<String,String> pdfPathMap= new HashMap<>();
if (directory.isFile()) { if (directory.isFile()) {
String path = ""; String path = "";
@@ -3320,46 +3358,16 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
path = pdfPath; path = pdfPath;
} }
} }
if (path != null) {
// 如果文件名包含"仲裁申请书"且是PDF格式,直接返回路径 // 如果文件名包含"仲裁申请书"且是PDF格式,直接返回路径
// 如果是PDF格式,直接添加到列表中 // 如果是PDF格式,直接添加到列表中
String name=""; // if(CollectionUtil.isNotEmpty(fatchRuleList)) {
if (directory.getName().contains("仲裁申请书")) { // for (FatchRule fatchRule : fatchRuleList) {
name="仲裁申请书"; // if(fatchRule.getFileName().contains(directory.getName())){
} pdfPathMap.put(directory.getName(), path);
if (directory.getName().contains("调解协议")) { // }
name="调解协议"; // }
} //
if (directory.getName().contains("情况说明")) { // }
name="情况说明";
}
if (directory.getName().contains("贷款合同")) {
name="贷款合同";
}
if (directory.getName().contains("营业执照")) {
name="营业执照";
}
if (directory.getName().contains("负责人证明")) {
name="负责人证明";
}
if (directory.getName().contains("负责人身份证")) {
name="负责人身份证";
}
if (directory.getName().contains("授权委托书")) {
name="授权委托书";
}
if (directory.getName().contains("经办人员的劳动合同")) {
name="经办人员的劳动合同";
}
if (directory.getName().contains("经办人员身份证")) {
name="经办人员的身份证";
}
if (directory.getName().contains("自然人身份证")) {
name="自然人身份证";
}
pdfPathMap.put(name,path);
}
// } // }
} else if (directory.isDirectory()) { } else if (directory.isDirectory()) {
searchAndConvertPDF(directory, pdfPathMap); searchAndConvertPDF(directory, pdfPathMap);
@@ -3391,51 +3399,18 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
continue; continue;
} }
if (file.isFile()) { if (file.isFile()) {
String name="";
if (file.getName().contains("仲裁申请书")) {
name="仲裁申请书";
}
if (file.getName().contains("调解协议")) {
name="调解协议";
}
if (file.getName().contains("情况说明")) {
name="情况说明";
}
if (file.getName().contains("贷款合同")) {
name="贷款合同";
}
if (file.getName().contains("营业执照")) {
name="营业执照";
}
if (file.getName().contains("负责人证明")) {
name="负责人证明";
}
if (file.getName().contains("负责人身份证")) {
name="负责人身份证";
}
if (file.getName().contains("授权委托书")) {
name="授权委托书";
}
if (file.getName().contains("经办人员的劳动合同")) {
name="经办人员的劳动合同";
}
if (file.getName().contains("经办人员的身份证")) {
name="经办人员身份证";
}
if (file.getName().contains("自然人身份证")) {
name="自然人身份证";
}
// 如果是文件且文件名包含"仲裁申请书" // 如果是文件且文件名包含"仲裁申请书"
// if (file.getName().contains("仲裁申请书")) { // if (file.getName().contains("仲裁申请书")) {
if (isPDF(file)) { if (isPDF(file)) {
// 如果是PDF格式,直接添加到列表中 // 如果是PDF格式,直接添加到列表中
pdfPathMap.put(name,file.getAbsolutePath()); pdfPathMap.put(file.getName(),file.getAbsolutePath());
} else { } else {
// 如果不是PDF格式,进行转换成PDF并添加转换后的路径到列表中 // 如果不是PDF格式,进行转换成PDF并添加转换后的路径到列表中
String pdfPath = convertToPDF(file); String pdfPath = convertToPDF(file);
if (pdfPath != null) { if (pdfPath != null) {
// 如果是PDF格式,直接添加到列表中 // 如果是PDF格式,直接添加到列表中
pdfPathMap.put(name,pdfPath); pdfPathMap.put(file.getName(),pdfPath);
} }
} }
@@ -1,23 +1,25 @@
package com.ruoyi.wisdomarbitrate.utils; package com.ruoyi.wisdomarbitrate.utils;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.wisdomarbitrate.domain.FatchRule;
import com.tencentcloudapi.bsca.v20210811.models.LicenseSummary; import com.tencentcloudapi.bsca.v20210811.models.LicenseSummary;
import com.tencentcloudapi.common.Credential; import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException; import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile; import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile; import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.ocr.v20181119.OcrClient; import com.tencentcloudapi.ocr.v20181119.OcrClient;
import com.tencentcloudapi.ocr.v20181119.models.SmartStructuralOCRV2Request; import com.tencentcloudapi.ocr.v20181119.models.*;
import com.tencentcloudapi.ocr.v20181119.models.SmartStructuralOCRV2Response;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.*;
import java.util.Base64; import java.util.stream.Collectors;
import java.util.List;
public class OCRUtils { public class OCRUtils {
//API的SecretId //API的SecretId
@@ -34,8 +36,88 @@ public class OCRUtils {
private static final String[] accordName = {"金融消费纠纷基本情况","经调解,双方自愿达成如下协议"}; private static final String[] accordName = {"金融消费纠纷基本情况","经调解,双方自愿达成如下协议"};
// 授权委托书识别字段 // 授权委托书识别字段
private static final String[] powerAttorneyName = {"职务"}; private static final String[] powerAttorneyName = {"职务"};
/**
* pdf识别成文字
* @param imageBase64
* @param pageNumber
* @param fatchRules 抓取规则
* @return
*/
public static String pdfIdentifyText(String imageBase64, Integer pageNumber, List<FatchRule> fatchRules) {
StringBuilder respStr=new StringBuilder();
try {
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
Credential cred = new Credential(SECRET_ID, SECRET_KEY);
// 实例化一个http选项,可选的,没有特殊需求可以跳过
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("ocr.tencentcloudapi.com");
// 实例化一个client选项,可选的,没有特殊需求可以跳过
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
// 实例化要请求产品的client对象,clientProfile是可选的
OcrClient client = new OcrClient(cred, "ap-beijing", clientProfile);
// 实例化一个请求对象,每个接口都会对应一个request对象
GeneralAccurateOCRRequest req = new GeneralAccurateOCRRequest();
req.setImageBase64(imageBase64);
req.setIsPdf(true);
req.setPdfPageNumber(pageNumber.longValue());
// 返回的resp是一个SmartStructuralOCRV2Response的实例,与请求对象对应
GeneralAccurateOCRResponse resp = client.GeneralAccurateOCR(req);
// 输出json格式的字符串回包
System.out.println(GeneralAccurateOCRResponse.toJsonString(resp));
// 获取响应内容
TextDetection[] textDetections = resp.getTextDetections();
if (textDetections == null || textDetections.length == 0) {
return respStr.toString();
}
for (TextDetection textDetection : textDetections) {
respStr.append(textDetection.getDetectedText());
}
}catch (TencentCloudSDKException e){
throw new ServiceException("ocr识别失败");
}
if(respStr.toString().endsWith(String.valueOf(pageNumber))){
int lastIndexOf = respStr.toString().lastIndexOf(String.valueOf(pageNumber));
return respStr.toString().substring(0,lastIndexOf);
}
return respStr.toString();
//
// //解析数据
// String s = GeneralAccurateOCRResponse.toJsonString(resp);
// // 解析JSON数据
// JSONObject jsonObject = new JSONObject(s);
// JSONArray structuralList = jsonObject.getJSONArray("TextDetections");
// // 遍历StructuralList中的Groups,获取Key对应的AutoName和Value对应的AutoConten
// StringBuilder stringBuilder = new StringBuilder(); // 创建一个StringBuilder对象
// for (int i = 0; i < structuralList.length(); i++) {
// JSONArray groups = structuralList.getJSONObject(i).getJSONArray("Groups");
// for (int j = 0; j < groups.length(); j++) {
// JSONArray lines = groups.getJSONObject(j).getJSONArray("Lines");
// for (int k = 0; k < lines.length(); k++) {
// JSONObject line = lines.getJSONObject(k);
// JSONObject key = line.getJSONObject("Key");
// JSONObject value = line.getJSONObject("Value");
// String autoName = key.getString("AutoName");
// String autoContent = value.getString("AutoContent");
// String text = autoName + Constants.PDFSTR + autoContent;
// if (stringBuilder.length() > 0) {
// stringBuilder.append(Constants.BR); // 在已有内容的情况下添加逗号分隔符
// }
// stringBuilder.append(text); // 拼接当前的字符串
// }
// }
// }
// return stringBuilder.toString(); // 获取最终的拼接结果
// } catch (TencentCloudSDKException e) {
// System.out.println(e.toString());
// }
}
/** /**
* pdf识别成文字 * pdf识别成文字
* @param imageBase64 * @param imageBase64
@@ -43,7 +125,7 @@ public class OCRUtils {
* @param type pdf类型 * @param type pdf类型
* @return * @return
*/ */
public static String pdfIdentifyText(String imageBase64, Integer pageNumber,String type) { public static String pdfIdentifyText1(String imageBase64, Integer pageNumber,String type) {
try { try {
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密 // 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305 // 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
@@ -122,4 +204,36 @@ public class OCRUtils {
return null; return null;
} }
/**
* 根据抓取规则获取内容
* @param ocrText ocr识别的text
* @param fatchRules 抓取规则
* @return
*/
public static void fatchRuleGetContent(String ocrText, List<FatchRule> fatchRules, Map<String, String> fatchMap) {
if (CollectionUtil.isNotEmpty(fatchRules)) {
for (FatchRule fatchRule : fatchRules) {
if (StrUtil.isEmpty(fatchRule.getStartContent())) {
continue;
}
// 开始截取字符串 申请人:赵会
// String[] startContentSplit = ocrText.split(fatchRule.getStartContent());
int startFirstIndex = ocrText.indexOf(fatchRule.getStartContent()) + fatchRule.getStartContent().length();
if (ocrText.length() >= startFirstIndex) {
ocrText = ocrText.substring(startFirstIndex);
}
if (StrUtil.isNotEmpty(fatchRule.getEndContent())) {
int endFirstIndex = ocrText.indexOf(fatchRule.getEndContent()) + fatchRule.getEndContent().length();
if (ocrText.length() >= (endFirstIndex-fatchRule.getEndContent().length())) {
fatchMap.put(fatchRule.getColumn(), ocrText.substring(0, endFirstIndex-fatchRule.getEndContent().length()));
ocrText = ocrText.substring(endFirstIndex-fatchRule.getEndContent().length());
}
}
}
}
}
} }
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.wisdomarbitrate.mapper.ColumnValueMapper">
<resultMap id="BaseResultMap" type="com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue" >
<result column="id" property="id" />
<result column="column" property="column" />
<result column="name" property="name" />
<result column="value" property="value" />
<result column="case_id" property="caseId" />
</resultMap>
<insert id="batchSave">
INSERT INTO column_value ( `COLUMN`, `NAME`, `VALUE`, case_id )
values
<foreach item="item" index="index" collection="list" separator=",">
(#{item.column},#{item.name},#{item.value},#{item.caseId})
</foreach>
</insert>
<select id="listByCaseId" resultMap="BaseResultMap">
select * from column_value where case_id=#{caseId}
</select>
</mapper>
@@ -5,16 +5,16 @@
<mapper namespace="com.ruoyi.wisdomarbitrate.mapper.FatchRuleMapper"> <mapper namespace="com.ruoyi.wisdomarbitrate.mapper.FatchRuleMapper">
<resultMap id="BaseResultMap" type="com.ruoyi.wisdomarbitrate.domain.FatchRule" > <resultMap id="BaseResultMap" type="com.ruoyi.wisdomarbitrate.domain.FatchRule" >
<result column="id" property="id" /> <result column="id" property="id" />
<result column="batch_number" property="batchNumber" />
<result column="file_name" property="fileName" /> <result column="file_name" property="fileName" />
<result column="start_content" property="startContent" /> <result column="start_content" property="startContent" />
<result column="end_content" property="endContent" /> <result column="end_content" property="endContent" />
<result column="column" property="column" /> <result column="column" property="column" />
<result column="is_default" property="isDefault" /> <result column="column_name" property="columnName" />
<result column="columnName" property="columnName" />
</resultMap> </resultMap>
<select id="list" resultMap="BaseResultMap"> <select id="listByTemplateId" resultMap="BaseResultMap">
select * from fatch_rule where batch_number=#{batchNumber} select fr.* from fatch_rule fr join template_fatch_rule tfr on fr.id=tfr.fatch_rule_id
where template_id=#{templateId}
</select> </select>
<select id="selectFatchRuleList" parameterType="FatchRule" resultMap="BaseResultMap"> <select id="selectFatchRuleList" parameterType="FatchRule" resultMap="BaseResultMap">