立案申请组庭功能开发

This commit is contained in:
qitz
2023-09-14 18:40:44 +08:00
parent b43f38c9dd
commit 891c67f39f
19 changed files with 921 additions and 11 deletions
@@ -0,0 +1,12 @@
package com.ruoyi.wisdomarbitrate.service;
import com.ruoyi.wisdomarbitrate.domain.Arbitrator;
import java.util.List;
public interface IArbitratorService {
List<Arbitrator> selectArbitratorList(Arbitrator arbitrator);
}
@@ -19,4 +19,10 @@ public interface ICaseApplicationService {
int deletecaseApplicationByIds(CaseApplication caseApplication);
CaseApplication selectCaseApplication(CaseApplication caseApplication);
String importCaseApplication(List<CaseApplication> caseApplicationList, String operName);
int pendTral(CaseApplication caseApplication);
int pendingAppointArbotrar(CaseApplication caseApplication);
}
@@ -0,0 +1,9 @@
package com.ruoyi.wisdomarbitrate.service;
import com.ruoyi.wisdomarbitrate.domain.IdentityAuthentication;
public interface IdentityAuthenticationService {
IdentityAuthentication selectIdentityInformation();
}
@@ -0,0 +1,28 @@
package com.ruoyi.wisdomarbitrate.service.impl;
import com.ruoyi.wisdomarbitrate.domain.Arbitrator;
import com.ruoyi.wisdomarbitrate.mapper.ArbitratorMapper;
import com.ruoyi.wisdomarbitrate.service.IArbitratorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ArbitratorServiceImpl implements IArbitratorService {
@Autowired
private ArbitratorMapper arbitratorMapper;
@Override
public List<Arbitrator> selectArbitratorList(Arbitrator arbitrator) {
return arbitratorMapper.selectArbitratorList(arbitrator);
}
}
@@ -1,6 +1,10 @@
package com.ruoyi.wisdomarbitrate.service.impl;
import com.ruoyi.common.constant.CaseApplicationConstants;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.wisdomarbitrate.domain.Arbitrator;
import com.ruoyi.wisdomarbitrate.domain.CaseAffiliate;
import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
import com.ruoyi.wisdomarbitrate.mapper.CaseAffiliateMapper;
@@ -11,9 +15,15 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.TreeSet;
import java.util.stream.Collectors;
import static com.ruoyi.common.core.domain.AjaxResult.error;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toCollection;
@Service
public class CaseApplicationServiceImpl implements ICaseApplicationService {
@@ -89,10 +99,162 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
CaseAffiliate caseAffiliate = new CaseAffiliate();
caseAffiliate.setCaseAppliId(caseApplication.getId());
List<CaseAffiliate> caseAffiliatListeselect = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
caseApplicationselect.setCaseAffiliates(caseAffiliatListeselect);
if(caseApplicationselect!=null){
caseApplicationselect.setCaseAffiliates(caseAffiliatListeselect);
}
return caseApplicationselect;
}
@Override
@Transactional
public String importCaseApplication(List<CaseApplication> caseApplicationList, String operName) {
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
int successNum = 0;
int failureNum = 0;
if(caseApplicationList!=null&&caseApplicationList.size()>0){
List<CaseApplication> caseApplicationListinsert = new ArrayList<>();
for (int i = 0; i < caseApplicationList.size(); i++){
CaseApplication caseApplication = caseApplicationList.get(i);
//赋值CaseApplication的案件关联人信息
List<CaseAffiliate> caseAffiliatesnew = new ArrayList<>();
assignmentCaseAffiliates(caseApplication,caseAffiliatesnew);
int caseApplicationCount = selectCaseApplicationCount(caseApplication);
if(caseApplicationCount>0){
failureNum++;
failureMsg.append("<br/>" + failureNum + "、立案编号 " + caseApplication.getCaseNum() + " 已存在");
}else {
caseApplicationListinsert.add(caseApplication);
}
}
if(caseApplicationListinsert!=null&&caseApplicationListinsert.size()>0){
List<CaseApplication> caseApplicationListinsertDiffer = caseApplicationListinsert.stream().collect(
collectingAndThen(
toCollection(() -> new TreeSet<>(Comparator.comparing(CaseApplication::getCaseNum))),
ArrayList::new));
//对不重复的立案对象集合的立案对象重新组装对应的案件关联人信息
if(caseApplicationListinsertDiffer!=null&&caseApplicationListinsertDiffer.size()>0){
List<CaseApplication> caseApplicationNewList = new ArrayList<>();
for (int i = 0; i < caseApplicationListinsertDiffer.size(); i++){
CaseApplication caseApplicationinsertDiffer = caseApplicationListinsertDiffer.get(i);
List<CaseAffiliate> caseAffiliatesnew = new ArrayList<>();
CaseApplication caseApplicationNew = new CaseApplication();
copyCaseApplication(caseApplicationinsertDiffer,caseApplicationNew);
if(caseApplicationListinsert!=null&&caseApplicationListinsert.size()>0){
for (int j = 0; j < caseApplicationListinsert.size(); j++){
CaseApplication caseApplicationinsert = caseApplicationListinsert.get(j);
if(StringUtils.isNotEmpty(caseApplicationinsert.getCaseNum())&&
caseApplicationinsert.getCaseNum().equals(caseApplicationinsertDiffer.getCaseNum())){
caseAffiliatesnew.addAll(caseApplicationinsert.getCaseAffiliates());
}
}
caseApplicationNew.setCaseAffiliates(caseAffiliatesnew);
caseApplicationNewList.add(caseApplicationNew);
}
for (int k = 0; k < caseApplicationNewList.size(); k++){
CaseApplication caseApplicationItera = caseApplicationNewList.get(k);
// 新增立案信息
caseApplicationItera.setCaseStatus(CaseApplicationConstants.CASE_APPLICATION);
int rows = caseApplicationMapper.insertCaseApplication(caseApplicationItera);
List<CaseAffiliate> caseAffiliates = caseApplicationItera.getCaseAffiliates();
if(caseAffiliates!=null&&caseAffiliates.size()>0){
for (CaseAffiliate caseAffiliate : caseAffiliates){
caseAffiliate.setCaseAppliId(caseApplicationItera.getId());
}
caseAffiliateMapper.batchCaseAffiliate(caseAffiliates);
}
successNum++;
successMsg.append("<br/>" + successNum + "、立案编号 " + caseApplicationItera.getCaseNum() + " 导入成功");
}
}
}
}
}else {
throw new ServiceException("导入立案申请数据不能为空!");
}
return successMsg.toString();
}
@Override
@Transactional
public int pendTral(CaseApplication caseApplication) {
List<Arbitrator> arbitrators = caseApplication.getArbitrators();
int rows = 0;
if(arbitrators!=null&&arbitrators.size()>0){
List<Long> ids = arbitrators.stream().map(Arbitrator::getId).collect(Collectors.toList());
List<String> arbitratorNames = arbitrators.stream().map(Arbitrator::getArbitratorName).collect(Collectors.toList());
String idstr = ids.stream().map(Object::toString).collect(Collectors.joining(","));
String arbitratorNamestr = arbitratorNames.stream().map(Object::toString).collect(Collectors.joining(","));
caseApplication.setArbitratorId(idstr);
caseApplication.setArbitratorName(arbitratorNamestr);
caseApplication.setCaseStatus(CaseApplicationConstants.CONFIRMDED_PENDING_TRIAL);
rows = caseApplicationMapper.submitCaseApplication(caseApplication);
}
return rows;
}
@Override
@Transactional
public int pendingAppointArbotrar(CaseApplication caseApplication) {
int pendingAppointArbotrar = caseApplication.getPendingAppointArbotrar();
List<Arbitrator> arbitrators = caseApplication.getArbitrators();
int rows = 0;
if(pendingAppointArbotrar==1){
if(arbitrators!=null&&arbitrators.size()>0){
List<Long> ids = arbitrators.stream().map(Arbitrator::getId).collect(Collectors.toList());
List<String> arbitratorNames = arbitrators.stream().map(Arbitrator::getArbitratorName).collect(Collectors.toList());
String idstr = ids.stream().map(Object::toString).collect(Collectors.joining(","));
String arbitratorNamestr = arbitratorNames.stream().map(Object::toString).collect(Collectors.joining(","));
caseApplication.setArbitratorId(idstr);
caseApplication.setArbitratorName(arbitratorNamestr);
caseApplication.setCaseStatus(CaseApplicationConstants.CONFIRMDED_PENDING_TRIAL);
caseApplication.setPendingAppointArbotrar(1);
rows = caseApplicationMapper.submitCaseApplication(caseApplication);
}
}else {
caseApplication.setCaseStatus(CaseApplicationConstants.PENDING_TRIAL);
caseApplication.setPendingAppointArbotrar(2);
rows = caseApplicationMapper.submitCaseApplication(caseApplication);
}
return rows;
}
private void assignmentCaseAffiliates(CaseApplication caseApplication, List<CaseAffiliate> caseAffiliatesnew) {
CaseAffiliate caseAffiliate = new CaseAffiliate();
// BeanUtils.copyBeanProp(caseApplication,caseAffiliate);
BeanUtils.copyBeanProp(caseAffiliate,caseApplication);
caseAffiliatesnew.add(caseAffiliate);
caseApplication.setCaseAffiliates(caseAffiliatesnew);
}
private void copyCaseApplication(CaseApplication caseApplicationinsertDiffer, CaseApplication caseApplicationNew) {
caseApplicationNew.setArbitratClaims(caseApplicationinsertDiffer.getArbitratClaims());
caseApplicationNew.setCaseNum(caseApplicationinsertDiffer.getCaseNum());
caseApplicationNew.setCaseSubjectAmount(caseApplicationinsertDiffer.getCaseSubjectAmount());
caseApplicationNew.setLoanStartDate(caseApplicationinsertDiffer.getLoanStartDate());
caseApplicationNew.setLoanEndDate(caseApplicationinsertDiffer.getLoanEndDate());
caseApplicationNew.setContractNumber(caseApplicationinsertDiffer.getContractNumber());
caseApplicationNew.setClaimInterestOwed(caseApplicationinsertDiffer.getClaimInterestOwed());
caseApplicationNew.setClaimPrinciOwed(caseApplicationinsertDiffer.getClaimPrinciOwed());
caseApplicationNew.setClaimLiquidDamag(caseApplicationinsertDiffer.getClaimLiquidDamag());
}
}
@@ -0,0 +1,98 @@
package com.ruoyi.wisdomarbitrate.service.impl;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.wisdomarbitrate.domain.IdentityAuthentication;
import com.ruoyi.wisdomarbitrate.mapper.IdentityAuthenticationMapper;
import com.ruoyi.wisdomarbitrate.service.ICaseApplicationService;
import com.ruoyi.wisdomarbitrate.service.IdentityAuthenticationService;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.ocr.v20181119.OcrClient;
import com.tencentcloudapi.ocr.v20181119.models.RecognizeTableAccurateOCRRequest;
import com.tencentcloudapi.ocr.v20181119.models.RecognizeTableAccurateOCRResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Base64;
@Service
public class IdentityAuthenticationServiceImpl implements IdentityAuthenticationService {
@Value("${identityAuthentication.credentialSecretId}")
private String credentialSecretId;
@Value("${identityAuthentication.credentialSecretKey}")
private String credentialSecretKey;
@Autowired
private IdentityAuthenticationMapper identityAuthenticationMapper;
private static final Logger log = LoggerFactory.getLogger(IdentityAuthenticationServiceImpl.class);
@Override
public IdentityAuthentication selectIdentityInformation() {
IdentityAuthentication identityAuthentication = new IdentityAuthentication();
try{
Credential credIdentityAuthentication = new Credential(credentialSecretId, credentialSecretKey);
HttpProfile httpProfileIdentityAuthentication = new HttpProfile();
httpProfileIdentityAuthentication.setEndpoint("ocr.tencentcloudapi.com");
String imagePathIdentityAuthentication = "本地png/jpg文件的绝对地址";
InputStream inputStreamIdentityAuthentication = null;
byte[] buffer = null;
//读取图片字节数组
try {
inputStreamIdentityAuthentication = new FileInputStream(imagePathIdentityAuthentication);
int count = 0;
while (count == 0) {
count = inputStreamIdentityAuthentication.available();
}
buffer = new byte[count];
inputStreamIdentityAuthentication.read(buffer);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (inputStreamIdentityAuthentication != null) {
try {
// 关闭inputStream流
inputStreamIdentityAuthentication.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
String imageBase64IdentityAuthentication = Base64.getEncoder().encodeToString(buffer);
ClientProfile clientProfileIdentityAuthentication = new ClientProfile();
clientProfileIdentityAuthentication.setHttpProfile(httpProfileIdentityAuthentication);
OcrClient clientIdentityAuthentication = new OcrClient(credIdentityAuthentication, "ap-shanghai", clientProfileIdentityAuthentication);
RecognizeTableAccurateOCRRequest reqIdentityAuthentication = new RecognizeTableAccurateOCRRequest();
reqIdentityAuthentication.setImageBase64(imageBase64IdentityAuthentication);
RecognizeTableAccurateOCRResponse respIdentityAuthentication = clientIdentityAuthentication.RecognizeTableAccurateOCR(reqIdentityAuthentication);
String stringRes = RecognizeTableAccurateOCRResponse.toJsonString(respIdentityAuthentication);
JSONObject stringObjectRes = (JSONObject) JSON.parse(stringRes);
JSONObject stringres = (JSONObject) stringObjectRes.get("Response");
identityAuthentication.setName(stringres.get("name").toString());
identityAuthentication.setIdentityNo(stringres.get("IdNum").toString());
// System.out.println(RecognizeTableAccurateOCRResponse.toJsonString(respIdentityAuthentication);
} catch (TencentCloudSDKException e) {
log.error("身份认证失败", e);
}
return identityAuthentication;
}
}