From 2c02b69b735581c575b12486a11d9bbdc3b75f98 Mon Sep 17 00:00:00 2001 From: liuxinxin Date: Wed, 1 Mar 2023 13:49:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=93=E5=AE=B6=E5=AE=A1=E6=A0=B8=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=BB=93=E6=9E=9C=E5=A4=84=E7=90=86=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/common/helper/UserInfoHelper.java | 2 + .../common/helper/impl/UserInfoHelperImpl.java | 7 ++ .../pmapi/expert/manage/ExpertMetaApplyManage.java | 126 ++++++++++++++++++++- .../expert/model/cmd/ExpertStorageDealCmd.java | 71 ++++++------ .../pmapi/expert/service/ExpertInfoService.java | 5 + .../expert/service/impl/ExpertInfoServiceImpl.java | 68 +++++++++++ 6 files changed, 242 insertions(+), 37 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java index d421e51..a9b9cc7 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java @@ -22,4 +22,6 @@ public interface UserInfoHelper { UserFullInfoDTO getUserFullInfo(Long userId); + String getUserName(Long userId); + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java index 5dcac28..c4cc856 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java @@ -30,4 +30,11 @@ public class UserInfoHelperImpl implements UserInfoHelper { UserFullInfoDTO userFullInfo = userAuthLoginManage.getUserFullInfo(userId); return userFullInfo; } + + @Override + public String getUserName(Long userId) { + UserFullInfoDTO userFullInfo = userAuthLoginManage.getUserFullInfo(userId); + String realName = userFullInfo.getRealName(); + return realName; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertMetaApplyManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertMetaApplyManage.java index ad41577..ac93a49 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertMetaApplyManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertMetaApplyManage.java @@ -10,6 +10,7 @@ import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.CollUtils; import com.ningdatech.pmapi.common.constant.BoolDisplayEnum; +import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.common.util.BizUtils; import com.ningdatech.pmapi.expert.constant.ExpertApplyStatusEnum; import com.ningdatech.pmapi.expert.constant.ExpertApplyTypeEnum; @@ -17,12 +18,17 @@ import com.ningdatech.pmapi.expert.constant.ExpertApplyTypeQueryEnum; import com.ningdatech.pmapi.expert.entity.ExpertMetaApply; import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo; import com.ningdatech.pmapi.expert.model.DictionaryFieldInfo; +import com.ningdatech.pmapi.expert.model.TagFieldInfo; import com.ningdatech.pmapi.expert.model.cmd.ExpertAdminExpertManageQueryCmd; +import com.ningdatech.pmapi.expert.model.cmd.ExpertStorageDealCmd; import com.ningdatech.pmapi.expert.model.cmd.MetaApplyListQuery; +import com.ningdatech.pmapi.expert.model.dto.ExpertDictionaryDTO; +import com.ningdatech.pmapi.expert.model.dto.ExpertTagDTO; import com.ningdatech.pmapi.expert.model.query.ExpertDictionaryQuery; import com.ningdatech.pmapi.expert.model.req.MetaApplyResultRequest; import com.ningdatech.pmapi.expert.model.vo.ExpertApplyMetaVO; import com.ningdatech.pmapi.expert.model.vo.MetaApplyResultVo; +import com.ningdatech.pmapi.expert.service.ExpertInfoService; import com.ningdatech.pmapi.expert.service.IExpertMetaApplyService; import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService; import com.ningdatech.pmapi.meta.constant.DictExpertInfoTypeEnum; @@ -36,6 +42,7 @@ import com.ningdatech.pmapi.user.util.LoginUserUtil; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.util.ArrayList; @@ -60,6 +67,10 @@ public class ExpertMetaApplyManage { private final IExpertUserFullInfoService userFullInfoService; private final DictionaryCache dictionaryCache; + private final ExpertInfoService expertInfoService; + + private final UserInfoHelper userInfoHelper; + public PageVo metaApplyListQuery(MetaApplyListQuery req) { Long expertAdminUserId = LoginUserUtil.getUserId(); @@ -94,10 +105,88 @@ public class ExpertMetaApplyManage { return result; } - public void metaApplyResult(MetaApplyResultRequest applyResultRequest) { + @Transactional(rollbackFor = Exception.class) + public void metaApplyResult(MetaApplyResultRequest req) { + Long applyId = req.getApplyId(); + ExpertMetaApply expertMetaApply = iMetaApplyService.getById(applyId); + Long userId = LoginUserUtil.getUserId(); + + // 校验专家管理员区域权限,是否可以审核当前专家申请 +// permissionCheckHelper.operationPermissionsCheck(userId, expertMetaApply.getUserId()); + String applyStatus = expertMetaApply.getApplyStatus(); + if (!ExpertApplyStatusEnum.PENDING_REVIEW.getKey().equals(applyStatus)) { + throw BizException.wrap("apply is already processed"); + } + ExpertApplyTypeEnum applyType = ExpertApplyTypeEnum.of(expertMetaApply.getApplyType()); + boolean applyResult = req.getApplyResult(); - } + switch (applyType) { + // 专家入库 + case EXPERT_STORAGE: { + ExpertStorageDealCmd expertStorageDealCmd = buildExpertStorageDealCmd(req, expertMetaApply.getUserId(), expertMetaApply); + expertInfoService.expertStorageDeal(expertStorageDealCmd); + // 专家入库时,需要先审核专家入库,入库成功后,再履职意向审核,如果履职意向跟专家层级是同一层级的,就直接同意不需要审核 + if (applyResult) { + Long expertUserId = expertMetaApply.getUserId(); +// ExpertRegionInfo expertRegionInfo = expertUserInfoHelper.getExpertRegionInfo(expertUserId); +// Integer regionLevel = expertRegionInfo.getRegionLevel(); +// String regionCode = expertRegionInfo.getRegionCode(); + + List expertJoinApplyList = iMetaApplyService.list(Wrappers.lambdaQuery(ExpertMetaApply.class) + .eq(ExpertMetaApply::getUserId, expertUserId) + .eq(ExpertMetaApply::getApplyStatus, ExpertApplyStatusEnum.PENDING_REVIEW.getKey()) + .eq(ExpertMetaApply::getApplyType, ExpertApplyTypeEnum.EXPERT_INTENTION_JOIN.getKey()) + .eq(ExpertMetaApply::getDisplayEnable, BoolDisplayEnum.Y.name())); +// .eq(ExpertMetaApply::getRegionLevel, regionLevel) +// .eq(ExpertMetaApply::getRegionCode, regionCode)); + BizUtils.notEmpty(expertJoinApplyList, list -> list.forEach(r -> { + MetaApplyResultRequest resultRequest = new MetaApplyResultRequest(); + resultRequest.setApplyId(r.getId()); + resultRequest.setApplyResult(true); + resultRequest.setAuditOpinion("同意"); + metaApplyResult(resultRequest); + })); + } + } + break; + // 专家出库 + case EXPERT_DELIVERY: +// ExpertDeliveryDealCmd expertDeliveryDealCmd = buildExpertDeliveryDealCmd(req, expertMetaApply.getUserId()); +// expertInfoService.expertDeliveryDeal(expertDeliveryDealCmd); + break; + // 长期请假 + case LONG_TERM_LEAVE: +// leaveManage.leaveAuditCallback(req.getApplyResult(), applyId); + break; + // 专家信息审核 + case EXPERT_INFO_MODIFY: +// ExpertInfoModifyApplyDealCmd applyDealCmd = buildExpertInfoModifyApplyDealCmd(req, expertMetaApply.getUserId(), applyId); +// expertInfoService.expertInfoModifyDeal(applyDealCmd); + break; + // 专家履职意向加入/离开 + case EXPERT_INTENTION_JOIN: + case EXPERT_INTENTION_LEAVE: +// ExpertIntentionApplyDealCmd expertIntentionApplyDealCmd = buildExpertIntentionApplyDealCmd(req, expertMetaApply); +// expertInfoService.expertIntentionApplyDeal(expertIntentionApplyDealCmd); + break; + default: + break; + } + Long expertUserId = expertMetaApply.getUserId(); + String auditOpinion = req.getAuditOpinion(); + // 发送审核结果短信 +// sendApplyResultNotify(applyType, applyResult, auditOpinion, expertUserId); + // 更新申请结果 + expertMetaApply.setApproverUserId(userId); + String adminUserName = userInfoHelper.getUserName(userId); + expertMetaApply.setApprover(adminUserName); + expertMetaApply.setAuditOpinion(auditOpinion); + expertMetaApply.setApplyStatus(applyResult ? ExpertApplyStatusEnum.PASSED.getKey() : ExpertApplyStatusEnum.REFUSED.getKey()); + expertMetaApply.setReviewTime(LocalDateTime.now()); + expertMetaApply.setUpdateOn(LocalDateTime.now()); + iMetaApplyService.saveOrUpdate(expertMetaApply); + } public MetaApplyResultVo metaApplyResult(Long applyId) { ExpertMetaApply metaApply = iMetaApplyService.getById(applyId); @@ -383,5 +472,38 @@ public class ExpertMetaApplyManage { return expertMetaApplyListQuery; } + private ExpertStorageDealCmd buildExpertStorageDealCmd( + MetaApplyResultRequest applyResultRequest, Long expertUserId, ExpertMetaApply expertMetaApply) { + MetaApplyResultRequest.StorageApplyResultExtraInfo extraInfo = applyResultRequest.getStorageApplyResultExtraInfo(); + ExpertStorageDealCmd expertStorageDealCmd = new ExpertStorageDealCmd(); + Boolean applyResult = applyResultRequest.getApplyResult(); + expertStorageDealCmd.setApplyResult(applyResult); + + if (Objects.nonNull(extraInfo)) { + List expertType = extraInfo.getExpertType(); + if (CollectionUtils.isNotEmpty(expertType)) { + expertStorageDealCmd.setExpertType(extraInfo.getExpertType().stream().map(r -> { + ExpertDictionaryDTO expertDictionaryDTO = new ExpertDictionaryDTO(); + expertDictionaryDTO.setExpertInfoField(r.getDictionaryFieldName()); + expertDictionaryDTO.setDictionaryCode(r.getDictionaryCode()); + return expertDictionaryDTO; + }).collect(Collectors.toList())); + } + List other = extraInfo.getOther(); + if (CollectionUtils.isNotEmpty(other)) { + expertStorageDealCmd.setOther(extraInfo.getOther().stream().map(r -> { + ExpertTagDTO expertTagDTO = new ExpertTagDTO(); + expertTagDTO.setExpertInfoField(r.getTagFieldName()); + expertTagDTO.setTagCode(r.getTagCode()); + return expertTagDTO; + }).collect(Collectors.toList())); + } + expertStorageDealCmd.setRemark(extraInfo.getRemark()); + } + expertStorageDealCmd.setExpertUserId(expertUserId); + expertStorageDealCmd.setJoinRegionCode(expertMetaApply.getRegionCode()); + expertStorageDealCmd.setJoinRegionLevel(expertMetaApply.getRegionLevel()); + return expertStorageDealCmd; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/model/cmd/ExpertStorageDealCmd.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/model/cmd/ExpertStorageDealCmd.java index 607fe5f..d615e19 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/model/cmd/ExpertStorageDealCmd.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/model/cmd/ExpertStorageDealCmd.java @@ -1,35 +1,36 @@ -//package com.ningdatech.pmapi.expert.model.cmd; -// -//import com.ningdatech.emapi.expert.entity.dto.ExpertDictionaryDTO; -//import com.ningdatech.emapi.expert.entity.dto.ExpertTagDTO; -//import lombok.Data; -// -//import java.util.List; -// -///** -// * @author liuxinxin -// * @date 2022/7/26 下午5:40 -// */ -//@Data -//public class ExpertStorageDealCmd { -// -// private Long expertUserId; -// -// private Boolean applyResult; -// -// private String joinRegionCode; -// -// private Integer joinRegionLevel; -// -// /** -// * 专家类型(内外围) -// */ -// private List expertType; -// -// /** -// * 其他标签(标签code) -// */ -// private List other; -// -// private String remark; -//} +package com.ningdatech.pmapi.expert.model.cmd; + + +import com.ningdatech.pmapi.expert.model.dto.ExpertDictionaryDTO; +import com.ningdatech.pmapi.expert.model.dto.ExpertTagDTO; +import lombok.Data; + +import java.util.List; + +/** + * @author liuxinxin + * @date 2022/7/26 下午5:40 + */ +@Data +public class ExpertStorageDealCmd { + + private Long expertUserId; + + private Boolean applyResult; + + private String joinRegionCode; + + private Integer joinRegionLevel; + + /** + * 专家类型(内外围) + */ + private List expertType; + + /** + * 其他标签(标签code) + */ + private List other; + + private String remark; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/service/ExpertInfoService.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/service/ExpertInfoService.java index e418920..6ca67a3 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/service/ExpertInfoService.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/service/ExpertInfoService.java @@ -2,6 +2,7 @@ package com.ningdatech.pmapi.expert.service; import com.ningdatech.pmapi.expert.model.cmd.ExpertFullInfoSaveCmd; import com.ningdatech.pmapi.expert.model.cmd.ExpertRecommendProofSaveCmd; +import com.ningdatech.pmapi.expert.model.cmd.ExpertStorageDealCmd; import com.ningdatech.pmapi.expert.model.dto.ExpertFullInfoAllDTO; /** @@ -27,4 +28,8 @@ public interface ExpertInfoService { * @return */ ExpertFullInfoAllDTO getExpertUserFullInfoAll(Long userId); + + + void expertStorageDeal(ExpertStorageDealCmd cmd); } + diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/service/impl/ExpertInfoServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/service/impl/ExpertInfoServiceImpl.java index c52202e..cbe3ded 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/service/impl/ExpertInfoServiceImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/service/impl/ExpertInfoServiceImpl.java @@ -2,6 +2,7 @@ package com.ningdatech.pmapi.expert.service.impl; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.pmapi.common.constant.BoolDisplayEnum; import com.ningdatech.pmapi.expert.assembler.ExpertUserInfoAssembler; @@ -15,8 +16,10 @@ import com.ningdatech.pmapi.expert.entity.ExpertMetaApply; import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo; import com.ningdatech.pmapi.expert.model.cmd.ExpertFullInfoSaveCmd; import com.ningdatech.pmapi.expert.model.cmd.ExpertRecommendProofSaveCmd; +import com.ningdatech.pmapi.expert.model.cmd.ExpertStorageDealCmd; import com.ningdatech.pmapi.expert.model.dto.*; import com.ningdatech.pmapi.expert.service.*; +import com.ningdatech.pmapi.meta.constant.DictExpertInfoTypeEnum; import com.ningdatech.pmapi.meta.model.entity.ExpertDictionary; import com.ningdatech.pmapi.meta.model.entity.ExpertTag; import com.ningdatech.pmapi.meta.service.IExpertDictionaryService; @@ -28,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -304,4 +308,68 @@ public class ExpertInfoServiceImpl implements ExpertInfoService { } + /** + * 专家入库审核 + * + * @param cmd + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void expertStorageDeal(ExpertStorageDealCmd cmd) { + boolean applyResult = cmd.getApplyResult(); + Long expertUserId = cmd.getExpertUserId(); + ExpertUserFullInfo expertUserFullInfo = iExpertUserFullInfoService.getByUserId(expertUserId); + + if (applyResult) { + // 修改专家状态为可用 + expertUserFullInfo.setExpertAccountStatus(ExpertAccountStatusEnum.AVAILABLE.getKey()); + expertUserFullInfo.setRemark(cmd.getRemark()); + expertUserFullInfo.setRegionCode(cmd.getJoinRegionCode()); + expertUserFullInfo.setRegionLevel(cmd.getJoinRegionLevel()); + + // 保存所有专家标签字段 + List saveExpertTagList = buildSaveExpertTagList(expertUserId, cmd.getOther()); + iExpertTagService.saveBatch(saveExpertTagList); + // 保存所有专家字典字段 + List expertType = cmd.getExpertType(); + if (CollectionUtils.isNotEmpty(expertType)) { + expertType = expertType.stream().peek(r -> r.setExpertInfoField(DictExpertInfoTypeEnum.EXPERT_TYPE.getKey())).collect(Collectors.toList()); + List saveExpertDictionaryList = buildSaveExpertDictionaryList(expertUserId, expertType); + iExpertDictionaryService.saveBatch(saveExpertDictionaryList); + } + + // 修改履职意向申请状态 + LambdaUpdateWrapper set = Wrappers.lambdaUpdate(ExpertMetaApply.class).eq(ExpertMetaApply::getUserId, expertUserId) + .eq(ExpertMetaApply::getApplyType, ExpertApplyTypeEnum.EXPERT_INTENTION_JOIN.getKey()) + .eq(ExpertMetaApply::getApplyStatus, ExpertApplyStatusEnum.PENDING_REVIEW.getKey()) + .eq(ExpertMetaApply::getDisplayEnable, BoolDisplayEnum.N.name()) + .set(ExpertMetaApply::getDisplayEnable, BoolDisplayEnum.Y.name()); + iExpertMetaApplyService.update(set); + + } else { + expertUserFullInfo.setUserInfoStep(ExpertUserInfoStepEnum.INFORMATION_TO_BE_SUBMITTED.getKey()); + } + if (applyResult) { + // 补充专家 专家角色 TODO +// SysRole sysRole = roleService.getOne(Wrappers.lambdaQuery(SysRole.class) +// .eq(SysRole::getCode, SysRoleEnum.EXPERT.getKey())); +// if (Objects.nonNull(sysRole)) { +// Long roleId = sysRole.getRoleId(); +// LambdaQueryWrapper eq = Wrappers.lambdaQuery(SysUsersRoles.class) +// .eq(SysUsersRoles::getUserId, expertUserFullInfo.getUserId()) +// .eq(SysUsersRoles::getRoleId, sysRole.getRoleId()); +// SysUsersRoles one = userRoleService.getOne(eq); +// if (Objects.isNull(one)) { +// SysUsersRoles sysUsersRolesSaveRecord = new SysUsersRoles(); +// sysUsersRolesSaveRecord.setUserId(expertUserFullInfo.getUserId()); +// sysUsersRolesSaveRecord.setRoleId(roleId); +// userRoleService.saveAndReloadRoleListForToken(Collections.singletonList(sysUsersRolesSaveRecord), false); +// } +// } + } + iExpertUserFullInfoService.saveOrUpdate(expertUserFullInfo); + } + + + }