429bug修复

This commit is contained in:
18792927508
2024-04-30 14:16:26 +08:00
parent 2299906c55
commit 8b490936aa
8 changed files with 132 additions and 78 deletions
@@ -60,9 +60,10 @@ public class MsVideoConferenceController extends BaseController {
/**
* 通用上传请求(单个)
* param officeFlag: 是否上传到onlyoffice,0-否,1-是
* param isMediaBook: 是否上调解书,1-是,其余为否
*/
@PostMapping("/upload")
public AjaxResult uploadFile(@RequestParam("file") MultipartFile file, @RequestParam("annexType") Integer annexType, @RequestParam(value = "officeFlag", required = false) Integer officeFlag,@RequestParam(value = "caseId") Long caseId) throws Exception
public AjaxResult uploadFile(@RequestParam("file") MultipartFile file, @RequestParam(value = "isMediaBook",required = false) Integer isMediaBook, @RequestParam("annexType") Integer annexType, @RequestParam(value = "officeFlag", required = false) Integer officeFlag,@RequestParam(value = "caseId",required = false) Long caseId) throws Exception
{
try
{
@@ -82,7 +83,7 @@ public class MsVideoConferenceController extends BaseController {
JSONArray jsonArray = caseApplicationService.uploadOnlyOffice(fileName,caseId);
if(jsonArray!=null && jsonArray.size() > 0) {
// 先删除之前的附件
if(Objects.equals(annexType, AnnexTypeEnum.MEDIATE_BOOK.getCode())) {
if(Objects.equals(annexType, AnnexTypeEnum.MEDIATE_BOOK.getCode()) && caseId!=null) {
msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseId, annexType);
}
MsCaseAttach caseAttach=null;
@@ -118,7 +119,15 @@ public class MsVideoConferenceController extends BaseController {
return AjaxResult.error("上传失败");
}
}else {
// 如果是调解书并且是pdf,则删除之前的在新增
if(isMediaBook != null && isMediaBook == 1 && caseId!=null){
if(StrUtil.isNotEmpty(suffix)&&!suffix.equals("pdf")){
return AjaxResult.error("请上传pdf格式文件");
}
annexType=AnnexTypeEnum.MEDIATE_BOOK_PDF.getCode();
// 先删除之前的附件
msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseId, annexType);
}
Long annexId = saveCaseAttach(annexType, fileName, file.getOriginalFilename(), caseId);
// 是否上传到onlyoffice
AjaxResult ajax = AjaxResult.success();
@@ -104,8 +104,9 @@ public class EmailOutUtil {
* @param message 邮件内容
* @param subject 邮件主题
* @param fileList 邮件附件
* @param fileNameMap 附件名称map,附件路径-附件名称
*/
public Boolean sendEmil(String to, String message, String subject, List<File> fileList, File file) {
public Boolean sendEmil(String to, String message, String subject, List<File> fileList, File file,Map<String,String> fileNameMap) {
try {
String messageContent = "<html><body><p style=\"font-family: Arial, sans-serif; font-size: 18px;\">"+message+"。</p></body></html>";
MimeBodyPart messageBodyPart = new MimeBodyPart();
@@ -162,7 +163,10 @@ public class EmailOutUtil {
for (File tempfile : fileList) {
MimeBodyPart attachmentPart = new MimeBodyPart();
attachmentPart.attachFile(tempfile);
attachmentPart.setFileName(MimeUtility.encodeText(tempfile.getName()));
// 设置附件名称
if(fileNameMap!=null && fileNameMap.containsKey(tempfile.getPath())) {
attachmentPart.setFileName(MimeUtility.encodeText(fileNameMap.get(tempfile.getPath())));
}
multipart.addBodyPart(attachmentPart);
}
msg.setContent(multipart);
@@ -25,6 +25,7 @@ public interface MsCaseAttachMapper {
int deleteByFileIds(@Param("ids") List<Integer> fileIds);
List<MsCaseAttach> listCaseAttachByCaseIdAndType(@Param("caseAppliId")Long caseAppliId,@Param("annexType") int annexType);
List<MsCaseAttach> listCaseAttachByCaseIdAndTypes(@Param("caseAppliId")Long caseAppliId,@Param("annexTypes") List<Integer> annexTypes);
MsCaseAttach queryAnnexById(@Param("annexId") Long annexId);
@@ -56,8 +56,9 @@ public interface MsCaseApplicationService {
* @param caseApplication
* @param affiliate
* @param groupOrder 组别
* @param operatorCount 操作人数量
*/
public void setCaseAfflicate(MsCaseApplicationVO caseApplication, MsCaseAffiliate affiliate,int groupOrder);
public int setCaseAfflicate(MsCaseApplicationVO caseApplication, MsCaseAffiliate affiliate,int groupOrder,int operatorCount);
/**
* 新增案件相关人员信息
* @param affiliate 相关人员信息
@@ -293,7 +293,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
}
for (MsCaseApplicationVO vo : list) {
if(vo.getMediatorId()!=null&&vo.getMediatorId()==loginUserId){
if(vo.getMediatorId()!=null&&vo.getMediatorId().equals(loginUserId)){
isMediatorRole=true;
}
// 设置申请人和被申请人
@@ -317,7 +317,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
}
}
// 签收按钮权限
if(affiliate.getUserId().equals(loginUserId) &&vo.getCaseStatusName().contains("签收")){
if(affiliate.getUserId().equals(loginUserId) &&vo.getCaseStatusName().equals("待申请人签收")){
vo.setSignFlag(1);
}
@@ -334,7 +334,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
}
}
// 签收按钮权限
if(affiliate.getUserId().equals(loginUserId) &&vo.getCaseStatusName().contains("签收")){
if(affiliate.getUserId().equals(loginUserId) &&vo.getCaseStatusName().equals("待被申请人签收")){
vo.setSignFlag(1);
}
}
@@ -683,26 +683,34 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
// 保存案件基本信息
if (msCaseApplicationMapper.insertSelective(caseApplication) > 0) {
List<MsCaseAttach> caseAttachList = caseApplication.getCaseAttachList();
int appOperatorCount=0;
int resOperatorCount=0;
// 保存案件相关人员
List<MsCaseAffiliateBase> applicant = msCaseAffiliateVO.getApplicant();
List<MsCaseAffiliateBase> res = msCaseAffiliateVO.getRes();
if(CollectionUtil.isNotEmpty(applicant)){
for (int i = 0; i < applicant.size(); i++) {
// 申请人
setCaseAfflicate(caseApplication, applicant.get(i).getApplicant(),i);
appOperatorCount= setCaseAfflicate(caseApplication, applicant.get(i).getApplicant(),i,appOperatorCount);
// 申请人代理人
setCaseAfflicate(caseApplication, applicant.get(i).getApplicantAgent(),i);
appOperatorCount=setCaseAfflicate(caseApplication, applicant.get(i).getApplicantAgent(),i,appOperatorCount);
}
}
if(CollectionUtil.isNotEmpty(res)){
for (int i = 0; i < res.size(); i++) {
// 申请人
setCaseAfflicate(caseApplication, res.get(i).getRes(),i);
resOperatorCount= setCaseAfflicate(caseApplication, res.get(i).getRes(),i,resOperatorCount);
// 申请人代理人
setCaseAfflicate(caseApplication, res.get(i).getResAgent(),i);
resOperatorCount= setCaseAfflicate(caseApplication, res.get(i).getResAgent(),i,resOperatorCount);
}
}
if (appOperatorCount < 1 && resOperatorCount < 1) {
throw new ServiceException("未设置申请操作人和被申请操作人");
} else if (appOperatorCount < 1) {
throw new ServiceException("未设置申请操作人");
} else if (resOperatorCount < 1) {
throw new ServiceException("未设置被申请操作人");
}
// 批量生成调解申请书
MsCaseApplicationReq req = new MsCaseApplicationReq();
@@ -753,13 +761,14 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
* @param affiliate
*/
@Transactional
public void setCaseAfflicate(MsCaseApplicationVO caseApplication, MsCaseAffiliate affiliate,int groupOrder) {
public int setCaseAfflicate(MsCaseApplicationVO caseApplication, MsCaseAffiliate affiliate,int groupOrder,int operatorCount) {
if(affiliate==null){
return;
return operatorCount;
}
boolean b = affiliate.getOrganizeFlag() != 1 && (affiliate.getRoleType() == 1||affiliate.getRoleType() == 3) && StrUtil.isEmpty(affiliate.getEmail());
if(b|| StrUtil.isEmpty(affiliate.getName())){
return;
return operatorCount;
}
affiliate.setGroupOrder(groupOrder);
// 获取角色缓存
@@ -858,6 +867,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
}
// 保存人员
msCaseAffiliateMapper.insert(affiliate);
if(affiliate.getOperatorFlag()!=null && affiliate.getOperatorFlag()==1){
operatorCount++;
}
return operatorCount;
}
/**
@@ -1048,27 +1061,34 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
Example affliateExample = new Example(MsCaseAffiliate.class);
affliateExample.createCriteria().andEqualTo("caseAppliId", caseApplication.getId());
msCaseAffiliateMapper.deleteByExample(affliateExample);
int appOperatorCount=0;
int resOperatorCount=0;
List<MsCaseAffiliateBase> applicant = msCaseAffiliateVO.getApplicant();
List<MsCaseAffiliateBase> res = msCaseAffiliateVO.getRes();
if(CollectionUtil.isNotEmpty(applicant)){
for (int i = 0; i < applicant.size(); i++) {
// 申请人
setCaseAfflicate(caseApplication, applicant.get(i).getApplicant(),i);
appOperatorCount=setCaseAfflicate(caseApplication, applicant.get(i).getApplicant(),i,appOperatorCount);
// 申请人代理人
setCaseAfflicate(caseApplication, applicant.get(i).getApplicantAgent(),i);
appOperatorCount= setCaseAfflicate(caseApplication, applicant.get(i).getApplicantAgent(),i,appOperatorCount);
}
}
if(CollectionUtil.isNotEmpty(res)){
for (int i = 0; i < res.size(); i++) {
// 申请人
setCaseAfflicate(caseApplication, res.get(i).getRes(),i);
resOperatorCount=setCaseAfflicate(caseApplication, res.get(i).getRes(),i,resOperatorCount);
// 申请人代理人
setCaseAfflicate(caseApplication, res.get(i).getResAgent(),i);
resOperatorCount=setCaseAfflicate(caseApplication, res.get(i).getResAgent(),i,resOperatorCount);
}
}
if (appOperatorCount < 1 && resOperatorCount < 1) {
throw new ServiceException("未设置申请操作人和被申请操作人");
} else if (appOperatorCount < 1) {
throw new ServiceException("未设置申请操作人");
} else if (resOperatorCount < 1) {
throw new ServiceException("未设置被申请操作人");
}
if (CollectionUtil.isNotEmpty(caseApplication.getCaseAttachList())) {
for (MsCaseAttach caseAttach : caseApplication.getCaseAttachList()) {
caseAttach.setCaseAppliId(caseApplication.getId());
@@ -2543,22 +2563,61 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
if (!applicantAffiliateOpt.isPresent() || !resAffiliateOpt.isPresent()) {
throw new ServiceException("未找到案件操作人员");
}
// 更新附件
List<MsCaseAttach> attachList = req.getAttachList();
if (CollectionUtil.isNotEmpty(attachList)) {
Map<Integer, List<MsCaseAttach>> annexTypeMap = attachList.stream().filter(attach -> attach.getAnnexType() != null).collect(Collectors.groupingBy(MsCaseAttach::getAnnexType));
for (Map.Entry<Integer, List<MsCaseAttach>> entry : annexTypeMap.entrySet()) {
if(entry.getKey()!=null && entry.getValue().size()>1){
return AjaxResult.error("同一案件同一类型附件只能上传一个");
}
}
// 先删除已存在的调解书
List<MsCaseAttach> existAttach = msCaseAttachMapper.listCaseAttachByCaseIdAndTypes(req.getId(), new ArrayList<>(annexTypeMap.keySet()));
if (CollectionUtil.isNotEmpty(existAttach)) {
// 对接北明,同步案件状态,删除
for (MsCaseAttach msCaseAttach : existAttach) {
if (StrUtil.isEmpty(msCaseAttach.getOtherSysFileId()) || StrUtil.isEmpty(msCaseAttach.getAnnexPath())) {
continue;
}
beiMingInterfaceService.deleteAttachmentInfo(application.getCaseNum(), msCaseAttach.getOtherSysFileId(), FileUtil.getName(msCaseAttach.getAnnexPath()));
}
}
for (MsCaseAttach attach : attachList) {
// 先删除已经存在的调解书
attach.setCaseAppliId(req.getId());
msCaseAttachMapper.updateCaseAttach(attach);
}
// 对接北明,调用上传附件接口
List<MsCaseAttach> msCaseAttaches = msCaseAttachMapper.listCaseAttachByCaseIdAndType(req.getId(), AnnexTypeEnum.MEDIATE_BOOK.getCode());
if (StrUtil.isEmpty(application.getCaseSource()) && CollectionUtil.isNotEmpty(msCaseAttaches)) {
for (MsCaseAttach msCaseAttach : msCaseAttaches) {
if (StrUtil.isEmpty(msCaseAttach.getAnnexPath())) {
continue;
}
String replacePath = msCaseAttach.getAnnexPath().replace("/profile/", "/home/ruoyi/uploadPath/");
File file = new File(replacePath);
MsCaseFileInfo caseFileInfo = beiMingInterfaceService.pushAttachmentInfo(BMUserName, BMPassword, file, BMSyncSource, application.getCaseNum(), AttachmentOperateTypeEnum.ADD, DocumentTypeEnum.EVEDENT_AGREEMENT);
// 更新附件表
if (caseFileInfo != null && StrUtil.isNotEmpty(caseFileInfo.getFileId())) {
msCaseAttach.setOtherSysFileId(caseFileInfo.getFileId());
msCaseAttachMapper.updateCaseAttach(msCaseAttach);
}
}
}
}
// 线上调解
if (application.getMediationMethod().equals("1")) {
Integer mediaResult = application.getMediaResult();
if (mediaResult == null) {
return AjaxResult.error("请选择调解结果");
}
// 线上调解
List<MsCaseAttach> attachList = req.getAttachList();
if (CollectionUtil.isNotEmpty(attachList)) {
// 先删除已经存在的调解书
msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(req.getId(), AnnexTypeEnum.MEDIATE_BOOK.getCode());
for (MsCaseAttach attach : attachList) {
attach.setCaseAppliId(req.getId());
msCaseAttachMapper.updateCaseAttach(attach);
}
}
if (mediaResult == 1) {
//达成调解
List<MsCaseAttach> caseAttachList = msCaseAttachMapper.queryAnnexPathByCaseId(req.getId());
@@ -3075,53 +3134,11 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
}
}
} else {
// 线下调解
Integer mediaResult=req.getMediaResult();
if(mediaResult==null){
return AjaxResult.error("请选择调解结果");
}
// 线下调解
List<MsCaseAttach> attachList = req.getAttachList();
if (CollectionUtil.isEmpty(attachList)) {
return AjaxResult.error("请上传调解资料");
}
// 先删除已经存在的调解书
if (StrUtil.isEmpty(application.getCaseSource())) {
List<MsCaseAttach> existAttach = msCaseAttachMapper.listCaseAttachByCaseIdAndType(req.getId(), AnnexTypeEnum.MEDIATE_BOOK.getCode());
if (CollectionUtil.isNotEmpty(existAttach)) {
// 对接北明,同步案件状态,删除
for (MsCaseAttach msCaseAttach : existAttach) {
if (StrUtil.isEmpty(msCaseAttach.getOtherSysFileId()) || StrUtil.isEmpty(msCaseAttach.getAnnexPath())) {
continue;
}
beiMingInterfaceService.deleteAttachmentInfo(application.getCaseNum(), msCaseAttach.getOtherSysFileId(), FileUtil.getName(msCaseAttach.getAnnexPath()));
}
}
}
msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(req.getId(), AnnexTypeEnum.MEDIATE_BOOK.getCode());
for (MsCaseAttach attach : attachList) {
attach.setCaseAppliId(req.getId());
msCaseAttachMapper.updateCaseAttach(attach);
}
// 对接北明,调用上传附件接口
List<MsCaseAttach> msCaseAttaches = msCaseAttachMapper.listCaseAttachByCaseIdAndType(req.getId(), AnnexTypeEnum.MEDIATE_BOOK.getCode());
if (StrUtil.isEmpty(application.getCaseSource()) && CollectionUtil.isNotEmpty(msCaseAttaches)) {
for (MsCaseAttach msCaseAttach : msCaseAttaches) {
if (StrUtil.isEmpty(msCaseAttach.getAnnexPath())) {
continue;
}
String replacePath = msCaseAttach.getAnnexPath().replace("/profile/", "/home/ruoyi/uploadPath/");
File file = new File(replacePath);
MsCaseFileInfo caseFileInfo = beiMingInterfaceService.pushAttachmentInfo(BMUserName, BMPassword, file, BMSyncSource, application.getCaseNum(), AttachmentOperateTypeEnum.ADD, DocumentTypeEnum.EVEDENT_AGREEMENT);
// 更新附件表
if (caseFileInfo != null && StrUtil.isNotEmpty(caseFileInfo.getFileId())) {
msCaseAttach.setOtherSysFileId(caseFileInfo.getFileId());
msCaseAttachMapper.updateCaseAttach(msCaseAttach);
}
}
}
// 修改案件状态为待送达
Example flowExample = new Example(MsCaseFlow.class);
if (mediaResult == 1 || mediaResult == 5) {
@@ -1219,6 +1219,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
List<File> fileList = new ArrayList<>();
File file = null;
Long fileId = null;
Map<String,String> fileNameMap = new HashMap<>();
if (caseAttachList != null && caseAttachList.size() > 0) {
for (MsCaseAttach caseAttach : caseAttachList) {
if (Objects.equals(caseAttach.getAnnexType(), AnnexTypeEnum.MEDIATE_BOOK_PDF.getCode())) {
@@ -1229,6 +1230,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
file = new File(path);
fileList.add(file);
fileId = caseAttach.getAnnexId();
fileNameMap.put(file.getPath(), caseAttach.getAnnexName());
System.out.println("文件长度==================:" + file.length());
}
}
@@ -1249,7 +1251,7 @@ public class MsSignSealServiceImpl implements MsSignSealService {
if (file != null && file.exists()) {
try {
Boolean aBoolean = emailOutUtil.sendEmil(email, "您好,审核后的调解书在附件中请查阅", "签署后的调解书", fileList, null);
Boolean aBoolean = emailOutUtil.sendEmil(email, "您好,审核后的调解书在附件中请查阅", "签署后的调解书", fileList, null,fileNameMap);
if (aBoolean) {
sendMailRecord.setSendStatus(1);
@@ -15,7 +15,9 @@ import org.springframework.stereotype.Service;
import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class SendMailRecordServiceImpl implements ISendMailRecordService {
@@ -73,6 +75,8 @@ public class SendMailRecordServiceImpl implements ISendMailRecordService {
@Override
public Boolean reSendMailRecord(SendMailRecord sendMailRecord) {
List<File> fileList = null;
// 附件名称map,路径-附件名称
Map<String,String> fileNameMap=new HashMap<>();
if (sendMailRecord.getFileIds() != null && sendMailRecord.getFileIds() != "") {
String[] fileIds = sendMailRecord.getFileIds().split(",");
for (int i = 0; i < fileIds.length; i++) {
@@ -87,13 +91,14 @@ public class SendMailRecordServiceImpl implements ISendMailRecordService {
String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex + 1);
File file = new File(path);
fileList.add(file);
fileNameMap.put(file.getPath(), msCaseAttach.getAnnexName());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Boolean flag = emailOutUtil.sendEmil(sendMailRecord.getMailAddress(), sendMailRecord.getMailContent(), sendMailRecord.getMailSubject(), fileList, null);
Boolean flag = emailOutUtil.sendEmil(sendMailRecord.getMailAddress(), sendMailRecord.getMailContent(), sendMailRecord.getMailSubject(), fileList, null,fileNameMap);
//发送成功后更细邮件记录的发送时间和发送状态
if (flag) {
sendMailRecord.setSendStatus(1);
@@ -61,6 +61,21 @@
</if>
</where>
</select>
<select id="listCaseAttachByCaseIdAndTypes" resultType="com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach" resultMap="CaseAttachResult">
select *
from ms_case_attach
<where>
<if test="caseAppliId != null ">
AND case_appli_id = #{caseAppliId}
</if>
<if test="annexTypes != null and annexTypes.size()>0 ">
AND annex_type in
<foreach collection="annexTypes" item="annex_type" open="(" separator="," close=")">
#{annex_type}
</foreach>
</if>
</where>
</select>
<delete id="deleteCaseAttachByCasedIdAndType">
delete from ms_case_attach