PC端人脸核身

This commit is contained in:
18792927508
2024-04-23 18:03:53 +08:00
parent 0fb56c95db
commit cc4d7139dc
7 changed files with 290 additions and 313 deletions
@@ -23,7 +23,7 @@ public class IdentityAuthenticationController extends BaseController {
@Anonymous @Anonymous
@PostMapping("/selectIdentityAuthenticaEIDtoken") @PostMapping("/selectIdentityAuthenticaEIDtoken")
public AjaxResult selectIdentityAuthenticaEIDtoken() { public AjaxResult selectIdentityAuthenticaEIDtoken() {
JSONObject tokenResult = identityAuthenticationService.selectIdentityAuthenticaEIDtoken(false); JSONObject tokenResult = identityAuthenticationService.selectIdentityAuthEIDToken(false);
return success(tokenResult); return success(tokenResult);
} }
/** /**
@@ -32,7 +32,7 @@ public class IdentityAuthenticationController extends BaseController {
@Anonymous @Anonymous
@PostMapping("/selectPCIdentityAuthenticaEIDtoken") @PostMapping("/selectPCIdentityAuthenticaEIDtoken")
public AjaxResult selectPCIdentityAuthenticaEIDtoken() { public AjaxResult selectPCIdentityAuthenticaEIDtoken() {
JSONObject tokenResult = identityAuthenticationService.selectIdentityAuthenticaEIDtoken(true); JSONObject tokenResult = identityAuthenticationService.selectIdentityAuthEIDToken(true);
return success(tokenResult); return success(tokenResult);
} }
/** /**
@@ -22,6 +22,7 @@ public enum AnnexTypeEnum implements EnumsInterface {
SEAL_PICTURE(10, "印章图片"), SEAL_PICTURE(10, "印章图片"),
FLOW_SVG(11, "流程节点SVG"), FLOW_SVG(11, "流程节点SVG"),
MEETING_FILE(12, "被申请人证据"), MEETING_FILE(12, "被申请人证据"),
MEDIATE_BOOK_PDF(13, "PDF调解书或和解协议"),
; ;
@@ -22,7 +22,7 @@ public interface IdentityAuthenticationService {
* isPC 是否PC端 * isPC 是否PC端
* @return * @return
*/ */
JSONObject selectIdentityAuthenticaEIDtoken(boolean isPC); JSONObject selectIdentityAuthEIDToken(boolean isPC);
/** /**
* 小程序人脸核身后查询身份认证结果 * 小程序人脸核身后查询身份认证结果
@@ -2,6 +2,7 @@ package com.ruoyi.wisdomarbitrate.service.miniprogress.impl;
import cn.hutool.core.codec.Base64; import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SmUtil; import cn.hutool.crypto.SmUtil;
import cn.hutool.crypto.asymmetric.SM2; import cn.hutool.crypto.asymmetric.SM2;
import cn.hutool.crypto.symmetric.SymmetricCrypto; import cn.hutool.crypto.symmetric.SymmetricCrypto;
@@ -90,7 +91,7 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication
* @return * @return
*/ */
@Override @Override
public JSONObject selectIdentityAuthenticaEIDtoken(boolean isPC) { public JSONObject selectIdentityAuthEIDToken(boolean isPC) {
JSONObject objJSON = new JSONObject(); JSONObject objJSON = new JSONObject();
objJSON.put("EidToken", ""); objJSON.put("EidToken", "");
try { try {
@@ -116,8 +117,7 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication
String respJSON = GetEidTokenResponse.toJsonString(resp); String respJSON = GetEidTokenResponse.toJsonString(resp);
objJSON = JSON.parseObject(respJSON); objJSON = JSON.parseObject(respJSON);
} catch (TencentCloudSDKException e) { } catch (TencentCloudSDKException e) {
System.out.println(e.toString()); throw new ServiceException("获取Eidtoken失败");
System.out.println("获取Eidtoken失败");
} }
return objJSON; return objJSON;
} }
@@ -139,7 +139,7 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication
parse = JSON.parseObject(s); parse = JSON.parseObject(s);
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println(e.toString()); throw new ServiceException(e.getMessage());
} }
return parse; return parse;
} }
@@ -226,13 +226,14 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication
} }
return AjaxResult.success(authentication); return AjaxResult.success(authentication);
} catch (TencentCloudSDKException e) { } catch (TencentCloudSDKException e) {
System.out.println(e.toString()); return AjaxResult.error(e.getMessage());
} }
return AjaxResult.success();
} }
@Override @Override
public JSONObject selectPCEIDtokenStatus(String eidToken) { public JSONObject selectPCEIDtokenStatus(String eidToken) {
// todo 送达时需要判断是否有pdf版的调解书,没有则不送达,签名完后下载pdf时不删除之前的doc调解书,上传调解书时,pdf的需要将类型设为13,异步发送短信邮件时将登录用户传参过来
// todo E证通审核过后将PC端的机器id在YML文件中改掉
JSONObject objJSON = null; JSONObject objJSON = null;
try { try {
Credential cred = new Credential(credentialSecretId, credentialSecretKey); Credential cred = new Credential(credentialSecretId, credentialSecretKey);
@@ -251,7 +252,9 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication
GetEidResultResponse resp = client.GetEidResult(req); GetEidResultResponse resp = client.GetEidResult(req);
// 输出json格式的字符串回包,Status String 枚举:init:token未验证 doing: 验证中 finished: 验证完成 timeout: token已超时 // 输出json格式的字符串回包,Status String 枚举:init:token未验证 doing: 验证中 finished: 验证完成 timeout: token已超时
String s = GetEidResultResponse.toJsonString(resp); String s = GetEidResultResponse.toJsonString(resp);
if(StrUtil.isNotEmpty(s)) {
objJSON = JSON.parseObject(s); objJSON = JSON.parseObject(s);
}
} catch (TencentCloudSDKException e) { } catch (TencentCloudSDKException e) {
throw new ServiceException("获取E证通Token状态失败"); throw new ServiceException("获取E证通Token状态失败");
} }
@@ -1,9 +1,11 @@
package com.ruoyi.wisdomarbitrate.service.mscase; package com.ruoyi.wisdomarbitrate.service.mscase;
import com.google.gson.Gson;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.EsignDemoException; import com.ruoyi.common.exception.EsignDemoException;
import com.ruoyi.wisdomarbitrate.domain.dto.mscase.MsSignSealDTO; import com.ruoyi.wisdomarbitrate.domain.dto.mscase.MsSignSealDTO;
import com.ruoyi.wisdomarbitrate.domain.dto.mscase.SealSignRecord; import com.ruoyi.wisdomarbitrate.domain.dto.mscase.SealSignRecord;
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseApplication;
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseLogRecordVO; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseLogRecordVO;
import java.io.IOException; import java.io.IOException;
@@ -32,4 +34,13 @@ public interface MsSignSealService {
AjaxResult signSeaalCaseApplicaCallback(String reqbodystr) throws EsignDemoException, IOException; AjaxResult signSeaalCaseApplicaCallback(String reqbodystr) throws EsignDemoException, IOException;
AjaxResult sealCheckCallback(String reqbodystr) throws EsignDemoException, IOException; AjaxResult sealCheckCallback(String reqbodystr) throws EsignDemoException, IOException;
/**
* 签名后下载调解书
* @param caseApplicationselect 案件信息
* @param signFlowId 签名流程id
* @param gson
* @param caseAppliId 案件id
*/
void downloadMediationBook(MsCaseApplication caseApplicationselect, String signFlowId, Gson gson, Long caseAppliId);
} }
@@ -3119,14 +3119,16 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
application.setCaseStatusName(caseFlow.getCaseStatusName()); application.setCaseStatusName(caseFlow.getCaseStatusName());
application.setMediaResult(mediaResult); application.setMediaResult(mediaResult);
msCaseApplicationMapper.updateByPrimaryKeySelective(application); msCaseApplicationMapper.updateByPrimaryKeySelective(application);
// 新增日志
CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), "");
if (mediaResult == 2 || mediaResult == 3 || mediaResult == 4) { if (mediaResult == 2 || mediaResult == 3 || mediaResult == 4) {
CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), null); CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), null);
// 结束对接北明,为调解失败状态 // 结束对接北明,为调解失败状态
caseApplicationService.pushStatusToBM(application, PushCaseStatusEnum.FAIL); caseApplicationService.pushStatusToBM(application, PushCaseStatusEnum.FAIL);
} }
}else {
msCaseApplicationMapper.updateByPrimaryKeySelective(application);
} }
// 新增日志
CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), "");
return AjaxResult.success(); return AjaxResult.success();
} }
@@ -78,9 +78,12 @@ import java.util.stream.Collectors;
import static com.google.common.io.Files.getFileExtension; import static com.google.common.io.Files.getFileExtension;
import static com.ruoyi.common.core.domain.AjaxResult.success; import static com.ruoyi.common.core.domain.AjaxResult.success;
@Slf4j @Slf4j
@Service @Service
public class MsSignSealServiceImpl implements MsSignSealService { public class MsSignSealServiceImpl implements MsSignSealService {
@Autowired
private MsSignSealService msSignSealService;
@Autowired @Autowired
MsCaseApplicationMapper msCaseApplicationMapper; MsCaseApplicationMapper msCaseApplicationMapper;
@@ -135,8 +138,6 @@ public class MsSignSealServiceImpl implements MsSignSealService {
ShortMessageService shortMessageService; ShortMessageService shortMessageService;
@Override @Override
@Transactional @Transactional
public AjaxResult sealApply(MsSignSealDTO dto) { public AjaxResult sealApply(MsSignSealDTO dto) {
@@ -341,86 +342,24 @@ public class MsSignSealServiceImpl implements MsSignSealService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AjaxResult msCaseFile(List<Long> ids) { public AjaxResult msCaseFile(List<Long> ids) {
// todo StringBuilder error = new StringBuilder();
try { try {
for (Long id : ids) { for (Long id : ids) {
MsCaseApplication caseApplication1 = msCaseApplicationMapper.selectByPrimaryKey(id); MsCaseApplication caseApplication1 = msCaseApplicationMapper.selectByPrimaryKey(id);
if (caseApplication1 == null) { if (caseApplication1 != null) {
return AjaxResult.error("未查询到相关案件");
}
MsCaseApplicationVO msCaseApplicationVO = new MsCaseApplicationVO(); MsCaseApplicationVO msCaseApplicationVO = new MsCaseApplicationVO();
BeanUtil.copyProperties(caseApplication1, msCaseApplicationVO); BeanUtil.copyProperties(caseApplication1, msCaseApplicationVO);
List<MsCaseAttach> caseAttachList = msCaseAttachMapper.queryCaseAttachList(msCaseApplicationVO); List<MsCaseAttach> caseAttachList = msCaseAttachMapper.queryCaseAttachList(msCaseApplicationVO);
if (caseAttachList != null && caseAttachList.size() > 0) { // 只能送达pdf版调解书
for (MsCaseAttach caseAttach : caseAttachList) {
if (caseAttach.getAnnexType() == AnnexTypeEnum.MEDIATE_BOOK.getCode()) {
String prefix = "/profile";
int startIndex = prefix.length();
String annexPath = caseAttach.getAnnexPath();
String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex+1);
File file = new File(path);
if (!file.exists()) {
Gson gson = new Gson();
MsSealSignRecord sealSignRecord = new MsSealSignRecord();
sealSignRecord.setCaseAppliId(id);
List<MsSealSignRecord> sealSignRecords = sealSignRecordMapper.selectSealSignRecord(sealSignRecord);
if (sealSignRecords != null && sealSignRecords.size() > 0) {
String signFlowid = sealSignRecords.get(0).getSignFlowId();
EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowid);
JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class);
JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data");
JsonArray filesArray = fileDownloadData.get("files").getAsJsonArray();
if (filesArray != null && filesArray.size() > 0) {
JsonObject fileObject = (JsonObject) filesArray.get(0);
String fileDownloadUrl = fileObject.get("downloadUrl").toString();
String filearbitraUrl = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1);
LocalDate now = LocalDate.now(); if (CollectionUtil.isNotEmpty(caseAttachList)) {
String year = Integer.toString(now.getYear()); long count = caseAttachList.stream().filter(msCaseAttach -> msCaseAttach.getAnnexType() != null && msCaseAttach.getAnnexType().equals(AnnexTypeEnum.MEDIATE_BOOK_PDF.getCode())).count();
String month = String.format("%02d", now.getMonthValue()); if (count > 0) {
String day = String.format("%02d", now.getDayOfMonth());
String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
String fileName = UUID.randomUUID().toString().replace("-", "") + ".pdf";
String saveName = fileName;
String savePath = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
// 创建日期目录
File saveFolder = new File(saveFolderPath);
if (!saveFolder.exists()) {
saveFolder.mkdirs();
}
String resultFilePath = saveFolderPath + "/" + fileName;
File resultFilePathFile = new File(resultFilePath);
if (!resultFilePathFile.exists()) {
resultFilePathFile.createNewFile();
}
boolean downLoadFile = FileTransformation.downLoadFileByUrl(filearbitraUrl, resultFilePath);
if (downLoadFile) {
MsCaseAttach caseAttach1 = new MsCaseAttach();
caseAttach1.setCaseAppliId(id);
caseAttach1.setAnnexType(7);
caseAttach1.setAnnexPath(savePath);
caseAttach1.setAnnexName(saveName);
msCaseAttachMapper.updateCaseAttachBycaseid(caseAttach1);
caseAttach.setAnnexPath(savePath);
caseAttach.setAnnexName(saveName);
}
}
}
}
}
}
}
Integer caseFlowId = caseApplication1.getCaseFlowId(); Integer caseFlowId = caseApplication1.getCaseFlowId();
// 查询当前节点 // 查询当前节点
MsCaseFlow currentFlow = caseFlowMapper.selectByPrimaryKey(caseFlowId); MsCaseFlow currentFlow = caseFlowMapper.selectByPrimaryKey(caseFlowId);
if(currentFlow==null){ if (currentFlow != null) {
return AjaxResult.error("未找到当前流程节点");
}
// 根据流程id查找下一个流程节点 // 根据流程id查找下一个流程节点
MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseFlowId); MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseFlowId);
caseApplication1.setCaseFlowId(nextFlow.getId()); caseApplication1.setCaseFlowId(nextFlow.getId());
@@ -429,16 +368,12 @@ public class MsSignSealServiceImpl implements MsSignSealService {
// 获取案件相关人员 // 获取案件相关人员
List<MsCaseAffiliate> affiliates = applicationService.selectAffliatesByCaseId(id); List<MsCaseAffiliate> affiliates = applicationService.selectAffliatesByCaseId(id);
if(CollectionUtil.isEmpty(affiliates)){ if (CollectionUtil.isNotEmpty(affiliates)) {
return AjaxResult.error("未找到案件相关人员");
}
// 申请操作人 // 申请操作人
Optional<MsCaseAffiliate> applicantAffiliateOpt = affiliates.stream().filter(affiliate -> affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(1) || affiliate.getRoleType().equals(2))).findFirst(); Optional<MsCaseAffiliate> applicantAffiliateOpt = affiliates.stream().filter(affiliate -> affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(1) || affiliate.getRoleType().equals(2))).findFirst();
// 被申请操作人 // 被申请操作人
Optional<MsCaseAffiliate> resAffiliateOpt = affiliates.stream().filter(affiliate -> affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(3) || affiliate.getRoleType().equals(4))).findFirst(); Optional<MsCaseAffiliate> resAffiliateOpt = affiliates.stream().filter(affiliate -> affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(3) || affiliate.getRoleType().equals(4))).findFirst();
if (!applicantAffiliateOpt.isPresent() || !resAffiliateOpt.isPresent()) { if (applicantAffiliateOpt.isPresent() && resAffiliateOpt.isPresent()) {
throw new ServiceException("未找到案件操作人员");
}
ExecutorService executor = ThreadUtil.createThreadPool(); ExecutorService executor = ThreadUtil.createThreadPool();
// 发送邮件 // 发送邮件
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
@@ -447,7 +382,8 @@ public class MsSignSealServiceImpl implements MsSignSealService {
} }
if (!StrUtil.isEmpty(resAffiliateOpt.get().getEmail())) { if (!StrUtil.isEmpty(resAffiliateOpt.get().getEmail())) {
boolean appEmailFlag = sendCaseEmail(caseApplication1, resAffiliateOpt.get().getEmail(), caseAttachList); boolean appEmailFlag = sendCaseEmail(caseApplication1, resAffiliateOpt.get().getEmail(), caseAttachList);
} }, executor); }
}, executor);
// 发送签收短信,2126313 尊敬的{1}用户,您的{2}文件已发送至邮箱,请点击链接进行确认签收https://txroom.xayunmei.com/#/sign?{3},如非本人操作,请忽略本短信 // 发送签收短信,2126313 尊敬的{1}用户,您的{2}文件已发送至邮箱,请点击链接进行确认签收https://txroom.xayunmei.com/#/sign?{3},如非本人操作,请忽略本短信
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
SysUser sysUser = sysUserMapper.selectUserById(applicantAffiliateOpt.get().getUserId()); SysUser sysUser = sysUserMapper.selectUserById(applicantAffiliateOpt.get().getUserId());
@@ -461,16 +397,30 @@ public class MsSignSealServiceImpl implements MsSignSealService {
sendEmail(caseApplication1, sysUser, "调解系统文件签收", content); sendEmail(caseApplication1, sysUser, "调解系统文件签收", content);
} }
}, executor); }, executor);
}
}
}
CaseLogUtils.insertCaseLog(caseApplication1.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), ""); CaseLogUtils.insertCaseLog(caseApplication1.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), "");
} else {
error.append("案件编号为" + caseApplication1.getCaseNum() + "未找到pdf版调解书,请上传\r\n");
}
} else {
error.append("案件编号为" + caseApplication1.getCaseNum() + "未找到pdf版调解书,请上传\r\n");
}
}
} }
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException("调解书发送失败"); throw new ServiceException("调解书发送失败");
} }
if (error.length() > 0) {
return AjaxResult.error(error.toString());
}
return AjaxResult.success(""); return AjaxResult.success("");
} }
public void sendEmail(MsCaseApplication application, SysUser user, String subject, String sendContent) { public void sendEmail(MsCaseApplication application, SysUser user, String subject, String sendContent) {
boolean emailFlag = emailOutUtil.sendMessage(user.getEmail(), subject, sendContent, null, null); boolean emailFlag = emailOutUtil.sendMessage(user.getEmail(), subject, sendContent, null, null);
@@ -498,6 +448,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
msSendMailHistoryRecord.setId(null); msSendMailHistoryRecord.setId(null);
sendMailHistoryRecordMapper.insertSelective(msSendMailHistoryRecord); sendMailHistoryRecordMapper.insertSelective(msSendMailHistoryRecord);
} }
@Override @Override
@Transactional @Transactional
public AjaxResult msCaseSign(MsSignSealDTO dto) { public AjaxResult msCaseSign(MsSignSealDTO dto) {
@@ -782,7 +733,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
sealSignRecordsel.setSignFlowStatus(3); sealSignRecordsel.setSignFlowStatus(3);
sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel);
// 下载调解书 // 下载调解书
downloadMediationBook(caseApplicationselect,signFlowId,gson,caseAppliId); msSignSealService.downloadMediationBook(caseApplicationselect, signFlowId, gson, caseAppliId);
} }
} }
@@ -824,7 +775,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
sealSignRecordsel.setSignFlowStatus(3); sealSignRecordsel.setSignFlowStatus(3);
sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel);
// 下载调解书 // 下载调解书
downloadMediationBook(caseApplicationselect,signFlowId,gson,caseAppliId); msSignSealService.downloadMediationBook(caseApplicationselect, signFlowId, gson, caseAppliId);
} }
} }
@@ -866,7 +817,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
sealSignRecordsel.setSignFlowStatus(3); sealSignRecordsel.setSignFlowStatus(3);
sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel);
// 下载调解书 // 下载调解书
downloadMediationBook(caseApplicationselect,signFlowId,gson,caseAppliId); msSignSealService.downloadMediationBook(caseApplicationselect, signFlowId, gson, caseAppliId);
} }
} }
@@ -892,7 +843,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
caseApplicationMapper.updateByPrimaryKeySelective(application); caseApplicationMapper.updateByPrimaryKeySelective(application);
//下载审核完成的调解书 //下载审核完成的调解书
downloadMediationBook(caseApplicationselect,signFlowId,gson,caseAppliId); msSignSealService.downloadMediationBook(caseApplicationselect, signFlowId, gson, caseAppliId);
} }
@@ -922,7 +873,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel);
//下载审核完成的调解书 //下载审核完成的调解书
downloadMediationBook(caseApplicationselect,signFlowId,gson,caseAppliId); msSignSealService.downloadMediationBook(caseApplicationselect, signFlowId, gson, caseAppliId);
// EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId); // EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId);
// JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class); // JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class);
// JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data"); // JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data");
@@ -1013,7 +964,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel);
//下载审核完成的调解书 //下载审核完成的调解书
downloadMediationBook(caseApplicationselect,signFlowId,gson,caseAppliId); msSignSealService.downloadMediationBook(caseApplicationselect, signFlowId, gson, caseAppliId);
// EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId); // EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId);
// JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class); // JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class);
// JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data"); // JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data");
@@ -1090,14 +1041,25 @@ public class MsSignSealServiceImpl implements MsSignSealService {
return AjaxResult.success("success"); return AjaxResult.success("success");
} }
private void downloadMediationBook(MsCaseApplication caseApplicationselect, String signFlowId, Gson gson, Long caseAppliId) throws EsignDemoException, IOException { /**
log.info("signFlowId===="+signFlowId); * 下载调解书
EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId); *
log.info("下载成功===="+fileDownload); * @param caseApplicationselect
* @param signFlowId
* @param gson
* @param caseAppliId
* @throws EsignDemoException
* @throws IOException
*/
@Transactional
public void downloadMediationBook(MsCaseApplication caseApplicationselect, String signFlowId, Gson gson, Long caseAppliId) {
EsignHttpResponse fileDownload = null;
try {
fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId);
JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class); JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class);
JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data"); JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data");
JsonArray filesArray = fileDownloadData.get("files").getAsJsonArray(); JsonArray filesArray = fileDownloadData.get("files").getAsJsonArray();
log.info("下载调解书pdf===="+filesArray);
if (filesArray != null && filesArray.size() > 0) { if (filesArray != null && filesArray.size() > 0) {
JsonObject fileObject = (JsonObject) filesArray.get(0); JsonObject fileObject = (JsonObject) filesArray.get(0);
String fileDownloadUrl = fileObject.get("downloadUrl").toString(); String fileDownloadUrl = fileObject.get("downloadUrl").toString();
@@ -1123,11 +1085,10 @@ public class MsSignSealServiceImpl implements MsSignSealService {
String fileDownloadUrlnew = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1); String fileDownloadUrlnew = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1);
boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath); boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath);
log.info("是否下载成功======="+downLoadFile);
if (downLoadFile) { if (downLoadFile) {
// 先删除已经存在的调解书 // 先删除已经存在的pdf调解书
if (StrUtil.isEmpty(caseApplicationselect.getCaseSource())) { if (StrUtil.isEmpty(caseApplicationselect.getCaseSource())) {
List<MsCaseAttach> existAttach = msCaseAttachMapper.listCaseAttachByCaseIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK.getCode()); List<MsCaseAttach> existAttach = msCaseAttachMapper.listCaseAttachByCaseIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK_PDF.getCode());
if (CollectionUtil.isNotEmpty(existAttach)) { if (CollectionUtil.isNotEmpty(existAttach)) {
// 对接北明,同步案件状态,删除 // 对接北明,同步案件状态,删除
for (MsCaseAttach msCaseAttach : existAttach) { for (MsCaseAttach msCaseAttach : existAttach) {
@@ -1138,15 +1099,14 @@ public class MsSignSealServiceImpl implements MsSignSealService {
} }
} }
} }
msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK.getCode()); msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK_PDF.getCode());
MsCaseAttach caseAttach = new MsCaseAttach(); MsCaseAttach caseAttach = new MsCaseAttach();
caseAttach.setCaseAppliId(caseAppliId); caseAttach.setCaseAppliId(caseAppliId);
caseAttach.setAnnexType(AnnexTypeEnum.MEDIATE_BOOK.getCode()); caseAttach.setAnnexType(AnnexTypeEnum.MEDIATE_BOOK_PDF.getCode());
caseAttach.setAnnexPath(savePath); caseAttach.setAnnexPath(savePath);
caseAttach.setAnnexName(saveName); caseAttach.setAnnexName(saveName);
caseAttach.setSuffix(getFileExtension(caseAttach.getAnnexPath())); caseAttach.setSuffix(getFileExtension(caseAttach.getAnnexPath()));
log.info("调解书保存======="+downLoadFile);
caseAttachMapper.save(caseAttach); caseAttachMapper.save(caseAttach);
// 对接北明,调用上传附件接口 // 对接北明,调用上传附件接口
if (StrUtil.isEmpty(caseApplicationselect.getCaseSource())) { if (StrUtil.isEmpty(caseApplicationselect.getCaseSource())) {
@@ -1163,6 +1123,9 @@ public class MsSignSealServiceImpl implements MsSignSealService {
} }
} }
} catch (Exception e) {
throw new ServiceException("E签宝下载调解书失败");
}
} }
@@ -1258,7 +1221,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
Long fileId = null; Long fileId = null;
if (caseAttachList != null && caseAttachList.size() > 0) { if (caseAttachList != null && caseAttachList.size() > 0) {
for (MsCaseAttach caseAttach : caseAttachList) { for (MsCaseAttach caseAttach : caseAttachList) {
if (Objects.equals(caseAttach.getAnnexType(), AnnexTypeEnum.MEDIATE_BOOK.getCode())) { if (Objects.equals(caseAttach.getAnnexType(), AnnexTypeEnum.MEDIATE_BOOK_PDF.getCode())) {
String prefix = "/profile"; String prefix = "/profile";
int startIndex = prefix.length(); int startIndex = prefix.length();
String annexPath = caseAttach.getAnnexPath(); String annexPath = caseAttach.getAnnexPath();
@@ -1315,7 +1278,4 @@ public class MsSignSealServiceImpl implements MsSignSealService {
} }
} }