Browse Source

修改专家抽取

tags/24080901
WendyYang 5 months ago
parent
commit
4714cbe785
8 changed files with 77 additions and 55 deletions
  1. +1
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/dto/ExpertChoseDTO.java
  2. +1
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/dto/ExpertJudgeTimeLimitDTO.java
  3. +1
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/dto/InviteCallIgnoreTimeDTO.java
  4. +5
    -5
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/enumeration/MeetingSettingsTypeEnum.java
  5. +9
    -4
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/req/MeetingSettingsSaveReq.java
  6. +41
    -31
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/ExpertInviteManage.java
  7. +1
    -2
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java
  8. +18
    -10
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/ExpertRandomInviteTask.java

hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/dto/ExpertChooseDTO.java → hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/dto/ExpertChoseDTO.java View File

@@ -16,7 +16,7 @@ import java.util.List;
*/
@Data
@AllArgsConstructor
public class ExpertChooseDTO {
public class ExpertChoseDTO {

private List<ExpertUserFullInfo> experts;


hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/dto/ExpertJudgeTimeLimitContentDTO.java → hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/dto/ExpertJudgeTimeLimitDTO.java View File

@@ -11,7 +11,7 @@ import lombok.Data;
* @since 09:24 2023/12/27
*/
@Data
public class ExpertJudgeTimeLimitContentDTO {
public class ExpertJudgeTimeLimitDTO {

private Integer days;


hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/dto/InviteCallIgnoreTimeContentDTO.java → hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/dto/InviteCallIgnoreTimeDTO.java View File

@@ -14,7 +14,7 @@ import java.time.LocalTime;
* @since 00:27 2023/12/27
*/
@Data
public class InviteCallIgnoreTimeContentDTO {
public class InviteCallIgnoreTimeDTO {

@JSONField(format = "HH:mm")
private LocalTime startTime;

+ 5
- 5
hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/enumeration/MeetingSettingsTypeEnum.java View File

@@ -1,7 +1,7 @@
package com.hz.pm.api.meeting.entity.enumeration;

import com.hz.pm.api.meeting.entity.dto.ExpertJudgeTimeLimitContentDTO;
import com.hz.pm.api.meeting.entity.dto.InviteCallIgnoreTimeContentDTO;
import com.hz.pm.api.meeting.entity.dto.ExpertJudgeTimeLimitDTO;
import com.hz.pm.api.meeting.entity.dto.InviteCallIgnoreTimeDTO;
import lombok.AllArgsConstructor;
import lombok.Getter;

@@ -17,9 +17,9 @@ import lombok.Getter;
@AllArgsConstructor
public enum MeetingSettingsTypeEnum {

INVITE_CALL_IGNORE_TIME("专家抽取免打扰时段配置", InviteCallIgnoreTimeContentDTO.class),
SMS_SEND_IGNORE_TIME("短信发送免打扰时间段", InviteCallIgnoreTimeContentDTO.class),
EXPERT_JUDGE_TIME_LIMIT("专家星级评分时间配置", ExpertJudgeTimeLimitContentDTO.class);
INVITE_CALL_IGNORE_TIME("专家抽取免打扰时段配置", InviteCallIgnoreTimeDTO.class),
SMS_SEND_IGNORE_TIME("短信发送免打扰时间段", InviteCallIgnoreTimeDTO.class),
EXPERT_JUDGE_TIME_LIMIT("专家星级评分时间配置", ExpertJudgeTimeLimitDTO.class);

private final String name;
private final Class<?> contentClass;


+ 9
- 4
hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/req/MeetingSettingsSaveReq.java View File

@@ -1,7 +1,8 @@
package com.hz.pm.api.meeting.entity.req;

import com.hz.pm.api.meeting.entity.dto.InviteCallIgnoreTimeContentDTO;
import com.hz.pm.api.meeting.entity.dto.ExpertJudgeTimeLimitContentDTO;
import cn.hutool.core.bean.BeanUtil;
import com.hz.pm.api.meeting.entity.dto.ExpertJudgeTimeLimitDTO;
import com.hz.pm.api.meeting.entity.dto.InviteCallIgnoreTimeDTO;
import com.hz.pm.api.meeting.entity.enumeration.MeetingSettingsTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -33,11 +34,15 @@ public class MeetingSettingsSaveReq {
public static class SettingsContentPackageDTO {

@ApiModelProperty("专家邀请免打扰时段设置")
private InviteCallIgnoreTimeContentDTO expertInviteIgnoreTimeContent;
private InviteCallIgnoreTimeDTO expertInviteIgnoreTime;

@ApiModelProperty("专家评价时间设置")
private ExpertJudgeTimeLimitContentDTO expertJudgeTimeLimitContent;
private ExpertJudgeTimeLimitDTO expertJudgeTimeLimit;

}

public <T> T getSettingsContent(Class<T> tClass) {
return BeanUtil.toBean(settingsContent, tClass);
}

}

+ 41
- 31
hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/ExpertInviteManage.java View File

@@ -292,21 +292,21 @@ public class ExpertInviteManage {
* @return 满足抽取条件的专家
* @author WendyYang
**/
public ExpertChooseDTO expertInviteByRandomRule(AvoidRuleDTO avoidRule,
RandomInviteRuleDTO randomRule,
List<Long> invitedExpertIds,
LocalDateTime sTime,
LocalDateTime eTime,
LocalDateTime meetingCreateOn) {
ExpertChooseDTO result = new ExpertChooseDTO(new ArrayList<>(), 0);
public ExpertChoseDTO expertInviteByRandomRule(AvoidRuleDTO avoidRule,
RandomInviteRuleDTO randomRule,
List<Long> invitedExpertIds,
LocalDateTime sTime,
LocalDateTime eTime,
LocalDateTime meetingCreateOn) {
ExpertChoseDTO result = new ExpertChoseDTO(new ArrayList<>(), 0);
MergeExpertIdDTO merge = mergeExpertIdsByCondition(randomRule, avoidRule);
if (merge.isSkip()) {
return result;
}
boolean avoidExpert = CollUtil.isNotEmpty(avoidRule.getExpertIds());
boolean avoidCompany = CollUtil.isNotEmpty(avoidRule.getAvoidUnitIdList());
boolean hasAvoidExpert = CollUtil.isNotEmpty(avoidRule.getExpertIds());
boolean hasAvoidCompany = CollUtil.isNotEmpty(avoidRule.getAvoidUnitIdList());
Set<String> avoidCompanyUniqCodes = new HashSet<>();
if (avoidCompany) {
if (hasAvoidCompany) {
avoidCompanyUniqCodes.addAll(avoidRule.getAvoidUnitIdList());
}
if (CollUtil.isNotEmpty(invitedExpertIds)) {
@@ -334,7 +334,7 @@ public class ExpertInviteManage {
// 处理专家层级
addRegionLimit(query, randomRule);
if (!expertIdsIn.isEmpty()) {
if (avoidExpert) {
if (hasAvoidExpert) {
expertIdsIn.removeIf(w -> avoidRule.getExpertIds().contains(w));
if (expertIdsIn.isEmpty()) {
// 字典、标签、履职意向地 筛选出的专家ID移除需要回避的专家ID、如果为空则说明没有符合条件的
@@ -353,7 +353,7 @@ public class ExpertInviteManage {
if (expertIdsIn.isEmpty()) {
return result;
}
} else if (avoidExpert || CollUtil.isNotEmpty(invitedExpertIds)) {
} else if (hasAvoidExpert || CollUtil.isNotEmpty(invitedExpertIds)) {
Set<Long> tmpExpert = expertInviteHelper.getAvoidExpert(invitedExpertIds, avoidRule, sTime, eTime);
expertIdsNotIn.addAll(tmpExpert);
} else {
@@ -405,18 +405,18 @@ public class ExpertInviteManage {
* @param msTime 会议开始时间
* @param meTime 会议结束时间
* @param reInvite 邀请已拒绝
* @return {@link ExpertChooseDTO}
* @return {@link ExpertChoseDTO}
* @author WendyYang
**/
public ExpertChooseDTO expertReplaceByRandomRule(AvoidRuleDTO avoidRule,
RandomInviteRuleDTO randomRule,
Collection<MeetingExpert> invitedExperts,
Integer count,
LocalDateTime msTime,
LocalDateTime meTime,
LocalDateTime tsTime,
boolean reInvite) {
ExpertChooseDTO result = new ExpertChooseDTO(new ArrayList<>(), 0);
public ExpertChoseDTO expertReplaceByRandomRule(AvoidRuleDTO avoidRule,
RandomInviteRuleDTO randomRule,
Collection<MeetingExpert> invitedExperts,
Integer count,
LocalDateTime msTime,
LocalDateTime meTime,
LocalDateTime tsTime,
boolean reInvite) {
ExpertChoseDTO result = new ExpertChoseDTO(new ArrayList<>(), 0);
// 合并标签、字典
MergeExpertIdDTO merge = mergeExpertIdsByCondition(randomRule, avoidRule);
if (merge.isSkip()) {
@@ -466,15 +466,26 @@ public class ExpertInviteManage {
Map<ExpertAttendStatusEnum, List<MeetingExpert>> expertGroupByStatus = invitedExperts.stream()
.collect(Collectors.groupingBy(w -> ExpertAttendStatusEnum.getByCode(w.getStatus())));
// 回避同单位其他专家
AvoidTypeEnum avoidType = avoidRule.getAvoidType() == null ? AvoidTypeEnum.NONE : AvoidTypeEnum.getByCode(avoidRule.getAvoidType());
List<MeetingExpert> agreeOrNoticing = new ArrayList<>();
BizUtils.notEmpty(expertGroupByStatus.get(AGREED), agreeOrNoticing::addAll);
BizUtils.notEmpty(expertGroupByStatus.get(NOTICING), agreeOrNoticing::addAll);
List<Long> agreeOrNoticingExpertIds = CollUtils.fieldList(agreeOrNoticing, MeetingExpert::getExpertId);
if (!agreeOrNoticingExpertIds.isEmpty()) {
expertIdsNotIn.addAll(agreeOrNoticingExpertIds);
List<ExpertUserFullInfo> agreeOrNoticingUserInfos = expertUserFullInfoService.listByUserIds(agreeOrNoticingExpertIds);
List<String> tmpUniqCompanyCodes = CollUtils.fieldList(agreeOrNoticingUserInfos, ExpertUserFullInfo::getCompanyUniqCode);
notInCompanyUniqCodeList.addAll(tmpUniqCompanyCodes);
if (AvoidTypeEnum.CURR_UNIT.equals(avoidType)) {
List<ExpertUserFullInfo> agreeOrNoticingUserInfos = expertUserFullInfoService.listByUserIds(agreeOrNoticingExpertIds);
List<String> tmpUniqCompanyCodes = CollUtils.fieldList(agreeOrNoticingUserInfos, ExpertUserFullInfo::getCompanyUniqCode);
notInCompanyUniqCodeList.addAll(tmpUniqCompanyCodes);
} else if (AvoidTypeEnum.CURR_STRIP.equals(avoidType)) {
List<ExpertGovBusinessStrip> expertStrips = expertGovBusinessStripService.listByUserIds(agreeOrNoticingExpertIds);
if (CollUtil.isNotEmpty(expertStrips)) {
List<String> businessStripCodes = CollUtils.fieldList(expertStrips, ExpertGovBusinessStrip::getBusinessStripCode);
query.notExists("select 1 from expert_gov_business_strip egbs " +
"where egbs.expertUserId = nd_expert_user_full_info.user_id " +
"and egbs.business_strip_code in " + BizUtils.inSqlJoin(businessStripCodes));
}
}
}
// 已请假的专家不再抽取
List<MeetingExpert> expertsOnLeave = expertGroupByStatus.get(ON_LEAVE);
@@ -513,15 +524,14 @@ public class ExpertInviteManage {
if (userFullInfos.isEmpty()) {
return result;
}
AvoidTypeEnum avoidType = avoidRule.getAvoidType() == null ? AvoidTypeEnum.CURR_UNIT : AvoidTypeEnum.getByCode(avoidRule.getAvoidType());
switch (avoidType) {
case NONE:
result.setExperts(inviteWithoutCompany(userFullInfos, expertsByRecentMeeting(), randomRule.getCount()));
result.setExperts(inviteWithoutCompany(userFullInfos, expertsByRecentMeeting(), count));
result.setTotal(userFullInfos.size());
break;
case CURR_UNIT:
Map<String, List<ExpertUserFullInfo>> unitGroup = CollUtils.group(userFullInfos, ExpertUserFullInfo::getCompanyUniqCode);
result.setExperts(inviteGroupByUnit(unitGroup, expertsByRecentMeeting(), randomRule.getCount()));
result.setExperts(inviteGroupByUnit(unitGroup, expertsByRecentMeeting(), count));
result.setTotal(unitGroup.size());
break;
case CURR_STRIP:
@@ -529,7 +539,7 @@ public class ExpertInviteManage {
List<ExpertGovBusinessStrip> expertStrips = expertGovBusinessStripService.listByUserIds(userIds);
if (!expertStrips.isEmpty()) {
Map<String, List<ExpertGovBusinessStrip>> stripGroup = CollUtils.group(expertStrips, ExpertGovBusinessStrip::getBusinessStripCode);
result.setExperts(inviteGroupByStrip(stripGroup, userFullInfos, expertsByRecentMeeting(), randomRule.getCount()));
result.setExperts(inviteGroupByStrip(stripGroup, userFullInfos, expertsByRecentMeeting(), count));
result.setTotal(stripGroup.size());
} else {
result.setTotal(0);
@@ -573,13 +583,13 @@ public class ExpertInviteManage {
// 处理随机抽取规则
if (CollUtil.isNotEmpty(randomRules)) {
List<ExpertInviteRule> randoms = new ArrayList<>();
List<ExpertChooseDTO> expertsByRandom = new ArrayList<>();
List<ExpertChoseDTO> expertsByRandom = new ArrayList<>();
List<Long> chooseExpertIds = new ArrayList<>();
LocalDateTime sTime = meeting.getStartTime();
LocalDateTime eTime = meeting.getEndTime();
LocalDateTime createOn = meeting.getCreateOn();
randomRules.forEach(rule -> {
ExpertChooseDTO tmpExperts = expertInviteByRandomRule(avoidRule, rule, chooseExpertIds, sTime, eTime, createOn);
ExpertChoseDTO tmpExperts = expertInviteByRandomRule(avoidRule, rule, chooseExpertIds, sTime, eTime, createOn);
if (tmpExperts.getTotal() < rule.getCount()) {
throw BizException.wrap("可抽取专家数量不足");
}


+ 1
- 2
hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java View File

@@ -2,7 +2,6 @@ package com.hz.pm.api.meeting.manage;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
@@ -301,7 +300,7 @@ public class MeetingManage {
List<Long> expertIdsChoose = new ArrayList<>();
for (int i = 0; i < req.getRandomRules().size(); i++) {
RandomInviteRuleDTO randomRule = req.getRandomRules().get(i);
ExpertChooseDTO chooseExpert = expertInviteManage.expertInviteByRandomRule(req.getAvoidRule(),
ExpertChoseDTO chooseExpert = expertInviteManage.expertInviteByRandomRule(req.getAvoidRule(),
randomRule, expertIdsChoose, meeting.getStartTime(), meeting.getEndTime(), meeting.getCreateOn());
if (i < req.getRandomRules().size() - 1 && chooseExpert.getTotal() > 0) {
List<Long> tempUserIds = CollUtils.fieldList(chooseExpert.getExperts(), ExpertUserFullInfo::getUserId);


+ 18
- 10
hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/ExpertRandomInviteTask.java View File

@@ -8,19 +8,20 @@ import com.hz.pm.api.common.util.SpringContextHolder;
import com.hz.pm.api.meeting.builder.ExpertInviteBuilder;
import com.hz.pm.api.meeting.entity.domain.Meeting;
import com.hz.pm.api.meeting.entity.domain.MeetingExpert;
import com.hz.pm.api.meeting.entity.dto.AvoidRuleDTO;
import com.hz.pm.api.meeting.entity.dto.ExpertChooseDTO;
import com.hz.pm.api.meeting.entity.dto.InviteCacheDTO;
import com.hz.pm.api.meeting.entity.dto.RandomInviteRuleDTO;
import com.hz.pm.api.meeting.entity.dto.*;
import com.hz.pm.api.meeting.entity.enumeration.ExpertAttendStatusEnum;
import com.hz.pm.api.meeting.entity.enumeration.MeetingSettingsTypeEnum;
import com.hz.pm.api.meeting.entity.req.ConfirmedRosterReq;
import com.hz.pm.api.meeting.entity.req.MeetingSettingsSaveReq;
import com.hz.pm.api.meeting.helper.MeetingNotifyHelper;
import com.hz.pm.api.meeting.manage.ExpertInviteManage;
import com.hz.pm.api.meeting.manage.MeetingManage;
import com.hz.pm.api.meeting.manage.MeetingSettingsManage;
import com.hz.pm.api.meeting.service.IExpertInviteAvoidRuleService;
import com.hz.pm.api.meeting.service.IExpertInviteRuleService;
import com.hz.pm.api.meeting.service.IMeetingExpertService;
import com.hz.pm.api.meeting.service.IMeetingService;
import com.hz.pm.api.sms.utils.DateUtil;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.basic.util.SpringUtils;
import com.ningdatech.cache.model.cache.CacheHashKey;
@@ -73,7 +74,7 @@ public class ExpertRandomInviteTask {
private final ExpertInviteManage expertInviteManage;
private final IExpertInviteAvoidRuleService inviteAvoidRuleService;
private final MeetingNotifyHelper meetingNotifyHelper;
private final MeetingSettingsManage meetingSettingsManage;
/**
* 用来存入线程执行句柄, 停止定时任务时使用
*/
@@ -85,9 +86,15 @@ public class ExpertRandomInviteTask {
}

private boolean inInviteTimeRange() {
int currHour = LocalTime.now().getHour();
return currHour >= properties.getInviteStartHour()
&& currHour < properties.getInviteEndHour();
MeetingSettingsSaveReq settings = meetingSettingsManage.getSettings(MeetingSettingsTypeEnum.INVITE_CALL_IGNORE_TIME);
LocalTime currTime = LocalTime.now();
if (settings != null) {
InviteCallIgnoreTimeDTO content = settings.getSettingsContent(InviteCallIgnoreTimeDTO.class);
return DateUtil.between(currTime, content.getStartTime(), content.getStopTime());
} else {
int currHour = currTime.getHour();
return currHour >= properties.getInviteStartHour() && currHour < properties.getInviteEndHour();
}
}

@PostConstruct
@@ -231,7 +238,8 @@ public class ExpertRandomInviteTask {
return;
}
Meeting meeting = meetingService.getById(meetingId);
if (meeting.getInviteStatus() || meeting.getStartTime().isBefore(LocalDateTime.now())) {
if (Boolean.TRUE.equals(meeting.getInviteStatus())
|| meeting.getStartTime().isBefore(LocalDateTime.now())) {
log.info("会议已开始停止抽取:{}", meeting);
killTaskAndDelCacheMeetingId(meetingId);
return;
@@ -259,7 +267,7 @@ public class ExpertRandomInviteTask {
return;
}
int needInviteCnt = value.getCount() - wouldAttendCnt;
ExpertChooseDTO expertChoose = expertInviteManage.expertReplaceByRandomRule(avoidRule, value,
ExpertChoseDTO expertChoose = expertInviteManage.expertReplaceByRandomRule(avoidRule, value,
tmpExperts, needInviteCnt, msTime, meTime, tsTime, reInvite);

if (expertChoose.getTotal() > 0) {


Loading…
Cancel
Save