|
|
@@ -3,9 +3,9 @@ package com.ningdatech.pmapi.meeting.manage; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.ningdatech.basic.exception.BizException; |
|
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
|
import com.ningdatech.pmapi.common.util.BizUtils; |
|
|
|
import com.ningdatech.pmapi.common.util.StrUtils; |
|
|
|
import com.ningdatech.pmapi.expert.constant.ExpertAccountStatusEnum; |
|
|
|
import com.ningdatech.pmapi.expert.entity.ExpertAvoidCompany; |
|
|
|
import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo; |
|
|
@@ -172,8 +172,9 @@ public class ExpertInviteManage { |
|
|
|
} |
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(avoidCompanyExpertIds)) { |
|
|
|
for (Long avoidCompanyExpertId : avoidCompanyExpertIds) { |
|
|
|
expertIdsIn.remove(avoidCompanyExpertId); |
|
|
|
expertIdsIn.removeIf(avoidCompanyExpertIds::contains); |
|
|
|
if (expertIdsIn.isEmpty()) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
return expertIdsIn; |
|
|
@@ -249,8 +250,8 @@ public class ExpertInviteManage { |
|
|
|
public ExpertChooseDTO expertInviteByRandomRule(AvoidRuleDTO avoidRule, |
|
|
|
RandomInviteRuleDTO randomRule, |
|
|
|
List<Long> appointExpertIds, |
|
|
|
LocalDateTime start, |
|
|
|
LocalDateTime end) { |
|
|
|
LocalDateTime sTime, |
|
|
|
LocalDateTime eTime) { |
|
|
|
ExpertChooseDTO result = new ExpertChooseDTO(new ArrayList<>(), 0); |
|
|
|
List<Long> expertIdsIn = mergeExpertIdsByCondition(randomRule, avoidRule); |
|
|
|
if (expertIdsIn == null) { |
|
|
@@ -287,17 +288,17 @@ public class ExpertInviteManage { |
|
|
|
} |
|
|
|
} |
|
|
|
// 过滤掉已参加会议的专家 |
|
|
|
List<Long> expertIdsLockByMeeting = expertInviteHelper.listInvitedExpertByTime(start, end); |
|
|
|
List<Long> expertIdsLockByMeeting = expertInviteHelper.listInvitedExpertByTime(sTime, eTime); |
|
|
|
expertIdsIn.removeIf(expertIdsLockByMeeting::contains); |
|
|
|
if (expertIdsIn.isEmpty()) { |
|
|
|
return result; |
|
|
|
} |
|
|
|
query.in(ExpertUserFullInfo::getUserId, expertIdsIn); |
|
|
|
} else if (avoidExpert || CollUtil.isNotEmpty(appointExpertIds)) { |
|
|
|
Set<Long> tempExperts = expertInviteHelper.getAvoidExpert(appointExpertIds, avoidRule, start, end); |
|
|
|
Set<Long> tempExperts = expertInviteHelper.getAvoidExpert(appointExpertIds, avoidRule, sTime, eTime); |
|
|
|
query.notIn(ExpertUserFullInfo::getUserId, tempExperts); |
|
|
|
} else { |
|
|
|
Set<Long> notInUserIds = expertInviteHelper.listExpertLeaveOrInvited(start, end); |
|
|
|
Set<Long> notInUserIds = expertInviteHelper.listExpertLeaveOrInvited(sTime, eTime); |
|
|
|
if (!notInUserIds.isEmpty()) { |
|
|
|
query.notIn(ExpertUserFullInfo::getUserId, notInUserIds); |
|
|
|
} |
|
|
@@ -307,11 +308,8 @@ public class ExpertInviteManage { |
|
|
|
return result; |
|
|
|
} |
|
|
|
Map<String, List<ExpertUserFullInfo>> userGroupByUnit = CollUtils.group(userInfoList, ExpertUserFullInfo::getCompanyUniqCode); |
|
|
|
result.setTotal(userInfoList.size()); |
|
|
|
// count为空表示数量校验 |
|
|
|
if (randomRule.getCount() == null || result.getTotal() >= randomRule.getCount()) { |
|
|
|
result.setExperts(inviteGroupByCompany(userGroupByUnit, randomRule.getCount())); |
|
|
|
} |
|
|
|
result.setTotal(userGroupByUnit.size()); |
|
|
|
result.setExperts(inviteGroupByCompany(userGroupByUnit, randomRule.getCount())); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
@@ -382,7 +380,7 @@ public class ExpertInviteManage { |
|
|
|
List<String> tmpUniqCompanyCodes = CollUtils.fieldList(agreeOrNoticingUserInfos, ExpertUserFullInfo::getCompanyUniqCode); |
|
|
|
notInCompanyUniqCodeList.addAll(tmpUniqCompanyCodes); |
|
|
|
} |
|
|
|
if (invitedRefused) { |
|
|
|
if (!invitedRefused) { |
|
|
|
// 拒绝参加的不可以被再次抽中 |
|
|
|
List<MeetingExpert> refusedExperts = expertGroupByStatus.get(REFUSED); |
|
|
|
if (refusedExperts.size() > 0) { |
|
|
@@ -526,25 +524,28 @@ public class ExpertInviteManage { |
|
|
|
* 专家抽取(会议创建时抽取) |
|
|
|
* |
|
|
|
* @param randomRules 随机抽取规则 |
|
|
|
* @param avoidRuled 回避信息 |
|
|
|
* @param avoidRule 回避信息 |
|
|
|
* @param meeting 会议信息 |
|
|
|
* @author WendyYang |
|
|
|
**/ |
|
|
|
public void expertInviteByMeetingCreate(Meeting meeting, |
|
|
|
List<RandomInviteRuleDTO> randomRules, |
|
|
|
AvoidRuleDTO avoidRuled) { |
|
|
|
AvoidRuleDTO avoidRule) { |
|
|
|
List<MeetingExpert> expertInserts = new ArrayList<>(); |
|
|
|
// 处理随机抽取规则 |
|
|
|
if (CollectionUtils.isNotEmpty(randomRules)) { |
|
|
|
List<ExpertInviteRule> randoms = new ArrayList<>(); |
|
|
|
List<ExpertChooseDTO> expertsByRandom = new ArrayList<>(); |
|
|
|
List<Long> chooseExpertIds = new ArrayList<>(); |
|
|
|
LocalDateTime startTime = meeting.getStartTime(); |
|
|
|
LocalDateTime endTime = meeting.getEndTime(); |
|
|
|
LocalDateTime sTime = meeting.getStartTime(); |
|
|
|
LocalDateTime eTime = meeting.getEndTime(); |
|
|
|
randomRules.forEach(rule -> { |
|
|
|
ExpertChooseDTO tempExperts = expertInviteByRandomRule(avoidRuled, rule, chooseExpertIds, startTime, endTime); |
|
|
|
expertsByRandom.add(tempExperts); |
|
|
|
chooseExpertIds.addAll(CollUtils.fieldList(tempExperts.getExperts(), ExpertUserFullInfo::getUserId)); |
|
|
|
ExpertChooseDTO tmpExperts = expertInviteByRandomRule(avoidRule, rule, chooseExpertIds, sTime, eTime); |
|
|
|
if (tmpExperts.getTotal() < rule.getCount()) { |
|
|
|
throw BizException.wrap("可抽取专家数量不足"); |
|
|
|
} |
|
|
|
expertsByRandom.add(tmpExperts); |
|
|
|
chooseExpertIds.addAll(CollUtils.fieldList(tmpExperts.getExperts(), ExpertUserFullInfo::getUserId)); |
|
|
|
randoms.add(getExpertInviteRule(rule, meeting.getId())); |
|
|
|
}); |
|
|
|
inviteRuleService.saveBatch(randoms); |
|
|
|