From f76a2e985005c29849e46232bb77f0af29f47b01 Mon Sep 17 00:00:00 2001 From: 18792927508 <1322446236@qq.com> Date: Thu, 18 Apr 2024 13:56:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E6=AD=A5=E5=8F=91=E9=80=81=E7=9F=AD?= =?UTF-8?q?=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/MsCaseApplicationServiceImpl.java | 126 ++++++++++-------- .../mscase/impl/MsCasePaymentServiceImpl.java | 11 +- 2 files changed, 79 insertions(+), 58 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java index b465408..f86a633 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java @@ -74,6 +74,8 @@ import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; import java.util.function.Function; import java.util.stream.Collectors; @@ -1609,20 +1611,23 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { application.setUpdateBy(SecurityUtils.getUsername()); application.setUpdateTime(new Date()); application.setBatchNumber(null); - // 给被申请人发送短信 - if (affiliateMap.containsKey(application.getId())) { - List affiliates = affiliateMap.get(application.getId()); - // 被申受理分配通知 - SMSNoticeDO resNotice = new SMSNoticeDO("待缴费通知", - "尊敬的用户,您的" + application.getCaseNum() + "的案件已成功提交,请登录调解系统进行缴费处理。请知晓,如非本人操作,请忽略本短信。", - "2074247", - new String[]{application.getCaseNum()} - ); - SMSNotice notice = new SMSNotice(null,resNotice); - caseApplicationService.sendNotice(application,affiliates,false,notice); - } + msCaseApplicationMapper.updateByPrimaryKeySelective(application); caseApplicationService.nextFlow(application.getId(), req.getCaseFlowId(),req.getLockStatus()); + ExecutorService executor = ThreadUtil.createThreadPool(); + CompletableFuture.runAsync(() -> { + // 给被申请人发送短信 + if (affiliateMap.containsKey(application.getId())) { + List affiliates = affiliateMap.get(application.getId()); + // 被申受理分配通知 + SMSNoticeDO resNotice = new SMSNoticeDO("待缴费通知", + "尊敬的用户,您的" + application.getCaseNum() + "的案件已成功提交,请登录调解系统进行缴费处理。请知晓,如非本人操作,请忽略本短信。", + "2074247", + new String[]{application.getCaseNum()} + ); + SMSNotice notice = new SMSNotice(null,resNotice); + caseApplicationService.sendNotice(application,affiliates,false,notice); + }}, executor); } /** @@ -1639,6 +1644,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { if(selectApplication==null){ return; } + ExecutorService executor = ThreadUtil.createThreadPool(); + CompletableFuture.runAsync(() -> { List appPhones=new ArrayList<>(); List resPhones=new ArrayList<>(); List appEmails=new ArrayList<>(); @@ -1682,7 +1689,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { } } } - } + }}, executor); } /** @@ -2125,54 +2132,58 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { msCaseApplicationMapper.updateByPrimaryKeySelective(application); // 根据案件id查询案件 MsCaseApplication caseApplication = msCaseApplicationMapper.selectByPrimaryKey(application.getId()); - // 发送开庭短信 - if(CollectionUtil.isNotEmpty(vo.getHerDates())) { - List affiliates = selectAffliatesByCaseId(application.getId()); - caseApplication.setHearDate(application.getHearDate()); - // 申请人发送开庭日期短信 - sendHearDateSms(caseApplication, affiliates); + long l = System.currentTimeMillis(); + ExecutorService executor = ThreadUtil.createThreadPool(); + CompletableFuture.runAsync(() -> { + // 发送开庭短信 + if (CollectionUtil.isNotEmpty(vo.getHerDates())) { + List affiliates = selectAffliatesByCaseId(application.getId()); + caseApplication.setHearDate(application.getHearDate()); + // 申请人发送开庭日期短信 + sendHearDateSms(caseApplication, affiliates); - // 调解员发送短信,根据调解员id查询用户 - if (caseApplication.getMediatorId() != null) { - // 线下调解 2077966 尊敬的用户,您的{1}案件,线下调解日期已确定为{2},请知晓,如非本人操作,请忽略本短信。 - SysUser sysUser = sysUserMapper.selectUserById(caseApplication.getMediatorId()); - String content="尊敬的用户,您的" + caseApplication.getCaseNum() + "的案件,线下调解日期已确定为"+application.getHearDate()+",请知晓,如非本人操作,请忽略本短信。"; - String templateId="2077966"; - String subject="开庭日期通知"; - MsCaseAffiliate meditorAffliate = new MsCaseAffiliate(); - meditorAffliate.setPhone(sysUser.getPhonenumber()); - meditorAffliate.setEmail(sysUser.getEmail()); - String roomUuid=null; - // 线上调解 - if(StrUtil.isNotEmpty(application.getMediationMethod()) && application.getMediationMethod().equals("1")){ - // 获取短信链接uuid - MeetingInfoVO meetingInfoVO= MeetingInfoVO.builder().userId(sysUser.getUserId()).userName(sysUser.getUserName()).caseId(application.getId()).roomId(application.getRoomId()).build(); - roomUuid = shortMessageService.buildMeetingInfoRecord(meetingInfoVO); - // 短信模板:2130103 线上调解时间和会议通知 尊敬的用户,您的{2}线上开庭时间为{3},会议链接https://txroom.xayunmei.com/#/home?{4},请点击链接参加会议,如非本人操作,请忽略本短信. - content="尊敬的用户,您的" + caseApplication.getCaseNum() + "线上开庭时间为"+application.getHearDate()+"会议链接https://txroom.xayunmei.com/#/home?"+roomUuid+",请点击链接参加会议,如非本人操作,请忽略本短信."; - templateId = "2130103"; - } - // 电话号不为空,发送短信,否则发邮箱 - if (StrUtil.isNotEmpty(sysUser.getPhonenumber())) { - if(roomUuid==null) { - SmsUtils.sendSms(caseApplication, templateId, sysUser.getPhonenumber(), - new String[]{caseApplication.getCaseNum(), application.getHearDate()}); - }else { - SmsUtils.sendSms(caseApplication, templateId, sysUser.getPhonenumber(), - new String[]{caseApplication.getCaseNum(), application.getHearDate(),roomUuid}); } + }, executor); + // 调解员发送短信,根据调解员id查询用户 + CompletableFuture.runAsync(() -> { if (caseApplication.getMediatorId() != null) { + // 线下调解 2077966 尊敬的用户,您的{1}案件,线下调解日期已确定为{2},请知晓,如非本人操作,请忽略本短信。 + SysUser sysUser = sysUserMapper.selectUserById(caseApplication.getMediatorId()); + String content = "尊敬的用户,您的" + caseApplication.getCaseNum() + "的案件,线下调解日期已确定为" + application.getHearDate() + ",请知晓,如非本人操作,请忽略本短信。"; + String templateId = "2077966"; + String subject = "开庭日期通知"; + MsCaseAffiliate meditorAffliate = new MsCaseAffiliate(); + meditorAffliate.setPhone(sysUser.getPhonenumber()); + meditorAffliate.setEmail(sysUser.getEmail()); + String roomUuid = null; + // 线上调解 + if (StrUtil.isNotEmpty(application.getMediationMethod()) && application.getMediationMethod().equals("1")) { + // 获取短信链接uuid + MeetingInfoVO meetingInfoVO = MeetingInfoVO.builder().userId(sysUser.getUserId()).userName(sysUser.getUserName()).caseId(application.getId()).roomId(application.getRoomId()).build(); + roomUuid = shortMessageService.buildMeetingInfoRecord(meetingInfoVO); + // 短信模板:2130103 线上调解时间和会议通知 尊敬的用户,您的{2}线上开庭时间为{3},会议链接https://txroom.xayunmei.com/#/home?{4},请点击链接参加会议,如非本人操作,请忽略本短信. - - } else { - // 发送邮件 - caseApplicationService.sendEmail(caseApplication, meditorAffliate, subject, content); - - } + content = "尊敬的用户,您的" + caseApplication.getCaseNum() + "线上开庭时间为" + application.getHearDate() + "会议链接https://txroom.xayunmei.com/#/home?" + roomUuid + ",请点击链接参加会议,如非本人操作,请忽略本短信."; + templateId = "2130103"; } - } - // 新增日志 + // 电话号不为空,发送短信,否则发邮箱 + if (StrUtil.isNotEmpty(sysUser.getPhonenumber())) { + if (roomUuid == null) { + SmsUtils.sendSms(caseApplication, templateId, sysUser.getPhonenumber(), + new String[]{caseApplication.getCaseNum(), application.getHearDate()}); + } else { + SmsUtils.sendSms(caseApplication, templateId, sysUser.getPhonenumber(), + new String[]{caseApplication.getCaseNum(), application.getHearDate(), roomUuid}); + } + + } else { + // 发送邮件 + caseApplicationService.sendEmail(caseApplication, meditorAffliate, subject, content); + + } + } }, executor); + // 新增日志 CaseLogUtils.insertCaseLog(caseApplication.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), ""); } @@ -2327,7 +2338,9 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { application.setRejectReason(reason); if(application.getCaseFlowId()!=null && application.getCaseFlowId()==4){ // todo 超过五日还没有受理,给申请操作人发送不受理通知,有手机号发短信,没有手机号发邮箱 - // 申请人不受理分配通知 + // 申请人不受理分配通知 // todo 短信异步 + ExecutorService executor = ThreadUtil.createThreadPool(); + CompletableFuture.runAsync(() -> { String rejectReason = application.getRejectReason() == null ? "" : application.getRejectReason(); SMSNoticeDO applicantNotice = new SMSNoticeDO("案件不受理通知", "尊敬的用户,您编号为" + application.getCaseNum() + "的案件由于" + rejectReason + "所以不予受理,请知晓,如非本人操作,请忽略本短信。", @@ -2337,6 +2350,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { SMSNotice notice = new SMSNotice(applicantNotice,null); caseApplicationService.sendNotice(application,affiliates,true,notice); + }, executor); // 修改案件状态为17,结束 MsCaseApplication caseApplication = new MsCaseApplication(); caseApplication.setId(id); diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCasePaymentServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCasePaymentServiceImpl.java index 4574587..73f650b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCasePaymentServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCasePaymentServiceImpl.java @@ -14,6 +14,7 @@ import com.ruoyi.common.enums.PaymentStatusEnum; import com.ruoyi.common.enums.YesOrNoEnum; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.ThreadUtil; import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.dto.PayRequest; import com.ruoyi.dto.PayResponse; @@ -41,6 +42,8 @@ import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -339,7 +342,8 @@ public class MsCasePaymentServiceImpl implements MsCasePaymentService { } casePaymentRecord.setCaseId(application.getId()); Example example = new Example(MsCasePaymentRecord.class); - example.createCriteria().andEqualTo("caseId", casePaymentRecord.getCaseId());casePaymentRecordMapper.updateByExampleSelective(casePaymentRecord, example); + example.createCriteria().andEqualTo("caseId", casePaymentRecord.getCaseId()); + casePaymentRecordMapper.updateByExampleSelective(casePaymentRecord, example); // 更改案件流程id和案件状态 application.setCaseFlowId(flow.getId()); application.setCaseStatusName(flow.getCaseStatusName()); @@ -379,6 +383,9 @@ public class MsCasePaymentServiceImpl implements MsCasePaymentService { if(CollectionUtil.isEmpty(operatorList)){ throw new ServiceException("未找到案件操作人员"); } + // 异步发送短信 + ExecutorService executor = ThreadUtil.createThreadPool(); + CompletableFuture.runAsync(() -> { if(dto.getApplicantConfirm()) { List appPhones=new ArrayList<>(); @@ -427,7 +434,7 @@ public class MsCasePaymentServiceImpl implements MsCasePaymentService { } } - } + }}, executor); }