From 451bde970082cc9c3a96f2bdea144f0d50b7de22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?niohe=C2=B7erbao?= Date: Thu, 30 Mar 2023 15:51:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=93=E5=AE=B6=E5=AE=A1=E6=A0=B8=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=BF=AE=E6=94=B9=E6=94=B9=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/expert/manage/ExpertMetaApplyManage.java | 37 +++- .../model/cmd/ExpertIntentionApplyDealCmd.java | 44 ++--- .../pmapi/expert/service/ExpertInfoService.java | 15 +- .../expert/service/impl/ExpertInfoServiceImpl.java | 209 ++++++++++++++++++++- .../expert/utils/SensitiveModifySegmentUtils.java | 53 ++++++ 5 files changed, 321 insertions(+), 37 deletions(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/expert/utils/SensitiveModifySegmentUtils.java 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 4846e27..e48dde8 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 @@ -22,9 +22,7 @@ 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.cmd.*; import com.ningdatech.pmapi.expert.model.dto.ExpertDictionaryDTO; import com.ningdatech.pmapi.expert.model.dto.ExpertTagDTO; import com.ningdatech.pmapi.expert.model.query.ExpertDictionaryQuery; @@ -170,14 +168,14 @@ public class ExpertMetaApplyManage { break; // 专家信息审核 case EXPERT_INFO_MODIFY: -// ExpertInfoModifyApplyDealCmd applyDealCmd = buildExpertInfoModifyApplyDealCmd(req, expertMetaApply.getUserId(), applyId); -// expertInfoService.expertInfoModifyDeal(applyDealCmd); + 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); + ExpertIntentionApplyDealCmd expertIntentionApplyDealCmd = buildExpertIntentionApplyDealCmd(req, expertMetaApply); + expertInfoService.expertIntentionApplyDeal(expertIntentionApplyDealCmd); break; default: break; @@ -535,4 +533,29 @@ public class ExpertMetaApplyManage { return expertStorageDealCmd; } + + private ExpertInfoModifyApplyDealCmd buildExpertInfoModifyApplyDealCmd(MetaApplyResultRequest applyResultRequest + , Long userId, Long applyId) { + ExpertInfoModifyApplyDealCmd expertInfoModifyApplyDealCmd = new ExpertInfoModifyApplyDealCmd(); + Boolean applyResult = applyResultRequest.getApplyResult(); + expertInfoModifyApplyDealCmd.setApplyResult(applyResult); + expertInfoModifyApplyDealCmd.setExpertUserId(userId); + expertInfoModifyApplyDealCmd.setApplyId(applyId); + return expertInfoModifyApplyDealCmd; + } + + private ExpertIntentionApplyDealCmd buildExpertIntentionApplyDealCmd(MetaApplyResultRequest applyResultRequest + , ExpertMetaApply expertMetaApply) { + Boolean applyResult = applyResultRequest.getApplyResult(); + String applyType = expertMetaApply.getApplyType(); + ExpertApplyTypeEnum applyTypeEnum = ExpertApplyTypeEnum.of(applyType); + + ExpertIntentionApplyDealCmd expertIntentionApplyDealCmd = new ExpertIntentionApplyDealCmd(); + expertIntentionApplyDealCmd.setApplyResult(applyResult); + expertIntentionApplyDealCmd.setApplyTypeEnum(applyTypeEnum); + expertIntentionApplyDealCmd.setExpertUserId(expertMetaApply.getUserId()); + expertIntentionApplyDealCmd.setExpertRegionCode(expertMetaApply.getRegionCode()); + expertIntentionApplyDealCmd.setExpertRegionLevel(expertMetaApply.getRegionLevel()); + return expertIntentionApplyDealCmd; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/model/cmd/ExpertIntentionApplyDealCmd.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/model/cmd/ExpertIntentionApplyDealCmd.java index 73aa7e6..a9787e2 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/model/cmd/ExpertIntentionApplyDealCmd.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/model/cmd/ExpertIntentionApplyDealCmd.java @@ -1,22 +1,22 @@ -//package com.ningdatech.pmapi.expert.model.cmd; -// -//import com.ningdatech.emapi.expert.constants.ExpertApplyTypeEnum; -//import lombok.Data; -// -///** -// * @author liuxinxin -// * @date 2022/7/27 上午9:06 -// */ -//@Data -//public class ExpertIntentionApplyDealCmd { -// -// private Long expertUserId; -// -// private Boolean applyResult; -// -// ExpertApplyTypeEnum applyTypeEnum; -// -// private String expertRegionCode; -// -// private Integer expertRegionLevel; -//} +package com.ningdatech.pmapi.expert.model.cmd; + +import com.ningdatech.pmapi.expert.constant.ExpertApplyTypeEnum; +import lombok.Data; + +/** + * @author liuxinxin + * @date 2022/7/27 上午9:06 + */ +@Data +public class ExpertIntentionApplyDealCmd { + + private Long expertUserId; + + private Boolean applyResult; + + ExpertApplyTypeEnum applyTypeEnum; + + private String expertRegionCode; + + private Integer expertRegionLevel; +} 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 56060b4..c0b9aa0 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 @@ -1,9 +1,6 @@ package com.ningdatech.pmapi.expert.service; -import com.ningdatech.pmapi.expert.model.cmd.ExpertFullInfoSaveCmd; -import com.ningdatech.pmapi.expert.model.cmd.ExpertInfoModifyCmd; -import com.ningdatech.pmapi.expert.model.cmd.ExpertRecommendProofSaveCmd; -import com.ningdatech.pmapi.expert.model.cmd.ExpertStorageDealCmd; +import com.ningdatech.pmapi.expert.model.cmd.*; import com.ningdatech.pmapi.expert.model.dto.ExpertFullInfoAllDTO; import java.util.List; @@ -24,6 +21,16 @@ public interface ExpertInfoService { */ void expertRecommendProofSave(ExpertRecommendProofSaveCmd expertRecommendProofSaveCmd); + void expertIntentionApplyDeal(ExpertIntentionApplyDealCmd expertIntentionApplyDealCmd); + + + /** + * 专家信息修改审核结果处理 + * + * @param expertInfoModifyApplyDealCmd + */ + void expertInfoModifyDeal(ExpertInfoModifyApplyDealCmd expertInfoModifyApplyDealCmd); + /** * 根据user_id 获取用户全量信息 * 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 880542b..50da3ed 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 @@ -5,6 +5,7 @@ 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.basic.exception.BizException; import com.ningdatech.basic.util.CollUtils; import com.ningdatech.pmapi.common.enumeration.BoolDisplayEnum; import com.ningdatech.pmapi.common.model.ExpertRegionModifyDiffBO; @@ -13,14 +14,14 @@ import com.ningdatech.pmapi.common.util.GzipUtils; import com.ningdatech.pmapi.expert.assembler.ExpertUserInfoAssembler; import com.ningdatech.pmapi.expert.constant.*; import com.ningdatech.pmapi.expert.entity.*; +import com.ningdatech.pmapi.expert.model.DictionaryFieldInfo; import com.ningdatech.pmapi.expert.model.SensitiveModifySegment; +import com.ningdatech.pmapi.expert.model.TagFieldInfo; import com.ningdatech.pmapi.expert.model.bo.ExpertInfoSensitiveFieldCheckBO; -import com.ningdatech.pmapi.expert.model.cmd.ExpertFullInfoSaveCmd; -import com.ningdatech.pmapi.expert.model.cmd.ExpertInfoModifyCmd; -import com.ningdatech.pmapi.expert.model.cmd.ExpertRecommendProofSaveCmd; -import com.ningdatech.pmapi.expert.model.cmd.ExpertStorageDealCmd; +import com.ningdatech.pmapi.expert.model.cmd.*; import com.ningdatech.pmapi.expert.model.dto.*; import com.ningdatech.pmapi.expert.service.*; +import com.ningdatech.pmapi.expert.utils.SensitiveModifySegmentUtils; import com.ningdatech.pmapi.meta.constant.DictExpertInfoTypeEnum; import com.ningdatech.pmapi.meta.constant.ExpertTagEnum; import com.ningdatech.pmapi.meta.model.ExpertRegionInfo; @@ -28,13 +29,16 @@ 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 com.ningdatech.yxt.utils.JSONUtils; import lombok.RequiredArgsConstructor; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -310,6 +314,49 @@ public class ExpertInfoServiceImpl implements ExpertInfoService { } + @Override + public void expertIntentionApplyDeal(ExpertIntentionApplyDealCmd cmd) { + Boolean applyResult = cmd.getApplyResult(); + ExpertApplyTypeEnum applyTypeEnum = cmd.getApplyTypeEnum(); + String expertRegionCode = cmd.getExpertRegionCode(); + Integer expertRegionLevel = cmd.getExpertRegionLevel(); + Long expertUserId = cmd.getExpertUserId(); + + if (applyResult) { + switch (applyTypeEnum) { + case EXPERT_INTENTION_JOIN: { + // 新增履职意向地 + LambdaQueryWrapper query = Wrappers.lambdaQuery(ExpertIntentionWorkRegion.class) + .eq(ExpertIntentionWorkRegion::getUserId, expertUserId) + .eq(ExpertIntentionWorkRegion::getRegionCode, expertRegionCode) + .eq(ExpertIntentionWorkRegion::getRegionLevel, expertRegionLevel); + ExpertIntentionWorkRegion one = iExpertIntentionWorkRegionService.getOne(query); + if (Objects.isNull(one)) { + ExpertIntentionWorkRegion expertIntentionWorkRegion = new ExpertIntentionWorkRegion(); + expertIntentionWorkRegion.setCreateOn(LocalDateTime.now()); + expertIntentionWorkRegion.setUpdateOn(LocalDateTime.now()); + expertIntentionWorkRegion.setRegionCode(expertRegionCode); + expertIntentionWorkRegion.setRegionLevel(expertRegionLevel); + expertIntentionWorkRegion.setUserId(expertUserId); + iExpertIntentionWorkRegionService.save(expertIntentionWorkRegion); + } + } + break; + case EXPERT_INTENTION_LEAVE: { + // 删除履职意向地 + LambdaUpdateWrapper expertIntentionWorkRegionQuery = Wrappers.lambdaUpdate(ExpertIntentionWorkRegion.class) + .eq(ExpertIntentionWorkRegion::getUserId, expertUserId) + .eq(ExpertIntentionWorkRegion::getRegionCode, expertRegionCode) + .eq(ExpertIntentionWorkRegion::getRegionLevel, expertRegionLevel); + iExpertIntentionWorkRegionService.remove(expertIntentionWorkRegionQuery); + } + break; + default: + throw new BizException("illegal request"); + } + } + } + /** * 专家入库审核 * @@ -620,4 +667,158 @@ public class ExpertInfoServiceImpl implements ExpertInfoService { } + @Override + public void expertInfoModifyDeal(ExpertInfoModifyApplyDealCmd expertInfoModifyApplyDealCmd) { + Boolean applyResult = expertInfoModifyApplyDealCmd.getApplyResult(); + Long expertUserId = expertInfoModifyApplyDealCmd.getExpertUserId(); + Long applyId = expertInfoModifyApplyDealCmd.getApplyId(); + if (applyResult) { + ExpertUserFullInfo originalExpertUserFullInfo = iExpertUserFullInfoService.getByUserId(expertUserId); + + LambdaQueryWrapper recordQuery = Wrappers.lambdaQuery(ExpertSensitiveInfoModifyDetailRecord.class) + .eq(ExpertSensitiveInfoModifyDetailRecord::getUserId, expertUserId) + .eq(ExpertSensitiveInfoModifyDetailRecord::getMetaApplyId, applyId); + ExpertSensitiveInfoModifyDetailRecord record = iExpertSensitiveInfoModifyDetailRecordService.getOne(recordQuery); + String modifyJson = record.getModifyJson(); + if (StringUtils.isNotEmpty(modifyJson)) { + modifyJson = GzipUtils.uncompress(modifyJson); + } + List sensitiveModifySegments = JSONUtils.parseArray(modifyJson, SensitiveModifySegment.class); + Map collectMap = sensitiveModifySegments + .stream().collect(Collectors.toMap(SensitiveModifySegment::getFieldName, Function.identity())); + + // 更新专家基 expert_user_full_info 表中数据 + assemblerExpertUserFullInfoSensitiveFieldSaveRecord(originalExpertUserFullInfo, ExpertUserInfoSensitiveFieldEnum.phone_no, collectMap); + assemblerExpertUserFullInfoSensitiveFieldSaveRecord(originalExpertUserFullInfo, ExpertUserInfoSensitiveFieldEnum.email, collectMap); + assemblerExpertUserFullInfoSensitiveFieldSaveRecord(originalExpertUserFullInfo, ExpertUserInfoSensitiveFieldEnum.company, collectMap); + assemblerExpertUserFullInfoSensitiveFieldSaveRecord(originalExpertUserFullInfo, ExpertUserInfoSensitiveFieldEnum.legal_entity_code, collectMap); + iExpertUserFullInfoService.saveOrUpdate(originalExpertUserFullInfo); + + // 更新专家字典字段 + executeExpertUserFullInfoDictionaryInfoUpdate(expertUserId, collectMap + , ExpertUserInfoSensitiveFieldEnum.administrative_rank + , ExpertUserInfoSensitiveFieldEnum.title_level); + + // 更新专家标签字段列表 + executeExpertUserFullInfoTagInfoUpdate(expertUserId, collectMap, ExpertUserInfoSensitiveFieldEnum.good_at + , ExpertUserInfoSensitiveFieldEnum.technical_expertise + , ExpertUserInfoSensitiveFieldEnum.industry_sector + , ExpertUserInfoSensitiveFieldEnum.other); + + } + + } + + private void executeExpertUserFullInfoDictionaryInfoUpdate(Long expertUserId, Map collectMap, ExpertUserInfoSensitiveFieldEnum... sensitiveFieldEnumArr) { + for (ExpertUserInfoSensitiveFieldEnum sensitiveFieldEnum : sensitiveFieldEnumArr) { + switch (sensitiveFieldEnum) { + case administrative_rank: + case title_level: { + SensitiveModifySegment segment = collectMap.get(sensitiveFieldEnum); + if (Objects.nonNull(segment)) { + List dictionaryFieldInfoList = SensitiveModifySegmentUtils.getDictionaryFieldInfoListApply(segment); + updateExpertDictionaryList(expertUserId, dictionaryFieldInfoList, sensitiveFieldEnum.getKey()); + } + } + break; + default: + break; + } + } + } + + + private void executeExpertUserFullInfoTagInfoUpdate(Long expertUserId, Map collectMap, ExpertUserInfoSensitiveFieldEnum... sensitiveFieldEnumArr) { + for (ExpertUserInfoSensitiveFieldEnum sensitiveFieldEnum : sensitiveFieldEnumArr) { + switch (sensitiveFieldEnum) { + case good_at: + case technical_expertise: + case industry_sector: + case other: { + SensitiveModifySegment segment = collectMap.get(sensitiveFieldEnum); + if (Objects.nonNull(segment)) { + List tagFieldInfoList = SensitiveModifySegmentUtils.getTagFieldInfoListApply(segment); + updateExpertTagList(expertUserId, tagFieldInfoList, sensitiveFieldEnum.getKey()); + } + } + break; + default: + break; + } + } + } + + /** + * 信息修改审核通过后 装配更新用户信息敏感字段 + * + * @param originalExpertUserFullInfo + * @param expertUserFullInfoStrEnum + * @param collectMap + */ + private void assemblerExpertUserFullInfoSensitiveFieldSaveRecord(ExpertUserFullInfo originalExpertUserFullInfo, ExpertUserInfoSensitiveFieldEnum expertUserFullInfoStrEnum + , Map collectMap) { + SensitiveModifySegment segment = collectMap.get(expertUserFullInfoStrEnum); + if (Objects.nonNull(segment)) { + String segmentApplyValue = (String) segment.getApply(); + switch (expertUserFullInfoStrEnum) { + case phone_no: + originalExpertUserFullInfo.setPhoneNo(segmentApplyValue); + break; + case email: + originalExpertUserFullInfo.setEmail(segmentApplyValue); + break; + case company: + originalExpertUserFullInfo.setCompany(segmentApplyValue); + break; + case legal_entity_code: + originalExpertUserFullInfo.setLegalEntityCode(segmentApplyValue); + break; + default: + break; + } + } + } + + private void updateExpertTagList(Long expertUserId, List tagFieldInfoList, String... tagExpertInfoTypeArr) { + if (CollectionUtils.isNotEmpty(tagFieldInfoList)) { + // 删除专家字典字段 + LambdaQueryWrapper expertTagRemove = Wrappers.lambdaQuery(ExpertTag.class) + .eq(ExpertTag::getUserId, expertUserId) + .in(tagExpertInfoTypeArr.length > 0, ExpertTag::getExpertInfoField, tagExpertInfoTypeArr); + iExpertTagService.remove(expertTagRemove); + List expertDictionarySaveList = tagFieldInfoList.stream().map(r -> { + ExpertTag expertTag = new ExpertTag(); + expertTag.setUpdateOn(LocalDateTime.now()); + expertTag.setUserId(expertUserId); + expertTag.setExpertInfoField(r.getTagFieldName()); + expertTag.setTagCode(r.getTagCode()); + return expertTag; + }).collect(Collectors.toList()); + iExpertTagService.saveBatch(expertDictionarySaveList); + } + } + + private void updateExpertDictionaryList(Long expertUserId, List dictionaryFieldInfoList, String... dictionaryExpertInfoTypeArr) { + if (CollectionUtils.isNotEmpty(dictionaryFieldInfoList)) { + // 删除专家字典字段 + LambdaQueryWrapper expertDictionaryRemove = Wrappers.lambdaQuery(ExpertDictionary.class) + .eq(ExpertDictionary::getUserId, expertUserId) + .in(dictionaryExpertInfoTypeArr.length > 0, ExpertDictionary::getExpertInfoField, dictionaryExpertInfoTypeArr); + iExpertDictionaryService.remove(expertDictionaryRemove); + List expertDictionarySaveList = dictionaryFieldInfoList.stream().map(r -> { + ExpertDictionary expertDictionary = new ExpertDictionary(); + expertDictionary.setUpdateOn(LocalDateTime.now()); + expertDictionary.setCreateOn(LocalDateTime.now()); + expertDictionary.setUserId(expertUserId); + expertDictionary.setExpertInfoField(r.getDictionaryFieldName()); + expertDictionary.setDictionaryCode(r.getDictionaryCode()); + return expertDictionary; + }).collect(Collectors.toList()); + iExpertDictionaryService.saveBatch(expertDictionarySaveList); + } + } + + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/utils/SensitiveModifySegmentUtils.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/utils/SensitiveModifySegmentUtils.java new file mode 100644 index 0000000..7f5467f --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/utils/SensitiveModifySegmentUtils.java @@ -0,0 +1,53 @@ +package com.ningdatech.pmapi.expert.utils; + + +import com.ningdatech.basic.exception.BizException; +import com.ningdatech.pmapi.expert.model.DictionaryFieldInfo; +import com.ningdatech.pmapi.expert.model.SensitiveModifySegment; +import com.ningdatech.pmapi.expert.model.TagFieldInfo; +import com.ningdatech.yxt.utils.JSONUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * @author liuxinxin + * @date 2022/8/24 下午3:36 + */ + +public class SensitiveModifySegmentUtils { + + private SensitiveModifySegmentUtils() { + } + + public static List getTagFieldInfoListApply(SensitiveModifySegment segment) { + switch (segment.getFieldName()) { + case good_at: + case technical_expertise: + case industry_sector: + case other: + if (Objects.nonNull(segment.getApply())) { + return JSONUtils.parseArray(segment.getApply().toString(), TagFieldInfo.class); + } + return new ArrayList<>(); + default: + throw new BizException("非法格式"); + } + + } + + public static List getDictionaryFieldInfoListApply(SensitiveModifySegment segment) { + switch (segment.getFieldName()) { + case administrative_rank: + case title_level: { + if (Objects.nonNull(segment.getApply())) { + return JSONUtils.parseArray(segment.getApply().toString(), DictionaryFieldInfo.class); + } + return new ArrayList<>(); + } + default: + throw new BizException("非法格式"); + } + } +}