Browse Source

优化专家抽取

tags/24080901
WendyYang 3 months ago
parent
commit
63cdf4fb86
8 changed files with 132 additions and 73 deletions
  1. +26
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/exception/ReturnException.java
  2. +7
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/handler/GlobalExceptionHandler.java
  3. +3
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/ExpertInviteHelper.java
  4. +23
    -4
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingNotifyHelper.java
  5. +47
    -55
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/ExpertInviteManage.java
  6. +10
    -9
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java
  7. +11
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/user/manage/SyncMhUserOrgManage.java
  8. +5
    -1
      hz-pm-api/src/main/resources/application-dev.yml

+ 26
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/exception/ReturnException.java View File

@@ -0,0 +1,26 @@
package com.hz.pm.api.common.exception;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
* <p>
* ReturnException
* </p>
*
* @author WendyYang
* @since 21:49 2024/6/9
*/
@Data
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class ReturnException extends RuntimeException {

private final String message;

public static ReturnException wrap(String message) {
return new ReturnException(message);
}

}

+ 7
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/handler/GlobalExceptionHandler.java View File

@@ -1,5 +1,6 @@
package com.hz.pm.api.common.handler; package com.hz.pm.api.common.handler;


import com.hz.pm.api.common.exception.ReturnException;
import com.ningdatech.basic.enumeration.Status; import com.ningdatech.basic.enumeration.Status;
import com.ningdatech.basic.model.ApiResponse; import com.ningdatech.basic.model.ApiResponse;
import com.ningdatech.basic.util.CollUtils; import com.ningdatech.basic.util.CollUtils;
@@ -68,4 +69,10 @@ public class GlobalExceptionHandler {
return ApiResponse.of(Status.BAD_REQUEST.getCode(), "系统异常,请联系管理员"); return ApiResponse.of(Status.BAD_REQUEST.getCode(), "系统异常,请联系管理员");
} }


@ResponseBody
@ExceptionHandler(value = ReturnException.class)
public ApiResponse<Void> returnException(ReturnException e) {
return ApiResponse.of(Status.BAD_REQUEST.getCode(), e.getMessage());
}

} }

+ 3
- 3
hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/ExpertInviteHelper.java View File

@@ -48,7 +48,7 @@ public class ExpertInviteHelper {
* @return java.util.List<java.lang.Long> * @return java.util.List<java.lang.Long>
* @author WendyYang * @author WendyYang
**/ **/
public List<Long> listInvitedExpertByTime(LocalDateTime start, LocalDateTime end) {
public List<Long> listInvitedExpertIds(LocalDateTime start, LocalDateTime end) {
LambdaQueryWrapper<Meeting> meetingQuery = Wrappers.lambdaQuery(Meeting.class) LambdaQueryWrapper<Meeting> meetingQuery = Wrappers.lambdaQuery(Meeting.class)
.select(Meeting::getId) .select(Meeting::getId)
.eq(Meeting::getStatus, MeetingStatusEnum.NORMAL.getCode()) .eq(Meeting::getStatus, MeetingStatusEnum.NORMAL.getCode())
@@ -68,7 +68,7 @@ public class ExpertInviteHelper {
} }


public Set<Long> listExpertLeaveOrInvited(LocalDateTime start, LocalDateTime end) { public Set<Long> listExpertLeaveOrInvited(LocalDateTime start, LocalDateTime end) {
return new HashSet<>(listInvitedExpertByTime(start, end));
return new HashSet<>(listInvitedExpertIds(start, end));
} }


public Set<Long> getAvoidExpert(List<Long> appoints, AvoidRuleDTO avoid, LocalDateTime start, LocalDateTime end) { public Set<Long> getAvoidExpert(List<Long> appoints, AvoidRuleDTO avoid, LocalDateTime start, LocalDateTime end) {
@@ -78,7 +78,7 @@ public class ExpertInviteHelper {
.flatMap(w -> Optional.ofNullable(w.getExpertIds())) .flatMap(w -> Optional.ofNullable(w.getExpertIds()))
.ifPresent(expertIds::addAll); .ifPresent(expertIds::addAll);
// 过滤掉请假专家 // 过滤掉请假专家
expertIds.addAll(listInvitedExpertByTime(start, end));
expertIds.addAll(listInvitedExpertIds(start, end));
return expertIds; return expertIds;
} }




+ 23
- 4
hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingNotifyHelper.java View File

@@ -1,9 +1,11 @@
package com.hz.pm.api.meeting.helper; package com.hz.pm.api.meeting.helper;


import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.common.helper.MsgCallHelper; import com.hz.pm.api.common.helper.MsgCallHelper;
import com.hz.pm.api.common.util.EnvironmentUtil;
import com.hz.pm.api.meeting.constant.MeetingMsgTemplateConst; import com.hz.pm.api.meeting.constant.MeetingMsgTemplateConst;
import com.hz.pm.api.meeting.entity.domain.Meeting; 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.domain.MeetingExpert;
@@ -24,7 +26,8 @@ import com.hz.pm.api.todocenter.bean.entity.WorkNoticeInfo;
import com.hz.pm.api.user.model.entity.UserInfo; import com.hz.pm.api.user.model.entity.UserInfo;
import com.hz.pm.api.user.service.IUserInfoService; import com.hz.pm.api.user.service.IUserInfoService;
import com.ningdatech.basic.util.CollUtils; import com.ningdatech.basic.util.CollUtils;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;


@@ -41,7 +44,7 @@ import java.util.*;
* @since 2023/4/20 * @since 2023/4/20
**/ **/
@Component @Component
@AllArgsConstructor
@RequiredArgsConstructor
public class MeetingNotifyHelper { public class MeetingNotifyHelper {


private final IUserInfoService userInfoService; private final IUserInfoService userInfoService;
@@ -50,7 +53,13 @@ public class MeetingNotifyHelper {
private final IDingEmployeeInfoService dingEmployeeInfoService; private final IDingEmployeeInfoService dingEmployeeInfoService;
private final IDingOrganizationService dingOrganizationService; private final IDingOrganizationService dingOrganizationService;
private final INotifyService notifyService; private final INotifyService notifyService;
private final EnvironmentUtil environmentUtil;


@Value("${expert-invite.skip-send-call:false}")
private Boolean inviteSkipSendCall;

@Value("${expert-invite.skip-send-sms:false}")
private Boolean inviteSkipSendSms;
private static final DateTimeFormatter MEETING_TIME_DTF = DateTimeFormatter.ofPattern("yyyy年M月d日 HH:mm"); private static final DateTimeFormatter MEETING_TIME_DTF = DateTimeFormatter.ofPattern("yyyy年M月d日 HH:mm");


private static String officialTime(LocalDateTime time) { private static String officialTime(LocalDateTime time) {
@@ -166,7 +175,12 @@ public class MeetingNotifyHelper {
meeting.getHoldOrg(), meeting.getName(), officialTime(meeting.getStartTime()), meeting.getHoldOrg(), meeting.getName(), officialTime(meeting.getStartTime()),
meeting.getMeetingAddress()); meeting.getMeetingAddress());
Set<String> phones = CollUtils.fieldSet(experts, MeetingExpert::getMobile); Set<String> phones = CollUtils.fieldSet(experts, MeetingExpert::getMobile);
String submitKey = msgCallHelper.sendCall(phones, content, BizTypeEnum.EXPERT_INVITE);
String submitKey;
if (environmentUtil.isDevEnv() && Boolean.TRUE.equals(inviteSkipSendCall)) {
submitKey = UUID.randomUUID().toString(true);
} else {
submitKey = msgCallHelper.sendCall(phones, content, BizTypeEnum.EXPERT_INVITE);
}
experts.forEach(w -> w.setSubmitKey(submitKey)); experts.forEach(w -> w.setSubmitKey(submitKey));
} }


@@ -181,7 +195,12 @@ public class MeetingNotifyHelper {
meeting.getHoldOrg(), meeting.getName(), officialTime(meeting.getStartTime()), meeting.getHoldOrg(), meeting.getName(), officialTime(meeting.getStartTime()),
meeting.getMeetingAddress()); meeting.getMeetingAddress());
Set<String> phones = CollUtils.fieldSet(experts, MeetingExpert::getMobile); Set<String> phones = CollUtils.fieldSet(experts, MeetingExpert::getMobile);
String submitKey = msgCallHelper.sendMsg(phones, content, BizTypeEnum.EXPERT_INVITE);
String submitKey;
if (environmentUtil.isDevEnv() && Boolean.TRUE.equals(inviteSkipSendSms)) {
submitKey = UUID.randomUUID().toString(true);
} else {
submitKey = msgCallHelper.sendMsg(phones, content, BizTypeEnum.EXPERT_INVITE);
}
// 短信发送成功返回的UUID // 短信发送成功返回的UUID
experts.forEach(w -> w.setSubmitKey(submitKey)); experts.forEach(w -> w.setSubmitKey(submitKey));
} }


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

@@ -3,6 +3,7 @@ package com.hz.pm.api.meeting.manage;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.common.exception.ReturnException;
import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.common.util.BizUtils;
import com.hz.pm.api.expert.entity.ExpertAvoidCompany; import com.hz.pm.api.expert.entity.ExpertAvoidCompany;
import com.hz.pm.api.expert.entity.ExpertGovBusinessStrip; import com.hz.pm.api.expert.entity.ExpertGovBusinessStrip;
@@ -29,7 +30,6 @@ import com.hz.pm.api.meta.model.entity.ExpertDictionary;
import com.hz.pm.api.meta.model.entity.ExpertTag; import com.hz.pm.api.meta.model.entity.ExpertTag;
import com.hz.pm.api.meta.service.IExpertDictionaryService; import com.hz.pm.api.meta.service.IExpertDictionaryService;
import com.hz.pm.api.meta.service.IExpertTagService; import com.hz.pm.api.meta.service.IExpertTagService;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.util.CollUtils; import com.ningdatech.basic.util.CollUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
@@ -79,7 +79,7 @@ public class ExpertInviteManage {


private static final Predicate<Collection<?>> COLL_EMPTY = (coll) -> coll != null && coll.isEmpty(); private static final Predicate<Collection<?>> COLL_EMPTY = (coll) -> coll != null && coll.isEmpty();


private LambdaQueryWrapper<ExpertUserFullInfo> buildBaseExpertQuery() {
private static LambdaQueryWrapper<ExpertUserFullInfo> buildBaseExpertQuery() {
return Wrappers.lambdaQuery(ExpertUserFullInfo.class) return Wrappers.lambdaQuery(ExpertUserFullInfo.class)
.select(ExpertUserFullInfo::getUserId, .select(ExpertUserFullInfo::getUserId,
ExpertUserFullInfo::getId, ExpertUserFullInfo::getId,
@@ -89,7 +89,7 @@ public class ExpertInviteManage {
ExpertUserFullInfo::getPhoneNo); ExpertUserFullInfo::getPhoneNo);
} }


private void buildAvoidCompanyAndBusinessStrip(LambdaQueryWrapper<ExpertUserFullInfo> query, List<String> units, List<String> strips) {
private static void buildAvoidCompanyAndBusinessStrip(LambdaQueryWrapper<ExpertUserFullInfo> query, List<String> units, List<String> strips) {
if (CollUtil.isNotEmpty(units)) { if (CollUtil.isNotEmpty(units)) {
String unitStr = BizUtils.inSqlJoin(units); String unitStr = BizUtils.inSqlJoin(units);
query.notExists("select 1 from expert_avoid_company eac where eac.user_id = nd_expert_user_full_info.user_id" + query.notExists("select 1 from expert_avoid_company eac where eac.user_id = nd_expert_user_full_info.user_id" +
@@ -303,19 +303,18 @@ public class ExpertInviteManage {
if (merge.isSkip()) { if (merge.isSkip()) {
return result; return result;
} }
boolean hasAvoidExpert = CollUtil.isNotEmpty(avoidRule.getExpertIds());
boolean hasAvoidCompany = CollUtil.isNotEmpty(avoidRule.getAvoidUnitIdList());
Set<String> avoidCompanyUniqCodes = new HashSet<>();
if (hasAvoidCompany) {
avoidCompanyUniqCodes.addAll(avoidRule.getAvoidUnitIdList());
}
Set<String> avoidUnitCodes = new HashSet<>();
BizUtils.notEmpty(avoidRule.getAvoidUnitIdList(), avoidUnitCodes::addAll);

LambdaQueryWrapper<ExpertUserFullInfo> query = buildBaseExpertQuery();
AvoidTypeEnum avoidType = avoidRule.getAvoidType() == null ? AvoidTypeEnum.NONE : AvoidTypeEnum.getByCode(avoidRule.getAvoidType());
if (CollUtil.isNotEmpty(invitedExpertIds)) { if (CollUtil.isNotEmpty(invitedExpertIds)) {
List<String> tmpCompanyUniqCodes = expertUserFullInfoService.listCompanyUniqCodeByUserIds(invitedExpertIds);
avoidCompanyUniqCodes.addAll(tmpCompanyUniqCodes);
buildAvoidUnitStripForQuery(invitedExpertIds, avoidType, avoidUnitCodes, query);
} }
// 处理专家层级
addRegionLimit(query, randomRule);
// 回避信息 // 回避信息
LambdaQueryWrapper<ExpertUserFullInfo> query = buildBaseExpertQuery();
query.notIn(!avoidCompanyUniqCodes.isEmpty(), ExpertUserFullInfo::getCompanyUniqCode, avoidCompanyUniqCodes);
query.notIn(!avoidUnitCodes.isEmpty(), ExpertUserFullInfo::getCompanyUniqCode, avoidUnitCodes);
// 处理回避单位与回避条线 // 处理回避单位与回避条线
buildAvoidCompanyAndBusinessStrip(query, avoidRule.getAvoidUnitIdList(), avoidRule.getAvoidOrgIdList()); buildAvoidCompanyAndBusinessStrip(query, avoidRule.getAvoidUnitIdList(), avoidRule.getAvoidOrgIdList());
Set<Long> expertIdsIn = new HashSet<>(); Set<Long> expertIdsIn = new HashSet<>();
@@ -326,34 +325,24 @@ public class ExpertInviteManage {
expertIdsNotIn.addAll(merge.getExpertIdsNotIn()); expertIdsNotIn.addAll(merge.getExpertIdsNotIn());
} }
// 处理回避专家次数 // 处理回避专家次数
if (avoidRule.getWeekInviteCount() != null) {
Integer weekInviteCount = avoidRule.getWeekInviteCount();
BizUtils.notNull(avoidRule.getWeekInviteCount(), weekInviteCount -> {
List<Long> tmpExpertIdsNotIn = listAgreedUserIdByRecentMeetings(weekInviteCount, recentDays, meetingCreateOn); List<Long> tmpExpertIdsNotIn = listAgreedUserIdByRecentMeetings(weekInviteCount, recentDays, meetingCreateOn);
expertIdsNotIn.addAll(tmpExpertIdsNotIn); expertIdsNotIn.addAll(tmpExpertIdsNotIn);
}
// 处理专家层级
addRegionLimit(query, randomRule);
});

if (!expertIdsIn.isEmpty()) { if (!expertIdsIn.isEmpty()) {
if (hasAvoidExpert) {
expertIdsIn.removeIf(w -> avoidRule.getExpertIds().contains(w));
if (expertIdsIn.isEmpty()) {
// 字典、标签、履职意向地 筛选出的专家ID移除需要回避的专家ID、如果为空则说明没有符合条件的
return result;
}
}
if (CollUtil.isNotEmpty(invitedExpertIds)) {
expertIdsIn.removeIf(invitedExpertIds::contains);
if (expertIdsIn.isEmpty()) {
return result;
}
BizUtils.notEmpty(avoidRule.getExpertIds(), w -> expertIdsIn.removeIf(w::contains));
BizUtils.notEmpty(invitedExpertIds, w -> expertIdsIn.removeIf(w::contains));
if (expertIdsIn.isEmpty()) {
return result;
} }
// 过滤掉已参加会议的专家 // 过滤掉已参加会议的专家
List<Long> expertIdsLockByMeeting = expertInviteHelper.listInvitedExpertByTime(sTime, eTime);
expertIdsIn.removeIf(expertIdsLockByMeeting::contains);
List<Long> lockedExpertIds = expertInviteHelper.listInvitedExpertIds(sTime, eTime);
expertIdsIn.removeIf(lockedExpertIds::contains);
if (expertIdsIn.isEmpty()) { if (expertIdsIn.isEmpty()) {
return result; return result;
} }
} else if (hasAvoidExpert || CollUtil.isNotEmpty(invitedExpertIds)) {
} else if (CollUtil.isNotEmpty(avoidRule.getExpertIds()) || CollUtil.isNotEmpty(invitedExpertIds)) {
Set<Long> tmpExpert = expertInviteHelper.getAvoidExpert(invitedExpertIds, avoidRule, sTime, eTime); Set<Long> tmpExpert = expertInviteHelper.getAvoidExpert(invitedExpertIds, avoidRule, sTime, eTime);
expertIdsNotIn.addAll(tmpExpert); expertIdsNotIn.addAll(tmpExpert);
} else { } else {
@@ -365,11 +354,11 @@ public class ExpertInviteManage {
} else if (!expertIdsNotIn.isEmpty()) { } else if (!expertIdsNotIn.isEmpty()) {
query.notIn(ExpertUserFullInfo::getUserId, expertIdsNotIn); query.notIn(ExpertUserFullInfo::getUserId, expertIdsNotIn);
} }
// 开始进行专家抽取
List<ExpertUserFullInfo> userInfoList = expertUserFullInfoService.list(query); List<ExpertUserFullInfo> userInfoList = expertUserFullInfoService.list(query);
if (userInfoList.isEmpty()) { if (userInfoList.isEmpty()) {
return result; return result;
} }
AvoidTypeEnum avoidType = avoidRule.getAvoidType() == null ? AvoidTypeEnum.CURR_UNIT : AvoidTypeEnum.getByCode(avoidRule.getAvoidType());
switch (avoidType) { switch (avoidType) {
case NONE: case NONE:
result.setExperts(inviteRandom(userInfoList, expertsByRecentMeeting(), randomRule.getCount())); result.setExperts(inviteRandom(userInfoList, expertsByRecentMeeting(), randomRule.getCount()));
@@ -395,6 +384,22 @@ public class ExpertInviteManage {
return result; return result;
} }


private void buildAvoidUnitStripForQuery(List<Long> invitedExpertIds, AvoidTypeEnum avoidType, Set<String> avoidUnitCodes, LambdaQueryWrapper<ExpertUserFullInfo> query) {
if (AvoidTypeEnum.CURR_UNIT.equals(avoidType)) {
List<ExpertUserFullInfo> tmpInvitedExperts = expertUserFullInfoService.listByUserIds(invitedExpertIds);
Set<String> tmpUnitCodes = CollUtils.fieldSet(tmpInvitedExperts, ExpertUserFullInfo::getCompanyUniqCode);
avoidUnitCodes.addAll(tmpUnitCodes);
} else if (AvoidTypeEnum.CURR_STRIP.equals(avoidType)) {
List<ExpertGovBusinessStrip> expertStrips = expertGovBusinessStripService.listByUserIds(invitedExpertIds);
if (CollUtil.isNotEmpty(expertStrips)) {
Set<String> businessStripCodes = CollUtils.fieldSet(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));
}
}
}

/** /**
* 专家替换、补充 * 专家替换、补充
* *
@@ -431,15 +436,14 @@ public class ExpertInviteManage {
} }
LambdaQueryWrapper<ExpertUserFullInfo> query = buildBaseExpertQuery(); LambdaQueryWrapper<ExpertUserFullInfo> query = buildBaseExpertQuery();
// 设置回避单位 // 设置回避单位
Set<String> notInCompanyUniqCodeList = new HashSet<>(avoidRule.getAvoidUnitIdList());
Set<String> avoidUnitCodes = new HashSet<>(avoidRule.getAvoidUnitIdList());
// 处理回避单位与回避条线 // 处理回避单位与回避条线
buildAvoidCompanyAndBusinessStrip(query, avoidRule.getAvoidUnitIdList(), avoidRule.getAvoidOrgIdList()); buildAvoidCompanyAndBusinessStrip(query, avoidRule.getAvoidUnitIdList(), avoidRule.getAvoidOrgIdList());
// 处理回避专家次数 // 处理回避专家次数
if (avoidRule.getWeekInviteCount() != null) {
Integer weekInviteCount = avoidRule.getWeekInviteCount();
BizUtils.notNull(avoidRule.getWeekInviteCount(), weekInviteCount -> {
List<Long> tmpExpertIdsNotIn = listAgreedUserIdByRecentMeetings(weekInviteCount, recentDays, msTime); List<Long> tmpExpertIdsNotIn = listAgreedUserIdByRecentMeetings(weekInviteCount, recentDays, msTime);
expertIdsNotIn.addAll(tmpExpertIdsNotIn); expertIdsNotIn.addAll(tmpExpertIdsNotIn);
}
});
// 处理专家层级 // 处理专家层级
addRegionLimit(query, randomRule); addRegionLimit(query, randomRule);


@@ -451,8 +455,8 @@ public class ExpertInviteManage {
return result; return result;
} }
} }
List<Long> lockExpertIds = expertInviteHelper.listInvitedExpertByTime(msTime, meTime);
expertIdsIn.removeIf(lockExpertIds::contains);
List<Long> lockedExpertIds = expertInviteHelper.listInvitedExpertIds(msTime, meTime);
expertIdsIn.removeIf(lockedExpertIds::contains);
if (expertIdsIn.isEmpty()) { if (expertIdsIn.isEmpty()) {
return result; return result;
} }
@@ -473,19 +477,7 @@ public class ExpertInviteManage {
List<Long> agreeOrNoticingExpertIds = CollUtils.fieldList(agreeOrNoticing, MeetingExpert::getExpertId); List<Long> agreeOrNoticingExpertIds = CollUtils.fieldList(agreeOrNoticing, MeetingExpert::getExpertId);
if (!agreeOrNoticingExpertIds.isEmpty()) { if (!agreeOrNoticingExpertIds.isEmpty()) {
expertIdsNotIn.addAll(agreeOrNoticingExpertIds); expertIdsNotIn.addAll(agreeOrNoticingExpertIds);
if (AvoidTypeEnum.CURR_UNIT.equals(avoidType)) {
List<ExpertUserFullInfo> agreeOrNoticingUserInfos = expertUserFullInfoService.listByUserIds(agreeOrNoticingExpertIds);
Set<String> tmpUniqCompanyCodes = CollUtils.fieldSet(agreeOrNoticingUserInfos, ExpertUserFullInfo::getCompanyUniqCode);
notInCompanyUniqCodeList.addAll(tmpUniqCompanyCodes);
} else if (AvoidTypeEnum.CURR_STRIP.equals(avoidType)) {
List<ExpertGovBusinessStrip> expertStrips = expertGovBusinessStripService.listByUserIds(agreeOrNoticingExpertIds);
if (CollUtil.isNotEmpty(expertStrips)) {
Set<String> businessStripCodes = CollUtils.fieldSet(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));
}
}
buildAvoidUnitStripForQuery(agreeOrNoticingExpertIds, avoidType, avoidUnitCodes, query);
} }
// 已请假的专家不再抽取 // 已请假的专家不再抽取
List<MeetingExpert> expertsOnLeave = expertGroupByStatus.get(ON_LEAVE); List<MeetingExpert> expertsOnLeave = expertGroupByStatus.get(ON_LEAVE);
@@ -519,7 +511,7 @@ public class ExpertInviteManage {
} else if (hasExpertIdNotIn) { } else if (hasExpertIdNotIn) {
query.notIn(ExpertUserFullInfo::getUserId, expertIdsNotIn); query.notIn(ExpertUserFullInfo::getUserId, expertIdsNotIn);
} }
query.notIn(!notInCompanyUniqCodeList.isEmpty(), ExpertUserFullInfo::getCompanyUniqCode, notInCompanyUniqCodeList);
query.notIn(!avoidUnitCodes.isEmpty(), ExpertUserFullInfo::getCompanyUniqCode, avoidUnitCodes);
List<ExpertUserFullInfo> userFullInfos = expertUserFullInfoService.list(query); List<ExpertUserFullInfo> userFullInfos = expertUserFullInfoService.list(query);
if (userFullInfos.isEmpty()) { if (userFullInfos.isEmpty()) {
return result; return result;
@@ -591,7 +583,7 @@ public class ExpertInviteManage {
randomRules.forEach(rule -> { randomRules.forEach(rule -> {
ExpertChoseDTO tmpExperts = expertInviteByRandomRule(avoidRule, rule, chooseExpertIds, sTime, eTime, createOn); ExpertChoseDTO tmpExperts = expertInviteByRandomRule(avoidRule, rule, chooseExpertIds, sTime, eTime, createOn);
if (tmpExperts.getTotal() < rule.getCount()) { if (tmpExperts.getTotal() < rule.getCount()) {
throw BizException.wrap("可抽取专家数量不足");
throw ReturnException.wrap("可抽取专家数量不足");
} }
expertsByRandom.add(tmpExperts); expertsByRandom.add(tmpExperts);
chooseExpertIds.addAll(CollUtils.fieldList(tmpExperts.getExperts(), ExpertUserFullInfo::getUserId)); chooseExpertIds.addAll(CollUtils.fieldList(tmpExperts.getExperts(), ExpertUserFullInfo::getUserId));


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

@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hz.pm.api.common.exception.ReturnException;
import com.hz.pm.api.common.helper.RegionCacheHelper; import com.hz.pm.api.common.helper.RegionCacheHelper;
import com.hz.pm.api.common.model.constant.BizConst; import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.common.util.BizUtils;
@@ -126,7 +127,7 @@ public class MeetingManage {
String meetingMd5 = SecureUtil.md5(JSONUtil.toJsonStr(req)); String meetingMd5 = SecureUtil.md5(JSONUtil.toJsonStr(req));
String key = MEETING_CREATE_KEY + meetingMd5; String key = MEETING_CREATE_KEY + meetingMd5;
if (!distributedLock.lock(key, RETRY_TIMES)) { if (!distributedLock.lock(key, RETRY_TIMES)) {
throw BizException.wrap("会议正在创建中");
throw ReturnException.wrap("会议正在创建中");
} }
try { try {
UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); UserInfoDetails userDetail = LoginUserUtil.loginUserDetail();
@@ -162,22 +163,22 @@ public class MeetingManage {
public void continueInvite(Long meetingId) { public void continueInvite(Long meetingId) {
String key = "CONTINUE_INVITE:" + meetingId; String key = "CONTINUE_INVITE:" + meetingId;
if (!distributedLock.lock(key, RETRY_TIMES)) { if (!distributedLock.lock(key, RETRY_TIMES)) {
throw BizException.wrap("已进行续抽,请勿重复点击");
throw ReturnException.wrap("已进行续抽,请勿重复点击");
} }
try { try {
Meeting meeting = meetingService.getById(meetingId); Meeting meeting = meetingService.getById(meetingId);
if (!meeting.getInviteStatus()) { if (!meeting.getInviteStatus()) {
throw BizException.wrap("该会议正在抽取专家,暂无法续抽");
throw ReturnException.wrap("该会议正在抽取专家,暂无法续抽");
} }
if (meeting.getStartTime().isBefore(LocalDateTime.now())) { if (meeting.getStartTime().isBefore(LocalDateTime.now())) {
throw BizException.wrap("会议已开始,不允许续抽");
throw ReturnException.wrap("会议已开始,不允许续抽");
} }
if (!MeetingStatusEnum.NORMAL.eq(meeting.getStatus())) { if (!MeetingStatusEnum.NORMAL.eq(meeting.getStatus())) {
throw BizException.wrap("续抽失败,请刷新后重试");
throw ReturnException.wrap("续抽失败,请刷新后重试");
} }
boolean invitedContinue = meetingManageHelper.checkCouldBeInvitedContinue(meetingId); boolean invitedContinue = meetingManageHelper.checkCouldBeInvitedContinue(meetingId);
if (!invitedContinue) { if (!invitedContinue) {
throw BizException.wrap("抽取人员数量已满足抽取规则");
throw ReturnException.wrap("抽取人员数量已满足抽取规则");
} }
expertRandomInviteTask.notifyInviteTask(meetingId); expertRandomInviteTask.notifyInviteTask(meetingId);
} finally { } finally {
@@ -189,12 +190,12 @@ public class MeetingManage {
public void convertToAppoint(Long meetingId) { public void convertToAppoint(Long meetingId) {
String key = "CONVERT_TO_APPOINT:" + meetingId; String key = "CONVERT_TO_APPOINT:" + meetingId;
if (!distributedLock.lock(key, RETRY_TIMES)) { if (!distributedLock.lock(key, RETRY_TIMES)) {
throw BizException.wrap("已进行转换,请勿重复点击");
throw ReturnException.wrap("已进行转换,请勿重复点击");
} }
try { try {
Meeting meeting = meetingService.getById(meetingId); Meeting meeting = meetingService.getById(meetingId);
if (!MeetingStatusEnum.NORMAL.eq(meeting.getStatus())) { if (!MeetingStatusEnum.NORMAL.eq(meeting.getStatus())) {
throw BizException.wrap("转换失败,请刷新后重试");
throw ReturnException.wrap("转换失败,请刷新后重试");
} }
expertRandomInviteTask.cancelByMeetingIdAndKillTask(meetingId); expertRandomInviteTask.cancelByMeetingIdAndKillTask(meetingId);
LambdaUpdateWrapper<Meeting> meetingUpdate = Wrappers.lambdaUpdate(Meeting.class) LambdaUpdateWrapper<Meeting> meetingUpdate = Wrappers.lambdaUpdate(Meeting.class)
@@ -225,7 +226,7 @@ public class MeetingManage {
public void expertInviteByCreate(ExpertInviteReq req) { public void expertInviteByCreate(ExpertInviteReq req) {
String key = INVITED_RULE_CREATE + req.getMeetingId(); String key = INVITED_RULE_CREATE + req.getMeetingId();
if (!distributedLock.lock(key, RETRY_TIMES)) { if (!distributedLock.lock(key, RETRY_TIMES)) {
throw BizException.wrap("不可重复进行专家抽取");
throw ReturnException.wrap("不可重复进行专家抽取");
} }
try { try {
Meeting meeting = meetingService.getById(req.getMeetingId()); Meeting meeting = meetingService.getById(req.getMeetingId());


+ 11
- 1
hz-pm-api/src/main/java/com/hz/pm/api/user/manage/SyncMhUserOrgManage.java View File

@@ -231,6 +231,11 @@ public class SyncMhUserOrgManage {
} }
} }


/**
* 保存评审专家
*
* @param reviewExperts \
*/
private void saveReviewExperts(List<MhReviewExpertDTO> reviewExperts) { private void saveReviewExperts(List<MhReviewExpertDTO> reviewExperts) {
List<String> expertNos = CollUtils.fieldList(reviewExperts, MhReviewExpertDTO::getExpertNo); List<String> expertNos = CollUtils.fieldList(reviewExperts, MhReviewExpertDTO::getExpertNo);
Map<String, ExpertUserFullInfo> expertMap = getExpertsMapMhExpertNo(expertNos); Map<String, ExpertUserFullInfo> expertMap = getExpertsMapMhExpertNo(expertNos);
@@ -306,6 +311,11 @@ public class SyncMhUserOrgManage {


} }


/**
* 保存技术专家
*
* @param techExperts \
*/
private void saveTechExperts(List<MhTechExpertDTO> techExperts) { private void saveTechExperts(List<MhTechExpertDTO> techExperts) {
List<String> expertNos = CollUtils.fieldList(techExperts, MhTechExpertDTO::getExpertNo); List<String> expertNos = CollUtils.fieldList(techExperts, MhTechExpertDTO::getExpertNo);
Map<String, ExpertUserFullInfo> expertMap = getExpertsMapMhExpertNo(expertNos); Map<String, ExpertUserFullInfo> expertMap = getExpertsMapMhExpertNo(expertNos);
@@ -328,7 +338,7 @@ public class SyncMhUserOrgManage {
eui.setDegreeCertFile(expert.getFileDegree()); eui.setDegreeCertFile(expert.getFileDegree());
eui.setMhCreateOn(LocalDateTimeUtil.of(expert.getCreateTime())); eui.setMhCreateOn(LocalDateTimeUtil.of(expert.getCreateTime()));
eui.setMhCreateBy(expert.getCreateUser()); eui.setMhCreateBy(expert.getCreateUser());
BizUtils.notBlank (expert.getInPutTime(),w -> {
BizUtils.notBlank(expert.getInPutTime(), w -> {
LocalDateTime inputTime = DateUtil.parse(w).toLocalDateTime(); LocalDateTime inputTime = DateUtil.parse(w).toLocalDateTime();
eui.setInPutTime(inputTime); eui.setInPutTime(inputTime);
}); });


+ 5
- 1
hz-pm-api/src/main/resources/application-dev.yml View File

@@ -218,4 +218,8 @@ web:
login: login:
url: http://hzpm.ningdatech.com url: http://hzpm.ningdatech.com
api: api:
url: http://hzpm.ningdatech.com/hzpm
url: http://hzpm.ningdatech.com/hzpm

expert-invite:
skip-send-call: true
skip-send-sms: true

Loading…
Cancel
Save