diff --git a/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java b/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java index 19ead9c..e06dd9d 100644 --- a/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java +++ b/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java @@ -56,7 +56,7 @@ public class GeneratorCodeKingbaseConfig { } 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"); } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/DashboardUserDataScopeProviderImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/DashboardUserDataScopeProviderImpl.java index 21c28f2..cae0e2a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/DashboardUserDataScopeProviderImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/DashboardUserDataScopeProviderImpl.java @@ -32,7 +32,7 @@ public class DashboardUserDataScopeProviderImpl implements DataScopeProvider { public Optional findDataFieldProperty() { UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); DataScopeDTO ds = new DataScopeDTO(); - ds.setEmployeeCode(userFullInfo.getOrganizationCode()); + ds.setEmployeeCode(userFullInfo.getEmployeeCode()); ds.setRegionCodes(Lists.newArrayList(userFullInfo.getRegionCode())); ds.setUserId(userFullInfo.getUserId()); ds.setRole(RoleEnum.DASHBOARD); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/OrdinaryUserDataScopeProviderImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/OrdinaryUserDataScopeProviderImpl.java index 2cb1565..e8c8b11 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/OrdinaryUserDataScopeProviderImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/OrdinaryUserDataScopeProviderImpl.java @@ -31,7 +31,7 @@ public class OrdinaryUserDataScopeProviderImpl implements DataScopeProvider { public Optional findDataFieldProperty() { UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); DataScopeDTO ds = new DataScopeDTO(); - ds.setEmployeeCode(userFullInfo.getOrganizationCode()); + ds.setEmployeeCode(userFullInfo.getEmployeeCode()); ds.setRegionCodes(Lists.newArrayList(userFullInfo.getRegionCode())); ds.setUserId(userFullInfo.getUserId()); ds.setRole(RoleEnum.NORMAL_MEMBER); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/OrgAdminDataScopeProviderImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/OrgAdminDataScopeProviderImpl.java index 03c2ea6..7bcfb21 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/OrgAdminDataScopeProviderImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/OrgAdminDataScopeProviderImpl.java @@ -30,7 +30,7 @@ public class OrgAdminDataScopeProviderImpl implements DataScopeProvider { public Optional findDataFieldProperty() { UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); DataScopeDTO ds = new DataScopeDTO(); - ds.setOrgCode(userFullInfo.getOrganizationCode()); + ds.setOrgCode(userFullInfo.getEmpPosUnitCode()); ds.setUserId(userFullInfo.getUserId()); ds.setEmployeeCode(userFullInfo.getEmployeeCode()); ds.setRole(RoleEnum.COMPANY_MANAGER); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/EmployeeBatchGetTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/EmployeeBatchGetTask.java index c8cd333..5d5df7e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/EmployeeBatchGetTask.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/EmployeeBatchGetTask.java @@ -57,7 +57,6 @@ public class EmployeeBatchGetTask { @Transactional(rollbackFor = Exception.class) public void batchGetEmployeeTask() { - // 获取所有的组织列表用户获取组织下的 用户信息 List dingOrganizationList = iDingOrganizationService.list(); if (CollUtil.isNotEmpty(dingOrganizationList)) { diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/entity/ExpertGovBusinessStrip.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/entity/ExpertGovBusinessStrip.java new file mode 100644 index 0000000..671cba0 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/entity/ExpertGovBusinessStrip.java @@ -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; + +/** + *

+ * + *

+ * + * @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; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/mapper/ExpertGovBusinessStripMapper.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/mapper/ExpertGovBusinessStripMapper.java new file mode 100644 index 0000000..b18281b --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/mapper/ExpertGovBusinessStripMapper.java @@ -0,0 +1,16 @@ +package com.ningdatech.pmapi.expert.mapper; + +import com.ningdatech.pmapi.expert.entity.ExpertGovBusinessStrip; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * Mapper 接口 + *

+ * + * @author Liuxinxin + * @since 2023-04-17 + */ +public interface ExpertGovBusinessStripMapper extends BaseMapper { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/mapper/ExpertGovBusinessStripMapper.xml b/pmapi/src/main/java/com/ningdatech/pmapi/expert/mapper/ExpertGovBusinessStripMapper.xml new file mode 100644 index 0000000..5329cbf --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/mapper/ExpertGovBusinessStripMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/service/IExpertGovBusinessStripService.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/service/IExpertGovBusinessStripService.java new file mode 100644 index 0000000..3aaefd7 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/service/IExpertGovBusinessStripService.java @@ -0,0 +1,16 @@ +package com.ningdatech.pmapi.expert.service; + +import com.ningdatech.pmapi.expert.entity.ExpertGovBusinessStrip; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 服务类 + *

+ * + * @author Liuxinxin + * @since 2023-04-17 + */ +public interface IExpertGovBusinessStripService extends IService { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/service/impl/ExpertGovBusinessStripServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/service/impl/ExpertGovBusinessStripServiceImpl.java new file mode 100644 index 0000000..ec02d72 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/service/impl/ExpertGovBusinessStripServiceImpl.java @@ -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; + +/** + *

+ * 服务实现类 + *

+ * + * @author Liuxinxin + * @since 2023-04-17 + */ +@Service +public class ExpertGovBusinessStripServiceImpl extends ServiceImpl implements IExpertGovBusinessStripService { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/fiscal/manage/CompanyFiscalCodeManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/fiscal/manage/CompanyFiscalCodeManage.java index db64160..e481d4a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/fiscal/manage/CompanyFiscalCodeManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/fiscal/manage/CompanyFiscalCodeManage.java @@ -35,7 +35,7 @@ public class CompanyFiscalCodeManage { String organizationCode = reqCompanyFiscalCodeAndSealSnPO.getOrganizationCode(); if (StringUtils.isBlank(organizationCode)) { - organizationCode = userInfoHelper.getOrganizationCode(userId); + organizationCode = userInfoHelper.getUserEmpPosUnitCode(userId); } // TODO 校验用户权限 @@ -73,7 +73,7 @@ public class CompanyFiscalCodeManage { Long userId = LoginUserUtil.getUserId(); String organizationCode = request.getOrganizationCode(); if (StringUtils.isBlank(organizationCode)) { - organizationCode = userInfoHelper.getOrganizationCode(userId); + organizationCode = userInfoHelper.getUserEmpPosUnitCode(userId); } CompanySignature companySignature = iCompanySignatureService.getByOrganizationCode(organizationCode); CompanyFiscalCode companyFiscalCode = iCompanyFiscalCodeService.getByOrganizationCode(organizationCode); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/fiscal/model/po/ReqCompanyFiscalCodeAndSealSnPO.java b/pmapi/src/main/java/com/ningdatech/pmapi/fiscal/model/po/ReqCompanyFiscalCodeAndSealSnPO.java index 05255ae..ff38f78 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/fiscal/model/po/ReqCompanyFiscalCodeAndSealSnPO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/fiscal/model/po/ReqCompanyFiscalCodeAndSealSnPO.java @@ -15,7 +15,7 @@ import javax.validation.constraints.NotBlank; public class ReqCompanyFiscalCodeAndSealSnPO { // @NotBlank(message = "组织编码 不能为空") - @ApiModelProperty("组织编码") + @ApiModelProperty("组织编码(需传入用户任职单位code)") private String organizationCode; @NotBlank(message = "财政编码 不能为空") diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/fiscal/model/po/ReqGetCompanyFiscalCodeAndSealSnPO.java b/pmapi/src/main/java/com/ningdatech/pmapi/fiscal/model/po/ReqGetCompanyFiscalCodeAndSealSnPO.java index bc6d313..d891f53 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/fiscal/model/po/ReqGetCompanyFiscalCodeAndSealSnPO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/fiscal/model/po/ReqGetCompanyFiscalCodeAndSealSnPO.java @@ -12,7 +12,7 @@ import lombok.Data; @ApiModel("获取财政编码配置") public class ReqGetCompanyFiscalCodeAndSealSnPO { - @ApiModelProperty("组织编码") + @ApiModelProperty("组织编码(需传入用户任职单位code)") private String organizationCode; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/InviteCacheDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/InviteCacheDTO.java index b7ed771..ba77705 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/InviteCacheDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/InviteCacheDTO.java @@ -2,6 +2,8 @@ package com.ningdatech.pmapi.meeting.entity.dto; import lombok.Data; +import java.time.LocalDateTime; + /** *

* MeetingInviteDTO @@ -15,12 +17,21 @@ public final class InviteCacheDTO { 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(); bo.setMeetingId(meetingId); - bo.setInvitedRefused(invitedRefused); + bo.setReInvite(reInvite); + bo.setTaskStartTime(startTime); return bo; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/MergeExpertIdDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/MergeExpertIdDTO.java new file mode 100644 index 0000000..328e14a --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/MergeExpertIdDTO.java @@ -0,0 +1,30 @@ +package com.ningdatech.pmapi.meeting.entity.dto; + +import lombok.Data; + +import java.util.List; + +/** + *

+ * MergeExpertIdDTO + *

+ * + * @author WendyYang + * @since 2023/4/14 + **/ +@Data +public class MergeExpertIdDTO { + + private List expertIdsIn; + + private List expertIdsNotIn; + + private Boolean skip; + + public static MergeExpertIdDTO noExpert() { + MergeExpertIdDTO condition = new MergeExpertIdDTO(); + condition.setSkip(Boolean.TRUE); + return condition; + } + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/YxtCallBackDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/YxtCallBackDTO.java new file mode 100644 index 0000000..4a1a5a2 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/YxtCallBackDTO.java @@ -0,0 +1,43 @@ +/** + * Copyright 2023 json.cn + */ +package com.ningdatech.pmapi.meeting.entity.dto; + +import lombok.Data; + +import java.time.LocalDateTime; + +/** + *

+ * 电话结果回调内容 + *

+ * + * @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; + +} \ No newline at end of file diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/vo/InviteExpertListItemVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/vo/InviteExpertListItemVO.java index 8170155..fdb0583 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/vo/InviteExpertListItemVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/vo/InviteExpertListItemVO.java @@ -41,6 +41,9 @@ public class InviteExpertListItemVO extends ExpertBasicInfoVO { @ApiModelProperty("邀请状态") private Integer status; + @ApiModelProperty("抽取类型") + private Integer inviteType; + @ApiModelProperty("通知时间") private LocalDateTime noticeTime; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/ExpertRandomInviteAlgorithm.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/ExpertRandomInviteAlgorithm.java new file mode 100644 index 0000000..44137e4 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/ExpertRandomInviteAlgorithm.java @@ -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; + +/** + *

+ * 专家抽取算法 + *

+ * + * @author WendyYang + * @since 2023/4/14 + **/ +public class ExpertRandomInviteAlgorithm { + + private static boolean expertMatchNone(List 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 inviteGroupByCompany(Map> expertGroupByUnit, + List> 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 result = new ArrayList<>(); + List keySet = new ArrayList<>(expertGroupByUnit.keySet()); + for (int i = 0; i < count; i++) { + String company = keySet.get(RandomUtils.nextInt(0, keySet.size())); + List expertsByCompany = expertGroupByUnit.get(company); + for (int j = 0; j < expertsByRecentMeeting.size(); j++) { + List experts = expertsByRecentMeeting.get(j); + List 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 inviteWithoutCompany(List userFullInfos, + List> expertsByRecentMeeting, + Integer count) { + List result; + if (expertsByRecentMeeting.isEmpty()) { + result = RandomUtil.randomEleList(userFullInfos, count); + } else { + result = new ArrayList<>(); + for (List experts : expertsByRecentMeeting) { + List 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; + } + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/MeetingManageHelper.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/MeetingManageHelper.java index 4d91b30..680b92a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/MeetingManageHelper.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/MeetingManageHelper.java @@ -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.MeetingExpert; 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.RandomInviteRuleDTO; import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; @@ -236,12 +235,10 @@ public class MeetingManageHelper { if (expertInfo != null) { String expertName = expertInfo.getExpertName(); switch (ExpertAttendStatusEnum.getByCode(w.getStatus())) { - case REFUSED: - throw BizException.wrap("专家%s已拒绝参加", expertName); case AGREED: - throw BizException.wrap("专家%s已同意参加", expertName); + throw BizException.wrap("专家 %s 已同意参加", expertName); case NOTICING: - throw BizException.wrap("专家%s正在通知中", expertName); + throw BizException.wrap("专家 %s 正在通知中", expertName); default: break; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/ExpertInviteManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/ExpertInviteManage.java index 4183bf4..1cc38c1 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/ExpertInviteManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/ExpertInviteManage.java @@ -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.Meeting; 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.helper.ExpertInviteHelper; 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.service.IExpertDictionaryService; import com.ningdatech.pmapi.meta.service.IExpertTagService; -import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.Predicate; 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 java.time.LocalDateTime; import java.util.*; 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.helper.ExpertInviteHelper.getExpertInviteRule; +import static com.ningdatech.pmapi.meeting.helper.ExpertRandomInviteAlgorithm.inviteGroupByCompany; /** *

@@ -56,7 +52,7 @@ import static com.ningdatech.pmapi.meeting.helper.ExpertInviteHelper.getExpertIn * @since 18:05 2022/8/8 */ @Component -@AllArgsConstructor +@RequiredArgsConstructor public class ExpertInviteManage { private final IExpertDictionaryService expertDictionaryService; @@ -71,6 +67,9 @@ public class ExpertInviteManage { private final IExpertAvoidCompanyService expertAvoidCompanyService; private final YxtCallOrSmsHelper yxtCallOrSmsHelper; + @Value("#{randomInviteProperties.recentMeetingCount}") + private Integer recentMeetingCount; + private static final Predicate> COLL_EMPTY = (coll) -> coll != null && coll.isEmpty(); private LambdaQueryWrapper buildBaseExpertQuery() { @@ -124,30 +123,32 @@ public class ExpertInviteManage { return new ArrayList<>(); } LambdaQueryWrapper query = Wrappers.lambdaQuery(ExpertAvoidCompany.class) + .select(ExpertAvoidCompany::getUserId) .in(ExpertAvoidCompany::getCompanyUniqCode, unitCodeList); List expertAvoidCompanyList = expertAvoidCompanyService.list(query); return CollUtils.fieldList(expertAvoidCompanyList, ExpertAvoidCompany::getUserId); } - private List mergeExpertIdsByCondition(RandomInviteRuleDTO rule, AvoidRuleDTO avoidInfo) { + private MergeExpertIdDTO mergeExpertIdsByCondition(RandomInviteRuleDTO rule, AvoidRuleDTO avoidInfo) { // 处理履职意向地 List expertIdsByIntentionRegion = expertIdsByRegion(rule); if (COLL_EMPTY.evaluate(expertIdsByIntentionRegion)) { - return null; + return MergeExpertIdDTO.noExpert(); } // 处理专家标签 List expertIdsByTag = expertIdsByTag(rule); if (COLL_EMPTY.evaluate(expertIdsByTag)) { - return null; + return MergeExpertIdDTO.noExpert(); } // 处理专家字典 List expertIdsByDict = expertIdsByDict(rule); if (COLL_EMPTY.evaluate(expertIdsByDict)) { - return null; + return MergeExpertIdDTO.noExpert(); } // 处理专家回避单位 与 抽取回避单位是否相同 - List avoidCompanyExpertIds = avoidCompanyExpertIds(avoidInfo.getAvoidUnitIdList()); + List avoidExpertIdsByUnit = avoidCompanyExpertIds(avoidInfo.getAvoidUnitIdList()); + MergeExpertIdDTO merge = new MergeExpertIdDTO(); // 聚合用户ID List expertIdsIn = new ArrayList<>(); if (ObjectUtils.anyNotNull(expertIdsByDict, expertIdsByTag, expertIdsByIntentionRegion)) { @@ -167,17 +168,22 @@ public class ExpertInviteManage { } }); 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()) { - 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 eTime) { ExpertChooseDTO result = new ExpertChooseDTO(new ArrayList<>(), 0); - List expertIdsIn = mergeExpertIdsByCondition(randomRule, avoidRule); - if (expertIdsIn == null) { + MergeExpertIdDTO merge = mergeExpertIdsByCondition(randomRule, avoidRule); + if (merge.getSkip()) { return result; } 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" + " and company_uniq_code in ({0})", CollUtils.joinByComma(avoidRule.getAvoidUnitIdList())); } + Set expertIdsIn = new HashSet<>(); + Set 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); if (!expertIdsIn.isEmpty()) { if (avoidExpert) { expertIdsIn.removeIf(w -> avoidRule.getExpertIds().contains(w)); if (expertIdsIn.isEmpty()) { - // 字典、标签、履职意向地筛选出的专家ID移除需要回避的专家ID - // 如果为空则说明没有符合条件的 + // 字典、标签、履职意向地 筛选出的专家ID移除需要回避的专家ID、如果为空则说明没有符合条件的 return result; } } @@ -293,15 +305,17 @@ public class ExpertInviteManage { if (expertIdsIn.isEmpty()) { return result; } - query.in(ExpertUserFullInfo::getUserId, expertIdsIn); } else if (avoidExpert || CollUtil.isNotEmpty(appointExpertIds)) { - Set tempExperts = expertInviteHelper.getAvoidExpert(appointExpertIds, avoidRule, sTime, eTime); - query.notIn(ExpertUserFullInfo::getUserId, tempExperts); + Set tmpExpert = expertInviteHelper.getAvoidExpert(appointExpertIds, avoidRule, sTime, eTime); + expertIdsNotIn.addAll(tmpExpert); } else { - Set notInUserIds = expertInviteHelper.listExpertLeaveOrInvited(sTime, eTime); - if (!notInUserIds.isEmpty()) { - query.notIn(ExpertUserFullInfo::getUserId, notInUserIds); - } + Set 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 userInfoList = expertUserFullInfoService.list(query); if (userInfoList.isEmpty()) { @@ -309,7 +323,8 @@ public class ExpertInviteManage { } Map> userGroupByUnit = CollUtils.group(userInfoList, ExpertUserFullInfo::getCompanyUniqCode); result.setTotal(userGroupByUnit.size()); - result.setExperts(inviteGroupByCompany(userGroupByUnit, randomRule.getCount())); + + result.setExperts(inviteGroupByCompany(userGroupByUnit, expertsByRecentMeeting(), randomRule.getCount())); return result; } @@ -320,8 +335,9 @@ public class ExpertInviteManage { * @param randomRule 随机抽取 * @param invitedExperts 已抽取人员 * @param count 抽取数量 - * @param start 会议开始时间 - * @param end 会议结束时间 + * @param msTime 会议开始时间 + * @param meTime 会议结束时间 + * @param reInvite 邀请已拒绝 * @return {@link ExpertChooseDTO} * @author WendyYang **/ @@ -329,16 +345,23 @@ public class ExpertInviteManage { RandomInviteRuleDTO randomRule, Collection invitedExperts, Integer count, - LocalDateTime start, - LocalDateTime end, - boolean invitedRefused) { + LocalDateTime msTime, + LocalDateTime meTime, + LocalDateTime tsTime, + boolean reInvite) { ExpertChooseDTO result = new ExpertChooseDTO(new ArrayList<>(), 0); // 合并标签、字典 - List expertIdsIn = mergeExpertIdsByCondition(randomRule, avoidRule); - List expertIdsNotIn = new ArrayList<>(); - if (expertIdsIn == null) { + MergeExpertIdDTO merge = mergeExpertIdsByCondition(randomRule, avoidRule); + if (merge.getSkip()) { return result; } + Set expertIdsIn = new HashSet<>(); + Set expertIdsNotIn = new HashSet<>(); + if (CollUtil.isNotEmpty(merge.getExpertIdsIn())) { + expertIdsIn.addAll(merge.getExpertIdsIn()); + } else if (CollUtil.isNotEmpty(merge.getExpertIdsNotIn())) { + expertIdsNotIn.addAll(merge.getExpertIdsNotIn()); + } LambdaQueryWrapper query = buildBaseExpertQuery(); // 设置回避单位 Set notInCompanyUniqCodeList = new HashSet<>(avoidRule.getAvoidUnitIdList()); @@ -355,16 +378,16 @@ public class ExpertInviteManage { return result; } } - List lockExpertIds = expertInviteHelper.listInvitedExpertByTime(start, end); + List lockExpertIds = expertInviteHelper.listInvitedExpertByTime(msTime, meTime); expertIdsIn.removeIf(lockExpertIds::contains); if (expertIdsIn.isEmpty()) { return result; } } else if (CollUtil.isNotEmpty(avoidRule.getExpertIds())) { - Set notInExpertIds = expertInviteHelper.getAvoidExpert(avoidRule.getExpertIds(), null, start, end); + Set notInExpertIds = expertInviteHelper.getAvoidExpert(avoidRule.getExpertIds(), null, msTime, meTime); expertIdsNotIn.addAll(notInExpertIds); } else { - Set notInUserIds = expertInviteHelper.listExpertLeaveOrInvited(start, end); + Set notInUserIds = expertInviteHelper.listExpertLeaveOrInvited(msTime, meTime); expertIdsNotIn.addAll(notInUserIds); } Map> expertGroupByStatus = invitedExperts.stream() @@ -380,14 +403,21 @@ public class ExpertInviteManage { List tmpUniqCompanyCodes = CollUtils.fieldList(agreeOrNoticingUserInfos, ExpertUserFullInfo::getCompanyUniqCode); notInCompanyUniqCodeList.addAll(tmpUniqCompanyCodes); } - if (!invitedRefused) { - // 拒绝参加的不可以被再次抽中 - List refusedExperts = expertGroupByStatus.get(REFUSED); - if (refusedExperts.size() > 0) { - List refusedExpertIds = CollUtils.fieldList(refusedExperts, MeetingExpert::getExpertId); - expertIdsNotIn.addAll(refusedExpertIds); + + // 处理已拒绝专家与重复抽取 + BizUtils.notEmpty(expertGroupByStatus.get(REFUSED), refuseExperts -> { + List 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 hasExpertIdNotIn = !expertIdsNotIn.isEmpty(); if (hasExpertIdIn && hasExpertIdNotIn) { @@ -408,15 +438,15 @@ public class ExpertInviteManage { } Map> userGroupByUnit = CollUtils.group(userFullInfos, ExpertUserFullInfo::getCompanyUniqCode); result.setTotal(userGroupByUnit.size()); - result.setExperts(inviteGroupByCompany(userGroupByUnit, count)); + result.setExperts(inviteGroupByCompany(userGroupByUnit, expertsByRecentMeeting(), count)); return result; } - private List> selectMeetingExpertByCount() { + private List> expertsByRecentMeeting() { LambdaQueryWrapper query = Wrappers.lambdaQuery(Meeting.class) .select(Meeting::getId) .orderByDesc(Meeting::getCreateOn) - .last("limit " + 5); + .last("limit " + recentMeetingCount); List meetingIds = CollUtils.fieldList(meetingService.list(query), Meeting::getId); if (meetingIds.isEmpty()) { return Collections.emptyList(); @@ -430,97 +460,6 @@ public class ExpertInviteManage { } /** - * 每个单位只抽取一人 - * - * @param expertGroupByUnit 需要抽取的人 - * @param count 抽取数量 - * @return 抽取到的专家信息 - * @author WendyYang - **/ - private List inviteGroupByCompany(Map> expertGroupByUnit, Integer count) { - if (MapUtils.isEmpty(expertGroupByUnit)) { - return Collections.emptyList(); - } - List> 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 result = new ArrayList<>(); - List keySet = new ArrayList<>(expertGroupByUnit.keySet()); - for (int i = 0; i < count; i++) { - String key = keySet.get(RandomUtils.nextInt(0, keySet.size())); - List expertUserFullInfos = expertGroupByUnit.get(key); - for (List expertList : meetingExperts) { - List 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 inviteWithoutCompany(List userFullInfos, Integer count) { - List result = new ArrayList<>(); - List> 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 meetingExperts : meetingExpertList) { - List 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 随机抽取规则 diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/MeetingManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/MeetingManage.java index 45cfe5b..4ca317d 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/MeetingManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/MeetingManage.java @@ -56,7 +56,7 @@ import org.springframework.util.Assert; import java.time.LocalDateTime; import java.util.*; -import java.util.function.Function; +import java.util.function.BiFunction; import java.util.stream.Collectors; import static com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum.*; @@ -236,8 +236,9 @@ public class MeetingManage { AvoidRuleDTO avoidInfo = req.getAvoidRule(); Assert.notNull(avoidInfo, "回避信息不能为空"); // 随机抽取的话则需进行抽取数量校验 + LocalDateTime now = LocalDateTime.now(); expertInviteManage.expertInviteByMeetingCreate(meeting, randomRules, avoidInfo); - expertInviteTask.addInviteTaskByMeetingCreate(meeting.getId(), 5); + expertInviteTask.addInviteTaskByMeetingCreate(meeting.getId(), now); LambdaUpdateWrapper mUpdate = Wrappers.lambdaUpdate(Meeting.class) .set(Meeting::getInviteStatus, false) .eq(Meeting::getId, meeting.getId()); @@ -469,7 +470,7 @@ public class MeetingManage { } List expertIds = CollUtils.fieldList(experts, MeetingExpert::getExpertId); Map expertMap = meetingManageHelper.getExpertBasicInfo(expertIds); - Function mapping = me -> { + BiFunction, InviteExpertListItemVO> mapping = (me, ruleMap) -> { ExpertBasicInfoVO expert = expertMap.get(me.getExpertId()); InviteExpertListItemVO item = BeanUtil.copyProperties(expert, InviteExpertListItemVO.class); item.setExpertMeetingId(me.getId()); @@ -479,6 +480,8 @@ public class MeetingManage { item.setNoticeTime(me.getCreateOn()); item.setRuleId(me.getRuleId()); item.setIsHeadman(me.getIsHeadman()); + ExpertInviteRule rule = ruleMap.get(me.getRuleId()); + item.setInviteType(rule == null ? ExpertInviteTypeEnum.APPOINT.getCode() : rule.getInviteType()); if (NOTICING.eq(me.getStatus())) { item.setNoticeStatus("通知中"); } else { @@ -486,12 +489,12 @@ public class MeetingManage { } return item; }; + List inviteRules = inviteRuleService.listByMeetingId(meetingId); + Map ruleMap = CollUtils.listToMap(inviteRules, ExpertInviteRule::getId); boolean isRandom = ExpertInviteTypeEnum.RANDOM.eq(meeting.getInviteType()); if (isRandom) { result.setInviteStatistics(new ArrayList<>()); Map> groupByRule = CollUtils.group(experts, MeetingExpert::getRuleId); - List inviteRules = inviteRuleService.listByMeetingId(meetingId); - Map ruleMap = CollUtils.listToMap(inviteRules, ExpertInviteRule::getId); ruleMap.forEach((k, v) -> { InviteStatisticsByRuleVO statistics = InviteStatisticsByRuleVO.init(k); statistics.setInviteCnt(v.getInviteCount()); @@ -507,7 +510,7 @@ public class MeetingManage { result.getInviteStatistics().add(statistics); }); } - List converts = CollUtils.convert(experts, mapping); + List converts = CollUtils.convert(experts, me -> mapping.apply(me, ruleMap)); result.setInviteExpertList(converts); // 确定参加列表 return result; @@ -579,7 +582,7 @@ public class MeetingManage { if (CollUtil.isNotEmpty(vo.getAvoidOrgIds())) { vo.setAvoidOrgs(businessStripService.listNameByCodes(avoidInfo.getAvoidOrgIdList())); } - if (CollUtil.isNotEmpty(vo.getAvoidUnits())) { + if (CollUtil.isNotEmpty(vo.getAvoidUnitIds())) { vo.setAvoidUnits(dingOrganizationService.listNameByCodes(avoidInfo.getAvoidUnitIdList())); } if (CollUtil.isNotEmpty(avoidInfo.getExpertIds())) { diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/mapper/MeetingExpertMapper.xml b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/mapper/MeetingExpertMapper.xml index ce790fb..4dc5475 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/mapper/MeetingExpertMapper.xml +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/mapper/MeetingExpertMapper.xml @@ -67,7 +67,7 @@ diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/ExpertCallResultRewriteTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/ExpertCallResultRewriteTask.java index 518c69a..2c0c5bd 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/ExpertCallResultRewriteTask.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/ExpertCallResultRewriteTask.java @@ -1,7 +1,6 @@ package com.ningdatech.pmapi.meeting.task; import cn.hutool.core.util.ObjectUtil; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.MeetingExpert; 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.ExpertInviteTypeEnum; 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 lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.stereotype.Component; @@ -69,6 +68,8 @@ public class ExpertCallResultRewriteTask { private final IExpertUserFullInfoService userFullInfoService; private final static int MINUTES_CALL_RESULT_FEEDBACK = 15; + private static final String AGREE_KEY = "1"; + @PostConstruct public void initTask() { if (!randomInviteProperties.getEnable()) { @@ -77,7 +78,8 @@ public class ExpertCallResultRewriteTask { } 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()) { List inviteRules = inviteRuleService.listByIds(randomRuleIds); 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()); }); } @@ -172,44 +174,37 @@ public class ExpertCallResultRewriteTask { } } - private static Optional 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 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(); } ExpertAttendStatusEnum status; - if (StrUtils.isNotBlank(callBackJson)) { + if (hasCallBack) { 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) { return Optional.empty(); } - Integer resultCode = callbackObject.getInteger("resultCode"); + Integer resultCode = callback.getResultCode(); 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 { - status = UNANSWERED; + if (waiting) { + return Optional.empty(); + } + status = REFUSED; } } catch (Exception e) { log.error("获取电话回调结果异常", e); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/ExpertInviteTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/ExpertInviteTask.java index 25e97d5..67befe8 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/ExpertInviteTask.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/ExpertInviteTask.java @@ -27,7 +27,6 @@ import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; import org.springframework.aop.framework.AopContext; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -39,13 +38,13 @@ import java.time.Duration; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ScheduledFuture; 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 final CachePlusOps cachePlusOps; - @Qualifier("expertInviteScheduler") @Resource(name = "expertInviteScheduler") private ThreadPoolTaskScheduler scheduler; private final IMeetingExpertService meetingExpertService; @@ -82,13 +80,13 @@ public class ExpertInviteTask { */ private static final ConcurrentMap> INVITE_TASK_MAP = new ConcurrentHashMap<>(); - public ExpertInviteTask currProxy() { + private ExpertInviteTask currProxy() { return (ExpertInviteTask) AopContext.currentProxy(); } 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 @@ -97,13 +95,13 @@ public class ExpertInviteTask { log.warn("随机邀请已关闭……"); return; } - initInviteTaskAfterAppStarted(); + initInviteTaskAfterStarted(); } /** * 项目重启之后重新初始化邀请任务 */ - private void initInviteTaskAfterAppStarted() { + private void initInviteTaskAfterStarted() { Map caches = cachePlusOps.hGetAll(getCacheKey(null)); if (MapUtils.isEmpty(caches)) { log.info("暂无需要初始化的抽取会议信息"); @@ -111,8 +109,9 @@ public class ExpertInviteTask { } Integer inviteDelay = properties.getInviteDelay(); 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) { cachePlusOps.hDel(getCacheKey(cache.getMeetingId())); } @@ -134,7 +133,7 @@ public class ExpertInviteTask { LambdaQueryWrapper query = Wrappers.lambdaQuery(MeetingExpert.class) .select(MeetingExpert::getRuleId, MeetingExpert::getStatus) .in(MeetingExpert::getRuleId, ruleMap.keySet()) - .in(MeetingExpert::getStatus, ExpertAttendStatusEnum.AGREED.getCode()); + .eq(MeetingExpert::getStatus, ExpertAttendStatusEnum.AGREED.getCode()); List experts = meetingExpertService.list(query); if (experts.isEmpty()) { return Boolean.TRUE; @@ -152,23 +151,20 @@ public class ExpertInviteTask { /** * 唤醒某个会议的抽取任务 * - * @param meetingId 会议ID - * @param invitedRefused 是否可邀请已拒绝的专家 + * @param meetingId 会议ID + * @param reInvite 是否可邀请已拒绝的专家 * @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 (addInviteTask(meetingId, false, properties.getInviteDelay(), tmpInvitedRefused)) { + if (addInviteTask(meetingId, false, properties.getInviteDelay(), tmpReInvite, LocalDateTime.now())) { log.info("重置会议的随机抽取状态:{}", meetingId); LambdaUpdateWrapper update = Wrappers.lambdaUpdate(Meeting.class); update.set(Meeting::getInviteStatus, false); update.eq(Meeting::getId, meetingId); meetingService.update(update); - InviteCacheDTO cacheVal = InviteCacheDTO.of(meetingId, tmpInvitedRefused); + InviteCacheDTO cacheVal = InviteCacheDTO.of(meetingId, tmpReInvite, LocalDateTime.now()); 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 是否添加任务成功 * @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)) { // 如果抽取数量满足直接返回 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(() -> { ExpertInviteTask bean = SpringContextHolder.getBean(ExpertInviteTask.class); try { - bean.invite(meetingId, invitedRefused); + bean.invite(meetingId, reInvite, tsTime); } catch (Exception e) { log.error("执行专家邀请任务异常:{}", meetingId, e); } @@ -206,25 +203,26 @@ public class ExpertInviteTask { /** * 创建会议时添加抽取任务 * - * @param meetingId 会议ID - * @param delayedMinutes 延迟时间 + * @param meetingId 会议ID + * @param tsTime 开始时间 * @author WendyYang **/ - public void addInviteTaskByMeetingCreate(Long meetingId, int delayedMinutes) { + public void addInviteTaskByMeetingCreate(Long meetingId, LocalDateTime tsTime) { 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); } /** * 抽取过程 * - * @param meetingId 会议ID - * @param invitedRefused 是否可以邀请已拒绝的专家 + * @param meetingId 会议ID + * @param reInvite 是否可以邀请已拒绝的专家 + * @param tsTime 任务开启时间 */ @Transactional(rollbackFor = Exception.class) - public void invite(Long meetingId, Boolean invitedRefused) { + public void invite(Long meetingId, Boolean reInvite, LocalDateTime tsTime) { log.info("开始进行专家后台抽取:{}", meetingId); Meeting meeting = meetingService.getById(meetingId); if (meeting.getStartTime().isBefore(LocalDateTime.now())) { @@ -239,11 +237,13 @@ public class ExpertInviteTask { // 还需要抽取的规则数量 AtomicInteger notIgnoreCnt = new AtomicInteger(ruleMap.size()); AtomicInteger notSupportCnt = new AtomicInteger(0); + LocalDateTime msTime = meeting.getStartTime(); + LocalDateTime meTime = meeting.getStartTime(); ruleMap.forEach((ruleId, value) -> { List tmpExperts = meetingExpertService.listExpertLastByMeetingId(meetingId); Map expertMap = CollUtils.listToMap(tmpExperts, MeetingExpert::getExpertId); // 统计通知中与同意参加专家数量 - Map countMap = countByAgree(expertMap); + Map countMap = countByAttendStatus(expertMap); ExpertCntBO cnt = countMap.getOrDefault(ruleId, ExpertCntBO.zeroInit()); int wouldAttendCnt = cnt.getAgreeCnt() + cnt.getNoticeCnt(); if (wouldAttendCnt == value.getCount()) { @@ -254,7 +254,7 @@ public class ExpertInviteTask { } int needInviteCnt = value.getCount() - wouldAttendCnt; ExpertChooseDTO expertChoose = expertInviteManage.expertReplaceByRandomRule(avoidRule, value, - tmpExperts, needInviteCnt, meeting.getStartTime(), meeting.getEndTime(), invitedRefused); + tmpExperts, needInviteCnt, msTime, meTime, tsTime, reInvite); if (expertChoose.getTotal() > 0) { List expertMeetings = CollUtils.convert(expertChoose.getExperts(), w -> { @@ -292,20 +292,18 @@ public class ExpertInviteTask { //================================================================================================================== - private Map countByAgree(Map 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 countByAttendStatus(Map expertMap) { + Map 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 diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/RandomInviteProperties.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/RandomInviteProperties.java index f69b4b5..c390799 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/RandomInviteProperties.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/RandomInviteProperties.java @@ -37,4 +37,9 @@ public class RandomInviteProperties { * 会议抽取完成通知 管理员下发会议通知 */ private Integer meetingInviteCompleteNoticeRate = 1; + + /** + * 近期会议数量(以此来降低专家抽中间隔) + */ + private Integer recentMeetingCount = 5; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/organization/controller/DingOrganizationController.java b/pmapi/src/main/java/com/ningdatech/pmapi/organization/controller/DingOrganizationController.java index 5d7bc7c..038877d 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/organization/controller/DingOrganizationController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/organization/controller/DingOrganizationController.java @@ -45,8 +45,8 @@ public class DingOrganizationController { @PostMapping("/get-child-list") @ApiOperation("获取组织架构的树状结构(单位筛选列表)") - public List getChildOrganizationList(@RequestParam(value = "parentCode", required = false) String parentCode,@RequestParam(value = "orgName", required = false) String orgName) { - return organizationManage.getChildOrganizationList(parentCode,orgName,false); + public List getChildOrganizationList(@RequestParam(value = "parentCode", required = false) String parentCode, @RequestParam(value = "orgName", required = false) String orgName) { + return organizationManage.getChildOrganizationList(parentCode, orgName, false); } @ApiOperation("组织树状列表筛选(前端定制化接口不可复用)") diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/organization/manage/OrganizationManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/organization/manage/OrganizationManage.java index 5f7e37d..eb5a8ce 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/organization/manage/OrganizationManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/organization/manage/OrganizationManage.java @@ -180,9 +180,15 @@ public class OrganizationManage { } public List treeEmployeeQuery(String employeeName, String organizationCode) { - List organizationCodeList = CollUtil.toList(organizationCode).stream() + List parentCodeList = CollUtil.toList(organizationCode).stream() .filter(StringUtils::isNotBlank) .collect(Collectors.toList()); + + // 获取所有的组织列表 + List organizationCodeList = new ArrayList<>(); + getChildList(organizationCodeList, parentCodeList); + organizationCodeList = organizationCodeList.stream().distinct().collect(Collectors.toList()); + List dingEmployeeInfoList = iDingEmployeeInfoService .list(Wrappers.lambdaQuery(DingEmployeeInfo.class) .like(DingEmployeeInfo::getEmployeeName, employeeName) @@ -213,6 +219,21 @@ public class OrganizationManage { return orgKeyTreeVOList; } + private void getChildList(List orgCodeList, List parentCodeList) { + if (CollUtil.isEmpty(parentCodeList)) { + return; + } + orgCodeList.addAll(parentCodeList); +// orgCodeList = orgCodeList.stream().distinct().collect(Collectors.toList()); + + for (String parentCode : parentCodeList) { + List childOrgList = iDingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class) + .in(DingOrganization::getParentCode, parentCode)); + List newParentCodeList = childOrgList.stream().map(DingOrganization::getOrganizationCode).collect(Collectors.toList()); + getChildList(orgCodeList, newParentCodeList); + } + } + private void employeeNameSearcheTreeVOList(List basicOrgKeyTreeVOList, List allDingEmployeeInfoList) { Map> orgCodeEmployeeMap = allDingEmployeeInfoList.stream() .filter(r -> StringUtils.isNotBlank(r.getOrganizationCode())) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/converter/ApplicationConverter.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/converter/ApplicationConverter.java index c76c37c..aeca03d 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/converter/ApplicationConverter.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/converter/ApplicationConverter.java @@ -190,7 +190,7 @@ public class ApplicationConverter { JSONObject fJson = (JSONObject) JSON.toJSON(f); Long fileId = fJson.getLong("id"); String fileName = fJson.getString("originalFileName"); - Map fileMap = fileService.findUrlById(Arrays.asList(fileId)); + Map fileMap = fileService.findUrlById(Lists.newArrayList(fileId)); String url = fileMap.get(fileId); url = removeExpire(url); FileDTO file = new FileDTO(); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.java index d252054..5134c96 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.java @@ -205,7 +205,7 @@ public class ConstructionPlanManage { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); //放入用户的单位 - req.setBuildOrgCode(user.getOrganizationCode()); + req.setBuildOrgCode(user.getEmpPosUnitCode()); return projectLibManage.projectLibList(req); } @@ -219,7 +219,7 @@ public class ConstructionPlanManage { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); //放入用户的单位 - req.setBuildOrgCode(user.getOrganizationCode()); + req.setBuildOrgCode(user.getEmpPosUnitCode()); req.setPageNumber(CommonConst.EXPORT_PAGE_NUMBER); req.setPageSize(CommonConst.EXPORT_PAGE_SIZE); LambdaQueryWrapper query = ProjectHelper.projectQuery(req); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java index 4850981..5b26800 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java @@ -122,8 +122,8 @@ public class DeclaredProjectManage { 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); @@ -132,8 +132,8 @@ public class DeclaredProjectManage { //如果主管单位没有 那么主管单位就是自己 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.setAreaCode(user.getRegionCode()); 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!"); Project projectInfo = projectService.getById(projectDto.getId()); @@ -352,8 +352,8 @@ public class DeclaredProjectManage { ProjectDraft draft = new ProjectDraft(); BeanUtils.copyProperties(projectInfo, draft); 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()); if(CollUtil.isNotEmpty(projectInfo.getDynamicForm())){ @@ -412,11 +412,11 @@ public class DeclaredProjectManage { //如果当前登录是单位管理员 if(user.getIsOrgAdmin()){ 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{ //否则 只能看到 非预审 并且 - query.and(q2 -> q2.eq(Project::getBuildOrgCode,user.getOrganizationCode())); + query.and(q2 -> q2.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode())); } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java index 92092eb..ed0bcc5 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java @@ -105,8 +105,8 @@ public class DefaultDeclaredProjectManage { return ProcessInstanceUserDto.builder() .userId(String.valueOf(userInfoDetail.getEmployeeCode())) .userName(userInfoDetail.getRealName()) - .orgCode(userInfoDetail.getOrganizationCode()) - .orgName(userInfoDetail.getOrganizationName()) + .orgCode(userInfoDetail.getEmpPosUnitCode()) + .orgName(userInfoDetail.getEmpPosUnitName()) .build(); } @@ -121,10 +121,10 @@ public class DefaultDeclaredProjectManage { log.warn("取不到员工 返回空map"); 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 startOrgParentName; // 如果申报时 上级主管单位,由该单位自己审核 @@ -187,7 +187,7 @@ public class DefaultDeclaredProjectManage { public DeclaredProjectStatisticsPO declaredProjectOrgStatistics(Integer year){ UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); //查此人建设单位的项目 - return statisticsService.getOrgStatistics(user.getOrganizationCode(),year); + return statisticsService.getOrgStatistics(user.getEmpPosUnitCode(),year); } //根据提交者的区域 他是区管或者超管 diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java index be065fe..9880632 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java @@ -100,9 +100,9 @@ public class PrequalificationDeclaredProjectManage { VUtils.isTrue(Objects.isNull(projectInfo)).throwMessage("提交失败 此项目不存在!"); //要判断 当前操作人 是不是项目主管单位的人 - VUtils.isTrue(Objects.isNull(user.getOrganizationCode())) + VUtils.isTrue(Objects.isNull(user.getEmpPosUnitCode())) .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())); //首先要判断 项目当前状态 是不是 待预审 @@ -264,8 +264,8 @@ public class PrequalificationDeclaredProjectManage { if(user.getIsOrgAdmin() && (ProjectStatusEnum.PENDING_PREQUALIFICATION.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); } return item; @@ -280,13 +280,13 @@ public class PrequalificationDeclaredProjectManage { public UserFullInfoDTO buildPermission(LambdaQueryWrapper query,UserFullInfoDTO user){ 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()) .and(s1 -> s1.eq(Project::getStatus,ProjectStatusEnum.PENDING_PREQUALIFICATION.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{ - query.eq(Project::getBuildOrgCode ,user.getOrganizationCode()); + query.eq(Project::getBuildOrgCode ,user.getEmpPosUnitCode()); } return user; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ProjectAdjustmentManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ProjectAdjustmentManage.java index 0dd30c2..d782a49 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ProjectAdjustmentManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ProjectAdjustmentManage.java @@ -152,7 +152,7 @@ public class ProjectAdjustmentManage { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); //放入用户的单位 - req.setBuildOrgCode(user.getOrganizationCode()); + req.setBuildOrgCode(user.getEmpPosUnitCode()); return projectLibManage.projectLibList(req); } @@ -170,7 +170,7 @@ public class ProjectAdjustmentManage { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); //放入用户的单位 - req.setBuildOrgCode(user.getOrganizationCode()); + req.setBuildOrgCode(user.getEmpPosUnitCode()); LambdaQueryWrapper query = ProjectHelper.projectQuery(req); List records = projectService.list(query); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/AnnualPlanLibManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/AnnualPlanLibManage.java index 371d1df..926ae84 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/AnnualPlanLibManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/AnnualPlanLibManage.java @@ -336,11 +336,11 @@ public class AnnualPlanLibManage { switch (currentUserDataScope.get().getRole()) { case NORMAL_MEMBER: //普通用户 只能看到自己单位去申报的 - query.eq(Project::getBuildOrgCode, user.getOrganizationCode()); + query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); break; case COMPANY_MANAGER: //单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目 - query.eq(Project::getBuildOrgCode, user.getOrganizationCode()); + query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); break; case SUPER_ADMIN: //超级管理员 看到丽水全市的 并且也要判断他 同时是不是单位管理员 diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java index 8777e91..424bc86 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java @@ -118,8 +118,8 @@ public class ProjectLibManage { item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); if (user.getIsOrgAdmin() && 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); } return item; @@ -180,7 +180,7 @@ public class ProjectLibManage { // 处理文件名 List fileIdList = new ArrayList<>(); 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()) { List files = fileService.listByIds(fileIdList); Map fileMap = CollUtils.listToMap(files, w -> w.getId().toString(), File::getOriginalFileName); @@ -237,14 +237,14 @@ public class ProjectLibManage { switch (currentUserDataScope.get().getRole()) { case NORMAL_MEMBER: //普通用户 只能看到自己单位去申报的 - query.eq(Project::getBuildOrgCode, user.getOrganizationCode()); + query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); break; 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()) .eq(Project::getStatus, ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()) - .eq(Project::getSuperOrgCode, user.getOrganizationCode()))); + .eq(Project::getSuperOrgCode, user.getEmpPosUnitCode()))); break; case SUPER_ADMIN: //超级管理员 看到丽水全市的 并且也要判断他 同时是不是单位管理员 diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/handle/WithDrawHandle.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/handle/WithDrawHandle.java index d74d5d2..1c4a134 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/handle/WithDrawHandle.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/handle/WithDrawHandle.java @@ -108,7 +108,7 @@ public class WithDrawHandle { // 判断当前工作流任务前一个审核人的部门和当前登录用户的部门是否是同一个,如果是同一个才可以撤回,否则抛出异常 // 获取当前当前工作流任务当前审核人信息 UserFullInfoDTO currentUserInfo = userInfoHelper.getUserFullInfoByEmployeeCode(currentProgressNode.getUserId()); - if(!currentUserInfo.getOrganizationCode().equals(user.getOrganizationCode())){ + if(!currentUserInfo.getEmpPosUnitCode().equals(user.getEmpPosUnitCode())){ return Boolean.FALSE; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/utils/BuildUserUtils.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/utils/BuildUserUtils.java index 9bc2021..bf1d439 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/utils/BuildUserUtils.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/utils/BuildUserUtils.java @@ -2,7 +2,7 @@ package com.ningdatech.pmapi.todocenter.utils; import cn.hutool.core.collection.CollUtil; 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.process.ProgressNode; import lombok.RequiredArgsConstructor; @@ -24,7 +24,7 @@ import java.util.Set; @Component public class BuildUserUtils { - private final IUserInfoService userInfoService; + private final UserInfoManage userInfoManage; public void buildUserByProcessInfo(List progressInfo) { Set userSet = Sets.newHashSet(); @@ -37,7 +37,7 @@ public class BuildUserUtils { userSet.add(node.getUserId()); } }); - Map userMap = userInfoService.getUserMapByEmployeeCode(userSet); + Map userMap = userInfoManage.getUserMapByEmployeeCode(userSet); buildUser(progressInfo,userMap); } private void buildUser(List progressInfo, Map userMap) { diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java index 5a7ac45..2556ea8 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java @@ -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.service.IUserInfoService; import com.ningdatech.pmapi.user.util.LoginUserUtil; +import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; 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; /** @@ -427,4 +425,57 @@ public class UserInfoManage { } return resUserDetailVO; } + + public Map getUserMapByIds(Set staterUsers) { + List 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 getUserMapByEmployeeCode(Set staterUsers) { + if(CollUtil.isEmpty(staterUsers)){ + return Collections.emptyMap(); + } + List 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; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java index 78088d8..a5ef005 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java @@ -2,10 +2,6 @@ package com.ningdatech.pmapi.user.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ningdatech.pmapi.user.entity.UserInfo; -import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; - -import java.util.Map; -import java.util.Set; /** *

@@ -16,11 +12,6 @@ import java.util.Set; * @since 2023-02-01 */ public interface IUserInfoService extends IService { - Map getUserMapByIds(Set staterUsers); - - Map getUserMapByEmployeeCode(Set staterUsers); - - ProcessInstanceUserDto getUserInfo(String userId); UserInfo getUserInfoByPhoneNo(String phoneNo); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java index cee1f45..929cf3c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java @@ -1,24 +1,14 @@ package com.ningdatech.pmapi.user.service.impl; -import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; 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.mapper.NdUserInfoMapper; import com.ningdatech.pmapi.user.service.IUserInfoService; -import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; -import java.util.*; -import java.util.stream.Collectors; - /** *

* 服务实现类 @@ -30,95 +20,7 @@ import java.util.stream.Collectors; @Service @RequiredArgsConstructor public class UserInfoServiceImpl extends ServiceImpl implements IUserInfoService { - private final NdUserInfoMapper userInfoMapper; - private final IDingEmployeeInfoService dingEmployeeInfoService; - - private final IDingOrganizationService dingOrganizationService; - - @Override - public Map getUserMapByIds(Set staterUsers) { - List 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 getUserMapByEmployeeCode(Set staterUsers) { - if(CollUtil.isEmpty(staterUsers)){ - return Collections.emptyMap(); - } - List 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 public UserInfo getUserInfoByPhoneNo(String phoneNo) { diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/organization/OrganizationTest.java b/pmapi/src/test/java/com/ningdatech/pmapi/organization/OrganizationTest.java index 0fb2cec..ee813bb 100644 --- a/pmapi/src/test/java/com/ningdatech/pmapi/organization/OrganizationTest.java +++ b/pmapi/src/test/java/com/ningdatech/pmapi/organization/OrganizationTest.java @@ -4,8 +4,6 @@ import com.ningdatech.pmapi.AppTests; import com.ningdatech.pmapi.ding.task.EmployeeBatchGetTask; import com.ningdatech.pmapi.ding.task.GovBusinessStripsTask; 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.springframework.beans.factory.annotation.Autowired; @@ -17,12 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired; class OrganizationTest extends AppTests { @Autowired - private ZwddClient zwddClient; - - @Autowired - private ZwddAuthClient zwddAuthClient; - - @Autowired private OrganizationBatchGetTask organizationBatchGetTask; @Autowired