From c754dcc7a07b866bfce853e1fea17916d34b4093 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Fri, 21 Apr 2023 15:12:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=93=E5=AE=B6?= =?UTF-8?q?=E8=AF=B7=E5=81=87=E7=9F=AD=E4=BF=A1=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ningdatech/pmapi/leave/manage/LeaveManage.java | 3 +++ .../meeting/constant/MeetingMsgTemplateConst.java | 4 ++++ .../meeting/helper/MeetingCallOrMsgHelper.java | 26 ++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/leave/manage/LeaveManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/leave/manage/LeaveManage.java index 64d0c2b..f8ebc2f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/leave/manage/LeaveManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/leave/manage/LeaveManage.java @@ -41,6 +41,7 @@ import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertInviteTypeEnum; import com.ningdatech.pmapi.meeting.entity.enumeration.MeetingStatusEnum; +import com.ningdatech.pmapi.meeting.helper.MeetingCallOrMsgHelper; import com.ningdatech.pmapi.meeting.service.IMeetingExpertService; import com.ningdatech.pmapi.meeting.service.IMeetingService; import com.ningdatech.pmapi.meeting.task.ExpertRandomInviteTask; @@ -77,6 +78,7 @@ public class LeaveManage { private final IExpertMetaApplyService metaApplyService; private final FileService fileService; private final IExpertUserFullInfoService userFullInfoService; + private final MeetingCallOrMsgHelper meetingCallOrMsgHelper; private static final int HOURS_BEFORE_MEETING = 2; @@ -217,6 +219,7 @@ public class LeaveManage { .eq(Meeting::getId, meeting.getId()); meetingService.update(mUpdate); } + meetingCallOrMsgHelper.sendExpertLeaveMsg(expert, meeting); // 临时请假无需审核 leave.setAuditId(0L); leave.setStatus(LeaveStatusEnum.PASSED.getCode()); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/constant/MeetingMsgTemplateConst.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/constant/MeetingMsgTemplateConst.java index 90cf49a..3a865db 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/constant/MeetingMsgTemplateConst.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/constant/MeetingMsgTemplateConst.java @@ -25,4 +25,8 @@ public interface MeetingMsgTemplateConst { */ String MEETING_CANCEL = "尊敬的%s专家,原定于%s的%s会议已取消。给您带来不便,敬请谅解。如有疑问请咨询会议联系人「%s」。"; + String EXPERT_LEAVE_RANDOM = "请注意,%s会议有专家请假,将重新抽取以替换该专家。"; + + String EXPERT_LEAVE_APPOINT = "请注意,%s会议的%s专家请假,请及时登录系统替换该专家。"; + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/MeetingCallOrMsgHelper.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/MeetingCallOrMsgHelper.java index 0955e82..9de3586 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/MeetingCallOrMsgHelper.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/MeetingCallOrMsgHelper.java @@ -7,6 +7,7 @@ import com.ningdatech.basic.util.CollUtils; import com.ningdatech.pmapi.meeting.constant.MeetingMsgTemplateConst; import com.ningdatech.pmapi.meeting.entity.domain.Meeting; import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; +import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertInviteTypeEnum; import com.ningdatech.pmapi.meeting.entity.enumeration.MeetingReviewTypeEnum; import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; import com.ningdatech.pmapi.organization.model.entity.DingOrganization; @@ -187,4 +188,29 @@ public class MeetingCallOrMsgHelper { experts.forEach(w -> w.setSubmitKey(submitKey)); } + public void sendExpertLeaveMsg(MeetingExpert expert, Meeting meeting) { + Long userId = meeting.getCreateBy(); + String msgContent; + if (ExpertInviteTypeEnum.RANDOM.eq(meeting.getInviteType())) { + msgContent = String.format(MeetingMsgTemplateConst.EXPERT_LEAVE_RANDOM, meeting.getName()); + } else { + msgContent = String.format(MeetingMsgTemplateConst.EXPERT_LEAVE_APPOINT, meeting.getName(), expert.getExpertName()); + } + UserInfo info = userInfoService.getById(userId); + SendSmsContext yxtContent = new SendSmsContext(); + yxtContent.setContent(msgContent); + yxtContent.setReceiveNumber(info.getMobile()); + yxtCallOrSmsHelper.sendSms(yxtContent); + // 发送工作通知 + if (info.getAccountId() != null) { + WorkNoticeInfo swn = getSendWorkNoticeInfo(info.getAccountId()); + swn.setMsg(msgContent); + workNoticeStagingService.addByWorkNotice(swn, MsgTypeEnum.REVIEW_MEETING); + Map map = new HashMap<>(2); + map.put("meetingId", meeting.getId()); + Notify notify = getNotify(userId, msgContent, MsgTypeEnum.REVIEW_MEETING, map); + notifyService.save(notify); + } + } + } From b2811313d224483dc9d89d115cee9227e933297b Mon Sep 17 00:00:00 2001 From: WendyYang Date: Fri, 21 Apr 2023 15:25:26 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=B8=93=E5=AE=B6=E8=AF=B7=E5=81=87?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E6=8F=90=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ningdatech/pmapi/leave/manage/LeaveManage.java | 158 +++++++++++---------- 1 file changed, 83 insertions(+), 75 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/leave/manage/LeaveManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/leave/manage/LeaveManage.java index f8ebc2f..31c9735 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/leave/manage/LeaveManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/leave/manage/LeaveManage.java @@ -144,88 +144,18 @@ public class LeaveManage { if (po.getAttachments() != null) { leave.setAttachment(CollUtils.joinByComma(po.getAttachments())); } - LocalDateTime now = LocalDateTime.now(); leave.setType(po.getType()); leave.setRemark(po.getPostscript()); leave.setLeaveUserId(leaveUserId); leave.setCreator(LoginUserUtil.getUsername()); List> leaveDetailTimes = new ArrayList<>(); if (type.equals(LeaveTypeEnum.FIXED_TERM) || type.equals(LeaveTypeEnum.LONG_TERM)) { - boolean fixedTerm = CollUtil.isNotEmpty(po.getFixedType()); - if (fixedTerm) { - // 固定时段请假 - leave.setFixedType(CollUtils.joinByComma(po.getFixedType())); - } - LocalDateTime tempStart = po.getStartTime(); - while (!tempStart.isAfter(po.getEndTime())) { - boolean add = true; - if (fixedTerm) { - int weekday = tempStart.getDayOfWeek().getValue(); - add = po.getFixedType().contains(weekday); - } - if (add) { - LocalDateTime tempEnd = tempStart.toLocalDate().atTime(DateUtil.LOCAL_TIME_3D); - leaveDetailTimes.add(KeyValDTO.of(tempStart, DateUtil.min(tempEnd, po.getEndTime()))); - } - tempStart = tempStart.plusDays(1).toLocalDate().atStartOfDay(); - } - if (leaveDetailTimes.isEmpty()) { - throw BizException.wrap("请假时间无效"); - } - if (leaveDetailService.existsLeaveByUserIdAndTime(leaveUserId, leaveDetailTimes)) { - throw BizException.wrap("该请假时段内已存在请假"); - } - List meetingExperts = listMeetingExpert(leaveUserId, leaveDetailTimes); - if (!meetingExperts.isEmpty()) { - if (meetingExperts.stream().anyMatch(w -> ExpertAttendStatusEnum.AGREED.eq(w.getStatus()))) { - throw BizException.wrap("有待参加会议,请先处理完会议,再发起请假"); - } - List expertsUpdate = meetingExperts.stream() - .map(w -> buildMeetingExpertUpdate(w.getExpertId(), ExpertAttendStatusEnum.ON_LEAVE)) - .collect(Collectors.toList()); - meetingExpertService.updateBatchById(expertsUpdate); - } - leave.setStatus(LeaveStatusEnum.APPLYING.getCode()); - } else if (type.equals(LeaveTypeEnum.TEMPORARY)) { - // 临时请假 - Meeting meeting = meetingService.getById(po.getMeetingId()); - if (MeetingStatusEnum.CANCELED.eq(meeting.getStatus())) { - throw BizException.wrap("该会议已取消"); - } - po.setStartTime(meeting.getStartTime()); - po.setEndTime(meeting.getEndTime()); - if (now.plusHours(HOURS_BEFORE_MEETING).isAfter(po.getStartTime())) { - throw BizException.wrap("会议开始前" + HOURS_BEFORE_MEETING + "小时,不能在线请假,请电话该会议的联系人。"); - } - MeetingExpert expert = meetingExpertService.getByMeetingIdAndExpertId(po.getMeetingId(), leaveUserId); - if (!ExpertAttendStatusEnum.AGREED.eq(expert.getStatus())) { - // 非确认参加状态无法临时请假 - throw BizException.wrap("未同意参加该会议,无法临时请假"); - } - LocalDateTime tempStart = po.getStartTime(); - while (!tempStart.isAfter(po.getEndTime())) { - LocalDateTime tempEnd = tempStart.toLocalDate().atTime(DateUtil.LOCAL_TIME_3D); - leaveDetailTimes.add(KeyValDTO.of(tempStart, DateUtil.min(tempEnd, po.getEndTime()))); - tempStart = tempStart.plusDays(1).toLocalDate().atStartOfDay(); - } - LeaveManage proxy = (LeaveManage) AopContext.currentProxy(); - proxy.cancelMeetingExpertByLeave(expert.getId(), ExpertAttendStatusEnum.ON_LEAVE); - if (ExpertInviteTypeEnum.RANDOM.eq(meeting.getInviteType())) { - inviteTask.notifyInviteTask(meeting.getId(), Boolean.FALSE); - } - if (meeting.getConfirmedRoster()) { - LambdaUpdateWrapper mUpdate = Wrappers.lambdaUpdate(Meeting.class) - .set(Meeting::getConfirmedRoster, Boolean.FALSE) - .eq(Meeting::getId, meeting.getId()); - meetingService.update(mUpdate); - } - meetingCallOrMsgHelper.sendExpertLeaveMsg(expert, meeting); - // 临时请假无需审核 - leave.setAuditId(0L); - leave.setStatus(LeaveStatusEnum.PASSED.getCode()); + leaveProcessByDateRange(po, leaveUserId, leave, leaveDetailTimes); + } else if (LeaveTypeEnum.TEMPORARY.equals(type)) { + leaveProcessByTemporary(po, leaveUserId, leave, leaveDetailTimes); } if (type != LeaveTypeEnum.TEMPORARY) { - ExpertMetaApply apply = getExpertMetaApply(po, leaveUserId, applyUserId, now); + ExpertMetaApply apply = getExpertMetaApply(po, leaveUserId, applyUserId); leave.setAuditId(apply.getId()); if (!leaveForSelf) { leave.setStatus(LeaveStatusEnum.PASSED.getCode()); @@ -240,8 +170,86 @@ public class LeaveManage { return IdVo.of(leave.getId()); } - private ExpertMetaApply getExpertMetaApply(LeaveCreateReq po, Long leaveUserId, Long applyUserId, LocalDateTime now) { + private void leaveProcessByTemporary(LeaveCreateReq po, Long leaveUserId, ExpertLeave leave, List> leaveDetailTimes) { + // 临时请假 + Meeting meeting = meetingService.getById(po.getMeetingId()); + if (MeetingStatusEnum.CANCELED.eq(meeting.getStatus())) { + throw BizException.wrap("该会议已取消"); + } + po.setStartTime(meeting.getStartTime()); + po.setEndTime(meeting.getEndTime()); + if (LocalDateTime.now().plusHours(HOURS_BEFORE_MEETING).isAfter(po.getStartTime())) { + throw BizException.wrap("会议开始前" + HOURS_BEFORE_MEETING + "小时,不能在线请假,请电话该会议的联系人。"); + } + MeetingExpert expert = meetingExpertService.getByMeetingIdAndExpertId(po.getMeetingId(), leaveUserId); + if (!ExpertAttendStatusEnum.AGREED.eq(expert.getStatus())) { + // 非确认参加状态无法临时请假 + throw BizException.wrap("未同意参加该会议,无法临时请假"); + } + LocalDateTime tempStart = po.getStartTime(); + while (!tempStart.isAfter(po.getEndTime())) { + LocalDateTime tempEnd = tempStart.toLocalDate().atTime(DateUtil.LOCAL_TIME_3D); + leaveDetailTimes.add(KeyValDTO.of(tempStart, DateUtil.min(tempEnd, po.getEndTime()))); + tempStart = tempStart.plusDays(1).toLocalDate().atStartOfDay(); + } + LeaveManage proxy = (LeaveManage) AopContext.currentProxy(); + proxy.cancelMeetingExpertByLeave(expert.getId(), ExpertAttendStatusEnum.ON_LEAVE); + if (ExpertInviteTypeEnum.RANDOM.eq(meeting.getInviteType())) { + inviteTask.notifyInviteTask(meeting.getId(), Boolean.FALSE); + } + if (meeting.getConfirmedRoster()) { + LambdaUpdateWrapper mUpdate = Wrappers.lambdaUpdate(Meeting.class) + .set(Meeting::getConfirmedRoster, Boolean.FALSE) + .eq(Meeting::getId, meeting.getId()); + meetingService.update(mUpdate); + } + meetingCallOrMsgHelper.sendExpertLeaveMsg(expert, meeting); + // 临时请假无需审核 + leave.setAuditId(0L); + leave.setStatus(LeaveStatusEnum.PASSED.getCode()); + } + + private void leaveProcessByDateRange(LeaveCreateReq req, Long leaveUserId, ExpertLeave leave, List> leaveDetailTimes) { + boolean fixedTerm = CollUtil.isNotEmpty(req.getFixedType()); + if (fixedTerm) { + // 固定时段请假 + leave.setFixedType(CollUtils.joinByComma(req.getFixedType())); + } + LocalDateTime tempStart = req.getStartTime(); + while (!tempStart.isAfter(req.getEndTime())) { + boolean add = true; + if (fixedTerm) { + int weekday = tempStart.getDayOfWeek().getValue(); + add = req.getFixedType().contains(weekday); + } + if (add) { + LocalDateTime tempEnd = tempStart.toLocalDate().atTime(DateUtil.LOCAL_TIME_3D); + leaveDetailTimes.add(KeyValDTO.of(tempStart, DateUtil.min(tempEnd, req.getEndTime()))); + } + tempStart = tempStart.plusDays(1).toLocalDate().atStartOfDay(); + } + if (leaveDetailTimes.isEmpty()) { + throw BizException.wrap("请假时间无效"); + } + if (leaveDetailService.existsLeaveByUserIdAndTime(leaveUserId, leaveDetailTimes)) { + throw BizException.wrap("该请假时段内已存在请假"); + } + List meetingExperts = listMeetingExpert(leaveUserId, leaveDetailTimes); + if (!meetingExperts.isEmpty()) { + if (meetingExperts.stream().anyMatch(w -> ExpertAttendStatusEnum.AGREED.eq(w.getStatus()))) { + throw BizException.wrap("有待参加会议,请先处理完会议,再发起请假"); + } + List expertsUpdate = meetingExperts.stream() + .map(w -> buildMeetingExpertUpdate(w.getExpertId(), ExpertAttendStatusEnum.ON_LEAVE)) + .collect(Collectors.toList()); + meetingExpertService.updateBatchById(expertsUpdate); + } + leave.setStatus(LeaveStatusEnum.APPLYING.getCode()); + } + + private ExpertMetaApply getExpertMetaApply(LeaveCreateReq po, Long leaveUserId, Long applyUserId) { // 非临时请假需要审批 + LocalDateTime now = LocalDateTime.now(); ExpertMetaApply apply = new ExpertMetaApply(); apply.setCreateOn(now); apply.setUpdateOn(now);