Browse Source

回避单位修改

tags/24080901
WendyYang 1 year ago
parent
commit
fff515c869
2 changed files with 17 additions and 35 deletions
  1. +16
    -34
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/ExpertInviteManage.java
  2. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/mapper/MeetingExpertMapper.xml

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

@@ -67,7 +67,7 @@ public class ExpertInviteManage {
private final ExpertInviteHelper expertInviteHelper;
private final IExpertUserFullInfoService expertUserFullInfoService;
private final IMeetingService meetingService;
private final IExpertAvoidCompanyService iExpertAvoidCompanyService;
private final IExpertAvoidCompanyService expertAvoidCompanyService;
private final YxtCallOrSmsHelper yxtCallOrSmsHelper;

private static final Predicate<Collection<?>> COLL_EMPTY = (coll) -> coll != null && coll.isEmpty();
@@ -114,27 +114,17 @@ public class ExpertInviteManage {
/**
* 如果抽取回避单位和专家回避单位一致,同样需要回避该专家
*
* @param companyNames /
* @param unitCodeList /
* @return /
*/
private List<Long> avoidCompanyExpertIds(List<String> companyNames) {
if (CollUtil.isEmpty(companyNames)) {
private List<Long> avoidCompanyExpertIds(List<String> unitCodeList) {
if (CollUtil.isEmpty(unitCodeList)) {
return new ArrayList<>();
}
List<String> dealCompanyNames = new ArrayList<>();
for (String companyName : companyNames) {
if (companyName.contains(",")) {
String[] splitCompanyNames = companyName.split(",");
for (String splitCompanyName : splitCompanyNames) {
dealCompanyNames.add(splitCompanyName);
}
} else {
dealCompanyNames.add(companyName);
}
}
List<ExpertAvoidCompany> expertAvoidCompanyList = iExpertAvoidCompanyService.list(Wrappers.lambdaQuery(ExpertAvoidCompany.class)
.in(ExpertAvoidCompany::getCompanyName, dealCompanyNames));
return expertAvoidCompanyList.stream().map(ExpertAvoidCompany::getUserId).distinct().collect(Collectors.toList());
LambdaQueryWrapper<ExpertAvoidCompany> query = Wrappers.lambdaQuery(ExpertAvoidCompany.class)
.in(ExpertAvoidCompany::getCompanyUniqCode, unitCodeList);
List<ExpertAvoidCompany> expertAvoidCompanyList = expertAvoidCompanyService.list(query);
return CollUtils.fieldList(expertAvoidCompanyList, ExpertAvoidCompany::getUserId);
}

private List<Long> mergeExpertIdsByCondition(RandomInviteRuleDTO rule, AvoidRuleDTO avoidInfo) {
@@ -268,22 +258,14 @@ public class ExpertInviteManage {
boolean avoidCompany = CollUtil.isNotEmpty(avoidRule.getAvoidUnitIdList());
Set<String> tmpAvoidCompany = new HashSet<>();
if (avoidCompany) {
List<String> companyIds = avoidRule.getAvoidUnitIdList();
for (String companyId : companyIds) {
if (companyId.contains(",")) {
String[] splitCompanyIds = companyId.split(",");
Collections.addAll(tmpAvoidCompany, splitCompanyIds);
} else {
tmpAvoidCompany.add(companyId);
}
}
tmpAvoidCompany.addAll(avoidRule.getAvoidUnitIdList());
}
// 回避信息
LambdaQueryWrapper<ExpertUserFullInfo> query = buildBaseExpertQuery();
query.notIn(!tmpAvoidCompany.isEmpty(), ExpertUserFullInfo::getCompany, tmpAvoidCompany);
query.notIn(!tmpAvoidCompany.isEmpty(), ExpertUserFullInfo::getCompanyUniqCode, tmpAvoidCompany);
if (avoidCompany) {
query.notExists("select 1 from expert_avoid_company eac where eac.user_id = nd_expert_user_full_info.user_id" +
" and company_name in ({0})", CollUtils.joinByComma(avoidRule.getAvoidUnitIdList()));
" and company_uniq_code in ({0})", CollUtils.joinByComma(avoidRule.getAvoidUnitIdList()));
}
// 处理专家层级
addRegionLimit(query, randomRule);
@@ -322,7 +304,7 @@ public class ExpertInviteManage {
if (userInfoList.isEmpty()) {
return result;
}
Map<String, List<ExpertUserFullInfo>> userGroupByUnit = CollUtils.group(userInfoList, ExpertUserFullInfo::getCompany);
Map<String, List<ExpertUserFullInfo>> userGroupByUnit = CollUtils.group(userInfoList, ExpertUserFullInfo::getCompanyUniqCode);
result.setTotal(userInfoList.size());
// count为空表示数量校验
if (randomRule.getCount() == null || result.getTotal() >= randomRule.getCount()) {
@@ -357,9 +339,9 @@ public class ExpertInviteManage {
return result;
}
LambdaQueryWrapper<ExpertUserFullInfo> query = buildBaseExpertQuery();
query.notIn(ExpertUserFullInfo::getCompany, avoidRule.getAvoidUnitIdList());
query.notIn(ExpertUserFullInfo::getCompanyUniqCode, avoidRule.getAvoidUnitIdList());
query.notExists("select 1 from expert_avoid_company eac where eac.user_id = nd_expert_user_full_info.user_id" +
" and company_name in ({0})", CollUtils.joinByComma(avoidRule.getAvoidOrgIdList()));
" and company_uniq_code in ({0})", CollUtils.joinByComma(avoidRule.getAvoidOrgIdList()));

// 处理专家层级
if (StrUtils.isNotBlank(randomRule.getExpertRegionCode())) {
@@ -411,7 +393,7 @@ public class ExpertInviteManage {
List<Long> tempExpertIds = CollUtils.fieldList(removeExpertByCompany, MeetingExpert::getExpertId);
// 移除确认参加、通知中的、拒绝参加、已取消
userFullInfos.removeIf(w -> tempExpertIds.contains(w.getUserId()) || removeExpertIds.contains(w.getUserId()));
Map<String, List<ExpertUserFullInfo>> userGroupByUnit = CollUtils.group(userFullInfos, ExpertUserFullInfo::getCompany);
Map<String, List<ExpertUserFullInfo>> userGroupByUnit = CollUtils.group(userFullInfos, ExpertUserFullInfo::getCompanyUniqCode);
result.setTotal(userGroupByUnit.size());
result.setExperts(inviteGroupByCompany(userGroupByUnit, count));
return result;
@@ -439,7 +421,7 @@ public class ExpertInviteManage {
*
* @param expertGroupByUnit 需要抽取的人
* @param count 抽取数量
* @return java.util.List<com.ningdatech.emapi.expert.entity.domain.ExpertUserFullInfo>
* @return 抽取到的专家信息
* @author WendyYang
**/
private List<ExpertUserFullInfo> inviteGroupByCompany(Map<String, List<ExpertUserFullInfo>> expertGroupByUnit, Integer count) {


+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/meeting/mapper/MeetingExpertMapper.xml View File

@@ -67,7 +67,7 @@

<select id="listExpertLastByMeetingIds" resultType="com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert">
SELECT * FROM (SELECT ROW_NUMBER() OVER ( PARTITION BY expert_id, meeting_id ORDER BY update_on DESC ) rowNumber,
ID, expert_id, status, meeting_id, invite_type, mobile, expert_name, update_on, pre_id, rule_id FROM meeting_expert
ID, expert_id, status, meeting_id, invite_type, mobile, expert_name, update_on, rule_id FROM meeting_expert
where meeting_id <foreach collection="meetingIds" separator="," close=")" open=" in (" item="item">
#{item}</foreach>) em WHERE rowNumber = 1
</select>


Loading…
Cancel
Save