diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/expert/service/IExpertUserFullInfoService.java b/hz-pm-api/src/main/java/com/hz/pm/api/expert/service/IExpertUserFullInfoService.java index 5ad918c..8d903a1 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/expert/service/IExpertUserFullInfoService.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/expert/service/IExpertUserFullInfoService.java @@ -34,7 +34,7 @@ public interface IExpertUserFullInfoService extends IService * @param userIds 用户ID * @return / */ - List listByUserIds(List userIds); + List listByUserIds(Collection userIds); default List listCompanyUniqCodeByUserIds(Collection userIds) { LambdaQueryWrapper query = Wrappers diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/expert/service/impl/ExpertUserFullInfoServiceImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/expert/service/impl/ExpertUserFullInfoServiceImpl.java index 7bf5e48..e5c36fb 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/expert/service/impl/ExpertUserFullInfoServiceImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/expert/service/impl/ExpertUserFullInfoServiceImpl.java @@ -7,6 +7,7 @@ import com.hz.pm.api.expert.mapper.ExpertUserFullInfoMapper; import com.hz.pm.api.expert.service.IExpertUserFullInfoService; import org.springframework.stereotype.Service; +import java.util.Collection; import java.util.List; /** @@ -26,7 +27,7 @@ public class ExpertUserFullInfoServiceImpl extends ServiceImpl listByUserIds(List userIds) { + public List listByUserIds(Collection userIds) { return list(Wrappers.lambdaQuery().in(ExpertUserFullInfo::getUserId, userIds)); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java index cecb22c..cf0f3f7 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java @@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hz.pm.api.common.helper.RegionCacheHelper; import com.hz.pm.api.common.model.constant.BizConst; +import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.expert.entity.ExpertUserFullInfo; import com.hz.pm.api.expert.service.IExpertUserFullInfoService; import com.hz.pm.api.external.MhApiClient; @@ -654,11 +655,11 @@ public class MeetingManage { if (!APPOINT.eq(meeting.getInviteType())) { throw BizException.wrap("该会议不能指定邀请专家"); } - if (meeting.getConfirmedRoster()) { - throw BizException.wrap("补充专家失败,已确认过专家名单"); + if (Boolean.TRUE.equals(meeting.getConfirmedRoster())) { + throw BizException.wrap("已确认过专家名单"); } if (!MeetingStatusEnum.NORMAL.eq(meeting.getStatus())) { - throw BizException.wrap("补充专家失败"); + throw BizException.wrap("请刷新后重试"); } AppointInviteRuleDTO rule = inviteRuleService.appointRuleByMeetingId(meetingId); List userInfos = meetingManageHelper.appointExpertCheck(meetingId, meeting.getInviteType(), req.getExpertIdList()); @@ -692,21 +693,22 @@ public class MeetingManage { if (meeting.getStartTime().isBefore(LocalDateTime.now())) { throw BizException.wrap("会议已开始,暂时无法取消"); } - LambdaUpdateWrapper meetingUpdate = Wrappers.lambdaUpdate(Meeting.class) + Wrapper meetingUpdate = Wrappers.lambdaUpdate(Meeting.class) .set(Meeting::getStatus, MeetingStatusEnum.CANCELED.getCode()) .eq(Meeting::getId, meetingId); meetingService.update(meetingUpdate); + // 取消抽取任务 expertRandomInviteTask.cancelByMeetingIdAndKillTask(meetingId); // 发送通知给专家 List experts = meetingExpertService.listAgreedExperts(meetingId); if (!experts.isEmpty()) { meetingNotifyHelper.sendCancelMeetingMsg(experts, meeting); } + // 将取消的会议推送给MH + mhApiClient.cancelMeetingToMh(meetingId); } finally { distributedLock.releaseLock(key); } - // 将取消的会议推送给MH - mhApiClient.cancelMeetingToMh(meetingId); } public ExpertInvitationDetailVO expertInvitationDetail(Long meetingId, Long expertId) { @@ -734,17 +736,17 @@ public class MeetingManage { public void confirmAttendByManager(ExpertConfirmReq req) { String key = "CONFIRM_ATTEND:" + req.getExpertMeetingId(); - String msgPrefix = req.getAgreed() ? "确认参加" : "拒绝参加"; if (!distributedLock.lock(key, RETRY_TIMES)) { - throw BizException.wrap("%s失败,请重试!", msgPrefix); + throw BizException.wrap("操作失败,请重试!"); } try { MeetingExpert me = meetingExpertService.getById(req.getExpertMeetingId()); if (!NOTICING.eq(me.getStatus())) { - throw BizException.wrap("%s失败,请重试!", msgPrefix); + throw BizException.wrap("操作失败,请重试!"); } - LambdaUpdateWrapper update = Wrappers.lambdaUpdate(MeetingExpert.class) - .set(MeetingExpert::getStatus, (req.getAgreed() ? AGREED : REFUSED).getCode()) + Integer status = (Boolean.TRUE.equals(req.getAgreed()) ? AGREED : REFUSED).getCode(); + Wrapper update = Wrappers.lambdaUpdate(MeetingExpert.class) + .set(MeetingExpert::getStatus, status) .eq(MeetingExpert::getId, req.getExpertMeetingId()); meetingExpertService.update(update); } finally { @@ -773,7 +775,7 @@ public class MeetingManage { if (!NOTICING.eq(expert.getStatus())) { throw BizException.wrap("已确认过的专家不允许移除!"); } - LambdaUpdateWrapper mUpdate = Wrappers.lambdaUpdate(Meeting.class) + Wrapper mUpdate = Wrappers.lambdaUpdate(Meeting.class) .set(Meeting::getConfirmedRoster, false) .eq(Meeting::getId, req.getMeetingId()); meetingService.update(mUpdate); @@ -793,7 +795,7 @@ public class MeetingManage { if (MeetingStatusEnum.CANCELED.eq(meeting.getStatus())) { throw BizException.wrap("会议已取消"); } - LambdaUpdateWrapper update = Wrappers.lambdaUpdate(MeetingExpert.class) + Wrapper update = Wrappers.lambdaUpdate(MeetingExpert.class) .set(MeetingExpert::getStatus, RELEASED.getCode()) .eq(MeetingExpert::getMeetingId, req.getMeetingId()); meetingExpertService.update(update); @@ -813,7 +815,7 @@ public class MeetingManage { if (MeetingStatusEnum.CANCELED.eq(meeting.getStatus())) { throw BizException.wrap("会议已取消"); } - LambdaUpdateWrapper cancel = Wrappers.lambdaUpdate(MeetingExpert.class) + Wrapper cancel = Wrappers.lambdaUpdate(MeetingExpert.class) .set(MeetingExpert::getIsHeadman, Boolean.FALSE) .eq(MeetingExpert::getIsHeadman, Boolean.TRUE) .eq(MeetingExpert::getMeetingId, req.getMeetingId()); @@ -823,7 +825,7 @@ public class MeetingManage { ExpertAttendStatusEnum status = getByCode(headman.getStatus()); throw BizException.wrap("该专家处于:%s状态,不能被设置为专家组长!", status.getValue()); } - LambdaUpdateWrapper setup = Wrappers.lambdaUpdate(MeetingExpert.class) + Wrapper setup = Wrappers.lambdaUpdate(MeetingExpert.class) .set(MeetingExpert::getIsHeadman, Boolean.TRUE) .eq(MeetingExpert::getId, req.getExpertMeetingId()); meetingExpertService.update(setup); @@ -883,33 +885,31 @@ public class MeetingManage { data.setConnecter(meeting.getConnecter()); data.setContact(meeting.getContact()); // 获取未签到的专家信息 - List expertList = experts.stream().filter(m -> Boolean.FALSE.equals(m.getSignStatus())).collect(Collectors.toList()); - Set userIds = expertList.stream().map(MeetingExpert::getExpertId).collect(Collectors.toSet()); - List userInfoList = userInfoService.list(Wrappers.lambdaQuery(UserInfo.class).in(UserInfo::getId, userIds)); - Map userInfoMap = userInfoList.stream().collect(Collectors.toMap(UserInfo::getId, v -> v)); - List userIdList = new ArrayList<>(userIds); - List expertUserFullInfos = expertUserFullInfoService.listByUserIds(userIdList); - Map userFullInfoMap = MapUtil.newHashMap(); - if (CollUtil.isNotEmpty(expertUserFullInfos)) { - userFullInfoMap = expertUserFullInfos.stream().collect(Collectors.toMap(ExpertUserFullInfo::getUserId, v -> v)); - } - Map finalUserFullInfoMap = userFullInfoMap; + Set expertIds = experts.stream() + .filter(m -> Boolean.FALSE.equals(m.getSignStatus())) + .map(MeetingExpert::getExpertId) + .collect(Collectors.toSet()); + // 用户基本信息 + List userInfoList = userInfoService.listByIds(expertIds); + Map userInfoMap = CollUtils.listToMap(userInfoList, UserInfo::getId); + + List expertUsers = expertUserFullInfoService.listByUserIds(expertIds); + Map expertUserMap = CollUtils.listToMap(expertUsers, ExpertUserFullInfo::getUserId); + data.setExpertInfoList(CollUtils.fieldList(experts, w -> { - ExpertInfoVO expertInfoVO = new ExpertInfoVO(); - expertInfoVO.setUserId(w.getExpertId()); - expertInfoVO.setName(w.getExpertName()); - expertInfoVO.setPhoneNo(w.getMobile()); - ExpertUserFullInfo expertUserFullInfo = finalUserFullInfoMap.get(w.getExpertId()); - if (Objects.nonNull(expertUserFullInfo)) { - expertInfoVO.setExpertId(expertUserFullInfo.getId()); - expertInfoVO.setMhExpertId(expertUserFullInfo.getMhExpertId()); - } - UserInfo userInfo = userInfoMap.get(w.getExpertId()); - if (Objects.nonNull(userInfo)) { - expertInfoVO.setMhUnitId(userInfo.getMhUnitId()); - expertInfoVO.setMhUnitName(userInfo.getMhUnitName()); - } - return expertInfoVO; + ExpertInfoVO item = new ExpertInfoVO(); + item.setUserId(w.getExpertId()); + item.setName(w.getExpertName()); + item.setPhoneNo(w.getMobile()); + BizUtils.notNull(expertUserMap.get(w.getExpertId()), expertUser -> { + item.setExpertId(expertUser.getId()); + item.setMhExpertId(expertUser.getMhExpertId()); + }); + BizUtils.notNull(userInfoMap.get(w.getExpertId()), user -> { + item.setMhUnitId(user.getMhUnitId()); + item.setMhUnitName(user.getMhUnitName()); + }); + return item; })); return data; }