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
@PostMapping("/selectIdentityAuthenticaEIDtoken")
public AjaxResult selectIdentityAuthenticaEIDtoken() {
JSONObject tokenResult = identityAuthenticationService.selectIdentityAuthenticaEIDtoken(false);
JSONObject tokenResult = identityAuthenticationService.selectIdentityAuthEIDToken(false);
return success(tokenResult);
}
/**
@@ -32,7 +32,7 @@ public class IdentityAuthenticationController extends BaseController {
@Anonymous
@PostMapping("/selectPCIdentityAuthenticaEIDtoken")
public AjaxResult selectPCIdentityAuthenticaEIDtoken() {
JSONObject tokenResult = identityAuthenticationService.selectIdentityAuthenticaEIDtoken(true);
JSONObject tokenResult = identityAuthenticationService.selectIdentityAuthEIDToken(true);
return success(tokenResult);
}
/**
@@ -22,6 +22,7 @@ public enum AnnexTypeEnum implements EnumsInterface {
SEAL_PICTURE(10, "印章图片"),
FLOW_SVG(11, "流程节点SVG"),
MEETING_FILE(12, "被申请人证据"),
MEDIATE_BOOK_PDF(13, "PDF调解书或和解协议"),
;
@@ -22,7 +22,7 @@ public interface IdentityAuthenticationService {
* isPC 是否PC端
* @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.util.StrUtil;
import cn.hutool.crypto.SmUtil;
import cn.hutool.crypto.asymmetric.SM2;
import cn.hutool.crypto.symmetric.SymmetricCrypto;
@@ -90,7 +91,7 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication
* @return
*/
@Override
public JSONObject selectIdentityAuthenticaEIDtoken(boolean isPC) {
public JSONObject selectIdentityAuthEIDToken(boolean isPC) {
JSONObject objJSON = new JSONObject();
objJSON.put("EidToken", "");
try {
@@ -116,8 +117,7 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication
String respJSON = GetEidTokenResponse.toJsonString(resp);
objJSON = JSON.parseObject(respJSON);
} catch (TencentCloudSDKException e) {
System.out.println(e.toString());
System.out.println("获取Eidtoken失败");
throw new ServiceException("获取Eidtoken失败");
}
return objJSON;
}
@@ -139,7 +139,7 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication
parse = JSON.parseObject(s);
}
} catch (Exception e) {
System.out.println(e.toString());
throw new ServiceException(e.getMessage());
}
return parse;
}
@@ -226,13 +226,14 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication
}
return AjaxResult.success(authentication);
} catch (TencentCloudSDKException e) {
System.out.println(e.toString());
return AjaxResult.error(e.getMessage());
}
return AjaxResult.success();
}
@Override
public JSONObject selectPCEIDtokenStatus(String eidToken) {
// todo 送达时需要判断是否有pdf版的调解书,没有则不送达,签名完后下载pdf时不删除之前的doc调解书,上传调解书时,pdf的需要将类型设为13,异步发送短信邮件时将登录用户传参过来
// todo E证通审核过后将PC端的机器id在YML文件中改掉
JSONObject objJSON = null;
try {
Credential cred = new Credential(credentialSecretId, credentialSecretKey);
@@ -251,7 +252,9 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication
GetEidResultResponse resp = client.GetEidResult(req);
// 输出json格式的字符串回包,Status String 枚举:init:token未验证 doing: 验证中 finished: 验证完成 timeout: token已超时
String s = GetEidResultResponse.toJsonString(resp);
objJSON = JSON.parseObject(s);
if(StrUtil.isNotEmpty(s)) {
objJSON = JSON.parseObject(s);
}
} catch (TencentCloudSDKException e) {
throw new ServiceException("获取E证通Token状态失败");
}
@@ -1,9 +1,11 @@
package com.ruoyi.wisdomarbitrate.service.mscase;
import com.google.gson.Gson;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.EsignDemoException;
import com.ruoyi.wisdomarbitrate.domain.dto.mscase.MsSignSealDTO;
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 java.io.IOException;
@@ -32,4 +34,13 @@ public interface MsSignSealService {
AjaxResult signSeaalCaseApplicaCallback(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);
}
@@ -3114,19 +3114,21 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
.execute();
}
MsCaseFlow caseFlow = caseFlowMapper.selectOneByExample(flowExample);
if (caseFlow != null) {
if (caseFlow != null ) {
application.setCaseFlowId(caseFlow.getId());
application.setCaseStatusName(caseFlow.getCaseStatusName());
application.setMediaResult(mediaResult);
msCaseApplicationMapper.updateByPrimaryKeySelective(application);
// 新增日志
CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), "");
if (mediaResult == 2 || mediaResult == 3 || mediaResult == 4) {
CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), null);
// 结束对接北明,为调解失败状态
caseApplicationService.pushStatusToBM(application, PushCaseStatusEnum.FAIL);
}
}else {
msCaseApplicationMapper.updateByPrimaryKeySelective(application);
}
// 新增日志
CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), "");
return AjaxResult.success();
}
@@ -78,9 +78,12 @@ import java.util.stream.Collectors;
import static com.google.common.io.Files.getFileExtension;
import static com.ruoyi.common.core.domain.AjaxResult.success;
@Slf4j
@Service
public class MsSignSealServiceImpl implements MsSignSealService {
@Autowired
private MsSignSealService msSignSealService;
@Autowired
MsCaseApplicationMapper msCaseApplicationMapper;
@@ -135,8 +138,6 @@ public class MsSignSealServiceImpl implements MsSignSealService {
ShortMessageService shortMessageService;
@Override
@Transactional
public AjaxResult sealApply(MsSignSealDTO dto) {
@@ -161,7 +162,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
application.setCaseFlowId(nextFlow.getId());
application.setCaseStatusName(nextFlow.getCaseStatusName());
caseApplicationMapper.updateByPrimaryKeySelective(application);
CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),null);
CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), null);
}
} else {
// 单独
@@ -171,7 +172,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
application.setCaseFlowId(nextFlow.getId());
application.setCaseStatusName(nextFlow.getCaseStatusName());
caseApplicationMapper.updateByPrimaryKeySelective(application);
CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),null);
CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), null);
}
return AjaxResult.success("用印申请成功");
@@ -217,13 +218,13 @@ public class MsSignSealServiceImpl implements MsSignSealService {
if (records != null && records.size() > 0) {
for (MsCaseLogRecordVO msCaseLogRecordVO : records) {
String content = msCaseLogRecordVO.getCaseStatusName();
if(StringUtils.isNotEmpty(content)){
if(content.equals("结束")){
if (StringUtils.isNotEmpty(content)) {
if (content.equals("结束")) {
recordsNew.add(msCaseLogRecordVO);
}else {
if(!content.equals(msCaseFlow.getCaseStatusName())){
} else {
if (!content.equals(msCaseFlow.getCaseStatusName())) {
recordsNew.add(msCaseLogRecordVO);
}else{
} else {
break;
}
}
@@ -234,28 +235,28 @@ public class MsSignSealServiceImpl implements MsSignSealService {
CaseLogRecord caseLogRecordin = new CaseLogRecord();
List<MsCaseLogRecordVO> caseLogRecordsin = new ArrayList<>();
if(!"结束".equals(msCaseFlow.getNodeName())){
if (!"结束".equals(msCaseFlow.getNodeName())) {
caseLogRecordin.setCaseNodeName(msCaseFlow.getNodeName());
List<MsCaseFlowVO> msCaseFlowvos = caseFlowMapper.selectFlowRole(caseFlowId);
StringBuilder roleIn = new StringBuilder();
for(MsCaseFlowVO mscaseFlowVO:msCaseFlowvos){
if(!"结束".equals(mscaseFlowVO.getNodeName())){
roleIn.append( mscaseFlowVO.getRoleName()+"正在进行"+mscaseFlowVO.getNodeName()+";");
for (MsCaseFlowVO mscaseFlowVO : msCaseFlowvos) {
if (!"结束".equals(mscaseFlowVO.getNodeName())) {
roleIn.append(mscaseFlowVO.getRoleName() + "正在进行" + mscaseFlowVO.getNodeName() + ";");
}
}
caseLogRecordin.setContent(roleIn.toString().substring(0,roleIn.toString().length()-1));
caseLogRecordin.setContent(roleIn.toString().substring(0, roleIn.toString().length() - 1));
MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseFlowId);
if(nextFlow!=null){
if (nextFlow != null) {
String nodeName = nextFlow.getNodeName();
if(StringUtils.isNotEmpty(nodeName)){
if(!"结束".equals(nodeName)){
if (StringUtils.isNotEmpty(nodeName)) {
if (!"结束".equals(nodeName)) {
List<MsCaseFlowVO> nextMsCaseFlowvo = caseFlowMapper.selectFlowRole(nextFlow.getId());
StringBuilder roleIn1 = new StringBuilder();
for(MsCaseFlowVO mscaseFlowVO:nextMsCaseFlowvo){
roleIn1.append( mscaseFlowVO.getRoleName()+";");
for (MsCaseFlowVO mscaseFlowVO : nextMsCaseFlowvo) {
roleIn1.append(mscaseFlowVO.getRoleName() + ";");
}
caseLogRecordin.setNextRoleName("下一节点角色:"+roleIn1.toString().substring(0,roleIn1.toString().length()-1));
caseLogRecordin.setNextRoleName("下一节点角色:" + roleIn1.toString().substring(0, roleIn1.toString().length() - 1));
}
}
}
@@ -274,24 +275,24 @@ public class MsSignSealServiceImpl implements MsSignSealService {
caseLogRecord1.setCaseNodeName(msCaseFlowVOs.get(0).getNodeName());
StringBuilder rolenext = new StringBuilder();
for(MsCaseFlowVO mscaseFlowVO:msCaseFlowVOs){
for (MsCaseFlowVO mscaseFlowVO : msCaseFlowVOs) {
String nodeName1 = mscaseFlowVO.getNodeName();
if(StringUtils.isNotEmpty(nodeName1)){
if("结束".equals(nodeName1)){
if (StringUtils.isNotEmpty(nodeName1)) {
if ("结束".equals(nodeName1)) {
rolenext.append("结束;");
}else {
rolenext.append( mscaseFlowVO.getRoleName()+"将进行"+mscaseFlowVO.getNodeName()+";");
} else {
rolenext.append(mscaseFlowVO.getRoleName() + "将进行" + mscaseFlowVO.getNodeName() + ";");
}
}
}
caseLogRecord1.setContent( rolenext.toString().substring(0,rolenext.toString().length()-1));
caseLogRecord1.setContent(rolenext.toString().substring(0, rolenext.toString().length() - 1));
caseLogRecordsnext.add(caseLogRecord1);
}
}
if(caseLogRecordsin!=null&&caseLogRecordsin.size()>0){
if (caseLogRecordsin != null && caseLogRecordsin.size() > 0) {
datas.put("finishCasenode", recordsNew);
}else {
} else {
MsCaseLogRecordVO msCaseLogRecordVO1 = new MsCaseLogRecordVO();
msCaseLogRecordVO1.setContent("结束");
recordsNew.add(msCaseLogRecordVO1);
@@ -308,27 +309,27 @@ public class MsSignSealServiceImpl implements MsSignSealService {
MsCaseLogRecord caseLogRecord = new MsCaseLogRecord();
caseLogRecord.setCaseAppliId(id);
List<MsCaseLogRecordVO> records = caseLogRecordMapper.selectCaseLogRecordList(caseLogRecord);
if(CollectionUtil.isNotEmpty(records)){
records.forEach(record->{
if (CollectionUtil.isNotEmpty(records)) {
records.forEach(record -> {
StringBuilder contentBuilder = new StringBuilder();
String caseNodeTime="";
if(record.getCreateTime()!=null){
caseNodeTime= DateUtil.format(record.getCreateTime(), DatePattern.NORM_DATETIME_FORMATTER);
String caseNodeTime = "";
if (record.getCreateTime() != null) {
caseNodeTime = DateUtil.format(record.getCreateTime(), DatePattern.NORM_DATETIME_FORMATTER);
}
Integer caseNode = record.getCaseNode();
String createBy = record.getCreateBy();
if(StrUtil.isNotEmpty(createBy)){
if (StrUtil.isNotEmpty(createBy)) {
contentBuilder.append(Optional.ofNullable(record.getCreateNickName()).orElse("")).append("(").append(record.getCreateBy()).append(")").append("于").append(caseNodeTime);
}else{
} else {
contentBuilder.append(Optional.ofNullable(record.getCreateNickName()).orElse("")).append("于").append(caseNodeTime);
}
if(StrUtil.isNotEmpty(record.getContent())){
if (StrUtil.isNotEmpty(record.getContent())) {
contentBuilder.append(record.getContent());
}else if(caseNode.intValue() == 0){
} else if (caseNode.intValue() == 0) {
contentBuilder.append(record.getCaseStatusName());
}
if(StrUtil.isNotEmpty(record.getNotes())){
if (StrUtil.isNotEmpty(record.getNotes())) {
contentBuilder.append(",").append(record.getNotes());
}
record.setContent(contentBuilder.toString());
@@ -340,137 +341,86 @@ public class MsSignSealServiceImpl implements MsSignSealService {
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult msCaseFile(List<Long> ids){
// todo
public AjaxResult msCaseFile(List<Long> ids) {
StringBuilder error = new StringBuilder();
try {
for (Long id : ids) {
MsCaseApplication caseApplication1 = msCaseApplicationMapper.selectByPrimaryKey(id);
if (caseApplication1 == null) {
return AjaxResult.error("未查询到相关案件");
}
MsCaseApplicationVO msCaseApplicationVO = new MsCaseApplicationVO();
BeanUtil.copyProperties(caseApplication1, msCaseApplicationVO);
List<MsCaseAttach> caseAttachList = msCaseAttachMapper.queryCaseAttachList(msCaseApplicationVO);
if (caseAttachList != null && caseAttachList.size() > 0) {
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);
if (caseApplication1 != null) {
LocalDate now = LocalDate.now();
String year = Integer.toString(now.getYear());
String month = String.format("%02d", now.getMonthValue());
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;
MsCaseApplicationVO msCaseApplicationVO = new MsCaseApplicationVO();
BeanUtil.copyProperties(caseApplication1, msCaseApplicationVO);
List<MsCaseAttach> caseAttachList = msCaseAttachMapper.queryCaseAttachList(msCaseApplicationVO);
// 只能送达pdf版调解书
// 创建日期目录
File saveFolder = new File(saveFolderPath);
if (!saveFolder.exists()) {
saveFolder.mkdirs();
}
String resultFilePath = saveFolderPath + "/" + fileName;
File resultFilePathFile = new File(resultFilePath);
if (!resultFilePathFile.exists()) {
resultFilePathFile.createNewFile();
}
if (CollectionUtil.isNotEmpty(caseAttachList)) {
long count = caseAttachList.stream().filter(msCaseAttach -> msCaseAttach.getAnnexType() != null && msCaseAttach.getAnnexType().equals(AnnexTypeEnum.MEDIATE_BOOK_PDF.getCode())).count();
if (count > 0) {
Integer caseFlowId = caseApplication1.getCaseFlowId();
// 查询当前节点
MsCaseFlow currentFlow = caseFlowMapper.selectByPrimaryKey(caseFlowId);
if (currentFlow != null) {
// 根据流程id查找下一个流程节点
MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseFlowId);
caseApplication1.setCaseFlowId(nextFlow.getId());
caseApplication1.setCaseStatusName(nextFlow.getCaseStatusName());
caseApplicationMapper.updateByPrimaryKeySelective(caseApplication1);
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);
}
// 获取案件相关人员
List<MsCaseAffiliate> affiliates = applicationService.selectAffliatesByCaseId(id);
if (CollectionUtil.isNotEmpty(affiliates)) {
// 申请操作人
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();
if (applicantAffiliateOpt.isPresent() && resAffiliateOpt.isPresent()) {
ExecutorService executor = ThreadUtil.createThreadPool();
// 发送邮件
CompletableFuture.runAsync(() -> {
if (StrUtil.isNotEmpty(applicantAffiliateOpt.get().getEmail())) {
boolean appEmailFlag = sendCaseEmail(caseApplication1, applicantAffiliateOpt.get().getEmail(), caseAttachList);
}
if (!StrUtil.isEmpty(resAffiliateOpt.get().getEmail())) {
boolean appEmailFlag = sendCaseEmail(caseApplication1, resAffiliateOpt.get().getEmail(), caseAttachList);
}
}, executor);
// 发送签收短信,2126313 尊敬的{1}用户,您的{2}文件已发送至邮箱,请点击链接进行确认签收https://txroom.xayunmei.com/#/sign?{3},如非本人操作,请忽略本短信
CompletableFuture.runAsync(() -> {
SysUser sysUser = sysUserMapper.selectUserById(applicantAffiliateOpt.get().getUserId());
// 获取短信链接uuid
MeetingInfoVO meetingInfoVO = MeetingInfoVO.builder().userId(sysUser.getUserId()).userName(sysUser.getUserName()).caseId(caseApplication1.getId()).systemType("TJ").build();
String roomUuid = shortMessageService.buildMeetingInfoRecord(meetingInfoVO);
if (!StrUtil.isEmpty(sysUser.getPhonenumber())) {
SmsUtils.sendSms(caseApplication1, "2126313", sysUser.getPhonenumber(), new String[]{sysUser.getNickName(), caseApplication1.getCaseNum(), "authId=" + roomUuid});
} else if (StrUtil.isNotEmpty(sysUser.getEmail())) {
String content = "尊敬的" + sysUser.getNickName() + "用户,您的" + caseApplication1.getCaseNum() + "文件已发送至邮箱,请点击链接进行确认签收https://txroom.xayunmei.com/#/sign?" + "authId=" + roomUuid + ",如非本人操作,请忽略本短信";
sendEmail(caseApplication1, sysUser, "调解系统文件签收", content);
}
}, executor);
}
}
}
CaseLogUtils.insertCaseLog(caseApplication1.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), "");
} else {
error.append("案件编号为" + caseApplication1.getCaseNum() + "未找到pdf版调解书,请上传\r\n");
}
} else {
error.append("案件编号为" + caseApplication1.getCaseNum() + "未找到pdf版调解书,请上传\r\n");
}
}
Integer caseFlowId = caseApplication1.getCaseFlowId();
// 查询当前节点
MsCaseFlow currentFlow = caseFlowMapper.selectByPrimaryKey(caseFlowId);
if(currentFlow==null){
return AjaxResult.error("未找到当前流程节点");
}
// 根据流程id查找下一个流程节点
MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseFlowId);
caseApplication1.setCaseFlowId(nextFlow.getId());
caseApplication1.setCaseStatusName(nextFlow.getCaseStatusName());
caseApplicationMapper.updateByPrimaryKeySelective(caseApplication1);
// 获取案件相关人员
List<MsCaseAffiliate> affiliates = applicationService.selectAffliatesByCaseId(id);
if(CollectionUtil.isEmpty(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> resAffiliateOpt = affiliates.stream().filter(affiliate -> affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(3) || affiliate.getRoleType().equals(4))).findFirst();
if (!applicantAffiliateOpt.isPresent() || !resAffiliateOpt.isPresent()) {
throw new ServiceException("未找到案件操作人员");
}
ExecutorService executor = ThreadUtil.createThreadPool();
// 发送邮件
CompletableFuture.runAsync(() -> {
if (StrUtil.isNotEmpty(applicantAffiliateOpt.get().getEmail())) {
boolean appEmailFlag = sendCaseEmail(caseApplication1, applicantAffiliateOpt.get().getEmail(), caseAttachList);
}
if (!StrUtil.isEmpty(resAffiliateOpt.get().getEmail())) {
boolean appEmailFlag = sendCaseEmail(caseApplication1, resAffiliateOpt.get().getEmail(), caseAttachList);
} }, executor);
// 发送签收短信,2126313 尊敬的{1}用户,您的{2}文件已发送至邮箱,请点击链接进行确认签收https://txroom.xayunmei.com/#/sign?{3},如非本人操作,请忽略本短信
CompletableFuture.runAsync(() -> {
SysUser sysUser = sysUserMapper.selectUserById(applicantAffiliateOpt.get().getUserId());
// 获取短信链接uuid
MeetingInfoVO meetingInfoVO = MeetingInfoVO.builder().userId(sysUser.getUserId()).userName(sysUser.getUserName()).caseId(caseApplication1.getId()).systemType("TJ").build();
String roomUuid = shortMessageService.buildMeetingInfoRecord(meetingInfoVO);
if (!StrUtil.isEmpty(sysUser.getPhonenumber())) {
SmsUtils.sendSms(caseApplication1,"2126313", sysUser.getPhonenumber(),new String[]{sysUser.getNickName(),caseApplication1.getCaseNum(),"authId="+ roomUuid});
}else if(StrUtil.isNotEmpty(sysUser.getEmail())){
String content = "尊敬的"+sysUser.getNickName()+"用户,您的" + caseApplication1.getCaseNum() + "文件已发送至邮箱,请点击链接进行确认签收https://txroom.xayunmei.com/#/sign?" + "authId="+ roomUuid + ",如非本人操作,请忽略本短信";
sendEmail(caseApplication1, sysUser, "调解系统文件签收", content);
}
}, executor);
CaseLogUtils.insertCaseLog(caseApplication1.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),"");
}
} catch (Exception e) {
throw new ServiceException("调解书发送失败");
}
if (error.length() > 0) {
return AjaxResult.error(error.toString());
}
return AjaxResult.success("");
}
public void sendEmail(MsCaseApplication application, SysUser user, String subject, String sendContent) {
boolean emailFlag = emailOutUtil.sendMessage(user.getEmail(), subject, sendContent, null, null);
@@ -498,12 +448,13 @@ public class MsSignSealServiceImpl implements MsSignSealService {
msSendMailHistoryRecord.setId(null);
sendMailHistoryRecordMapper.insertSelective(msSendMailHistoryRecord);
}
@Override
@Transactional
public AjaxResult msCaseSign(MsSignSealDTO dto) {
Long caseId = dto.getCaseId();
MsCaseApplication caseApplicationselect = msCaseApplicationMapper.selectByPrimaryKey(caseId);
if(caseApplicationselect==null){
if (caseApplicationselect == null) {
return AjaxResult.error("当前案件不存在");
}
// 查询当前节点
@@ -515,20 +466,20 @@ public class MsSignSealServiceImpl implements MsSignSealService {
Example example = new Example(MsCaseAffiliate.class);
example.createCriteria().andEqualTo("caseAppliId", caseId);
List<MsCaseAffiliate> msCaseAffiliates = msCaseAffiliateMapper.selectByExample(example);
if(CollectionUtil.isEmpty(msCaseAffiliates)){
if (CollectionUtil.isEmpty(msCaseAffiliates)) {
return AjaxResult.error("未找到案件相关人员");
}
// 被申请操作人
Optional<MsCaseAffiliate> resAffiliateOpt = msCaseAffiliates.stream().filter(affiliate -> affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(3) || affiliate.getRoleType().equals(4))).findFirst();
ExecutorService executor = ThreadUtil.createThreadPool();
if(!resAffiliateOpt.isPresent()){
if (!resAffiliateOpt.isPresent()) {
return AjaxResult.error("案件相关人员不完整");
}
for (MsCaseAffiliate affiliate : msCaseAffiliates) {
// 申请人签收,根据流程id查找下一个流程节点
if(affiliate.getUserId()!=null
if (affiliate.getUserId() != null
&& loginUserId.equals(affiliate.getUserId())
&&affiliate.getRoleType()!=null&&(affiliate.getRoleType().equals(1)||affiliate.getRoleType().equals(2))) {
&& affiliate.getRoleType() != null && (affiliate.getRoleType().equals(1) || affiliate.getRoleType().equals(2))) {
MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId());
caseApplicationselect.setCaseFlowId(nextFlow.getId());
caseApplicationselect.setCaseStatusName(nextFlow.getCaseStatusName());
@@ -552,19 +503,19 @@ public class MsSignSealServiceImpl implements MsSignSealService {
}
// 被申请人签收
if(affiliate.getUserId()!=null
if (affiliate.getUserId() != null
&& loginUserId.equals(affiliate.getUserId())
&&affiliate.getRoleType()!=null&&(affiliate.getRoleType().equals(3)||affiliate.getRoleType().equals(4))) {
&& affiliate.getRoleType() != null && (affiliate.getRoleType().equals(3) || affiliate.getRoleType().equals(4))) {
// 根据流程id查找下一个流程节点
MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId());
caseApplicationselect.setCaseFlowId(nextFlow.getId());
caseApplicationselect.setCaseStatusName(nextFlow.getCaseStatusName());
caseApplicationMapper.updateByPrimaryKeySelective(caseApplicationselect);
CaseLogUtils.insertCaseLog(caseApplicationselect.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),null);
CaseLogUtils.insertCaseLog(caseApplicationselect.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), null);
CaseLogUtils.insertCaseLog(caseApplicationselect.getId(), 17, "结束", null);
// 被申请人签收结束对接北明,为调解成功状态
if(StrUtil.isEmpty(caseApplicationselect.getCaseSource())) {
if (StrUtil.isEmpty(caseApplicationselect.getCaseSource())) {
applicationService.pushStatusToBM(caseApplicationselect, PushCaseStatusEnum.SUCCESS);
}
break;
@@ -580,39 +531,39 @@ public class MsSignSealServiceImpl implements MsSignSealService {
public AjaxResult msCaseSignUrlApplyPC(MsSignSealDTO dto) throws EsignDemoException {
Long caseId = dto.getCaseId();
List<MsCaseAffiliate> affiliates = applicationService.selectAffliatesByCaseId(caseId);
if(CollectionUtil.isEmpty(affiliates)){
if (CollectionUtil.isEmpty(affiliates)) {
return AjaxResult.error("未找到案件相关人员");
}
SysUser user = sysUserMapper.selectUserById(SecurityUtils.getLoginUser().getUser().getUserId());
List<SysRole> roles = user.getRoles();
if(CollectionUtil.isEmpty(roles)){
if (CollectionUtil.isEmpty(roles)) {
return AjaxResult.error("该用户未绑定角色");
}
long mediatorCount = roles.stream().filter(sysRole -> sysRole.getRoleName().equals("调解员")).count();
List<MsCaseAffiliate> operatorList = affiliates.stream().filter(msCaseAffiliate -> msCaseAffiliate.getOperatorFlag() != null
&& msCaseAffiliate.getOperatorFlag() == 1
&& StrUtil.isNotEmpty(msCaseAffiliate.getPhone())).collect(Collectors.toList());
Optional<MsCaseAffiliate> appOpt =null;
Optional<MsCaseAffiliate> resOpt =null;
if(CollectionUtil.isNotEmpty(operatorList)){
appOpt = operatorList.stream().filter(msCaseAffiliate -> msCaseAffiliate.getRoleType() != null && msCaseAffiliate.getUserId()!=null
Optional<MsCaseAffiliate> appOpt = null;
Optional<MsCaseAffiliate> resOpt = null;
if (CollectionUtil.isNotEmpty(operatorList)) {
appOpt = operatorList.stream().filter(msCaseAffiliate -> msCaseAffiliate.getRoleType() != null && msCaseAffiliate.getUserId() != null
&& (msCaseAffiliate.getRoleType() == 1 || msCaseAffiliate.getRoleType() == 2))
.findFirst();
resOpt = operatorList.stream().filter(msCaseAffiliate -> msCaseAffiliate.getRoleType() != null&& msCaseAffiliate.getUserId()!=null
resOpt = operatorList.stream().filter(msCaseAffiliate -> msCaseAffiliate.getRoleType() != null && msCaseAffiliate.getUserId() != null
&& (msCaseAffiliate.getRoleType() == 3 || msCaseAffiliate.getRoleType() == 4))
.findFirst();
}
if(appOpt==null || !appOpt.isPresent()){
if (appOpt == null || !appOpt.isPresent()) {
return AjaxResult.error("未找到案件申请操作人");
}
if(resOpt==null || !resOpt.isPresent()){
if (resOpt == null || !resOpt.isPresent()) {
return AjaxResult.error("未找到案件被申请操作人");
}
MsCaseApplication caseApplication = msCaseApplicationMapper.selectByPrimaryKey(caseId);
Long userId = SecurityUtils.getUserId();
if(appOpt.get().getUserId()!=null && appOpt.get().getUserId().equals(userId)){
if (appOpt.get().getUserId() != null && appOpt.get().getUserId().equals(userId)) {
// 申请人链接
SealSignRecord sealSignRecordres = new SealSignRecord();
MsSealSignRecord mssealSignRecord = new MsSealSignRecord();
@@ -620,29 +571,29 @@ public class MsSignSealServiceImpl implements MsSignSealService {
List<MsSealSignRecord> sealSignRecords = sealSignRecordMapper.selectSealSignRecord(mssealSignRecord);
if (sealSignRecords != null && sealSignRecords.size() > 0) {
String signFlowid = sealSignRecords.get(0).getSignFlowId();
SealSignRecord sealSignRecord = new SealSignRecord();
sealSignRecord.setPensonAccount(appOpt.get().getPhone());
sealSignRecord.setPensonName(appOpt.get().getName());
sealSignRecord.setSignFlowid(signFlowid);
SealSignRecord sealSignRecord = new SealSignRecord();
sealSignRecord.setPensonAccount(appOpt.get().getPhone());
sealSignRecord.setPensonName(appOpt.get().getName());
sealSignRecord.setSignFlowid(signFlowid);
Gson gson = new Gson();
EsignHttpResponse signUrl = SignAward.signUrl(sealSignRecord);
JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class);
if(signUrlJsonObject.get("data")==null||signUrlJsonObject.get("data").isJsonNull()){
throw new ServiceException("该用户和流程无关,不能查看当前流程");
}else {
JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data");
String urlapply = signUrlData.get("shortUrl").getAsString();
sealSignRecordres.setSealUrl(urlapply);
}
Gson gson = new Gson();
EsignHttpResponse signUrl = SignAward.signUrl(sealSignRecord);
JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class);
if (signUrlJsonObject.get("data") == null || signUrlJsonObject.get("data").isJsonNull()) {
throw new ServiceException("该用户和流程无关,不能查看当前流程");
} else {
JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data");
String urlapply = signUrlData.get("shortUrl").getAsString();
sealSignRecordres.setSealUrl(urlapply);
}
return AjaxResult.success(sealSignRecordres);
}else {
} else {
return AjaxResult.error();
}
}
if(resOpt.get().getUserId()!=null && resOpt.get().getUserId().equals(userId)){
if (resOpt.get().getUserId() != null && resOpt.get().getUserId().equals(userId)) {
// 被申
SealSignRecord sealSignRecordres = new SealSignRecord();
MsSealSignRecord mssealSignRecord = new MsSealSignRecord();
@@ -662,11 +613,11 @@ public class MsSignSealServiceImpl implements MsSignSealService {
String urlapply = signUrlData.get("shortUrl").getAsString();
sealSignRecordres.setSealUrl(urlapply);
return AjaxResult.success(sealSignRecordres);
}else {
} else {
return AjaxResult.error();
}
}
if(mediatorCount>0){
if (mediatorCount > 0) {
// 调解员
SealSignRecord sealSignRecordres = new SealSignRecord();
MsSealSignRecord mssealSignRecord = new MsSealSignRecord();
@@ -677,7 +628,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
SealSignRecord sealSignRecord = new SealSignRecord();
Long arbitratorId = caseApplication.getMediatorId();
if (arbitratorId!=null) {
if (arbitratorId != null) {
SysUser sysUser = sysUserMapper.selectUserById(arbitratorId);
if (sysUser == null) {
return AjaxResult.error();
@@ -693,7 +644,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
String urlapply = signUrlData.get("shortUrl").getAsString();
sealSignRecordres.setSealUrl(urlapply);
return AjaxResult.success(sealSignRecordres);
}else {
} else {
return AjaxResult.error();
}
@@ -708,7 +659,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
JSONObject jsonObjectCallback = JSONObject.parseObject(reqbodystr);
Gson gson = new Gson();
if (jsonObjectCallback != null) {
log.info("签名回调======"+jsonObjectCallback);
log.info("签名回调======" + jsonObjectCallback);
int signResult = jsonObjectCallback.getIntValue("signResult");
String action = jsonObjectCallback.getString("action");
String signFlowId = jsonObjectCallback.getString("signFlowId");
@@ -742,10 +693,10 @@ public class MsSignSealServiceImpl implements MsSignSealService {
MsCaseFlow currentFlow = caseFlowMapper.selectByPrimaryKey(caseApplicationselect.getCaseFlowId());
Integer caseNode = currentFlow.getNodeId();
String caseStatusName = currentFlow.getCaseStatusName();
if("SIGN_MISSON_COMPLETE".equals(action) && signResult==2){
if(mediaResult.equals(1)){
if ("SIGN_MISSON_COMPLETE".equals(action) && signResult == 2) {
if (mediaResult.equals(1)) {
//调解
if(StringUtils.isNotEmpty(accountMobile)&&accountMobile.equals(pensonAccountApply)){
if (StringUtils.isNotEmpty(accountMobile) && accountMobile.equals(pensonAccountApply)) {
//申请人签名
sealSignRecordsel.setSignStatusApply(1);
sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel);
@@ -756,14 +707,14 @@ public class MsSignSealServiceImpl implements MsSignSealService {
operLog.setCaseNode(caseNode);
operLog.setCreateTime(dateOperate);
caseLogRecordMapper.insert(operLog);
if(signStatusResponse!=null&&signStatusResponse.equals(1)&&
signStatusMediator!=null&&signStatusMediator.equals(1)){
if (signStatusResponse != null && signStatusResponse.equals(1) &&
signStatusMediator != null && signStatusMediator.equals(1)) {
// 根据流程id查找下一个流程节点
MsCaseFlow nextFlow=null;
if(caseApplicationselect.getSealFlag()!=null&&caseApplicationselect.getSealFlag().equals(1)) {
MsCaseFlow nextFlow = null;
if (caseApplicationselect.getSealFlag() != null && caseApplicationselect.getSealFlag().equals(1)) {
// 需要用印
nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId());
}else {
nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId());
} else {
// 不需要用印
nextFlow = caseFlowMapper.nextFlow1(caseApplicationselect.getCaseFlowId());
}
@@ -774,19 +725,19 @@ public class MsSignSealServiceImpl implements MsSignSealService {
caseApplicationMapper.updateByPrimaryKeySelective(application);
//修改"签署用印记录表"的状态为待用印
if(caseApplicationselect.getSealFlag()!=null&&caseApplicationselect.getSealFlag()==1) {
if (caseApplicationselect.getSealFlag() != null && caseApplicationselect.getSealFlag() == 1) {
sealSignRecordsel.setSignFlowStatus(2);
sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel);
}else {
} else {
// 否则为已完成
sealSignRecordsel.setSignFlowStatus(3);
sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel);
// 下载调解书
downloadMediationBook(caseApplicationselect,signFlowId,gson,caseAppliId);
msSignSealService.downloadMediationBook(caseApplicationselect, signFlowId, gson, caseAppliId);
}
}
}else if(StringUtils.isNotEmpty(accountMobile)&&accountMobile.equals(pensonAccountRes)){
} else if (StringUtils.isNotEmpty(accountMobile) && accountMobile.equals(pensonAccountRes)) {
//被申请人签名
sealSignRecordsel.setSignStatusResponse(1);
sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel);
@@ -797,15 +748,15 @@ public class MsSignSealServiceImpl implements MsSignSealService {
operLog.setCaseNode(caseNode);
operLog.setCreateTime(dateOperate);
caseLogRecordMapper.insert(operLog);
if(signStatusApply!=null&&signStatusApply.equals(1)&&
signStatusMediator!=null&&signStatusMediator.equals(1)){
if (signStatusApply != null && signStatusApply.equals(1) &&
signStatusMediator != null && signStatusMediator.equals(1)) {
// 根据流程id查找下一个流程节点
// 根据流程id查找下一个流程节点
MsCaseFlow nextFlow=null;
if(caseApplicationselect.getSealFlag()!=null&&caseApplicationselect.getSealFlag()==1) {
MsCaseFlow nextFlow = null;
if (caseApplicationselect.getSealFlag() != null && caseApplicationselect.getSealFlag() == 1) {
// 需要用印
nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId());
}else {
} else {
// 不需要用印
nextFlow = caseFlowMapper.nextFlow1(caseApplicationselect.getCaseFlowId());
}
@@ -816,19 +767,19 @@ public class MsSignSealServiceImpl implements MsSignSealService {
caseApplicationMapper.updateByPrimaryKeySelective(application);
//修改"签署用印记录表"的状态为待用印
if(caseApplicationselect.getSealFlag()!=null&&caseApplicationselect.getSealFlag()==1) {
if (caseApplicationselect.getSealFlag() != null && caseApplicationselect.getSealFlag() == 1) {
sealSignRecordsel.setSignFlowStatus(2);
sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel);
}else {
} else {
// 否则为已完成
sealSignRecordsel.setSignFlowStatus(3);
sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel);
// 下载调解书
downloadMediationBook(caseApplicationselect,signFlowId,gson,caseAppliId);
msSignSealService.downloadMediationBook(caseApplicationselect, signFlowId, gson, caseAppliId);
}
}
}else if(StringUtils.isNotEmpty(accountMobile)&&accountMobile.equals(pensonAccountMedi)){
} else if (StringUtils.isNotEmpty(accountMobile) && accountMobile.equals(pensonAccountMedi)) {
//调解员签名
sealSignRecordsel.setSignStatusMediator(1);
sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel);
@@ -839,15 +790,15 @@ public class MsSignSealServiceImpl implements MsSignSealService {
operLog.setCaseNode(caseNode);
operLog.setCreateTime(dateOperate);
caseLogRecordMapper.insert(operLog);
if(signStatusApply!=null&&signStatusApply.equals(1)&&
signStatusResponse!=null&&signStatusResponse.equals(1)){
if (signStatusApply != null && signStatusApply.equals(1) &&
signStatusResponse != null && signStatusResponse.equals(1)) {
// 根据流程id查找下一个流程节点
// 根据流程id查找下一个流程节点
MsCaseFlow nextFlow=null;
if(caseApplicationselect.getSealFlag()!=null&&caseApplicationselect.getSealFlag()==1) {
MsCaseFlow nextFlow = null;
if (caseApplicationselect.getSealFlag() != null && caseApplicationselect.getSealFlag() == 1) {
// 需要用印
nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId());
}else {
} else {
// 不需要用印
nextFlow = caseFlowMapper.nextFlow1(caseApplicationselect.getCaseFlowId());
}
@@ -858,19 +809,19 @@ public class MsSignSealServiceImpl implements MsSignSealService {
caseApplicationMapper.updateByPrimaryKeySelective(application);
//修改"签署用印记录表"的状态为待用印
if(caseApplicationselect.getSealFlag()!=null&&caseApplicationselect.getSealFlag()==1) {
if (caseApplicationselect.getSealFlag() != null && caseApplicationselect.getSealFlag() == 1) {
sealSignRecordsel.setSignFlowStatus(2);
sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel);
}else {
} else {
// 否则为已完成
sealSignRecordsel.setSignFlowStatus(3);
sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel);
// 下载调解书
downloadMediationBook(caseApplicationselect,signFlowId,gson,caseAppliId);
msSignSealService.downloadMediationBook(caseApplicationselect, signFlowId, gson, caseAppliId);
}
}
}else if(StringUtils.isNotEmpty(accountMobile)&&accountMobile.equals(orgnNamePsnAcc) && caseApplicationselect.getSealFlag()!=null && caseApplicationselect.getSealFlag()==1 ){
} else if (StringUtils.isNotEmpty(accountMobile) && accountMobile.equals(orgnNamePsnAcc) && caseApplicationselect.getSealFlag() != null && caseApplicationselect.getSealFlag() == 1) {
//需要用印
sealSignRecordsel.setSealStatus(1);
sealSignRecordsel.setSignFlowStatus(3);
@@ -892,13 +843,13 @@ public class MsSignSealServiceImpl implements MsSignSealService {
caseApplicationMapper.updateByPrimaryKeySelective(application);
//下载审核完成的调解书
downloadMediationBook(caseApplicationselect,signFlowId,gson,caseAppliId);
msSignSealService.downloadMediationBook(caseApplicationselect, signFlowId, gson, caseAppliId);
}
}else if(mediaResult.equals(5)){
} else if (mediaResult.equals(5)) {
//和解
if(StringUtils.isNotEmpty(accountMobile)&&accountMobile.equals(pensonAccountApply)){
if (StringUtils.isNotEmpty(accountMobile) && accountMobile.equals(pensonAccountApply)) {
//申请人签名
sealSignRecordsel.setSignStatusApply(1);
sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel);
@@ -909,7 +860,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
operLog.setCaseNode(caseNode);
operLog.setCreateTime(dateOperate);
caseLogRecordMapper.insert(operLog);
if(signStatusResponse!=null&&signStatusResponse.equals(1)){
if (signStatusResponse != null && signStatusResponse.equals(1)) {
MsCaseFlow nextFlow = caseFlowMapper.nextFlow1(caseApplicationselect.getCaseFlowId());
MsCaseApplication application = new MsCaseApplication();
application.setId(caseApplicationselect.getId());
@@ -922,7 +873,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel);
//下载审核完成的调解书
downloadMediationBook(caseApplicationselect,signFlowId,gson,caseAppliId);
msSignSealService.downloadMediationBook(caseApplicationselect, signFlowId, gson, caseAppliId);
// EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId);
// JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class);
// JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data");
@@ -989,7 +940,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
//
// }
}
}else if(StringUtils.isNotEmpty(accountMobile)&&accountMobile.equals(pensonAccountRes)){
} else if (StringUtils.isNotEmpty(accountMobile) && accountMobile.equals(pensonAccountRes)) {
//被申请人签名
sealSignRecordsel.setSignStatusResponse(1);
sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel);
@@ -1000,7 +951,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
operLog.setCaseNode(caseNode);
operLog.setCreateTime(dateOperate);
caseLogRecordMapper.insert(operLog);
if(signStatusApply!=null&&signStatusApply.equals(1)){
if (signStatusApply != null && signStatusApply.equals(1)) {
MsCaseFlow nextFlow = caseFlowMapper.nextFlow1(caseApplicationselect.getCaseFlowId());
MsCaseApplication application = new MsCaseApplication();
application.setId(caseApplicationselect.getId());
@@ -1013,7 +964,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel);
//下载审核完成的调解书
downloadMediationBook(caseApplicationselect,signFlowId,gson,caseAppliId);
msSignSealService.downloadMediationBook(caseApplicationselect, signFlowId, gson, caseAppliId);
// EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId);
// JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class);
// JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data");
@@ -1084,84 +1035,96 @@ public class MsSignSealServiceImpl implements MsSignSealService {
}
}
}else{
} else {
return AjaxResult.error("error");
}
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);
JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class);
JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data");
JsonArray filesArray = fileDownloadData.get("files").getAsJsonArray();
log.info("下载调解书pdf===="+filesArray);
if (filesArray != null && filesArray.size() > 0) {
JsonObject fileObject = (JsonObject) filesArray.get(0);
String fileDownloadUrl = fileObject.get("downloadUrl").toString();
LocalDate now = LocalDate.now();
String year = Integer.toString(now.getYear());
String month = String.format("%02d", now.getMonthValue());
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;
/**
* 下载调解书
*
* @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);
// 创建日期目录
File saveFolder = new File(saveFolderPath);
if (!saveFolder.exists()) {
saveFolder.mkdirs();
}
String resultFilePath = saveFolderPath + "/" + fileName;
File resultFilePathFile = new File(resultFilePath);
if (!resultFilePathFile.exists()) {
resultFilePathFile.createNewFile();
}
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();
LocalDate now = LocalDate.now();
String year = Integer.toString(now.getYear());
String month = String.format("%02d", now.getMonthValue());
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;
String fileDownloadUrlnew = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1);
boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath);
log.info("是否下载成功======="+downLoadFile);
if (downLoadFile) {
// 先删除已经存在的调解书
if(StrUtil.isEmpty(caseApplicationselect.getCaseSource())){
List<MsCaseAttach> existAttach = msCaseAttachMapper.listCaseAttachByCaseIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK.getCode());
if(CollectionUtil.isNotEmpty(existAttach)){
// 对接北明,同步案件状态,删除
for (MsCaseAttach msCaseAttach : existAttach) {
if(StrUtil.isEmpty(msCaseAttach.getOtherSysFileId())||StrUtil.isEmpty(msCaseAttach.getAnnexPath())){
continue;
// 创建日期目录
File saveFolder = new File(saveFolderPath);
if (!saveFolder.exists()) {
saveFolder.mkdirs();
}
String resultFilePath = saveFolderPath + "/" + fileName;
File resultFilePathFile = new File(resultFilePath);
if (!resultFilePathFile.exists()) {
resultFilePathFile.createNewFile();
}
String fileDownloadUrlnew = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1);
boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath);
if (downLoadFile) {
// 先删除已经存在的pdf调解书
if (StrUtil.isEmpty(caseApplicationselect.getCaseSource())) {
List<MsCaseAttach> existAttach = msCaseAttachMapper.listCaseAttachByCaseIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK_PDF.getCode());
if (CollectionUtil.isNotEmpty(existAttach)) {
// 对接北明,同步案件状态,删除
for (MsCaseAttach msCaseAttach : existAttach) {
if (StrUtil.isEmpty(msCaseAttach.getOtherSysFileId()) || StrUtil.isEmpty(msCaseAttach.getAnnexPath())) {
continue;
}
beiMingInterfaceService.deleteAttachmentInfo(caseApplicationselect.getCaseNum(), msCaseAttach.getOtherSysFileId(), FileUtil.getName(msCaseAttach.getAnnexPath()));
}
beiMingInterfaceService.deleteAttachmentInfo(caseApplicationselect.getCaseNum(), msCaseAttach.getOtherSysFileId(), FileUtil.getName(msCaseAttach.getAnnexPath()));
}
}
}
msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK.getCode());
msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK_PDF.getCode());
MsCaseAttach caseAttach = new MsCaseAttach();
caseAttach.setCaseAppliId(caseAppliId);
caseAttach.setAnnexType(AnnexTypeEnum.MEDIATE_BOOK_PDF.getCode());
caseAttach.setAnnexPath(savePath);
caseAttach.setAnnexName(saveName);
caseAttach.setSuffix(getFileExtension(caseAttach.getAnnexPath()));
caseAttachMapper.save(caseAttach);
// 对接北明,调用上传附件接口
if (StrUtil.isEmpty(caseApplicationselect.getCaseSource())) {
String templatePath = "/home/ruoyi" + savePath;
File file = new File(templatePath.replace("/profile", "/uploadPath"));
MsCaseFileInfo caseFileInfo = beiMingInterfaceService.pushAttachmentInfo(BMUserName, BMPassword, file, BMSyncSource, caseApplicationselect.getCaseNum(), AttachmentOperateTypeEnum.ADD, DocumentTypeEnum.EVEDENT_AGREEMENT);
// 更新附件表
if (caseFileInfo != null && StrUtil.isNotEmpty(caseFileInfo.getFileId())) {
caseAttach.setOtherSysFileId(caseFileInfo.getFileId());
msCaseAttachMapper.updateCaseAttachBycaseid(caseAttach);
}
MsCaseAttach caseAttach = new MsCaseAttach();
caseAttach.setCaseAppliId(caseAppliId);
caseAttach.setAnnexType(AnnexTypeEnum.MEDIATE_BOOK.getCode());
caseAttach.setAnnexPath(savePath);
caseAttach.setAnnexName(saveName);
caseAttach.setSuffix(getFileExtension(caseAttach.getAnnexPath()));
log.info("调解书保存======="+downLoadFile);
caseAttachMapper.save(caseAttach);
// 对接北明,调用上传附件接口
if(StrUtil.isEmpty(caseApplicationselect.getCaseSource()) ) {
String templatePath = "/home/ruoyi" + savePath;
File file = new File(templatePath.replace("/profile", "/uploadPath"));
MsCaseFileInfo caseFileInfo = beiMingInterfaceService.pushAttachmentInfo(BMUserName, BMPassword, file, BMSyncSource, caseApplicationselect.getCaseNum(), AttachmentOperateTypeEnum.ADD, DocumentTypeEnum.EVEDENT_AGREEMENT);
// 更新附件表
if(caseFileInfo!=null && StrUtil.isNotEmpty(caseFileInfo.getFileId())){
caseAttach.setOtherSysFileId(caseFileInfo.getFileId());
msCaseAttachMapper.updateCaseAttachBycaseid(caseAttach);
}
}
}
}
} catch (Exception e) {
throw new ServiceException("E签宝下载调解书失败");
}
}
@@ -1193,7 +1156,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
}
}
if("SEAL_AUDIT".equals(action) && auditStatus==1){
if ("SEAL_AUDIT".equals(action) && auditStatus == 1) {
EsignHttpResponse response = SignAward.getOrgSeal(orgId, sealId);
JSONObject jsonObject = JSONObject.parseObject(response.getBody());
int code = jsonObject.getIntValue("code");
@@ -1241,7 +1204,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
}
}
}
}else{
} else {
return AjaxResult.error("error");
}
return AjaxResult.success("success");
@@ -1258,14 +1221,14 @@ public class MsSignSealServiceImpl implements MsSignSealService {
Long fileId = null;
if (caseAttachList != null && caseAttachList.size() > 0) {
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";
int startIndex = prefix.length();
String annexPath = caseAttach.getAnnexPath();
String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex+1);
String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex + 1);
file = new File(path);
fileList.add(file);
fileId=caseAttach.getAnnexId();
fileId = caseAttach.getAnnexId();
System.out.println("文件长度==================:" + file.length());
}
}
@@ -1279,7 +1242,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
sendMailRecord.setSendTime(new Date());
sendMailRecord.setMailSubject("签署后的调解书");
sendMailRecord.setMailFromAddress(emailFrom);
sendMailRecord.setFileIds(fileId!=null?fileId.toString():null);
sendMailRecord.setFileIds(fileId != null ? fileId.toString() : null);
// sendMailRecord.setCreateBy(SecurityUtils.getUsername());
sendMailRecord.setCreateTime(new Date());
sendMailRecord.setMailFromAddress(emailFrom);
@@ -1315,7 +1278,4 @@ public class MsSignSealServiceImpl implements MsSignSealService {
}
}