实现归档送达功能
This commit is contained in:
+4
@@ -2,6 +2,8 @@ package com.ruoyi.wisdomarbitrate.domain.dto.mscase;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MsSignSealDTO {
|
||||
|
||||
@@ -18,6 +20,8 @@ public class MsSignSealDTO {
|
||||
*/
|
||||
private Integer caseFlowId;
|
||||
|
||||
private List<Long> ids;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -23,4 +23,5 @@ public interface MsSignSealService {
|
||||
|
||||
List<MsCaseLogRecordVO> selectCaseLogRecordList(MsSignSealDTO dto);
|
||||
|
||||
AjaxResult msCaseFile(List<Long> ids);
|
||||
}
|
||||
|
||||
+146
@@ -10,12 +10,14 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.ruoyi.common.constant.CaseApplicationConstants;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.enums.YesOrNoEnum;
|
||||
import com.ruoyi.common.exception.EsignDemoException;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.EmailOutUtil;
|
||||
import com.ruoyi.common.utils.SmsUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.file.SaaSAPIFileUtils;
|
||||
@@ -27,6 +29,7 @@ import com.ruoyi.wisdomarbitrate.domain.dto.dept.SealManage;
|
||||
import com.ruoyi.wisdomarbitrate.domain.dto.mscase.CaseLogRecord;
|
||||
import com.ruoyi.wisdomarbitrate.domain.dto.mscase.MsSignSealDTO;
|
||||
import com.ruoyi.wisdomarbitrate.domain.dto.mscase.SealSignRecord;
|
||||
import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SendMailRecord;
|
||||
import com.ruoyi.wisdomarbitrate.domain.entity.dept.MsSealSignRecord;
|
||||
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.*;
|
||||
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationVO;
|
||||
@@ -38,6 +41,7 @@ import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseAffiliateMapper;
|
||||
import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseApplicationMapper;
|
||||
import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseAttachMapper;
|
||||
import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseLogRecordMapper;
|
||||
import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SendMailRecordMapper;
|
||||
import com.ruoyi.wisdomarbitrate.service.mscase.MsCaseApplicationService;
|
||||
import com.ruoyi.wisdomarbitrate.service.mscase.MsSignSealService;
|
||||
import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
|
||||
@@ -47,7 +51,10 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
|
||||
import static com.ruoyi.common.utils.SecurityUtils.getUsername;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -83,6 +90,12 @@ public class MsSignSealServiceImpl implements MsSignSealService {
|
||||
@Autowired
|
||||
private MsCaseLogRecordMapper caseLogRecordMapper;
|
||||
|
||||
@Autowired
|
||||
private EmailOutUtil emailOutUtil;
|
||||
|
||||
@Autowired
|
||||
private SendMailRecordMapper sendMailRecordMapper;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@@ -494,6 +507,139 @@ public class MsSignSealServiceImpl implements MsSignSealService {
|
||||
return records;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public AjaxResult msCaseFile(List<Long> ids) {
|
||||
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() == 3) {
|
||||
String annexName = caseAttach.getAnnexName();
|
||||
String prefix = "/profile/upload/";
|
||||
int startIndex = prefix.length();
|
||||
String path = caseAttach.getAnnexPath() + annexName.substring(startIndex);
|
||||
File file = new File(path);
|
||||
// todo 部署放开
|
||||
if (!file.exists()) {
|
||||
return AjaxResult.error("未生成裁决书");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Integer caseFlowId = caseApplication1.getCaseFlowId();
|
||||
// 根据流程id查找下一个流程节点
|
||||
MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseFlowId);
|
||||
caseApplication1.setCaseFlowId(nextFlow.getId());
|
||||
caseApplication1.setCaseStatusName(nextFlow.getCaseStatusName());
|
||||
caseApplicationMapper.updateByPrimaryKeySelective(caseApplication1);
|
||||
|
||||
String appEmail = "";
|
||||
String resEmail = "";
|
||||
MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(id);
|
||||
appEmail = caseAffiliate.getAgentEmail();
|
||||
resEmail = caseAffiliate.getRespondentEmail();
|
||||
|
||||
boolean appEmailFlag = sendCaseEmail(caseApplication1, appEmail, caseAttachList);
|
||||
|
||||
SendMailRecord sendMailRecord = new SendMailRecord();
|
||||
sendMailRecord.setCaseId(id);
|
||||
sendMailRecord.setMailAddress(appEmail);
|
||||
sendMailRecord.setMailContent("您好,审核后的裁决书在附件中请查阅");
|
||||
// sendMailRecord.setMailContent("您好,您的{"+caseApplication1.getCaseNum()+"}案件,审核后的裁决书在附件中请查阅");
|
||||
sendMailRecord.setMailName("签署后的裁决书");
|
||||
sendMailRecord.setSendTime(new Date());
|
||||
sendMailRecord.setCreateBy(getUsername());
|
||||
if (appEmailFlag) {
|
||||
sendMailRecord.setSendStatus(1);
|
||||
} else {
|
||||
sendMailRecord.setSendStatus(0);
|
||||
}
|
||||
sendMailRecordMapper.saveSendMailRecord(sendMailRecord);
|
||||
|
||||
boolean resEmailFlag = sendCaseEmail(caseApplication1, resEmail, caseAttachList);
|
||||
|
||||
SendMailRecord sendMailRecord1 = new SendMailRecord();
|
||||
sendMailRecord1.setCaseId(id);
|
||||
sendMailRecord1.setMailAddress(resEmail);
|
||||
// sendMailRecord.setMailContent("您好,您的{"+caseApplication1.getCaseNum()+"}案件,审核后的裁决书在附件中请查阅");
|
||||
sendMailRecord1.setMailContent("您好,审核后的裁决书在附件中请查阅");
|
||||
sendMailRecord1.setMailName("签署后的裁决书");
|
||||
sendMailRecord1.setSendTime(new Date());
|
||||
sendMailRecord1.setCreateBy(getUsername());
|
||||
if (resEmailFlag) {
|
||||
sendMailRecord1.setSendStatus(1);
|
||||
}else {
|
||||
sendMailRecord1.setSendStatus(0);
|
||||
}
|
||||
sendMailRecordMapper.saveSendMailRecord(sendMailRecord1);
|
||||
if(!appEmailFlag&&!resEmailFlag){
|
||||
throw new ServiceException("裁决书发送失败");
|
||||
}
|
||||
if(!appEmailFlag){
|
||||
throw new ServiceException("申请人裁决书发送失败");
|
||||
}
|
||||
if(!resEmailFlag){
|
||||
throw new ServiceException("被申请人裁决书发送失败");
|
||||
}
|
||||
|
||||
CaseLogUtils.insertCaseLog(caseApplication1.getId(), nextFlow.getNodeId(), nextFlow.getCaseStatusName(),"归档");
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
return AjaxResult.success("归档成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过邮件发送裁决书文件
|
||||
*
|
||||
* @param caseApplication1
|
||||
*/
|
||||
private boolean sendCaseEmail(MsCaseApplication caseApplication1, String email, List<MsCaseAttach> caseAttachList) {
|
||||
List<File> fileList = new ArrayList<>();
|
||||
File file = null;
|
||||
if (caseAttachList != null && caseAttachList.size() > 0) {
|
||||
for (MsCaseAttach caseAttach : caseAttachList) {
|
||||
if (caseAttach.getAnnexType() == 3) {
|
||||
String annexName = caseAttach.getAnnexName();
|
||||
String prefix = "/profile/upload/";
|
||||
int startIndex = prefix.length();
|
||||
String path = caseAttach.getAnnexPath() + annexName.substring(startIndex);
|
||||
// todo 部署放开
|
||||
file = new File(path);
|
||||
fileList.add(file);
|
||||
System.out.println("文件长度==================:" + file.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (file != null && file.exists()) {
|
||||
try {
|
||||
Boolean aBoolean = emailOutUtil.sendEmil(email, "您好,审核后的裁决书在附件中请查阅", "签署后的裁决书", fileList, null);
|
||||
|
||||
if (aBoolean) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("邮件发送失败++++++++++++++++++++++++++++++++");
|
||||
System.out.println(e.toString());
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
|
||||
private MsCaseLogRecordVO getNextCaseLogRecord(String nodeName) {
|
||||
MsCaseLogRecordVO caseLogRecord = new MsCaseLogRecordVO();
|
||||
|
||||
Reference in New Issue
Block a user