Browse Source

优化回避单位

tags/24080901
WendyYang 1 year ago
parent
commit
3e97c8c7bf
2 changed files with 23 additions and 27 deletions
  1. +13
    -13
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/ExpertInviteManage.java
  2. +10
    -14
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/MeetingManage.java

+ 13
- 13
pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/ExpertInviteManage.java View File

@@ -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;
@@ -307,11 +307,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;
}

@@ -526,25 +523,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);


+ 10
- 14
pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/MeetingManage.java View File

@@ -233,21 +233,12 @@ public class MeetingManage {
AvoidRuleDTO avoidInfo = req.getAvoidRule();
Assert.notNull(avoidInfo, "回避信息不能为空");
// 随机抽取的话则需进行抽取数量校验
ExpertCountOnChangeVO countOnChange = expertCountOnChange(req);
if (!countOnChange.getStatus()) {
throw BizException.wrap(countOnChange.getMessage());
}
for (int i = 0; i < randomRules.size(); i++) {
Integer checkCount = countOnChange.getCountList().get(i);
Integer inviteCount = randomRules.get(i).getCount();
Assert.isTrue(checkCount >= inviteCount, "可供抽取的专家数量不足");
}
expertInviteManage.expertInviteByMeetingCreate(meeting, randomRules, avoidInfo);
expertInviteTask.addInviteTaskByMeetingCreate(meeting.getId(), 5);
LambdaUpdateWrapper<Meeting> update = Wrappers.lambdaUpdate(Meeting.class);
update.set(Meeting::getInviteStatus, false);
update.eq(Meeting::getId, meeting.getId());
meetingService.update(update);
LambdaUpdateWrapper<Meeting> mUpdate = Wrappers.lambdaUpdate(Meeting.class)
.set(Meeting::getInviteStatus, false)
.eq(Meeting::getId, meeting.getId());
meetingService.update(mUpdate);
// 回避规则
ExpertInviteAvoidRule avoidRule = new ExpertInviteAvoidRule();
avoidRule.setMeetingId(meeting.getId());
@@ -301,9 +292,14 @@ public class MeetingManage {
return resultCount;
}
List<Long> expertIdsChoose = new ArrayList<>();
for (RandomInviteRuleDTO randomRule : req.getRandomRules()) {
for (int i = 0; i < req.getRandomRules().size(); i++) {
RandomInviteRuleDTO randomRule = req.getRandomRules().get(i);
ExpertChooseDTO chooseExpert = expertInviteManage.expertInviteByRandomRule(req.getAvoidRule(),
randomRule, expertIdsChoose, meeting.getStartTime(), meeting.getEndTime());
if (i < req.getRandomRules().size() - 1 && chooseExpert.getTotal() > 0) {
List<Long> tempUserIds = CollUtils.fieldList(chooseExpert.getExperts(), ExpertUserFullInfo::getUserId);
expertIdsChoose.addAll(tempUserIds);
}
resultCount.addCountList(chooseExpert.getTotal());
}
return resultCount;


Loading…
Cancel
Save