@@ -56,7 +56,7 @@ public class GeneratorCodeKingbaseConfig { | |||||
} | } | ||||
public static void main(String[] args) { | public static void main(String[] args) { | ||||
generate("Liuxinxin", "expert", PATH_LXX, "expert_sensitive_info_modify_detail_record"); | |||||
generate("Liuxinxin", "expert", PATH_LXX, "expert_gov_business_strip"); | |||||
} | } | ||||
} | } |
@@ -32,7 +32,7 @@ public class DashboardUserDataScopeProviderImpl implements DataScopeProvider { | |||||
public Optional<DataScopeDTO> findDataFieldProperty() { | public Optional<DataScopeDTO> findDataFieldProperty() { | ||||
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | ||||
DataScopeDTO ds = new DataScopeDTO(); | DataScopeDTO ds = new DataScopeDTO(); | ||||
ds.setEmployeeCode(userFullInfo.getOrganizationCode()); | |||||
ds.setEmployeeCode(userFullInfo.getEmployeeCode()); | |||||
ds.setRegionCodes(Lists.newArrayList(userFullInfo.getRegionCode())); | ds.setRegionCodes(Lists.newArrayList(userFullInfo.getRegionCode())); | ||||
ds.setUserId(userFullInfo.getUserId()); | ds.setUserId(userFullInfo.getUserId()); | ||||
ds.setRole(RoleEnum.DASHBOARD); | ds.setRole(RoleEnum.DASHBOARD); | ||||
@@ -31,7 +31,7 @@ public class OrdinaryUserDataScopeProviderImpl implements DataScopeProvider { | |||||
public Optional<DataScopeDTO> findDataFieldProperty() { | public Optional<DataScopeDTO> findDataFieldProperty() { | ||||
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | ||||
DataScopeDTO ds = new DataScopeDTO(); | DataScopeDTO ds = new DataScopeDTO(); | ||||
ds.setEmployeeCode(userFullInfo.getOrganizationCode()); | |||||
ds.setEmployeeCode(userFullInfo.getEmployeeCode()); | |||||
ds.setRegionCodes(Lists.newArrayList(userFullInfo.getRegionCode())); | ds.setRegionCodes(Lists.newArrayList(userFullInfo.getRegionCode())); | ||||
ds.setUserId(userFullInfo.getUserId()); | ds.setUserId(userFullInfo.getUserId()); | ||||
ds.setRole(RoleEnum.NORMAL_MEMBER); | ds.setRole(RoleEnum.NORMAL_MEMBER); | ||||
@@ -30,7 +30,7 @@ public class OrgAdminDataScopeProviderImpl implements DataScopeProvider { | |||||
public Optional<DataScopeDTO> findDataFieldProperty() { | public Optional<DataScopeDTO> findDataFieldProperty() { | ||||
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | ||||
DataScopeDTO ds = new DataScopeDTO(); | DataScopeDTO ds = new DataScopeDTO(); | ||||
ds.setOrgCode(userFullInfo.getOrganizationCode()); | |||||
ds.setOrgCode(userFullInfo.getEmpPosUnitCode()); | |||||
ds.setUserId(userFullInfo.getUserId()); | ds.setUserId(userFullInfo.getUserId()); | ||||
ds.setEmployeeCode(userFullInfo.getEmployeeCode()); | ds.setEmployeeCode(userFullInfo.getEmployeeCode()); | ||||
ds.setRole(RoleEnum.COMPANY_MANAGER); | ds.setRole(RoleEnum.COMPANY_MANAGER); | ||||
@@ -57,7 +57,6 @@ public class EmployeeBatchGetTask { | |||||
@Transactional(rollbackFor = Exception.class) | @Transactional(rollbackFor = Exception.class) | ||||
public void batchGetEmployeeTask() { | public void batchGetEmployeeTask() { | ||||
// 获取所有的组织列表用户获取组织下的 用户信息 | // 获取所有的组织列表用户获取组织下的 用户信息 | ||||
List<DingOrganization> dingOrganizationList = iDingOrganizationService.list(); | List<DingOrganization> dingOrganizationList = iDingOrganizationService.list(); | ||||
if (CollUtil.isNotEmpty(dingOrganizationList)) { | if (CollUtil.isNotEmpty(dingOrganizationList)) { | ||||
@@ -0,0 +1,31 @@ | |||||
package com.ningdatech.pmapi.expert.entity; | |||||
import com.baomidou.mybatisplus.annotation.TableName; | |||||
import io.swagger.annotations.ApiModel; | |||||
import lombok.Data; | |||||
import java.io.Serializable; | |||||
/** | |||||
* <p> | |||||
* | |||||
* </p> | |||||
* | |||||
* @author Liuxinxin | |||||
* @since 2023-04-17 | |||||
*/ | |||||
@TableName("expert_gov_business_strip") | |||||
@Data | |||||
@ApiModel(value = "ExpertGovBusinessStrip对象", description = "") | |||||
public class ExpertGovBusinessStrip implements Serializable { | |||||
private static final long serialVersionUID = 1L; | |||||
private Long id; | |||||
private String businessStripCode; | |||||
private String businessStripName; | |||||
private Long expertUserId; | |||||
} |
@@ -0,0 +1,16 @@ | |||||
package com.ningdatech.pmapi.expert.mapper; | |||||
import com.ningdatech.pmapi.expert.entity.ExpertGovBusinessStrip; | |||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||||
/** | |||||
* <p> | |||||
* Mapper 接口 | |||||
* </p> | |||||
* | |||||
* @author Liuxinxin | |||||
* @since 2023-04-17 | |||||
*/ | |||||
public interface ExpertGovBusinessStripMapper extends BaseMapper<ExpertGovBusinessStrip> { | |||||
} |
@@ -0,0 +1,5 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
<mapper namespace="com.ningdatech.pmapi.expert.mapper.ExpertGovBusinessStripMapper"> | |||||
</mapper> |
@@ -0,0 +1,16 @@ | |||||
package com.ningdatech.pmapi.expert.service; | |||||
import com.ningdatech.pmapi.expert.entity.ExpertGovBusinessStrip; | |||||
import com.baomidou.mybatisplus.extension.service.IService; | |||||
/** | |||||
* <p> | |||||
* 服务类 | |||||
* </p> | |||||
* | |||||
* @author Liuxinxin | |||||
* @since 2023-04-17 | |||||
*/ | |||||
public interface IExpertGovBusinessStripService extends IService<ExpertGovBusinessStrip> { | |||||
} |
@@ -0,0 +1,20 @@ | |||||
package com.ningdatech.pmapi.expert.service.impl; | |||||
import com.ningdatech.pmapi.expert.entity.ExpertGovBusinessStrip; | |||||
import com.ningdatech.pmapi.expert.mapper.ExpertGovBusinessStripMapper; | |||||
import com.ningdatech.pmapi.expert.service.IExpertGovBusinessStripService; | |||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||||
import org.springframework.stereotype.Service; | |||||
/** | |||||
* <p> | |||||
* 服务实现类 | |||||
* </p> | |||||
* | |||||
* @author Liuxinxin | |||||
* @since 2023-04-17 | |||||
*/ | |||||
@Service | |||||
public class ExpertGovBusinessStripServiceImpl extends ServiceImpl<ExpertGovBusinessStripMapper, ExpertGovBusinessStrip> implements IExpertGovBusinessStripService { | |||||
} |
@@ -35,7 +35,7 @@ public class CompanyFiscalCodeManage { | |||||
String organizationCode = reqCompanyFiscalCodeAndSealSnPO.getOrganizationCode(); | String organizationCode = reqCompanyFiscalCodeAndSealSnPO.getOrganizationCode(); | ||||
if (StringUtils.isBlank(organizationCode)) { | if (StringUtils.isBlank(organizationCode)) { | ||||
organizationCode = userInfoHelper.getOrganizationCode(userId); | |||||
organizationCode = userInfoHelper.getUserEmpPosUnitCode(userId); | |||||
} | } | ||||
// TODO 校验用户权限 | // TODO 校验用户权限 | ||||
@@ -73,7 +73,7 @@ public class CompanyFiscalCodeManage { | |||||
Long userId = LoginUserUtil.getUserId(); | Long userId = LoginUserUtil.getUserId(); | ||||
String organizationCode = request.getOrganizationCode(); | String organizationCode = request.getOrganizationCode(); | ||||
if (StringUtils.isBlank(organizationCode)) { | if (StringUtils.isBlank(organizationCode)) { | ||||
organizationCode = userInfoHelper.getOrganizationCode(userId); | |||||
organizationCode = userInfoHelper.getUserEmpPosUnitCode(userId); | |||||
} | } | ||||
CompanySignature companySignature = iCompanySignatureService.getByOrganizationCode(organizationCode); | CompanySignature companySignature = iCompanySignatureService.getByOrganizationCode(organizationCode); | ||||
CompanyFiscalCode companyFiscalCode = iCompanyFiscalCodeService.getByOrganizationCode(organizationCode); | CompanyFiscalCode companyFiscalCode = iCompanyFiscalCodeService.getByOrganizationCode(organizationCode); | ||||
@@ -15,7 +15,7 @@ import javax.validation.constraints.NotBlank; | |||||
public class ReqCompanyFiscalCodeAndSealSnPO { | public class ReqCompanyFiscalCodeAndSealSnPO { | ||||
// @NotBlank(message = "组织编码 不能为空") | // @NotBlank(message = "组织编码 不能为空") | ||||
@ApiModelProperty("组织编码") | |||||
@ApiModelProperty("组织编码(需传入用户任职单位code)") | |||||
private String organizationCode; | private String organizationCode; | ||||
@NotBlank(message = "财政编码 不能为空") | @NotBlank(message = "财政编码 不能为空") | ||||
@@ -12,7 +12,7 @@ import lombok.Data; | |||||
@ApiModel("获取财政编码配置") | @ApiModel("获取财政编码配置") | ||||
public class ReqGetCompanyFiscalCodeAndSealSnPO { | public class ReqGetCompanyFiscalCodeAndSealSnPO { | ||||
@ApiModelProperty("组织编码") | |||||
@ApiModelProperty("组织编码(需传入用户任职单位code)") | |||||
private String organizationCode; | private String organizationCode; | ||||
} | } |
@@ -2,6 +2,8 @@ package com.ningdatech.pmapi.meeting.entity.dto; | |||||
import lombok.Data; | import lombok.Data; | ||||
import java.time.LocalDateTime; | |||||
/** | /** | ||||
* <p> | * <p> | ||||
* MeetingInviteDTO | * MeetingInviteDTO | ||||
@@ -15,12 +17,21 @@ public final class InviteCacheDTO { | |||||
private Long meetingId; | private Long meetingId; | ||||
private Boolean invitedRefused; | |||||
/** | |||||
* 拒绝的专家是否可以再次邀请 | |||||
*/ | |||||
private Boolean reInvite; | |||||
/** | |||||
* 任务触发时间 | |||||
*/ | |||||
private LocalDateTime taskStartTime; | |||||
public static InviteCacheDTO of(Long meetingId, Boolean invitedRefused) { | |||||
public static InviteCacheDTO of(Long meetingId, Boolean reInvite, LocalDateTime startTime) { | |||||
InviteCacheDTO bo = new InviteCacheDTO(); | InviteCacheDTO bo = new InviteCacheDTO(); | ||||
bo.setMeetingId(meetingId); | bo.setMeetingId(meetingId); | ||||
bo.setInvitedRefused(invitedRefused); | |||||
bo.setReInvite(reInvite); | |||||
bo.setTaskStartTime(startTime); | |||||
return bo; | return bo; | ||||
} | } | ||||
@@ -0,0 +1,30 @@ | |||||
package com.ningdatech.pmapi.meeting.entity.dto; | |||||
import lombok.Data; | |||||
import java.util.List; | |||||
/** | |||||
* <p> | |||||
* MergeExpertIdDTO | |||||
* </p> | |||||
* | |||||
* @author WendyYang | |||||
* @since 2023/4/14 | |||||
**/ | |||||
@Data | |||||
public class MergeExpertIdDTO { | |||||
private List<Long> expertIdsIn; | |||||
private List<Long> expertIdsNotIn; | |||||
private Boolean skip; | |||||
public static MergeExpertIdDTO noExpert() { | |||||
MergeExpertIdDTO condition = new MergeExpertIdDTO(); | |||||
condition.setSkip(Boolean.TRUE); | |||||
return condition; | |||||
} | |||||
} |
@@ -0,0 +1,43 @@ | |||||
/** | |||||
* Copyright 2023 json.cn | |||||
*/ | |||||
package com.ningdatech.pmapi.meeting.entity.dto; | |||||
import lombok.Data; | |||||
import java.time.LocalDateTime; | |||||
/** | |||||
* <p> | |||||
* 电话结果回调内容 | |||||
* </p> | |||||
* | |||||
* @author WendyYang | |||||
* @since 2023/4/17 | |||||
**/ | |||||
@Data | |||||
public class YxtCallBackDTO { | |||||
private Integer duration; | |||||
private String pressKey; | |||||
private String receiveNumber; | |||||
private LocalDateTime dialEndTime; | |||||
private Integer resultCode; | |||||
private Integer retryNumber; | |||||
private String failCode; | |||||
private LocalDateTime dialBeginTime; | |||||
private String sendNumber; | |||||
private String failReason; | |||||
private String transactionId; | |||||
} |
@@ -41,6 +41,9 @@ public class InviteExpertListItemVO extends ExpertBasicInfoVO { | |||||
@ApiModelProperty("邀请状态") | @ApiModelProperty("邀请状态") | ||||
private Integer status; | private Integer status; | ||||
@ApiModelProperty("抽取类型") | |||||
private Integer inviteType; | |||||
@ApiModelProperty("通知时间") | @ApiModelProperty("通知时间") | ||||
private LocalDateTime noticeTime; | private LocalDateTime noticeTime; | ||||
@@ -0,0 +1,119 @@ | |||||
package com.ningdatech.pmapi.meeting.helper; | |||||
import cn.hutool.core.util.RandomUtil; | |||||
import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo; | |||||
import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; | |||||
import org.apache.commons.collections4.MapUtils; | |||||
import org.apache.commons.lang3.RandomUtils; | |||||
import java.util.ArrayList; | |||||
import java.util.Collections; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import java.util.stream.Collectors; | |||||
/** | |||||
* <p> | |||||
* 专家抽取算法 | |||||
* </p> | |||||
* | |||||
* @author WendyYang | |||||
* @since 2023/4/14 | |||||
**/ | |||||
public class ExpertRandomInviteAlgorithm { | |||||
private static boolean expertMatchNone(List<MeetingExpert> experts, ExpertUserFullInfo userInfo) { | |||||
return experts.stream().noneMatch(w -> w.getExpertId().equals(userInfo.getUserId())); | |||||
} | |||||
/** | |||||
* 每个单位只抽取一人 | |||||
* | |||||
* @param expertGroupByUnit 需要抽取的人 | |||||
* @param expertsByRecentMeeting 最近会议抽取到的专家 | |||||
* @param count 抽取数量 | |||||
* @return 抽取到的专家信息 | |||||
* @author WendyYang | |||||
**/ | |||||
public static List<ExpertUserFullInfo> inviteGroupByCompany(Map<String, List<ExpertUserFullInfo>> expertGroupByUnit, | |||||
List<List<MeetingExpert>> expertsByRecentMeeting, | |||||
Integer count) { | |||||
if (MapUtils.isEmpty(expertGroupByUnit)) { | |||||
return Collections.emptyList(); | |||||
} | |||||
if (expertsByRecentMeeting.isEmpty()) { | |||||
return expertGroupByUnit.values().stream() | |||||
.map(RandomUtil::randomEle) | |||||
.limit(count).collect(Collectors.toList()); | |||||
} else { | |||||
List<ExpertUserFullInfo> result = new ArrayList<>(); | |||||
List<String> keySet = new ArrayList<>(expertGroupByUnit.keySet()); | |||||
for (int i = 0; i < count; i++) { | |||||
String company = keySet.get(RandomUtils.nextInt(0, keySet.size())); | |||||
List<ExpertUserFullInfo> expertsByCompany = expertGroupByUnit.get(company); | |||||
for (int j = 0; j < expertsByRecentMeeting.size(); j++) { | |||||
List<MeetingExpert> experts = expertsByRecentMeeting.get(j); | |||||
List<ExpertUserFullInfo> notInvitedUsers = expertsByCompany.stream() | |||||
.filter(w -> expertMatchNone(experts, w)) | |||||
.collect(Collectors.toList()); | |||||
if (!notInvitedUsers.isEmpty()) { | |||||
result.add(RandomUtil.randomEle(notInvitedUsers)); | |||||
break; | |||||
} else if (j == (expertsByRecentMeeting.size() - 1)) { | |||||
result.add(RandomUtil.randomEle(expertsByCompany)); | |||||
} | |||||
} | |||||
if (result.size() < count) { | |||||
keySet.remove(company); | |||||
if (keySet.isEmpty()) { | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
return result; | |||||
} | |||||
} | |||||
/** | |||||
* 随机抽取专家 | |||||
* | |||||
* @param userFullInfos 可抽取的所有专家 | |||||
* @param expertsByRecentMeeting 最近会议抽取到的专家 | |||||
* @param count 抽取数量 | |||||
* @return 抽取到的专家信息 | |||||
* @author WendyYang | |||||
**/ | |||||
public static List<ExpertUserFullInfo> inviteWithoutCompany(List<ExpertUserFullInfo> userFullInfos, | |||||
List<List<MeetingExpert>> expertsByRecentMeeting, | |||||
Integer count) { | |||||
List<ExpertUserFullInfo> result; | |||||
if (expertsByRecentMeeting.isEmpty()) { | |||||
result = RandomUtil.randomEleList(userFullInfos, count); | |||||
} else { | |||||
result = new ArrayList<>(); | |||||
for (List<MeetingExpert> experts : expertsByRecentMeeting) { | |||||
List<ExpertUserFullInfo> notInvitedUsers = userFullInfos.stream() | |||||
.filter(w -> expertMatchNone(experts, w)) | |||||
.collect(Collectors.toList()); | |||||
if (!notInvitedUsers.isEmpty()) { | |||||
result.addAll(notInvitedUsers); | |||||
if (result.size() >= count) { | |||||
return result.subList(0, count); | |||||
} | |||||
userFullInfos.removeAll(notInvitedUsers); | |||||
} | |||||
} | |||||
if (userFullInfos.size() == 0) { | |||||
return result; | |||||
} | |||||
int restCnt = Math.min(count - result.size(), userFullInfos.size()); | |||||
if (userFullInfos.size() > restCnt) { | |||||
result.addAll(RandomUtil.randomEleList(userFullInfos, restCnt)); | |||||
} else { | |||||
result.addAll(userFullInfos); | |||||
} | |||||
} | |||||
return result; | |||||
} | |||||
} |
@@ -20,7 +20,6 @@ import com.ningdatech.pmapi.meeting.entity.domain.ExpertInviteAvoidRule; | |||||
import com.ningdatech.pmapi.meeting.entity.domain.Meeting; | import com.ningdatech.pmapi.meeting.entity.domain.Meeting; | ||||
import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; | import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; | ||||
import com.ningdatech.pmapi.meeting.entity.dto.AvoidRuleDTO; | import com.ningdatech.pmapi.meeting.entity.dto.AvoidRuleDTO; | ||||
import com.ningdatech.pmapi.meeting.entity.dto.MeetingAndAttendStatusDTO; | |||||
import com.ningdatech.pmapi.meeting.entity.dto.MeetingBasicDTO; | import com.ningdatech.pmapi.meeting.entity.dto.MeetingBasicDTO; | ||||
import com.ningdatech.pmapi.meeting.entity.dto.RandomInviteRuleDTO; | import com.ningdatech.pmapi.meeting.entity.dto.RandomInviteRuleDTO; | ||||
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; | import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; | ||||
@@ -236,12 +235,10 @@ public class MeetingManageHelper { | |||||
if (expertInfo != null) { | if (expertInfo != null) { | ||||
String expertName = expertInfo.getExpertName(); | String expertName = expertInfo.getExpertName(); | ||||
switch (ExpertAttendStatusEnum.getByCode(w.getStatus())) { | switch (ExpertAttendStatusEnum.getByCode(w.getStatus())) { | ||||
case REFUSED: | |||||
throw BizException.wrap("专家%s已拒绝参加", expertName); | |||||
case AGREED: | case AGREED: | ||||
throw BizException.wrap("专家%s已同意参加", expertName); | |||||
throw BizException.wrap("专家 %s 已同意参加", expertName); | |||||
case NOTICING: | case NOTICING: | ||||
throw BizException.wrap("专家%s正在通知中", expertName); | |||||
throw BizException.wrap("专家 %s 正在通知中", expertName); | |||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
@@ -16,10 +16,7 @@ import com.ningdatech.pmapi.meeting.builder.ExpertInviteBuilder; | |||||
import com.ningdatech.pmapi.meeting.entity.domain.ExpertInviteRule; | import com.ningdatech.pmapi.meeting.entity.domain.ExpertInviteRule; | ||||
import com.ningdatech.pmapi.meeting.entity.domain.Meeting; | import com.ningdatech.pmapi.meeting.entity.domain.Meeting; | ||||
import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; | import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; | ||||
import com.ningdatech.pmapi.meeting.entity.dto.AvoidRuleDTO; | |||||
import com.ningdatech.pmapi.meeting.entity.dto.ExpertChooseDTO; | |||||
import com.ningdatech.pmapi.meeting.entity.dto.ExpertDictChooseDTO; | |||||
import com.ningdatech.pmapi.meeting.entity.dto.RandomInviteRuleDTO; | |||||
import com.ningdatech.pmapi.meeting.entity.dto.*; | |||||
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; | import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; | ||||
import com.ningdatech.pmapi.meeting.helper.ExpertInviteHelper; | import com.ningdatech.pmapi.meeting.helper.ExpertInviteHelper; | ||||
import com.ningdatech.pmapi.meeting.helper.YxtCallOrSmsHelper; | import com.ningdatech.pmapi.meeting.helper.YxtCallOrSmsHelper; | ||||
@@ -31,21 +28,20 @@ import com.ningdatech.pmapi.meta.model.entity.ExpertDictionary; | |||||
import com.ningdatech.pmapi.meta.model.entity.ExpertTag; | import com.ningdatech.pmapi.meta.model.entity.ExpertTag; | ||||
import com.ningdatech.pmapi.meta.service.IExpertDictionaryService; | import com.ningdatech.pmapi.meta.service.IExpertDictionaryService; | ||||
import com.ningdatech.pmapi.meta.service.IExpertTagService; | import com.ningdatech.pmapi.meta.service.IExpertTagService; | ||||
import lombok.AllArgsConstructor; | |||||
import lombok.RequiredArgsConstructor; | |||||
import org.apache.commons.collections4.CollectionUtils; | import org.apache.commons.collections4.CollectionUtils; | ||||
import org.apache.commons.collections4.MapUtils; | |||||
import org.apache.commons.collections4.Predicate; | import org.apache.commons.collections4.Predicate; | ||||
import org.apache.commons.lang3.ObjectUtils; | import org.apache.commons.lang3.ObjectUtils; | ||||
import org.apache.commons.lang3.RandomUtils; | |||||
import org.springframework.beans.factory.annotation.Value; | |||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||
import java.util.*; | import java.util.*; | ||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
import java.util.stream.Stream; | |||||
import static com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum.*; | import static com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum.*; | ||||
import static com.ningdatech.pmapi.meeting.helper.ExpertInviteHelper.getExpertInviteRule; | import static com.ningdatech.pmapi.meeting.helper.ExpertInviteHelper.getExpertInviteRule; | ||||
import static com.ningdatech.pmapi.meeting.helper.ExpertRandomInviteAlgorithm.inviteGroupByCompany; | |||||
/** | /** | ||||
* <p> | * <p> | ||||
@@ -56,7 +52,7 @@ import static com.ningdatech.pmapi.meeting.helper.ExpertInviteHelper.getExpertIn | |||||
* @since 18:05 2022/8/8 | * @since 18:05 2022/8/8 | ||||
*/ | */ | ||||
@Component | @Component | ||||
@AllArgsConstructor | |||||
@RequiredArgsConstructor | |||||
public class ExpertInviteManage { | public class ExpertInviteManage { | ||||
private final IExpertDictionaryService expertDictionaryService; | private final IExpertDictionaryService expertDictionaryService; | ||||
@@ -71,6 +67,9 @@ public class ExpertInviteManage { | |||||
private final IExpertAvoidCompanyService expertAvoidCompanyService; | private final IExpertAvoidCompanyService expertAvoidCompanyService; | ||||
private final YxtCallOrSmsHelper yxtCallOrSmsHelper; | private final YxtCallOrSmsHelper yxtCallOrSmsHelper; | ||||
@Value("#{randomInviteProperties.recentMeetingCount}") | |||||
private Integer recentMeetingCount; | |||||
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 LambdaQueryWrapper<ExpertUserFullInfo> buildBaseExpertQuery() { | ||||
@@ -124,30 +123,32 @@ public class ExpertInviteManage { | |||||
return new ArrayList<>(); | return new ArrayList<>(); | ||||
} | } | ||||
LambdaQueryWrapper<ExpertAvoidCompany> query = Wrappers.lambdaQuery(ExpertAvoidCompany.class) | LambdaQueryWrapper<ExpertAvoidCompany> query = Wrappers.lambdaQuery(ExpertAvoidCompany.class) | ||||
.select(ExpertAvoidCompany::getUserId) | |||||
.in(ExpertAvoidCompany::getCompanyUniqCode, unitCodeList); | .in(ExpertAvoidCompany::getCompanyUniqCode, unitCodeList); | ||||
List<ExpertAvoidCompany> expertAvoidCompanyList = expertAvoidCompanyService.list(query); | List<ExpertAvoidCompany> expertAvoidCompanyList = expertAvoidCompanyService.list(query); | ||||
return CollUtils.fieldList(expertAvoidCompanyList, ExpertAvoidCompany::getUserId); | return CollUtils.fieldList(expertAvoidCompanyList, ExpertAvoidCompany::getUserId); | ||||
} | } | ||||
private List<Long> mergeExpertIdsByCondition(RandomInviteRuleDTO rule, AvoidRuleDTO avoidInfo) { | |||||
private MergeExpertIdDTO mergeExpertIdsByCondition(RandomInviteRuleDTO rule, AvoidRuleDTO avoidInfo) { | |||||
// 处理履职意向地 | // 处理履职意向地 | ||||
List<Long> expertIdsByIntentionRegion = expertIdsByRegion(rule); | List<Long> expertIdsByIntentionRegion = expertIdsByRegion(rule); | ||||
if (COLL_EMPTY.evaluate(expertIdsByIntentionRegion)) { | if (COLL_EMPTY.evaluate(expertIdsByIntentionRegion)) { | ||||
return null; | |||||
return MergeExpertIdDTO.noExpert(); | |||||
} | } | ||||
// 处理专家标签 | // 处理专家标签 | ||||
List<Long> expertIdsByTag = expertIdsByTag(rule); | List<Long> expertIdsByTag = expertIdsByTag(rule); | ||||
if (COLL_EMPTY.evaluate(expertIdsByTag)) { | if (COLL_EMPTY.evaluate(expertIdsByTag)) { | ||||
return null; | |||||
return MergeExpertIdDTO.noExpert(); | |||||
} | } | ||||
// 处理专家字典 | // 处理专家字典 | ||||
List<Long> expertIdsByDict = expertIdsByDict(rule); | List<Long> expertIdsByDict = expertIdsByDict(rule); | ||||
if (COLL_EMPTY.evaluate(expertIdsByDict)) { | if (COLL_EMPTY.evaluate(expertIdsByDict)) { | ||||
return null; | |||||
return MergeExpertIdDTO.noExpert(); | |||||
} | } | ||||
// 处理专家回避单位 与 抽取回避单位是否相同 | // 处理专家回避单位 与 抽取回避单位是否相同 | ||||
List<Long> avoidCompanyExpertIds = avoidCompanyExpertIds(avoidInfo.getAvoidUnitIdList()); | |||||
List<Long> avoidExpertIdsByUnit = avoidCompanyExpertIds(avoidInfo.getAvoidUnitIdList()); | |||||
MergeExpertIdDTO merge = new MergeExpertIdDTO(); | |||||
// 聚合用户ID | // 聚合用户ID | ||||
List<Long> expertIdsIn = new ArrayList<>(); | List<Long> expertIdsIn = new ArrayList<>(); | ||||
if (ObjectUtils.anyNotNull(expertIdsByDict, expertIdsByTag, expertIdsByIntentionRegion)) { | if (ObjectUtils.anyNotNull(expertIdsByDict, expertIdsByTag, expertIdsByIntentionRegion)) { | ||||
@@ -167,17 +168,22 @@ public class ExpertInviteManage { | |||||
} | } | ||||
}); | }); | ||||
if (expertIdsIn.isEmpty()) { | if (expertIdsIn.isEmpty()) { | ||||
return null; | |||||
return MergeExpertIdDTO.noExpert(); | |||||
} | } | ||||
merge.setExpertIdsIn(expertIdsIn); | |||||
} | } | ||||
if (CollUtil.isNotEmpty(avoidCompanyExpertIds)) { | |||||
expertIdsIn.removeIf(avoidCompanyExpertIds::contains); | |||||
if (CollUtil.isNotEmpty(avoidExpertIdsByUnit)) { | |||||
if (expertIdsIn.isEmpty()) { | if (expertIdsIn.isEmpty()) { | ||||
return null; | |||||
merge.setExpertIdsNotIn(avoidExpertIdsByUnit); | |||||
} else { | |||||
expertIdsIn.removeIf(avoidExpertIdsByUnit::contains); | |||||
if (expertIdsIn.isEmpty()) { | |||||
return MergeExpertIdDTO.noExpert(); | |||||
} | |||||
} | } | ||||
} | } | ||||
return expertIdsIn; | |||||
merge.setSkip(Boolean.FALSE); | |||||
return merge; | |||||
} | } | ||||
/** | /** | ||||
@@ -253,8 +259,8 @@ public class ExpertInviteManage { | |||||
LocalDateTime sTime, | LocalDateTime sTime, | ||||
LocalDateTime eTime) { | LocalDateTime eTime) { | ||||
ExpertChooseDTO result = new ExpertChooseDTO(new ArrayList<>(), 0); | ExpertChooseDTO result = new ExpertChooseDTO(new ArrayList<>(), 0); | ||||
List<Long> expertIdsIn = mergeExpertIdsByCondition(randomRule, avoidRule); | |||||
if (expertIdsIn == null) { | |||||
MergeExpertIdDTO merge = mergeExpertIdsByCondition(randomRule, avoidRule); | |||||
if (merge.getSkip()) { | |||||
return result; | return result; | ||||
} | } | ||||
boolean avoidExpert = CollUtil.isNotEmpty(avoidRule.getExpertIds()); | boolean avoidExpert = CollUtil.isNotEmpty(avoidRule.getExpertIds()); | ||||
@@ -270,14 +276,20 @@ public class ExpertInviteManage { | |||||
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" + | ||||
" and company_uniq_code in ({0})", CollUtils.joinByComma(avoidRule.getAvoidUnitIdList())); | " and company_uniq_code in ({0})", CollUtils.joinByComma(avoidRule.getAvoidUnitIdList())); | ||||
} | } | ||||
Set<Long> expertIdsIn = new HashSet<>(); | |||||
Set<Long> expertIdsNotIn = new HashSet<>(); | |||||
if (CollUtil.isNotEmpty(merge.getExpertIdsIn())) { | |||||
expertIdsIn.addAll(merge.getExpertIdsIn()); | |||||
} else if (CollUtil.isNotEmpty(merge.getExpertIdsNotIn())) { | |||||
expertIdsNotIn.addAll(merge.getExpertIdsNotIn()); | |||||
} | |||||
// 处理专家层级 | // 处理专家层级 | ||||
addRegionLimit(query, randomRule); | addRegionLimit(query, randomRule); | ||||
if (!expertIdsIn.isEmpty()) { | if (!expertIdsIn.isEmpty()) { | ||||
if (avoidExpert) { | if (avoidExpert) { | ||||
expertIdsIn.removeIf(w -> avoidRule.getExpertIds().contains(w)); | expertIdsIn.removeIf(w -> avoidRule.getExpertIds().contains(w)); | ||||
if (expertIdsIn.isEmpty()) { | if (expertIdsIn.isEmpty()) { | ||||
// 字典、标签、履职意向地筛选出的专家ID移除需要回避的专家ID | |||||
// 如果为空则说明没有符合条件的 | |||||
// 字典、标签、履职意向地 筛选出的专家ID移除需要回避的专家ID、如果为空则说明没有符合条件的 | |||||
return result; | return result; | ||||
} | } | ||||
} | } | ||||
@@ -293,15 +305,17 @@ public class ExpertInviteManage { | |||||
if (expertIdsIn.isEmpty()) { | if (expertIdsIn.isEmpty()) { | ||||
return result; | return result; | ||||
} | } | ||||
query.in(ExpertUserFullInfo::getUserId, expertIdsIn); | |||||
} else if (avoidExpert || CollUtil.isNotEmpty(appointExpertIds)) { | } else if (avoidExpert || CollUtil.isNotEmpty(appointExpertIds)) { | ||||
Set<Long> tempExperts = expertInviteHelper.getAvoidExpert(appointExpertIds, avoidRule, sTime, eTime); | |||||
query.notIn(ExpertUserFullInfo::getUserId, tempExperts); | |||||
Set<Long> tmpExpert = expertInviteHelper.getAvoidExpert(appointExpertIds, avoidRule, sTime, eTime); | |||||
expertIdsNotIn.addAll(tmpExpert); | |||||
} else { | } else { | ||||
Set<Long> notInUserIds = expertInviteHelper.listExpertLeaveOrInvited(sTime, eTime); | |||||
if (!notInUserIds.isEmpty()) { | |||||
query.notIn(ExpertUserFullInfo::getUserId, notInUserIds); | |||||
} | |||||
Set<Long> tmpNotInUserIds = expertInviteHelper.listExpertLeaveOrInvited(sTime, eTime); | |||||
expertIdsNotIn.addAll(tmpNotInUserIds); | |||||
} | |||||
if (!expertIdsIn.isEmpty()) { | |||||
query.in(ExpertUserFullInfo::getUserId, expertIdsIn); | |||||
} else if (!expertIdsNotIn.isEmpty()) { | |||||
query.notIn(ExpertUserFullInfo::getUserId, expertIdsNotIn); | |||||
} | } | ||||
List<ExpertUserFullInfo> userInfoList = expertUserFullInfoService.list(query); | List<ExpertUserFullInfo> userInfoList = expertUserFullInfoService.list(query); | ||||
if (userInfoList.isEmpty()) { | if (userInfoList.isEmpty()) { | ||||
@@ -309,7 +323,8 @@ public class ExpertInviteManage { | |||||
} | } | ||||
Map<String, List<ExpertUserFullInfo>> userGroupByUnit = CollUtils.group(userInfoList, ExpertUserFullInfo::getCompanyUniqCode); | Map<String, List<ExpertUserFullInfo>> userGroupByUnit = CollUtils.group(userInfoList, ExpertUserFullInfo::getCompanyUniqCode); | ||||
result.setTotal(userGroupByUnit.size()); | result.setTotal(userGroupByUnit.size()); | ||||
result.setExperts(inviteGroupByCompany(userGroupByUnit, randomRule.getCount())); | |||||
result.setExperts(inviteGroupByCompany(userGroupByUnit, expertsByRecentMeeting(), randomRule.getCount())); | |||||
return result; | return result; | ||||
} | } | ||||
@@ -320,8 +335,9 @@ public class ExpertInviteManage { | |||||
* @param randomRule 随机抽取 | * @param randomRule 随机抽取 | ||||
* @param invitedExperts 已抽取人员 | * @param invitedExperts 已抽取人员 | ||||
* @param count 抽取数量 | * @param count 抽取数量 | ||||
* @param start 会议开始时间 | |||||
* @param end 会议结束时间 | |||||
* @param msTime 会议开始时间 | |||||
* @param meTime 会议结束时间 | |||||
* @param reInvite 邀请已拒绝 | |||||
* @return {@link ExpertChooseDTO} | * @return {@link ExpertChooseDTO} | ||||
* @author WendyYang | * @author WendyYang | ||||
**/ | **/ | ||||
@@ -329,16 +345,23 @@ public class ExpertInviteManage { | |||||
RandomInviteRuleDTO randomRule, | RandomInviteRuleDTO randomRule, | ||||
Collection<MeetingExpert> invitedExperts, | Collection<MeetingExpert> invitedExperts, | ||||
Integer count, | Integer count, | ||||
LocalDateTime start, | |||||
LocalDateTime end, | |||||
boolean invitedRefused) { | |||||
LocalDateTime msTime, | |||||
LocalDateTime meTime, | |||||
LocalDateTime tsTime, | |||||
boolean reInvite) { | |||||
ExpertChooseDTO result = new ExpertChooseDTO(new ArrayList<>(), 0); | ExpertChooseDTO result = new ExpertChooseDTO(new ArrayList<>(), 0); | ||||
// 合并标签、字典 | // 合并标签、字典 | ||||
List<Long> expertIdsIn = mergeExpertIdsByCondition(randomRule, avoidRule); | |||||
List<Long> expertIdsNotIn = new ArrayList<>(); | |||||
if (expertIdsIn == null) { | |||||
MergeExpertIdDTO merge = mergeExpertIdsByCondition(randomRule, avoidRule); | |||||
if (merge.getSkip()) { | |||||
return result; | return result; | ||||
} | } | ||||
Set<Long> expertIdsIn = new HashSet<>(); | |||||
Set<Long> expertIdsNotIn = new HashSet<>(); | |||||
if (CollUtil.isNotEmpty(merge.getExpertIdsIn())) { | |||||
expertIdsIn.addAll(merge.getExpertIdsIn()); | |||||
} else if (CollUtil.isNotEmpty(merge.getExpertIdsNotIn())) { | |||||
expertIdsNotIn.addAll(merge.getExpertIdsNotIn()); | |||||
} | |||||
LambdaQueryWrapper<ExpertUserFullInfo> query = buildBaseExpertQuery(); | LambdaQueryWrapper<ExpertUserFullInfo> query = buildBaseExpertQuery(); | ||||
// 设置回避单位 | // 设置回避单位 | ||||
Set<String> notInCompanyUniqCodeList = new HashSet<>(avoidRule.getAvoidUnitIdList()); | Set<String> notInCompanyUniqCodeList = new HashSet<>(avoidRule.getAvoidUnitIdList()); | ||||
@@ -355,16 +378,16 @@ public class ExpertInviteManage { | |||||
return result; | return result; | ||||
} | } | ||||
} | } | ||||
List<Long> lockExpertIds = expertInviteHelper.listInvitedExpertByTime(start, end); | |||||
List<Long> lockExpertIds = expertInviteHelper.listInvitedExpertByTime(msTime, meTime); | |||||
expertIdsIn.removeIf(lockExpertIds::contains); | expertIdsIn.removeIf(lockExpertIds::contains); | ||||
if (expertIdsIn.isEmpty()) { | if (expertIdsIn.isEmpty()) { | ||||
return result; | return result; | ||||
} | } | ||||
} else if (CollUtil.isNotEmpty(avoidRule.getExpertIds())) { | } else if (CollUtil.isNotEmpty(avoidRule.getExpertIds())) { | ||||
Set<Long> notInExpertIds = expertInviteHelper.getAvoidExpert(avoidRule.getExpertIds(), null, start, end); | |||||
Set<Long> notInExpertIds = expertInviteHelper.getAvoidExpert(avoidRule.getExpertIds(), null, msTime, meTime); | |||||
expertIdsNotIn.addAll(notInExpertIds); | expertIdsNotIn.addAll(notInExpertIds); | ||||
} else { | } else { | ||||
Set<Long> notInUserIds = expertInviteHelper.listExpertLeaveOrInvited(start, end); | |||||
Set<Long> notInUserIds = expertInviteHelper.listExpertLeaveOrInvited(msTime, meTime); | |||||
expertIdsNotIn.addAll(notInUserIds); | expertIdsNotIn.addAll(notInUserIds); | ||||
} | } | ||||
Map<ExpertAttendStatusEnum, List<MeetingExpert>> expertGroupByStatus = invitedExperts.stream() | Map<ExpertAttendStatusEnum, List<MeetingExpert>> expertGroupByStatus = invitedExperts.stream() | ||||
@@ -380,14 +403,21 @@ public class ExpertInviteManage { | |||||
List<String> tmpUniqCompanyCodes = CollUtils.fieldList(agreeOrNoticingUserInfos, ExpertUserFullInfo::getCompanyUniqCode); | List<String> tmpUniqCompanyCodes = CollUtils.fieldList(agreeOrNoticingUserInfos, ExpertUserFullInfo::getCompanyUniqCode); | ||||
notInCompanyUniqCodeList.addAll(tmpUniqCompanyCodes); | notInCompanyUniqCodeList.addAll(tmpUniqCompanyCodes); | ||||
} | } | ||||
if (!invitedRefused) { | |||||
// 拒绝参加的不可以被再次抽中 | |||||
List<MeetingExpert> refusedExperts = expertGroupByStatus.get(REFUSED); | |||||
if (refusedExperts.size() > 0) { | |||||
List<Long> refusedExpertIds = CollUtils.fieldList(refusedExperts, MeetingExpert::getExpertId); | |||||
expertIdsNotIn.addAll(refusedExpertIds); | |||||
// 处理已拒绝专家与重复抽取 | |||||
BizUtils.notEmpty(expertGroupByStatus.get(REFUSED), refuseExperts -> { | |||||
List<Long> tmpExpertIdsNotIn; | |||||
if (reInvite) { | |||||
tmpExpertIdsNotIn = refuseExperts.stream() | |||||
.filter(w -> w.getCreateOn().isAfter(tsTime)) | |||||
.map(MeetingExpert::getExpertId) | |||||
.collect(Collectors.toList()); | |||||
} else { | |||||
tmpExpertIdsNotIn = CollUtils.fieldList(refuseExperts, MeetingExpert::getExpertId); | |||||
} | } | ||||
} | |||||
expertIdsNotIn.addAll(tmpExpertIdsNotIn); | |||||
}); | |||||
boolean hasExpertIdIn = !expertIdsIn.isEmpty(); | boolean hasExpertIdIn = !expertIdsIn.isEmpty(); | ||||
boolean hasExpertIdNotIn = !expertIdsNotIn.isEmpty(); | boolean hasExpertIdNotIn = !expertIdsNotIn.isEmpty(); | ||||
if (hasExpertIdIn && hasExpertIdNotIn) { | if (hasExpertIdIn && hasExpertIdNotIn) { | ||||
@@ -408,15 +438,15 @@ public class ExpertInviteManage { | |||||
} | } | ||||
Map<String, List<ExpertUserFullInfo>> userGroupByUnit = CollUtils.group(userFullInfos, ExpertUserFullInfo::getCompanyUniqCode); | Map<String, List<ExpertUserFullInfo>> userGroupByUnit = CollUtils.group(userFullInfos, ExpertUserFullInfo::getCompanyUniqCode); | ||||
result.setTotal(userGroupByUnit.size()); | result.setTotal(userGroupByUnit.size()); | ||||
result.setExperts(inviteGroupByCompany(userGroupByUnit, count)); | |||||
result.setExperts(inviteGroupByCompany(userGroupByUnit, expertsByRecentMeeting(), count)); | |||||
return result; | return result; | ||||
} | } | ||||
private List<List<MeetingExpert>> selectMeetingExpertByCount() { | |||||
private List<List<MeetingExpert>> expertsByRecentMeeting() { | |||||
LambdaQueryWrapper<Meeting> query = Wrappers.lambdaQuery(Meeting.class) | LambdaQueryWrapper<Meeting> query = Wrappers.lambdaQuery(Meeting.class) | ||||
.select(Meeting::getId) | .select(Meeting::getId) | ||||
.orderByDesc(Meeting::getCreateOn) | .orderByDesc(Meeting::getCreateOn) | ||||
.last("limit " + 5); | |||||
.last("limit " + recentMeetingCount); | |||||
List<Long> meetingIds = CollUtils.fieldList(meetingService.list(query), Meeting::getId); | List<Long> meetingIds = CollUtils.fieldList(meetingService.list(query), Meeting::getId); | ||||
if (meetingIds.isEmpty()) { | if (meetingIds.isEmpty()) { | ||||
return Collections.emptyList(); | return Collections.emptyList(); | ||||
@@ -430,97 +460,6 @@ public class ExpertInviteManage { | |||||
} | } | ||||
/** | /** | ||||
* 每个单位只抽取一人 | |||||
* | |||||
* @param expertGroupByUnit 需要抽取的人 | |||||
* @param count 抽取数量 | |||||
* @return 抽取到的专家信息 | |||||
* @author WendyYang | |||||
**/ | |||||
private List<ExpertUserFullInfo> inviteGroupByCompany(Map<String, List<ExpertUserFullInfo>> expertGroupByUnit, Integer count) { | |||||
if (MapUtils.isEmpty(expertGroupByUnit)) { | |||||
return Collections.emptyList(); | |||||
} | |||||
List<List<MeetingExpert>> meetingExperts = selectMeetingExpertByCount(); | |||||
if (meetingExperts.isEmpty()) { | |||||
return expertGroupByUnit.values().stream() | |||||
.map(expertUsers -> expertUsers.get(RandomUtils.nextInt(0, expertUsers.size()))) | |||||
.limit(count).collect(Collectors.toList()); | |||||
} else { | |||||
List<ExpertUserFullInfo> result = new ArrayList<>(); | |||||
List<String> keySet = new ArrayList<>(expertGroupByUnit.keySet()); | |||||
for (int i = 0; i < count; i++) { | |||||
String key = keySet.get(RandomUtils.nextInt(0, keySet.size())); | |||||
List<ExpertUserFullInfo> expertUserFullInfos = expertGroupByUnit.get(key); | |||||
for (List<MeetingExpert> expertList : meetingExperts) { | |||||
List<ExpertUserFullInfo> tempList = expertUserFullInfos.stream() | |||||
.filter(w -> expertList.stream().noneMatch(expert -> expert.getExpertId().equals(w.getUserId()))) | |||||
.collect(Collectors.toList()); | |||||
if (!tempList.isEmpty()) { | |||||
result.add(tempList.get(RandomUtils.nextInt(0, tempList.size()))); | |||||
break; | |||||
} else if (meetingExperts.indexOf(expertList) == (meetingExperts.size() - 1)) { | |||||
result.add(expertUserFullInfos.get(RandomUtils.nextInt(0, expertUserFullInfos.size()))); | |||||
} | |||||
} | |||||
if (result.size() < count) { | |||||
keySet.remove(key); | |||||
if (keySet.isEmpty()) { | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
return result; | |||||
} | |||||
} | |||||
private List<ExpertUserFullInfo> inviteWithoutCompany(List<ExpertUserFullInfo> userFullInfos, Integer count) { | |||||
List<ExpertUserFullInfo> result = new ArrayList<>(); | |||||
List<List<MeetingExpert>> meetingExpertList = selectMeetingExpertByCount(); | |||||
if (meetingExpertList.isEmpty()) { | |||||
for (int i = 0; i < count; i++) { | |||||
int randomIndex = RandomUtils.nextInt(0, userFullInfos.size()); | |||||
result.add(userFullInfos.remove(randomIndex)); | |||||
if (userFullInfos.size() == 0) { | |||||
break; | |||||
} | |||||
} | |||||
} else { | |||||
for (List<MeetingExpert> meetingExperts : meetingExpertList) { | |||||
List<ExpertUserFullInfo> unSelectedUsers = userFullInfos.stream() | |||||
.filter(w -> meetingExperts.stream().noneMatch(expert -> expert.getExpertId().equals(w.getUserId()))) | |||||
.collect(Collectors.toList()); | |||||
if (!unSelectedUsers.isEmpty()) { | |||||
result.addAll(unSelectedUsers); | |||||
if (result.size() >= count) { | |||||
return result.subList(0, count); | |||||
} | |||||
userFullInfos.removeAll(unSelectedUsers); | |||||
} | |||||
} | |||||
if (userFullInfos.size() == 0) { | |||||
return result; | |||||
} | |||||
int restCount = Math.min(count - result.size(), userFullInfos.size()); | |||||
int groupCount = userFullInfos.size() / restCount; | |||||
if (userFullInfos.size() > restCount) { | |||||
Stream.iterate(0, t -> t + 1).limit(restCount) | |||||
.forEach(t -> { | |||||
int start = t * groupCount; | |||||
int end = start + groupCount; | |||||
if (end >= groupCount * restCount) { | |||||
end = userFullInfos.size(); | |||||
} | |||||
result.add(userFullInfos.get(RandomUtils.nextInt(start, end))); | |||||
}); | |||||
} else { | |||||
result.addAll(userFullInfos); | |||||
} | |||||
} | |||||
return result; | |||||
} | |||||
/** | |||||
* 专家抽取(会议创建时抽取) | * 专家抽取(会议创建时抽取) | ||||
* | * | ||||
* @param randomRules 随机抽取规则 | * @param randomRules 随机抽取规则 | ||||
@@ -56,7 +56,7 @@ import org.springframework.util.Assert; | |||||
import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||
import java.util.*; | import java.util.*; | ||||
import java.util.function.Function; | |||||
import java.util.function.BiFunction; | |||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
import static com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum.*; | import static com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum.*; | ||||
@@ -236,8 +236,9 @@ public class MeetingManage { | |||||
AvoidRuleDTO avoidInfo = req.getAvoidRule(); | AvoidRuleDTO avoidInfo = req.getAvoidRule(); | ||||
Assert.notNull(avoidInfo, "回避信息不能为空"); | Assert.notNull(avoidInfo, "回避信息不能为空"); | ||||
// 随机抽取的话则需进行抽取数量校验 | // 随机抽取的话则需进行抽取数量校验 | ||||
LocalDateTime now = LocalDateTime.now(); | |||||
expertInviteManage.expertInviteByMeetingCreate(meeting, randomRules, avoidInfo); | expertInviteManage.expertInviteByMeetingCreate(meeting, randomRules, avoidInfo); | ||||
expertInviteTask.addInviteTaskByMeetingCreate(meeting.getId(), 5); | |||||
expertInviteTask.addInviteTaskByMeetingCreate(meeting.getId(), now); | |||||
LambdaUpdateWrapper<Meeting> mUpdate = Wrappers.lambdaUpdate(Meeting.class) | LambdaUpdateWrapper<Meeting> mUpdate = Wrappers.lambdaUpdate(Meeting.class) | ||||
.set(Meeting::getInviteStatus, false) | .set(Meeting::getInviteStatus, false) | ||||
.eq(Meeting::getId, meeting.getId()); | .eq(Meeting::getId, meeting.getId()); | ||||
@@ -469,7 +470,7 @@ public class MeetingManage { | |||||
} | } | ||||
List<Long> expertIds = CollUtils.fieldList(experts, MeetingExpert::getExpertId); | List<Long> expertIds = CollUtils.fieldList(experts, MeetingExpert::getExpertId); | ||||
Map<Long, ExpertBasicInfoVO> expertMap = meetingManageHelper.getExpertBasicInfo(expertIds); | Map<Long, ExpertBasicInfoVO> expertMap = meetingManageHelper.getExpertBasicInfo(expertIds); | ||||
Function<MeetingExpert, InviteExpertListItemVO> mapping = me -> { | |||||
BiFunction<MeetingExpert, Map<Long, ExpertInviteRule>, InviteExpertListItemVO> mapping = (me, ruleMap) -> { | |||||
ExpertBasicInfoVO expert = expertMap.get(me.getExpertId()); | ExpertBasicInfoVO expert = expertMap.get(me.getExpertId()); | ||||
InviteExpertListItemVO item = BeanUtil.copyProperties(expert, InviteExpertListItemVO.class); | InviteExpertListItemVO item = BeanUtil.copyProperties(expert, InviteExpertListItemVO.class); | ||||
item.setExpertMeetingId(me.getId()); | item.setExpertMeetingId(me.getId()); | ||||
@@ -479,6 +480,8 @@ public class MeetingManage { | |||||
item.setNoticeTime(me.getCreateOn()); | item.setNoticeTime(me.getCreateOn()); | ||||
item.setRuleId(me.getRuleId()); | item.setRuleId(me.getRuleId()); | ||||
item.setIsHeadman(me.getIsHeadman()); | item.setIsHeadman(me.getIsHeadman()); | ||||
ExpertInviteRule rule = ruleMap.get(me.getRuleId()); | |||||
item.setInviteType(rule == null ? ExpertInviteTypeEnum.APPOINT.getCode() : rule.getInviteType()); | |||||
if (NOTICING.eq(me.getStatus())) { | if (NOTICING.eq(me.getStatus())) { | ||||
item.setNoticeStatus("通知中"); | item.setNoticeStatus("通知中"); | ||||
} else { | } else { | ||||
@@ -486,12 +489,12 @@ public class MeetingManage { | |||||
} | } | ||||
return item; | return item; | ||||
}; | }; | ||||
List<ExpertInviteRule> inviteRules = inviteRuleService.listByMeetingId(meetingId); | |||||
Map<Long, ExpertInviteRule> ruleMap = CollUtils.listToMap(inviteRules, ExpertInviteRule::getId); | |||||
boolean isRandom = ExpertInviteTypeEnum.RANDOM.eq(meeting.getInviteType()); | boolean isRandom = ExpertInviteTypeEnum.RANDOM.eq(meeting.getInviteType()); | ||||
if (isRandom) { | if (isRandom) { | ||||
result.setInviteStatistics(new ArrayList<>()); | result.setInviteStatistics(new ArrayList<>()); | ||||
Map<Long, List<MeetingExpert>> groupByRule = CollUtils.group(experts, MeetingExpert::getRuleId); | Map<Long, List<MeetingExpert>> groupByRule = CollUtils.group(experts, MeetingExpert::getRuleId); | ||||
List<ExpertInviteRule> inviteRules = inviteRuleService.listByMeetingId(meetingId); | |||||
Map<Long, ExpertInviteRule> ruleMap = CollUtils.listToMap(inviteRules, ExpertInviteRule::getId); | |||||
ruleMap.forEach((k, v) -> { | ruleMap.forEach((k, v) -> { | ||||
InviteStatisticsByRuleVO statistics = InviteStatisticsByRuleVO.init(k); | InviteStatisticsByRuleVO statistics = InviteStatisticsByRuleVO.init(k); | ||||
statistics.setInviteCnt(v.getInviteCount()); | statistics.setInviteCnt(v.getInviteCount()); | ||||
@@ -507,7 +510,7 @@ public class MeetingManage { | |||||
result.getInviteStatistics().add(statistics); | result.getInviteStatistics().add(statistics); | ||||
}); | }); | ||||
} | } | ||||
List<InviteExpertListItemVO> converts = CollUtils.convert(experts, mapping); | |||||
List<InviteExpertListItemVO> converts = CollUtils.convert(experts, me -> mapping.apply(me, ruleMap)); | |||||
result.setInviteExpertList(converts); | result.setInviteExpertList(converts); | ||||
// 确定参加列表 | // 确定参加列表 | ||||
return result; | return result; | ||||
@@ -579,7 +582,7 @@ public class MeetingManage { | |||||
if (CollUtil.isNotEmpty(vo.getAvoidOrgIds())) { | if (CollUtil.isNotEmpty(vo.getAvoidOrgIds())) { | ||||
vo.setAvoidOrgs(businessStripService.listNameByCodes(avoidInfo.getAvoidOrgIdList())); | vo.setAvoidOrgs(businessStripService.listNameByCodes(avoidInfo.getAvoidOrgIdList())); | ||||
} | } | ||||
if (CollUtil.isNotEmpty(vo.getAvoidUnits())) { | |||||
if (CollUtil.isNotEmpty(vo.getAvoidUnitIds())) { | |||||
vo.setAvoidUnits(dingOrganizationService.listNameByCodes(avoidInfo.getAvoidUnitIdList())); | vo.setAvoidUnits(dingOrganizationService.listNameByCodes(avoidInfo.getAvoidUnitIdList())); | ||||
} | } | ||||
if (CollUtil.isNotEmpty(avoidInfo.getExpertIds())) { | if (CollUtil.isNotEmpty(avoidInfo.getExpertIds())) { | ||||
@@ -67,7 +67,7 @@ | |||||
<select id="listExpertLastByMeetingIds" resultType="com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert"> | <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, | 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, rule_id FROM meeting_expert | |||||
ID, expert_id, status, meeting_id, invite_type, mobile, expert_name, update_on, rule_id, create_on FROM meeting_expert | |||||
where meeting_id <foreach collection="meetingIds" separator="," close=")" open=" in (" item="item"> | where meeting_id <foreach collection="meetingIds" separator="," close=")" open=" in (" item="item"> | ||||
#{item}</foreach>) em WHERE rowNumber = 1 | #{item}</foreach>) em WHERE rowNumber = 1 | ||||
</select> | </select> | ||||
@@ -1,7 +1,6 @@ | |||||
package com.ningdatech.pmapi.meeting.task; | package com.ningdatech.pmapi.meeting.task; | ||||
import cn.hutool.core.util.ObjectUtil; | import cn.hutool.core.util.ObjectUtil; | ||||
import com.alibaba.fastjson.JSON; | |||||
import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
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; | ||||
@@ -14,6 +13,7 @@ import com.ningdatech.pmapi.meeting.entity.domain.ExpertInviteRule; | |||||
import com.ningdatech.pmapi.meeting.entity.domain.Meeting; | import com.ningdatech.pmapi.meeting.entity.domain.Meeting; | ||||
import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; | import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; | ||||
import com.ningdatech.pmapi.meeting.entity.dto.RandomInviteRuleDTO; | import com.ningdatech.pmapi.meeting.entity.dto.RandomInviteRuleDTO; | ||||
import com.ningdatech.pmapi.meeting.entity.dto.YxtCallBackDTO; | |||||
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; | import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; | ||||
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertInviteTypeEnum; | import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertInviteTypeEnum; | ||||
import com.ningdatech.pmapi.meeting.helper.YxtCallOrSmsHelper; | import com.ningdatech.pmapi.meeting.helper.YxtCallOrSmsHelper; | ||||
@@ -28,7 +28,6 @@ import com.ningdatech.yxt.model.cmd.SendSmsCmd.SendSmsContext; | |||||
import com.ningdatech.yxt.service.ISysMsgRecordDetailService; | import com.ningdatech.yxt.service.ISysMsgRecordDetailService; | ||||
import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; | import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; | ||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
@@ -69,6 +68,8 @@ public class ExpertCallResultRewriteTask { | |||||
private final IExpertUserFullInfoService userFullInfoService; | private final IExpertUserFullInfoService userFullInfoService; | ||||
private final static int MINUTES_CALL_RESULT_FEEDBACK = 15; | private final static int MINUTES_CALL_RESULT_FEEDBACK = 15; | ||||
private static final String AGREE_KEY = "1"; | |||||
@PostConstruct | @PostConstruct | ||||
public void initTask() { | public void initTask() { | ||||
if (!randomInviteProperties.getEnable()) { | if (!randomInviteProperties.getEnable()) { | ||||
@@ -77,7 +78,8 @@ public class ExpertCallResultRewriteTask { | |||||
} | } | ||||
Instant startTime = Instant.now().plus(randomInviteProperties.getResultRewriteFixedRate(), ChronoUnit.MINUTES); | Instant startTime = Instant.now().plus(randomInviteProperties.getResultRewriteFixedRate(), ChronoUnit.MINUTES); | ||||
// 处理电话结果回填 | // 处理电话结果回填 | ||||
scheduler.scheduleAtFixedRate(this::rewritePhoneCallResult, startTime, Duration.ofMinutes(randomInviteProperties.getResultRewriteFixedRate())); | |||||
Duration fixedRate = Duration.ofMinutes(randomInviteProperties.getResultRewriteFixedRate()); | |||||
scheduler.scheduleAtFixedRate(this::rewritePhoneCallResult, startTime, fixedRate); | |||||
} | } | ||||
@@ -101,7 +103,7 @@ public class ExpertCallResultRewriteTask { | |||||
if (!randomRuleIds.isEmpty()) { | if (!randomRuleIds.isEmpty()) { | ||||
List<ExpertInviteRule> inviteRules = inviteRuleService.listByIds(randomRuleIds); | List<ExpertInviteRule> inviteRules = inviteRuleService.listByIds(randomRuleIds); | ||||
inviteRules.forEach(w -> { | inviteRules.forEach(w -> { | ||||
RandomInviteRuleDTO rule = JSON.parseObject(w.getInviteRule(), RandomInviteRuleDTO.class); | |||||
RandomInviteRuleDTO rule = JSONObject.parseObject(w.getInviteRule(), RandomInviteRuleDTO.class); | |||||
callbackMinutes.put(w.getId(), rule.getWaitForCallbackMinutes()); | callbackMinutes.put(w.getId(), rule.getWaitForCallbackMinutes()); | ||||
}); | }); | ||||
} | } | ||||
@@ -172,44 +174,37 @@ public class ExpertCallResultRewriteTask { | |||||
} | } | ||||
} | } | ||||
private static Optional<Integer> getStatusByMsgRecordDetail(SysMsgRecordDetail msgRecordDetail, int minutes, LocalDateTime createOn) { | |||||
LocalDateTime time = LocalDateTime.now().minusMinutes(minutes); | |||||
String callBackJson = msgRecordDetail.getCallBackJson(); | |||||
if (StrUtils.isBlank(callBackJson) && time.isBefore(createOn)) { | |||||
private static Optional<Integer> getStatusByMsgRecordDetail(SysMsgRecordDetail mrd, int minutes, LocalDateTime createOn) { | |||||
LocalDateTime limitTime = LocalDateTime.now().minusMinutes(minutes); | |||||
String callBackJson = mrd.getCallBackJson(); | |||||
boolean waiting = limitTime.isBefore(createOn); | |||||
boolean hasCallBack = StrUtils.isNotBlank(callBackJson); | |||||
if (!hasCallBack && waiting) { | |||||
return Optional.empty(); | return Optional.empty(); | ||||
} | } | ||||
ExpertAttendStatusEnum status; | ExpertAttendStatusEnum status; | ||||
if (StrUtils.isNotBlank(callBackJson)) { | |||||
if (hasCallBack) { | |||||
try { | try { | ||||
JSONObject callbackObject = JSON.parseObject(callBackJson); | |||||
Date dialBeginTime = callbackObject.getDate("dialBeginTime"); | |||||
YxtCallBackDTO callback = JSONObject.parseObject(callBackJson, YxtCallBackDTO.class); | |||||
LocalDateTime dialBeginTime = callback.getDialBeginTime(); | |||||
if (dialBeginTime == null) { | if (dialBeginTime == null) { | ||||
return Optional.empty(); | return Optional.empty(); | ||||
} | } | ||||
Integer resultCode = callbackObject.getInteger("resultCode"); | |||||
Integer resultCode = callback.getResultCode(); | |||||
if (resultCode != null && resultCode == 0) { | if (resultCode != null && resultCode == 0) { | ||||
String pressKeyStr = callbackObject.getString("pressKey"); | |||||
if (Objects.nonNull(pressKeyStr)) { | |||||
pressKeyStr = pressKeyStr.replaceAll("\\*", "").trim(); | |||||
} | |||||
Integer pressKey = null; | |||||
if (StringUtils.isNotBlank(pressKeyStr)) { | |||||
pressKey = Integer.parseInt(pressKeyStr); | |||||
String pressKey = callback.getPressKey(); | |||||
if (pressKey != null) { | |||||
pressKey = pressKey.replaceAll("\\*", "").trim(); | |||||
} | } | ||||
if (pressKey == null) { | |||||
if (time.isBefore(createOn)) { | |||||
return Optional.empty(); | |||||
} | |||||
status = REFUSED; | |||||
} else { | |||||
if (pressKey == 1) { | |||||
status = AGREED; | |||||
} else { | |||||
status = REFUSED; | |||||
} | |||||
if (StrUtils.isBlank(pressKey) && waiting) { | |||||
return Optional.empty(); | |||||
} | } | ||||
status = AGREE_KEY.equals(pressKey) ? AGREED : REFUSED; | |||||
} else { | } else { | ||||
status = UNANSWERED; | |||||
if (waiting) { | |||||
return Optional.empty(); | |||||
} | |||||
status = REFUSED; | |||||
} | } | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
log.error("获取电话回调结果异常", e); | log.error("获取电话回调结果异常", e); | ||||
@@ -27,7 +27,6 @@ import lombok.Data; | |||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.apache.commons.collections4.MapUtils; | import org.apache.commons.collections4.MapUtils; | ||||
import org.springframework.aop.framework.AopContext; | import org.springframework.aop.framework.AopContext; | ||||
import org.springframework.beans.factory.annotation.Qualifier; | |||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; | import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; | ||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
@@ -39,13 +38,13 @@ import java.time.Duration; | |||||
import java.time.Instant; | import java.time.Instant; | ||||
import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||
import java.time.ZoneId; | import java.time.ZoneId; | ||||
import java.util.HashMap; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
import java.util.concurrent.ConcurrentHashMap; | import java.util.concurrent.ConcurrentHashMap; | ||||
import java.util.concurrent.ConcurrentMap; | import java.util.concurrent.ConcurrentMap; | ||||
import java.util.concurrent.ScheduledFuture; | import java.util.concurrent.ScheduledFuture; | ||||
import java.util.concurrent.atomic.AtomicInteger; | import java.util.concurrent.atomic.AtomicInteger; | ||||
import java.util.stream.Collectors; | |||||
/** | /** | ||||
@@ -67,7 +66,6 @@ public class ExpertInviteTask { | |||||
private static final Duration EXPIRE_TIME = Duration.ofDays(60); | private static final Duration EXPIRE_TIME = Duration.ofDays(60); | ||||
private final CachePlusOps cachePlusOps; | private final CachePlusOps cachePlusOps; | ||||
@Qualifier("expertInviteScheduler") | |||||
@Resource(name = "expertInviteScheduler") | @Resource(name = "expertInviteScheduler") | ||||
private ThreadPoolTaskScheduler scheduler; | private ThreadPoolTaskScheduler scheduler; | ||||
private final IMeetingExpertService meetingExpertService; | private final IMeetingExpertService meetingExpertService; | ||||
@@ -82,13 +80,13 @@ public class ExpertInviteTask { | |||||
*/ | */ | ||||
private static final ConcurrentMap<Long, ScheduledFuture<?>> INVITE_TASK_MAP = new ConcurrentHashMap<>(); | private static final ConcurrentMap<Long, ScheduledFuture<?>> INVITE_TASK_MAP = new ConcurrentHashMap<>(); | ||||
public ExpertInviteTask currProxy() { | |||||
private ExpertInviteTask currProxy() { | |||||
return (ExpertInviteTask) AopContext.currentProxy(); | return (ExpertInviteTask) AopContext.currentProxy(); | ||||
} | } | ||||
private CacheHashKey getCacheKey(Long meetingId) { | private CacheHashKey getCacheKey(Long meetingId) { | ||||
String meetingIdStr = meetingId == null ? null : meetingId.toString(); | |||||
return new CacheHashKey(MEETING_ID_INVITE_RANDOM, meetingIdStr, EXPIRE_TIME); | |||||
String field = meetingId == null ? null : meetingId.toString(); | |||||
return new CacheHashKey(MEETING_ID_INVITE_RANDOM, field, EXPIRE_TIME); | |||||
} | } | ||||
@PostConstruct | @PostConstruct | ||||
@@ -97,13 +95,13 @@ public class ExpertInviteTask { | |||||
log.warn("随机邀请已关闭……"); | log.warn("随机邀请已关闭……"); | ||||
return; | return; | ||||
} | } | ||||
initInviteTaskAfterAppStarted(); | |||||
initInviteTaskAfterStarted(); | |||||
} | } | ||||
/** | /** | ||||
* 项目重启之后重新初始化邀请任务 | * 项目重启之后重新初始化邀请任务 | ||||
*/ | */ | ||||
private void initInviteTaskAfterAppStarted() { | |||||
private void initInviteTaskAfterStarted() { | |||||
Map<Long, InviteCacheDTO> caches = cachePlusOps.hGetAll(getCacheKey(null)); | Map<Long, InviteCacheDTO> caches = cachePlusOps.hGetAll(getCacheKey(null)); | ||||
if (MapUtils.isEmpty(caches)) { | if (MapUtils.isEmpty(caches)) { | ||||
log.info("暂无需要初始化的抽取会议信息"); | log.info("暂无需要初始化的抽取会议信息"); | ||||
@@ -111,8 +109,9 @@ public class ExpertInviteTask { | |||||
} | } | ||||
Integer inviteDelay = properties.getInviteDelay(); | Integer inviteDelay = properties.getInviteDelay(); | ||||
for (InviteCacheDTO cache : caches.values()) { | for (InviteCacheDTO cache : caches.values()) { | ||||
Boolean invitedRefused = cache.getInvitedRefused(); | |||||
boolean added = addInviteTask(cache.getMeetingId(), true, inviteDelay, invitedRefused); | |||||
Boolean reInvite = cache.getReInvite(); | |||||
LocalDateTime tsTime = cache.getTaskStartTime(); | |||||
boolean added = addInviteTask(cache.getMeetingId(), true, inviteDelay, reInvite, tsTime); | |||||
if (!added) { | if (!added) { | ||||
cachePlusOps.hDel(getCacheKey(cache.getMeetingId())); | cachePlusOps.hDel(getCacheKey(cache.getMeetingId())); | ||||
} | } | ||||
@@ -134,7 +133,7 @@ public class ExpertInviteTask { | |||||
LambdaQueryWrapper<MeetingExpert> query = Wrappers.lambdaQuery(MeetingExpert.class) | LambdaQueryWrapper<MeetingExpert> query = Wrappers.lambdaQuery(MeetingExpert.class) | ||||
.select(MeetingExpert::getRuleId, MeetingExpert::getStatus) | .select(MeetingExpert::getRuleId, MeetingExpert::getStatus) | ||||
.in(MeetingExpert::getRuleId, ruleMap.keySet()) | .in(MeetingExpert::getRuleId, ruleMap.keySet()) | ||||
.in(MeetingExpert::getStatus, ExpertAttendStatusEnum.AGREED.getCode()); | |||||
.eq(MeetingExpert::getStatus, ExpertAttendStatusEnum.AGREED.getCode()); | |||||
List<MeetingExpert> experts = meetingExpertService.list(query); | List<MeetingExpert> experts = meetingExpertService.list(query); | ||||
if (experts.isEmpty()) { | if (experts.isEmpty()) { | ||||
return Boolean.TRUE; | return Boolean.TRUE; | ||||
@@ -152,23 +151,20 @@ public class ExpertInviteTask { | |||||
/** | /** | ||||
* 唤醒某个会议的抽取任务 | * 唤醒某个会议的抽取任务 | ||||
* | * | ||||
* @param meetingId 会议ID | |||||
* @param invitedRefused 是否可邀请已拒绝的专家 | |||||
* @param meetingId 会议ID | |||||
* @param reInvite 是否可邀请已拒绝的专家 | |||||
* @author WendyYang | * @author WendyYang | ||||
**/ | **/ | ||||
public void notifyInviteTask(Long meetingId, boolean... invitedRefused) { | |||||
boolean tmpInvitedRefused = true; | |||||
if (ArrayUtil.isNotEmpty(invitedRefused)) { | |||||
tmpInvitedRefused = invitedRefused[0]; | |||||
} | |||||
public void notifyInviteTask(Long meetingId, boolean... reInvite) { | |||||
boolean tmpReInvite = ArrayUtil.isEmpty(reInvite) || reInvite[0]; | |||||
if (!INVITE_TASK_MAP.containsKey(meetingId)) { | if (!INVITE_TASK_MAP.containsKey(meetingId)) { | ||||
if (addInviteTask(meetingId, false, properties.getInviteDelay(), tmpInvitedRefused)) { | |||||
if (addInviteTask(meetingId, false, properties.getInviteDelay(), tmpReInvite, LocalDateTime.now())) { | |||||
log.info("重置会议的随机抽取状态:{}", meetingId); | log.info("重置会议的随机抽取状态:{}", meetingId); | ||||
LambdaUpdateWrapper<Meeting> update = Wrappers.lambdaUpdate(Meeting.class); | LambdaUpdateWrapper<Meeting> update = Wrappers.lambdaUpdate(Meeting.class); | ||||
update.set(Meeting::getInviteStatus, false); | update.set(Meeting::getInviteStatus, false); | ||||
update.eq(Meeting::getId, meetingId); | update.eq(Meeting::getId, meetingId); | ||||
meetingService.update(update); | meetingService.update(update); | ||||
InviteCacheDTO cacheVal = InviteCacheDTO.of(meetingId, tmpInvitedRefused); | |||||
InviteCacheDTO cacheVal = InviteCacheDTO.of(meetingId, tmpReInvite, LocalDateTime.now()); | |||||
cachePlusOps.hSet(getCacheKey(meetingId), cacheVal); | cachePlusOps.hSet(getCacheKey(meetingId), cacheVal); | ||||
} | } | ||||
} | } | ||||
@@ -177,23 +173,24 @@ public class ExpertInviteTask { | |||||
/** | /** | ||||
* 添加专家抽取校验任务 | * 添加专家抽取校验任务 | ||||
* | * | ||||
* @param meetingId 会议ID | |||||
* @param checked 是否前置校验 | |||||
* @param delayedMinutes 延迟执行时间 | |||||
* @param invitedRefused 是否可以邀请被拒绝的专家 | |||||
* @param meetingId 会议ID | |||||
* @param checked 是否前置校验 | |||||
* @param delayTime 延迟执行时间 | |||||
* @param reInvite 是否可以邀请被拒绝的专家 | |||||
* @param tsTime 任务启动时间 | |||||
* @return 是否添加任务成功 | * @return 是否添加任务成功 | ||||
* @author WendyYang | * @author WendyYang | ||||
**/ | **/ | ||||
public boolean addInviteTask(Long meetingId, boolean checked, int delayedMinutes, boolean invitedRefused) { | |||||
private boolean addInviteTask(Long meetingId, boolean checked, int delayTime, boolean reInvite, LocalDateTime tsTime) { | |||||
if (checked && !inviteCountCheck(meetingId)) { | if (checked && !inviteCountCheck(meetingId)) { | ||||
// 如果抽取数量满足直接返回 | // 如果抽取数量满足直接返回 | ||||
return Boolean.FALSE; | return Boolean.FALSE; | ||||
} | } | ||||
Instant startTime = LocalDateTime.now().plusMinutes(delayedMinutes).atZone(ZoneId.systemDefault()).toInstant(); | |||||
Instant startTime = LocalDateTime.now().plusMinutes(delayTime).atZone(ZoneId.systemDefault()).toInstant(); | |||||
ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(() -> { | ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(() -> { | ||||
ExpertInviteTask bean = SpringContextHolder.getBean(ExpertInviteTask.class); | ExpertInviteTask bean = SpringContextHolder.getBean(ExpertInviteTask.class); | ||||
try { | try { | ||||
bean.invite(meetingId, invitedRefused); | |||||
bean.invite(meetingId, reInvite, tsTime); | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
log.error("执行专家邀请任务异常:{}", meetingId, e); | log.error("执行专家邀请任务异常:{}", meetingId, e); | ||||
} | } | ||||
@@ -206,25 +203,26 @@ public class ExpertInviteTask { | |||||
/** | /** | ||||
* 创建会议时添加抽取任务 | * 创建会议时添加抽取任务 | ||||
* | * | ||||
* @param meetingId 会议ID | |||||
* @param delayedMinutes 延迟时间 | |||||
* @param meetingId 会议ID | |||||
* @param tsTime 开始时间 | |||||
* @author WendyYang | * @author WendyYang | ||||
**/ | **/ | ||||
public void addInviteTaskByMeetingCreate(Long meetingId, int delayedMinutes) { | |||||
public void addInviteTaskByMeetingCreate(Long meetingId, LocalDateTime tsTime) { | |||||
Assert.isTrue(properties.getEnable(), "随机邀请已关闭"); | Assert.isTrue(properties.getEnable(), "随机邀请已关闭"); | ||||
addInviteTask(meetingId, false, delayedMinutes, false); | |||||
InviteCacheDTO cacheVal = InviteCacheDTO.of(meetingId, false); | |||||
addInviteTask(meetingId, false, properties.getInviteDelay(), false, tsTime); | |||||
InviteCacheDTO cacheVal = InviteCacheDTO.of(meetingId, false, tsTime); | |||||
cachePlusOps.hSet(getCacheKey(meetingId), cacheVal); | cachePlusOps.hSet(getCacheKey(meetingId), cacheVal); | ||||
} | } | ||||
/** | /** | ||||
* 抽取过程 | * 抽取过程 | ||||
* | * | ||||
* @param meetingId 会议ID | |||||
* @param invitedRefused 是否可以邀请已拒绝的专家 | |||||
* @param meetingId 会议ID | |||||
* @param reInvite 是否可以邀请已拒绝的专家 | |||||
* @param tsTime 任务开启时间 | |||||
*/ | */ | ||||
@Transactional(rollbackFor = Exception.class) | @Transactional(rollbackFor = Exception.class) | ||||
public void invite(Long meetingId, Boolean invitedRefused) { | |||||
public void invite(Long meetingId, Boolean reInvite, LocalDateTime tsTime) { | |||||
log.info("开始进行专家后台抽取:{}", meetingId); | log.info("开始进行专家后台抽取:{}", meetingId); | ||||
Meeting meeting = meetingService.getById(meetingId); | Meeting meeting = meetingService.getById(meetingId); | ||||
if (meeting.getStartTime().isBefore(LocalDateTime.now())) { | if (meeting.getStartTime().isBefore(LocalDateTime.now())) { | ||||
@@ -239,11 +237,13 @@ public class ExpertInviteTask { | |||||
// 还需要抽取的规则数量 | // 还需要抽取的规则数量 | ||||
AtomicInteger notIgnoreCnt = new AtomicInteger(ruleMap.size()); | AtomicInteger notIgnoreCnt = new AtomicInteger(ruleMap.size()); | ||||
AtomicInteger notSupportCnt = new AtomicInteger(0); | AtomicInteger notSupportCnt = new AtomicInteger(0); | ||||
LocalDateTime msTime = meeting.getStartTime(); | |||||
LocalDateTime meTime = meeting.getStartTime(); | |||||
ruleMap.forEach((ruleId, value) -> { | ruleMap.forEach((ruleId, value) -> { | ||||
List<MeetingExpert> tmpExperts = meetingExpertService.listExpertLastByMeetingId(meetingId); | List<MeetingExpert> tmpExperts = meetingExpertService.listExpertLastByMeetingId(meetingId); | ||||
Map<Long, MeetingExpert> expertMap = CollUtils.listToMap(tmpExperts, MeetingExpert::getExpertId); | Map<Long, MeetingExpert> expertMap = CollUtils.listToMap(tmpExperts, MeetingExpert::getExpertId); | ||||
// 统计通知中与同意参加专家数量 | // 统计通知中与同意参加专家数量 | ||||
Map<Long, ExpertCntBO> countMap = countByAgree(expertMap); | |||||
Map<Long, ExpertCntBO> countMap = countByAttendStatus(expertMap); | |||||
ExpertCntBO cnt = countMap.getOrDefault(ruleId, ExpertCntBO.zeroInit()); | ExpertCntBO cnt = countMap.getOrDefault(ruleId, ExpertCntBO.zeroInit()); | ||||
int wouldAttendCnt = cnt.getAgreeCnt() + cnt.getNoticeCnt(); | int wouldAttendCnt = cnt.getAgreeCnt() + cnt.getNoticeCnt(); | ||||
if (wouldAttendCnt == value.getCount()) { | if (wouldAttendCnt == value.getCount()) { | ||||
@@ -254,7 +254,7 @@ public class ExpertInviteTask { | |||||
} | } | ||||
int needInviteCnt = value.getCount() - wouldAttendCnt; | int needInviteCnt = value.getCount() - wouldAttendCnt; | ||||
ExpertChooseDTO expertChoose = expertInviteManage.expertReplaceByRandomRule(avoidRule, value, | ExpertChooseDTO expertChoose = expertInviteManage.expertReplaceByRandomRule(avoidRule, value, | ||||
tmpExperts, needInviteCnt, meeting.getStartTime(), meeting.getEndTime(), invitedRefused); | |||||
tmpExperts, needInviteCnt, msTime, meTime, tsTime, reInvite); | |||||
if (expertChoose.getTotal() > 0) { | if (expertChoose.getTotal() > 0) { | ||||
List<MeetingExpert> expertMeetings = CollUtils.convert(expertChoose.getExperts(), w -> { | List<MeetingExpert> expertMeetings = CollUtils.convert(expertChoose.getExperts(), w -> { | ||||
@@ -292,20 +292,18 @@ public class ExpertInviteTask { | |||||
//================================================================================================================== | //================================================================================================================== | ||||
private Map<Long, ExpertCntBO> countByAgree(Map<Long, MeetingExpert> expertMap) { | |||||
return expertMap.entrySet().stream() | |||||
.collect(Collectors.groupingBy(w -> w.getValue().getRuleId(), | |||||
Collectors.collectingAndThen(Collectors.mapping(Map.Entry::getValue, Collectors.toList()), w -> { | |||||
ExpertCntBO cnt = ExpertCntBO.zeroInit(); | |||||
for (MeetingExpert expert : w) { | |||||
if (ExpertAttendStatusEnum.AGREED.eq(expert.getStatus())) { | |||||
cnt.incrAgreeCnt(); | |||||
} else if (ExpertAttendStatusEnum.NOTICING.eq(expert.getStatus())) { | |||||
cnt.incrNoticeCnt(); | |||||
} | |||||
} | |||||
return cnt; | |||||
}))); | |||||
private Map<Long, ExpertCntBO> countByAttendStatus(Map<Long, MeetingExpert> expertMap) { | |||||
Map<Long, ExpertCntBO> cntMap = new HashMap<>(8); | |||||
expertMap.values().forEach(w -> { | |||||
Long ruleId = w.getRuleId(); | |||||
ExpertCntBO cnt = cntMap.computeIfAbsent(ruleId, k -> ExpertCntBO.zeroInit()); | |||||
if (ExpertAttendStatusEnum.AGREED.eq(w.getStatus())) { | |||||
cnt.incrAgreeCnt(); | |||||
} else if (ExpertAttendStatusEnum.NOTICING.eq(w.getStatus())) { | |||||
cnt.incrNoticeCnt(); | |||||
} | |||||
}); | |||||
return cntMap; | |||||
} | } | ||||
@Data | @Data | ||||
@@ -37,4 +37,9 @@ public class RandomInviteProperties { | |||||
* 会议抽取完成通知 管理员下发会议通知 | * 会议抽取完成通知 管理员下发会议通知 | ||||
*/ | */ | ||||
private Integer meetingInviteCompleteNoticeRate = 1; | private Integer meetingInviteCompleteNoticeRate = 1; | ||||
/** | |||||
* 近期会议数量(以此来降低专家抽中间隔) | |||||
*/ | |||||
private Integer recentMeetingCount = 5; | |||||
} | } |
@@ -45,8 +45,8 @@ public class DingOrganizationController { | |||||
@PostMapping("/get-child-list") | @PostMapping("/get-child-list") | ||||
@ApiOperation("获取组织架构的树状结构(单位筛选列表)") | @ApiOperation("获取组织架构的树状结构(单位筛选列表)") | ||||
public List<OrganizationTreeVO> getChildOrganizationList(@RequestParam(value = "parentCode", required = false) String parentCode,@RequestParam(value = "orgName", required = false) String orgName) { | |||||
return organizationManage.getChildOrganizationList(parentCode,orgName,false); | |||||
public List<OrganizationTreeVO> getChildOrganizationList(@RequestParam(value = "parentCode", required = false) String parentCode, @RequestParam(value = "orgName", required = false) String orgName) { | |||||
return organizationManage.getChildOrganizationList(parentCode, orgName, false); | |||||
} | } | ||||
@ApiOperation("组织树状列表筛选(前端定制化接口不可复用)") | @ApiOperation("组织树状列表筛选(前端定制化接口不可复用)") | ||||
@@ -180,9 +180,15 @@ public class OrganizationManage { | |||||
} | } | ||||
public List<KeyTreeVO> treeEmployeeQuery(String employeeName, String organizationCode) { | public List<KeyTreeVO> treeEmployeeQuery(String employeeName, String organizationCode) { | ||||
List<String> organizationCodeList = CollUtil.toList(organizationCode).stream() | |||||
List<String> parentCodeList = CollUtil.toList(organizationCode).stream() | |||||
.filter(StringUtils::isNotBlank) | .filter(StringUtils::isNotBlank) | ||||
.collect(Collectors.toList()); | .collect(Collectors.toList()); | ||||
// 获取所有的组织列表 | |||||
List<String> organizationCodeList = new ArrayList<>(); | |||||
getChildList(organizationCodeList, parentCodeList); | |||||
organizationCodeList = organizationCodeList.stream().distinct().collect(Collectors.toList()); | |||||
List<DingEmployeeInfo> dingEmployeeInfoList = iDingEmployeeInfoService | List<DingEmployeeInfo> dingEmployeeInfoList = iDingEmployeeInfoService | ||||
.list(Wrappers.lambdaQuery(DingEmployeeInfo.class) | .list(Wrappers.lambdaQuery(DingEmployeeInfo.class) | ||||
.like(DingEmployeeInfo::getEmployeeName, employeeName) | .like(DingEmployeeInfo::getEmployeeName, employeeName) | ||||
@@ -213,6 +219,21 @@ public class OrganizationManage { | |||||
return orgKeyTreeVOList; | return orgKeyTreeVOList; | ||||
} | } | ||||
private void getChildList(List<String> orgCodeList, List<String> parentCodeList) { | |||||
if (CollUtil.isEmpty(parentCodeList)) { | |||||
return; | |||||
} | |||||
orgCodeList.addAll(parentCodeList); | |||||
// orgCodeList = orgCodeList.stream().distinct().collect(Collectors.toList()); | |||||
for (String parentCode : parentCodeList) { | |||||
List<DingOrganization> childOrgList = iDingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class) | |||||
.in(DingOrganization::getParentCode, parentCode)); | |||||
List<String> newParentCodeList = childOrgList.stream().map(DingOrganization::getOrganizationCode).collect(Collectors.toList()); | |||||
getChildList(orgCodeList, newParentCodeList); | |||||
} | |||||
} | |||||
private void employeeNameSearcheTreeVOList(List<KeyTreeVO> basicOrgKeyTreeVOList, List<DingEmployeeInfo> allDingEmployeeInfoList) { | private void employeeNameSearcheTreeVOList(List<KeyTreeVO> basicOrgKeyTreeVOList, List<DingEmployeeInfo> allDingEmployeeInfoList) { | ||||
Map<String, List<DingEmployeeInfo>> orgCodeEmployeeMap = allDingEmployeeInfoList.stream() | Map<String, List<DingEmployeeInfo>> orgCodeEmployeeMap = allDingEmployeeInfoList.stream() | ||||
.filter(r -> StringUtils.isNotBlank(r.getOrganizationCode())) | .filter(r -> StringUtils.isNotBlank(r.getOrganizationCode())) | ||||
@@ -190,7 +190,7 @@ public class ApplicationConverter { | |||||
JSONObject fJson = (JSONObject) JSON.toJSON(f); | JSONObject fJson = (JSONObject) JSON.toJSON(f); | ||||
Long fileId = fJson.getLong("id"); | Long fileId = fJson.getLong("id"); | ||||
String fileName = fJson.getString("originalFileName"); | String fileName = fJson.getString("originalFileName"); | ||||
Map<Long, String> fileMap = fileService.findUrlById(Arrays.asList(fileId)); | |||||
Map<Long, String> fileMap = fileService.findUrlById(Lists.newArrayList(fileId)); | |||||
String url = fileMap.get(fileId); | String url = fileMap.get(fileId); | ||||
url = removeExpire(url); | url = removeExpire(url); | ||||
FileDTO file = new FileDTO(); | FileDTO file = new FileDTO(); | ||||
@@ -205,7 +205,7 @@ public class ConstructionPlanManage { | |||||
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | ||||
VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); | VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); | ||||
//放入用户的单位 | //放入用户的单位 | ||||
req.setBuildOrgCode(user.getOrganizationCode()); | |||||
req.setBuildOrgCode(user.getEmpPosUnitCode()); | |||||
return projectLibManage.projectLibList(req); | return projectLibManage.projectLibList(req); | ||||
} | } | ||||
@@ -219,7 +219,7 @@ public class ConstructionPlanManage { | |||||
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | ||||
VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); | VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); | ||||
//放入用户的单位 | //放入用户的单位 | ||||
req.setBuildOrgCode(user.getOrganizationCode()); | |||||
req.setBuildOrgCode(user.getEmpPosUnitCode()); | |||||
req.setPageNumber(CommonConst.EXPORT_PAGE_NUMBER); | req.setPageNumber(CommonConst.EXPORT_PAGE_NUMBER); | ||||
req.setPageSize(CommonConst.EXPORT_PAGE_SIZE); | req.setPageSize(CommonConst.EXPORT_PAGE_SIZE); | ||||
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req); | LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req); | ||||
@@ -122,8 +122,8 @@ public class DeclaredProjectManage { | |||||
projectInfo.setArea(regionCacheHelper.getRegionName(user.getRegionCode(), RegionConst.RL_COUNTY)); | projectInfo.setArea(regionCacheHelper.getRegionName(user.getRegionCode(), RegionConst.RL_COUNTY)); | ||||
} | } | ||||
projectInfo.setBuildOrgCode(user.getOrganizationCode()); | |||||
projectInfo.setBuildOrgName(user.getOrganizationName()); | |||||
projectInfo.setBuildOrgCode(user.getEmpPosUnitCode()); | |||||
projectInfo.setBuildOrgName(user.getEmpPosUnitName()); | |||||
//项目名称去重 | //项目名称去重 | ||||
defaultDeclaredProjectManage.checkDuplication(projectInfo); | defaultDeclaredProjectManage.checkDuplication(projectInfo); | ||||
@@ -132,8 +132,8 @@ public class DeclaredProjectManage { | |||||
//如果主管单位没有 那么主管单位就是自己 | //如果主管单位没有 那么主管单位就是自己 | ||||
if(CommonEnum.NO.getCode().equals(projectInfo.getIsSuperOrg())){ | if(CommonEnum.NO.getCode().equals(projectInfo.getIsSuperOrg())){ | ||||
projectInfo.setSuperOrgCode(user.getOrganizationCode()); | |||||
projectInfo.setSuperOrg(user.getOrganizationName()); | |||||
projectInfo.setSuperOrgCode(user.getEmpPosUnitCode()); | |||||
projectInfo.setSuperOrg(user.getEmpPosUnitName()); | |||||
} | } | ||||
//如果是重新提交的话 判断下 项目是否存在 | //如果是重新提交的话 判断下 项目是否存在 | ||||
@@ -198,8 +198,8 @@ public class DeclaredProjectManage { | |||||
ProjectDTO projectDto = dto.getProjectInfo(); | ProjectDTO projectDto = dto.getProjectInfo(); | ||||
projectDto.setAreaCode(user.getRegionCode()); | projectDto.setAreaCode(user.getRegionCode()); | ||||
projectDto.setArea(regionCacheHelper.getRegionName(user.getRegionCode(), RegionConst.RL_COUNTY)); | projectDto.setArea(regionCacheHelper.getRegionName(user.getRegionCode(), RegionConst.RL_COUNTY)); | ||||
projectDto.setBuildOrgCode(user.getOrganizationCode()); | |||||
projectDto.setBuildOrgName(user.getOrganizationName()); | |||||
projectDto.setBuildOrgCode(user.getEmpPosUnitCode()); | |||||
projectDto.setBuildOrgName(user.getEmpPosUnitName()); | |||||
VUtils.isTrue(Objects.isNull(projectDto.getId())).throwMessage("提交失败 缺少项目ID!"); | VUtils.isTrue(Objects.isNull(projectDto.getId())).throwMessage("提交失败 缺少项目ID!"); | ||||
Project projectInfo = projectService.getById(projectDto.getId()); | Project projectInfo = projectService.getById(projectDto.getId()); | ||||
@@ -352,8 +352,8 @@ public class DeclaredProjectManage { | |||||
ProjectDraft draft = new ProjectDraft(); | ProjectDraft draft = new ProjectDraft(); | ||||
BeanUtils.copyProperties(projectInfo, draft); | BeanUtils.copyProperties(projectInfo, draft); | ||||
draft.setUserId(String.valueOf(userId)); | draft.setUserId(String.valueOf(userId)); | ||||
draft.setBuildOrgCode(user.getOrganizationCode()); | |||||
draft.setBuildOrgName(user.getOrganizationName()); | |||||
draft.setBuildOrgCode(user.getEmpPosUnitCode()); | |||||
draft.setBuildOrgName(user.getEmpPosUnitName()); | |||||
draft.setAreaCode(user.getRegionCode()); | draft.setAreaCode(user.getRegionCode()); | ||||
if(CollUtil.isNotEmpty(projectInfo.getDynamicForm())){ | if(CollUtil.isNotEmpty(projectInfo.getDynamicForm())){ | ||||
@@ -412,11 +412,11 @@ public class DeclaredProjectManage { | |||||
//如果当前登录是单位管理员 | //如果当前登录是单位管理员 | ||||
if(user.getIsOrgAdmin()){ | if(user.getIsOrgAdmin()){ | ||||
query.and(s1 -> s1.eq(Project::getStatus,ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode()) | query.and(s1 -> s1.eq(Project::getStatus,ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode()) | ||||
.eq(Project::getSuperOrgCode,user.getOrganizationCode()) | |||||
.or(q2 -> q2.eq(Project::getBuildOrgCode,user.getOrganizationCode()))); | |||||
.eq(Project::getSuperOrgCode,user.getEmpPosUnitCode()) | |||||
.or(q2 -> q2.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode()))); | |||||
}else{ | }else{ | ||||
//否则 只能看到 非预审 并且 | //否则 只能看到 非预审 并且 | ||||
query.and(q2 -> q2.eq(Project::getBuildOrgCode,user.getOrganizationCode())); | |||||
query.and(q2 -> q2.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode())); | |||||
} | } | ||||
} | } | ||||
@@ -105,8 +105,8 @@ public class DefaultDeclaredProjectManage { | |||||
return ProcessInstanceUserDto.builder() | return ProcessInstanceUserDto.builder() | ||||
.userId(String.valueOf(userInfoDetail.getEmployeeCode())) | .userId(String.valueOf(userInfoDetail.getEmployeeCode())) | ||||
.userName(userInfoDetail.getRealName()) | .userName(userInfoDetail.getRealName()) | ||||
.orgCode(userInfoDetail.getOrganizationCode()) | |||||
.orgName(userInfoDetail.getOrganizationName()) | |||||
.orgCode(userInfoDetail.getEmpPosUnitCode()) | |||||
.orgName(userInfoDetail.getEmpPosUnitName()) | |||||
.build(); | .build(); | ||||
} | } | ||||
@@ -121,10 +121,10 @@ public class DefaultDeclaredProjectManage { | |||||
log.warn("取不到员工 返回空map"); | log.warn("取不到员工 返回空map"); | ||||
return Collections.emptyMap(); | return Collections.emptyMap(); | ||||
} | } | ||||
DingOrganization startOrg = dingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) | |||||
.eq(DingOrganization::getOrganizationCode, userFullInfo.getOrganizationCode())); | |||||
String startOrgCode = startOrg.getOrganizationCode(); | |||||
String startOrgName = startOrg.getOrganizationName(); | |||||
UserFullInfoDTO startUser = userInfoHelper.getUserFullInfo(userFullInfo.getUserId()); | |||||
String startOrgCode = startUser.getEmpPosUnitCode(); | |||||
String startOrgName = startUser.getEmpPosUnitName(); | |||||
String startOrgParentCode; | String startOrgParentCode; | ||||
String startOrgParentName; | String startOrgParentName; | ||||
// 如果申报时 上级主管单位,由该单位自己审核 | // 如果申报时 上级主管单位,由该单位自己审核 | ||||
@@ -187,7 +187,7 @@ public class DefaultDeclaredProjectManage { | |||||
public DeclaredProjectStatisticsPO declaredProjectOrgStatistics(Integer year){ | public DeclaredProjectStatisticsPO declaredProjectOrgStatistics(Integer year){ | ||||
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | ||||
//查此人建设单位的项目 | //查此人建设单位的项目 | ||||
return statisticsService.getOrgStatistics(user.getOrganizationCode(),year); | |||||
return statisticsService.getOrgStatistics(user.getEmpPosUnitCode(),year); | |||||
} | } | ||||
//根据提交者的区域 他是区管或者超管 | //根据提交者的区域 他是区管或者超管 | ||||
@@ -100,9 +100,9 @@ public class PrequalificationDeclaredProjectManage { | |||||
VUtils.isTrue(Objects.isNull(projectInfo)).throwMessage("提交失败 此项目不存在!"); | VUtils.isTrue(Objects.isNull(projectInfo)).throwMessage("提交失败 此项目不存在!"); | ||||
//要判断 当前操作人 是不是项目主管单位的人 | //要判断 当前操作人 是不是项目主管单位的人 | ||||
VUtils.isTrue(Objects.isNull(user.getOrganizationCode())) | |||||
VUtils.isTrue(Objects.isNull(user.getEmpPosUnitCode())) | |||||
.throwMessage(String.format("当前登录人没有单位 【%s】",user.getRealName())); | .throwMessage(String.format("当前登录人没有单位 【%s】",user.getRealName())); | ||||
VUtils.isTrue(!user.getOrganizationCode().equals(projectInfo.getSuperOrgCode())) | |||||
VUtils.isTrue(!user.getEmpPosUnitCode().equals(projectInfo.getSuperOrgCode())) | |||||
.throwMessage(String.format("只有主管单位 【%s】的人 才能够提交",projectInfo.getSuperOrg())); | .throwMessage(String.format("只有主管单位 【%s】的人 才能够提交",projectInfo.getSuperOrg())); | ||||
//首先要判断 项目当前状态 是不是 待预审 | //首先要判断 项目当前状态 是不是 待预审 | ||||
@@ -264,8 +264,8 @@ public class PrequalificationDeclaredProjectManage { | |||||
if(user.getIsOrgAdmin() && | if(user.getIsOrgAdmin() && | ||||
(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode().equals(item.getStatus()) || | (ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode().equals(item.getStatus()) || | ||||
ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode().equals(item.getStatus())) | ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode().equals(item.getStatus())) | ||||
&& StringUtils.isNotBlank(w.getSuperOrgCode()) && StringUtils.isNotBlank(user.getOrganizationCode()) | |||||
&& w.getSuperOrgCode().equals(user.getOrganizationCode())){ | |||||
&& StringUtils.isNotBlank(w.getSuperOrgCode()) && StringUtils.isNotBlank(user.getEmpPosUnitCode()) | |||||
&& w.getSuperOrgCode().equals(user.getEmpPosUnitCode())){ | |||||
item.setCanPreDeclared(Boolean.TRUE); | item.setCanPreDeclared(Boolean.TRUE); | ||||
} | } | ||||
return item; | return item; | ||||
@@ -280,13 +280,13 @@ public class PrequalificationDeclaredProjectManage { | |||||
public UserFullInfoDTO buildPermission(LambdaQueryWrapper<Project> query,UserFullInfoDTO user){ | public UserFullInfoDTO buildPermission(LambdaQueryWrapper<Project> query,UserFullInfoDTO user){ | ||||
if(user.getIsOrgAdmin()){ | if(user.getIsOrgAdmin()){ | ||||
//单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目 | //单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目 | ||||
query.and(q1 -> q1.eq(Project::getBuildOrgCode ,user.getOrganizationCode()) | |||||
query.and(q1 -> q1.eq(Project::getBuildOrgCode ,user.getEmpPosUnitCode()) | |||||
.or(q2 -> q2.eq(Project::getStage,ProjectStatusEnum.NOT_APPROVED.getCode()) | .or(q2 -> q2.eq(Project::getStage,ProjectStatusEnum.NOT_APPROVED.getCode()) | ||||
.and(s1 -> s1.eq(Project::getStatus,ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()) | .and(s1 -> s1.eq(Project::getStatus,ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()) | ||||
.or(s2 -> s2.eq(Project::getStatus,ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode()))) | .or(s2 -> s2.eq(Project::getStatus,ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode()))) | ||||
.eq(Project::getSuperOrgCode,user.getOrganizationCode()))); | |||||
.eq(Project::getSuperOrgCode,user.getEmpPosUnitCode()))); | |||||
}else{ | }else{ | ||||
query.eq(Project::getBuildOrgCode ,user.getOrganizationCode()); | |||||
query.eq(Project::getBuildOrgCode ,user.getEmpPosUnitCode()); | |||||
} | } | ||||
return user; | return user; | ||||
} | } | ||||
@@ -152,7 +152,7 @@ public class ProjectAdjustmentManage { | |||||
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | ||||
VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); | VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); | ||||
//放入用户的单位 | //放入用户的单位 | ||||
req.setBuildOrgCode(user.getOrganizationCode()); | |||||
req.setBuildOrgCode(user.getEmpPosUnitCode()); | |||||
return projectLibManage.projectLibList(req); | return projectLibManage.projectLibList(req); | ||||
} | } | ||||
@@ -170,7 +170,7 @@ public class ProjectAdjustmentManage { | |||||
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | ||||
VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); | VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); | ||||
//放入用户的单位 | //放入用户的单位 | ||||
req.setBuildOrgCode(user.getOrganizationCode()); | |||||
req.setBuildOrgCode(user.getEmpPosUnitCode()); | |||||
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req); | LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req); | ||||
List<Project> records = projectService.list(query); | List<Project> records = projectService.list(query); | ||||
@@ -336,11 +336,11 @@ public class AnnualPlanLibManage { | |||||
switch (currentUserDataScope.get().getRole()) { | switch (currentUserDataScope.get().getRole()) { | ||||
case NORMAL_MEMBER: | case NORMAL_MEMBER: | ||||
//普通用户 只能看到自己单位去申报的 | //普通用户 只能看到自己单位去申报的 | ||||
query.eq(Project::getBuildOrgCode, user.getOrganizationCode()); | |||||
query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); | |||||
break; | break; | ||||
case COMPANY_MANAGER: | case COMPANY_MANAGER: | ||||
//单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目 | //单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目 | ||||
query.eq(Project::getBuildOrgCode, user.getOrganizationCode()); | |||||
query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); | |||||
break; | break; | ||||
case SUPER_ADMIN: | case SUPER_ADMIN: | ||||
//超级管理员 看到丽水全市的 并且也要判断他 同时是不是单位管理员 | //超级管理员 看到丽水全市的 并且也要判断他 同时是不是单位管理员 | ||||
@@ -118,8 +118,8 @@ public class ProjectLibManage { | |||||
item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); | item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); | ||||
if (user.getIsOrgAdmin() && | if (user.getIsOrgAdmin() && | ||||
ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode().equals(item.getStatus()) | ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode().equals(item.getStatus()) | ||||
&& StringUtils.isNotBlank(w.getSuperOrgCode()) && StringUtils.isNotBlank(user.getOrganizationCode()) | |||||
&& w.getSuperOrgCode().equals(user.getOrganizationCode())) { | |||||
&& StringUtils.isNotBlank(w.getSuperOrgCode()) && StringUtils.isNotBlank(user.getEmpPosUnitCode()) | |||||
&& w.getSuperOrgCode().equals(user.getEmpPosUnitCode())) { | |||||
item.setCanPreDeclared(Boolean.TRUE); | item.setCanPreDeclared(Boolean.TRUE); | ||||
} | } | ||||
return item; | return item; | ||||
@@ -180,7 +180,7 @@ public class ProjectLibManage { | |||||
// 处理文件名 | // 处理文件名 | ||||
List<Long> fileIdList = new ArrayList<>(); | List<Long> fileIdList = new ArrayList<>(); | ||||
BizUtils.notBlank(vo.getApprovedFile(), w -> fileIdList.add(Long.parseLong(w))); | BizUtils.notBlank(vo.getApprovedFile(), w -> fileIdList.add(Long.parseLong(w))); | ||||
BizUtils.notBlank(vo.getApprovedConstructionPlanFileName(), w -> fileIdList.add(Long.parseLong(w))); | |||||
BizUtils.notBlank(vo.getApprovedConstructionPlanFile(), w -> fileIdList.add(Long.parseLong(w))); | |||||
if (!fileIdList.isEmpty()) { | if (!fileIdList.isEmpty()) { | ||||
List<File> files = fileService.listByIds(fileIdList); | List<File> files = fileService.listByIds(fileIdList); | ||||
Map<String, String> fileMap = CollUtils.listToMap(files, w -> w.getId().toString(), File::getOriginalFileName); | Map<String, String> fileMap = CollUtils.listToMap(files, w -> w.getId().toString(), File::getOriginalFileName); | ||||
@@ -237,14 +237,14 @@ public class ProjectLibManage { | |||||
switch (currentUserDataScope.get().getRole()) { | switch (currentUserDataScope.get().getRole()) { | ||||
case NORMAL_MEMBER: | case NORMAL_MEMBER: | ||||
//普通用户 只能看到自己单位去申报的 | //普通用户 只能看到自己单位去申报的 | ||||
query.eq(Project::getBuildOrgCode, user.getOrganizationCode()); | |||||
query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); | |||||
break; | break; | ||||
case COMPANY_MANAGER: | case COMPANY_MANAGER: | ||||
//单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目 | //单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目 | ||||
query.and(q1 -> q1.eq(Project::getBuildOrgCode, user.getOrganizationCode()).or(q2 -> | |||||
query.and(q1 -> q1.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()).or(q2 -> | |||||
q2.eq(Project::getStage, ProjectStatusEnum.NOT_APPROVED.getCode()) | q2.eq(Project::getStage, ProjectStatusEnum.NOT_APPROVED.getCode()) | ||||
.eq(Project::getStatus, ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()) | .eq(Project::getStatus, ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()) | ||||
.eq(Project::getSuperOrgCode, user.getOrganizationCode()))); | |||||
.eq(Project::getSuperOrgCode, user.getEmpPosUnitCode()))); | |||||
break; | break; | ||||
case SUPER_ADMIN: | case SUPER_ADMIN: | ||||
//超级管理员 看到丽水全市的 并且也要判断他 同时是不是单位管理员 | //超级管理员 看到丽水全市的 并且也要判断他 同时是不是单位管理员 | ||||
@@ -108,7 +108,7 @@ public class WithDrawHandle { | |||||
// 判断当前工作流任务前一个审核人的部门和当前登录用户的部门是否是同一个,如果是同一个才可以撤回,否则抛出异常 | // 判断当前工作流任务前一个审核人的部门和当前登录用户的部门是否是同一个,如果是同一个才可以撤回,否则抛出异常 | ||||
// 获取当前当前工作流任务当前审核人信息 | // 获取当前当前工作流任务当前审核人信息 | ||||
UserFullInfoDTO currentUserInfo = userInfoHelper.getUserFullInfoByEmployeeCode(currentProgressNode.getUserId()); | UserFullInfoDTO currentUserInfo = userInfoHelper.getUserFullInfoByEmployeeCode(currentProgressNode.getUserId()); | ||||
if(!currentUserInfo.getOrganizationCode().equals(user.getOrganizationCode())){ | |||||
if(!currentUserInfo.getEmpPosUnitCode().equals(user.getEmpPosUnitCode())){ | |||||
return Boolean.FALSE; | return Boolean.FALSE; | ||||
} | } | ||||
@@ -2,7 +2,7 @@ package com.ningdatech.pmapi.todocenter.utils; | |||||
import cn.hutool.core.collection.CollUtil; | import cn.hutool.core.collection.CollUtil; | ||||
import com.google.common.collect.Sets; | import com.google.common.collect.Sets; | ||||
import com.ningdatech.pmapi.user.service.IUserInfoService; | |||||
import com.ningdatech.pmapi.user.manage.UserInfoManage; | |||||
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; | import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; | ||||
import com.wflow.workflow.bean.process.ProgressNode; | import com.wflow.workflow.bean.process.ProgressNode; | ||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
@@ -24,7 +24,7 @@ import java.util.Set; | |||||
@Component | @Component | ||||
public class BuildUserUtils { | public class BuildUserUtils { | ||||
private final IUserInfoService userInfoService; | |||||
private final UserInfoManage userInfoManage; | |||||
public void buildUserByProcessInfo(List<ProgressNode> progressInfo) { | public void buildUserByProcessInfo(List<ProgressNode> progressInfo) { | ||||
Set<String> userSet = Sets.newHashSet(); | Set<String> userSet = Sets.newHashSet(); | ||||
@@ -37,7 +37,7 @@ public class BuildUserUtils { | |||||
userSet.add(node.getUserId()); | userSet.add(node.getUserId()); | ||||
} | } | ||||
}); | }); | ||||
Map<String, ProcessInstanceUserDto> userMap = userInfoService.getUserMapByEmployeeCode(userSet); | |||||
Map<String, ProcessInstanceUserDto> userMap = userInfoManage.getUserMapByEmployeeCode(userSet); | |||||
buildUser(progressInfo,userMap); | buildUser(progressInfo,userMap); | ||||
} | } | ||||
private void buildUser(List<ProgressNode> progressInfo, Map<String, ProcessInstanceUserDto> userMap) { | private void buildUser(List<ProgressNode> progressInfo, Map<String, ProcessInstanceUserDto> userMap) { | ||||
@@ -30,15 +30,13 @@ import com.ningdatech.pmapi.user.model.vo.UserRoleVO; | |||||
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | ||||
import com.ningdatech.pmapi.user.service.IUserInfoService; | import com.ningdatech.pmapi.user.service.IUserInfoService; | ||||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | import com.ningdatech.pmapi.user.util.LoginUserUtil; | ||||
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; | |||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import java.util.Objects; | |||||
import java.util.*; | |||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
/** | /** | ||||
@@ -427,4 +425,57 @@ public class UserInfoManage { | |||||
} | } | ||||
return resUserDetailVO; | return resUserDetailVO; | ||||
} | } | ||||
public Map<String, ProcessInstanceUserDto> getUserMapByIds(Set<String> staterUsers) { | |||||
List<UserInfo> userInfos = iUserInfoService.listByIds(staterUsers); | |||||
return userInfos.stream().map(u -> { | |||||
ProcessInstanceUserDto userInfo = new ProcessInstanceUserDto(); | |||||
userInfo.setUserId(u.getEmployeeCode()); | |||||
userInfo.setUserName(u.getRealName()); | |||||
// 根据 单位code获取单位名称 | |||||
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(u.getId()); | |||||
if(Objects.nonNull(userFullInfo)){ | |||||
userInfo.setOrgCode(userFullInfo.getEmpPosUnitCode()); | |||||
userInfo.setOrgName(userFullInfo.getEmpPosUnitName()); | |||||
} | |||||
return userInfo; | |||||
}).collect(Collectors.toMap((ProcessInstanceUserDto::getUserId), v -> v)); | |||||
} | |||||
public Map<String, ProcessInstanceUserDto> getUserMapByEmployeeCode(Set<String> staterUsers) { | |||||
if(CollUtil.isEmpty(staterUsers)){ | |||||
return Collections.emptyMap(); | |||||
} | |||||
List<UserInfo> userInfos = iUserInfoService.list(Wrappers.lambdaQuery(UserInfo.class) | |||||
.in(UserInfo::getEmployeeCode,staterUsers)); | |||||
if(CollUtil.isEmpty(userInfos)){ | |||||
return Collections.emptyMap(); | |||||
} | |||||
return userInfos.stream().map(u -> { | |||||
ProcessInstanceUserDto userInfo = new ProcessInstanceUserDto(); | |||||
userInfo.setUserId(u.getEmployeeCode()); | |||||
userInfo.setUserName(u.getRealName()); | |||||
// 根据 单位code获取单位名称 | |||||
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(u.getId()); | |||||
if(Objects.nonNull(userFullInfo)){ | |||||
userInfo.setOrgCode(userFullInfo.getEmpPosUnitCode()); | |||||
userInfo.setOrgName(userFullInfo.getEmpPosUnitName()); | |||||
} | |||||
return userInfo; | |||||
}).collect(Collectors.toMap((ProcessInstanceUserDto::getUserId), v -> v)); | |||||
} | |||||
public ProcessInstanceUserDto getUserInfo(String userId) { | |||||
UserInfo userInfo = iUserInfoService.getById(userId); | |||||
ProcessInstanceUserDto processInstanceUserDto = new ProcessInstanceUserDto(); | |||||
processInstanceUserDto.setUserId(String.valueOf(userInfo.getId())); | |||||
processInstanceUserDto.setUserName(userInfo.getRealName()); | |||||
// 根据 单位code获取单位名称 | |||||
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userInfo.getId()); | |||||
if(Objects.nonNull(userFullInfo)){ | |||||
processInstanceUserDto.setOrgCode(userFullInfo.getEmpPosUnitCode()); | |||||
processInstanceUserDto.setOrgName(userFullInfo.getEmpPosUnitName()); | |||||
} | |||||
return processInstanceUserDto; | |||||
} | |||||
} | } |
@@ -2,10 +2,6 @@ package com.ningdatech.pmapi.user.service; | |||||
import com.baomidou.mybatisplus.extension.service.IService; | import com.baomidou.mybatisplus.extension.service.IService; | ||||
import com.ningdatech.pmapi.user.entity.UserInfo; | import com.ningdatech.pmapi.user.entity.UserInfo; | ||||
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; | |||||
import java.util.Map; | |||||
import java.util.Set; | |||||
/** | /** | ||||
* <p> | * <p> | ||||
@@ -16,11 +12,6 @@ import java.util.Set; | |||||
* @since 2023-02-01 | * @since 2023-02-01 | ||||
*/ | */ | ||||
public interface IUserInfoService extends IService<UserInfo> { | public interface IUserInfoService extends IService<UserInfo> { | ||||
Map<String, ProcessInstanceUserDto> getUserMapByIds(Set<String> staterUsers); | |||||
Map<String, ProcessInstanceUserDto> getUserMapByEmployeeCode(Set<String> staterUsers); | |||||
ProcessInstanceUserDto getUserInfo(String userId); | |||||
UserInfo getUserInfoByPhoneNo(String phoneNo); | UserInfo getUserInfoByPhoneNo(String phoneNo); | ||||
@@ -1,24 +1,14 @@ | |||||
package com.ningdatech.pmapi.user.service.impl; | package com.ningdatech.pmapi.user.service.impl; | ||||
import cn.hutool.core.collection.CollUtil; | |||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||||
import com.ningdatech.basic.exception.BizException; | |||||
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; | |||||
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; | |||||
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService; | |||||
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; | |||||
import com.ningdatech.pmapi.user.entity.UserInfo; | import com.ningdatech.pmapi.user.entity.UserInfo; | ||||
import com.ningdatech.pmapi.user.mapper.NdUserInfoMapper; | import com.ningdatech.pmapi.user.mapper.NdUserInfoMapper; | ||||
import com.ningdatech.pmapi.user.service.IUserInfoService; | import com.ningdatech.pmapi.user.service.IUserInfoService; | ||||
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; | |||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.*; | |||||
import java.util.stream.Collectors; | |||||
/** | /** | ||||
* <p> | * <p> | ||||
* 服务实现类 | * 服务实现类 | ||||
@@ -30,95 +20,7 @@ import java.util.stream.Collectors; | |||||
@Service | @Service | ||||
@RequiredArgsConstructor | @RequiredArgsConstructor | ||||
public class UserInfoServiceImpl extends ServiceImpl<NdUserInfoMapper, UserInfo> implements IUserInfoService { | public class UserInfoServiceImpl extends ServiceImpl<NdUserInfoMapper, UserInfo> implements IUserInfoService { | ||||
private final NdUserInfoMapper userInfoMapper; | private final NdUserInfoMapper userInfoMapper; | ||||
private final IDingEmployeeInfoService dingEmployeeInfoService; | |||||
private final IDingOrganizationService dingOrganizationService; | |||||
@Override | |||||
public Map<String, ProcessInstanceUserDto> getUserMapByIds(Set<String> staterUsers) { | |||||
List<UserInfo> userInfos = userInfoMapper.selectBatchIds(staterUsers); | |||||
return userInfos.stream().map(u -> { | |||||
ProcessInstanceUserDto userInfo = new ProcessInstanceUserDto(); | |||||
userInfo.setUserId(String.valueOf(u.getId())); | |||||
userInfo.setUserName(u.getRealName()); | |||||
Long accountId = u.getAccountId(); | |||||
if (Objects.isNull(accountId)) { | |||||
throw new BizException("该用户没有录入浙政钉用户信息!"); | |||||
} | |||||
// 根据浙政钉用户ID获取单位code | |||||
DingEmployeeInfo employeeInfo = dingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) | |||||
.eq(DingEmployeeInfo::getAccountId, accountId) | |||||
.eq(DingEmployeeInfo::getMainJob, String.valueOf(Boolean.TRUE)) | |||||
.last("limit 1")); | |||||
String organizationCode = employeeInfo.getOrganizationCode(); | |||||
// 根据 单位code获取单位名称 | |||||
DingOrganization dingOrganization = dingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) | |||||
.eq(DingOrganization::getOrganizationCode, organizationCode).last("limit 1")); | |||||
String organizationName = dingOrganization.getOrganizationName(); | |||||
userInfo.setOrgCode(organizationCode); | |||||
userInfo.setOrgName(organizationName); | |||||
return userInfo; | |||||
}).collect(Collectors.toMap((ProcessInstanceUserDto::getUserId), v -> v)); | |||||
} | |||||
@Override | |||||
public Map<String, ProcessInstanceUserDto> getUserMapByEmployeeCode(Set<String> staterUsers) { | |||||
if(CollUtil.isEmpty(staterUsers)){ | |||||
return Collections.emptyMap(); | |||||
} | |||||
List<UserInfo> userInfos = userInfoMapper.selectList(Wrappers.lambdaQuery(UserInfo.class) | |||||
.in(UserInfo::getEmployeeCode,staterUsers)); | |||||
if(CollUtil.isEmpty(userInfos)){ | |||||
return Collections.emptyMap(); | |||||
} | |||||
return userInfos.stream().map(u -> { | |||||
ProcessInstanceUserDto userInfo = new ProcessInstanceUserDto(); | |||||
userInfo.setUserId(u.getEmployeeCode()); | |||||
userInfo.setUserName(u.getRealName()); | |||||
Long accountId = u.getAccountId(); | |||||
if (Objects.isNull(accountId)) { | |||||
throw new BizException("该用户没有录入浙政钉用户信息!"); | |||||
} | |||||
// 根据浙政钉用户ID获取单位code | |||||
DingEmployeeInfo employeeInfo = dingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) | |||||
.eq(DingEmployeeInfo::getAccountId, accountId) | |||||
.eq(DingEmployeeInfo::getMainJob, String.valueOf(Boolean.TRUE)) | |||||
.last("limit 1")); | |||||
String organizationCode = employeeInfo.getOrganizationCode(); | |||||
// 根据 单位code获取单位名称 | |||||
DingOrganization dingOrganization = dingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) | |||||
.eq(DingOrganization::getOrganizationCode, organizationCode).last("limit 1")); | |||||
String organizationName = dingOrganization.getOrganizationName(); | |||||
userInfo.setOrgCode(organizationCode); | |||||
userInfo.setOrgName(organizationName); | |||||
return userInfo; | |||||
}).collect(Collectors.toMap((ProcessInstanceUserDto::getUserId), v -> v)); | |||||
} | |||||
@Override | |||||
public ProcessInstanceUserDto getUserInfo(String userId) { | |||||
UserInfo userInfo = userInfoMapper.selectById(Long.valueOf(userId)); | |||||
ProcessInstanceUserDto processInstanceUserDto = new ProcessInstanceUserDto(); | |||||
processInstanceUserDto.setUserId(String.valueOf(userInfo.getId())); | |||||
processInstanceUserDto.setUserName(userInfo.getRealName()); | |||||
Long accountId = userInfo.getAccountId(); | |||||
if (Objects.isNull(accountId)) { | |||||
throw new BizException("该用户没有录入浙政钉用户信息!"); | |||||
} | |||||
// 根据浙政钉用户ID获取部门code | |||||
DingEmployeeInfo employeeInfo = dingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) | |||||
.eq(DingEmployeeInfo::getId, accountId)); | |||||
String organizationCode = employeeInfo.getOrganizationCode(); | |||||
// 根据部门code获取部门名称 | |||||
DingOrganization dingOrganization = dingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) | |||||
.eq(DingOrganization::getOrganizationCode, organizationCode)); | |||||
String organizationName = dingOrganization.getOrganizationName(); | |||||
processInstanceUserDto.setOrgCode(organizationCode); | |||||
processInstanceUserDto.setOrgName(organizationName); | |||||
return processInstanceUserDto; | |||||
} | |||||
@Override | @Override | ||||
public UserInfo getUserInfoByPhoneNo(String phoneNo) { | public UserInfo getUserInfoByPhoneNo(String phoneNo) { | ||||
@@ -4,8 +4,6 @@ import com.ningdatech.pmapi.AppTests; | |||||
import com.ningdatech.pmapi.ding.task.EmployeeBatchGetTask; | import com.ningdatech.pmapi.ding.task.EmployeeBatchGetTask; | ||||
import com.ningdatech.pmapi.ding.task.GovBusinessStripsTask; | import com.ningdatech.pmapi.ding.task.GovBusinessStripsTask; | ||||
import com.ningdatech.pmapi.ding.task.OrganizationBatchGetTask; | import com.ningdatech.pmapi.ding.task.OrganizationBatchGetTask; | ||||
import com.ningdatech.zwdd.client.ZwddAuthClient; | |||||
import com.ningdatech.zwdd.client.ZwddClient; | |||||
import org.junit.jupiter.api.Test; | import org.junit.jupiter.api.Test; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
@@ -17,12 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired; | |||||
class OrganizationTest extends AppTests { | class OrganizationTest extends AppTests { | ||||
@Autowired | @Autowired | ||||
private ZwddClient zwddClient; | |||||
@Autowired | |||||
private ZwddAuthClient zwddAuthClient; | |||||
@Autowired | |||||
private OrganizationBatchGetTask organizationBatchGetTask; | private OrganizationBatchGetTask organizationBatchGetTask; | ||||
@Autowired | @Autowired | ||||