From 52a00b824399bc735d587b534c3eab0c09611d16 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Wed, 24 Jan 2024 16:46:12 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E8=AD=A6=E9=80=9A=E7=9F=A5=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../expert/service/impl/ExpertInfoServiceImpl.java | 74 ++++++++++------------ .../api/meeting/helper/MeetingCallOrMsgHelper.java | 12 ++-- .../pm/api/meeting/helper/YxtCallOrSmsHelper.java | 47 -------------- .../hz/pm/api/meeting/helper/YxtClientHelper.java | 47 ++++++++++++++ .../hz/pm/api/sys/manage/EarlyWarningManage.java | 26 +++++--- 5 files changed, 103 insertions(+), 103 deletions(-) delete mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/YxtCallOrSmsHelper.java create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/YxtClientHelper.java diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/expert/service/impl/ExpertInfoServiceImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/expert/service/impl/ExpertInfoServiceImpl.java index 2267e24..daa8693 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/expert/service/impl/ExpertInfoServiceImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/expert/service/impl/ExpertInfoServiceImpl.java @@ -24,7 +24,7 @@ import com.hz.pm.api.expert.model.cmd.*; import com.hz.pm.api.expert.model.dto.*; import com.hz.pm.api.expert.service.*; import com.hz.pm.api.expert.utils.SensitiveModifySegmentUtils; -import com.hz.pm.api.meeting.helper.YxtCallOrSmsHelper; +import com.hz.pm.api.meeting.helper.YxtClientHelper; import com.hz.pm.api.meta.constant.ExpertDictTypeEnum; import com.hz.pm.api.meta.model.ExpertRegionInfo; import com.hz.pm.api.meta.model.entity.ExpertDictionary; @@ -78,7 +78,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService { private final IUserRoleService userRoleService; private final IExpertSensitiveInfoModifyDetailRecordService iExpertSensitiveInfoModifyDetailRecordService; private final IUserInfoService userInfoService; - private final YxtCallOrSmsHelper yxtCallOrSmsHelper; + private final YxtClientHelper yxtClientHelper; private final IExpertGovBusinessStripService expertGovBusinessStripService; @Value("${login.url:}") @@ -101,7 +101,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService { ExpertUserFullInfo expertUserFullInfo = iExpertUserFullInfoService.getByUserId(userId); - ExpertUserFullInfo saveExpertUserFullInfo = buildSaveExpertUserFullInfo(expertUserInfoDTO); + ExpertUserFullInfo saveExpertUserFullInfo = buildExpertUserFullInfo(expertUserInfoDTO); if (Objects.nonNull(expertUserFullInfo)) { // 专家信息审核通过之前,所有信息无需备份 iExpertUserFullInfoService.removeById(expertUserFullInfo.getId()); @@ -129,7 +129,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService { iExpertTagService.saveBatch(saveExpertTagList); } // 保存所有专家字典字段 - List saveExpertDictionaryList = buildSaveExpertDictionaryList(userId, expertDictionaryList); + List saveExpertDictionaryList = buildExpertDicts(userId, expertDictionaryList); if (CollectionUtils.isNotEmpty(saveExpertDictionaryList)) { iExpertDictionaryService.saveBatch(saveExpertDictionaryList); } @@ -141,14 +141,14 @@ public class ExpertInfoServiceImpl implements ExpertInfoService { iExpertMetaApplyService.saveBatch(saveExpertIntentionWorkRegionApplyList); } // 保存所有专家回避单位 - List saveExpertAvoidCompanyList = buildSaveExpertAvoidCompanyList(userId, expertAvoidCompanyList); + List saveExpertAvoidCompanyList = buildExpertAvoidCompany(userId, expertAvoidCompanyList); if (CollectionUtils.isNotEmpty(saveExpertAvoidCompanyList)) { iExpertAvoidCompanyService.saveBatch(saveExpertAvoidCompanyList); } } - private ExpertUserFullInfo buildSaveExpertUserFullInfo(ExpertUserFullInfoDTO expertUserInfoDTO) { + private ExpertUserFullInfo buildExpertUserFullInfo(ExpertUserFullInfoDTO expertUserInfoDTO) { ExpertUserFullInfo expertUserFullInfo = new ExpertUserFullInfo(); if (Objects.nonNull(expertUserInfoDTO.getIsDingUser())) { expertUserFullInfo.setIsDingUser(expertUserInfoDTO.getIsDingUser()); @@ -197,33 +197,35 @@ public class ExpertInfoServiceImpl implements ExpertInfoService { }).collect(Collectors.toList()); } - private List buildSaveExpertDictionaryList(Long userId, List expertDictionaryList) { - if (CollectionUtils.isEmpty(expertDictionaryList)) { - return new ArrayList<>(); - } - return expertDictionaryList.stream().map(r -> { - ExpertDictionary expertDictionary = new ExpertDictionary(); - expertDictionary.setUserId(userId); - expertDictionary.setExpertInfoField(r.getExpertInfoField()); - expertDictionary.setDictionaryCode(r.getDictionaryCode()); - expertDictionary.setUpdateOn(LocalDateTime.now()); - expertDictionary.setCreateOn(LocalDateTime.now()); - return expertDictionary; + private List buildExpertDicts(Long userId, List exertDicts) { + if (CollectionUtils.isEmpty(exertDicts)) { + return Collections.emptyList(); + } + LocalDateTime now = LocalDateTime.now(); + return exertDicts.stream().map(r -> { + ExpertDictionary expertDict = new ExpertDictionary(); + expertDict.setUserId(userId); + expertDict.setExpertInfoField(r.getExpertInfoField()); + expertDict.setDictionaryCode(r.getDictionaryCode()); + expertDict.setUpdateOn(now); + expertDict.setCreateOn(now); + return expertDict; }).collect(Collectors.toList()); } - private List buildSaveExpertAvoidCompanyList(Long userId, List expertAvoidCompanyList) { - if (CollectionUtils.isEmpty(expertAvoidCompanyList)) { - return new ArrayList<>(); + private List buildExpertAvoidCompany(Long userId, List avoidCompanies) { + if (CollectionUtils.isEmpty(avoidCompanies)) { + return Collections.emptyList(); } - return expertAvoidCompanyList.stream().map(r -> { + LocalDateTime now = LocalDateTime.now(); + return avoidCompanies.stream().map(r -> { ExpertAvoidCompany expertAvoidCompany = new ExpertAvoidCompany(); expertAvoidCompany.setCompanyName(r.getCompanyName()); expertAvoidCompany.setUserId(userId); expertAvoidCompany.setCompanyUniqCode(r.getCompanyUniqCode()); - expertAvoidCompany.setCreateOn(LocalDateTime.now()); - expertAvoidCompany.setUpdateOn(LocalDateTime.now()); + expertAvoidCompany.setCreateOn(now); + expertAvoidCompany.setUpdateOn(now); return expertAvoidCompany; }).collect(Collectors.toList()); } @@ -239,15 +241,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService { List recommendedWayList = cmd.getRecommendedWay(); if (CollectionUtils.isNotEmpty(recommendedWayList)) { - List saveExpertDictionaryList = recommendedWayList.stream().map(r -> { - ExpertDictionary expertDictionary = new ExpertDictionary(); - expertDictionary.setUserId(userId); - expertDictionary.setExpertInfoField(r.getExpertInfoField()); - expertDictionary.setDictionaryCode(r.getDictionaryCode()); - expertDictionary.setUpdateOn(LocalDateTime.now()); - expertDictionary.setCreateOn(LocalDateTime.now()); - return expertDictionary; - }).collect(Collectors.toList()); + List saveExpertDictionaryList = buildExpertDicts(userId, recommendedWayList); iExpertDictionaryService.saveBatch(saveExpertDictionaryList); } @@ -325,7 +319,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService { Integer expertRegionLevel = cmd.getExpertRegionLevel(); Long expertUserId = cmd.getExpertUserId(); - if (applyResult) { + if (Boolean.TRUE.equals(applyResult)) { switch (applyTypeEnum) { case EXPERT_INTENTION_JOIN: { // 新增履职意向地 @@ -372,7 +366,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService { ExpertUserFullInfo expertInfo = iExpertUserFullInfoService.getByUserId(expertUserId); UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); String content; - if (cmd.getApplyResult()) { + if (Boolean.TRUE.equals(cmd.getApplyResult())) { // 修改专家状态为可用 // 账号启用 LambdaUpdateWrapper userInfoUpdate = Wrappers.lambdaUpdate(UserInfo.class) @@ -387,7 +381,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService { List expertType = cmd.getExpertType(); if (CollUtil.isNotEmpty(expertType)) { expertType.forEach(r -> r.setExpertInfoField(ExpertDictTypeEnum.EXPERT_TYPE.getKey())); - List saveExpertDictList = buildSaveExpertDictionaryList(expertUserId, expertType); + List saveExpertDictList = buildExpertDicts(expertUserId, expertType); iExpertDictionaryService.saveBatch(saveExpertDictList); } // 补充专家 专家角色 @@ -410,7 +404,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService { SendSmsContext smsCtx = new SendSmsContext(); smsCtx.setContent(content); smsCtx.setReceiveNumber(expertInfo.getPhoneNo()); - yxtCallOrSmsHelper.sendSms(smsCtx); + yxtClientHelper.sendSms(smsCtx); } } @@ -464,7 +458,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService { List applyIdList = new ArrayList<>(); ExpertUserFullInfo originalExpertUserFullInfo = iExpertUserFullInfoService.getByUserId(userId); - ExpertUserFullInfo saveExpertUserFullInfo = buildSaveExpertUserFullInfo(expertUserInfoDTO); + ExpertUserFullInfo saveExpertUserFullInfo = buildExpertUserFullInfo(expertUserInfoDTO); if (Objects.nonNull(originalExpertUserFullInfo)) { saveExpertUserFullInfo.setId(originalExpertUserFullInfo.getId()); // 删除所有专家字典字段(需审核敏感字段不删除) @@ -497,7 +491,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService { iExpertUserFullInfoService.saveOrUpdate(saveExpertUserFullInfo); // 保存所有专家字典字段 - List saveExpertDictionaryList = buildSaveExpertDictionaryList(userId, expertDictionaryList); + List saveExpertDictionaryList = buildExpertDicts(userId, expertDictionaryList); saveExpertDictionaryList = saveExpertDictionaryList .stream().filter(r -> !ExpertUserInfoSensitiveFieldEnum.getSensitiveDictionaryList().contains(r.getExpertInfoField())) .collect(Collectors.toList()); @@ -506,7 +500,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService { } // 保存所有专家回避单位 - List saveExpertAvoidCompanyList = buildSaveExpertAvoidCompanyList(userId, expertAvoidCompanyList); + List saveExpertAvoidCompanyList = buildExpertAvoidCompany(userId, expertAvoidCompanyList); if (CollectionUtils.isNotEmpty(saveExpertAvoidCompanyList)) { // 删除回避单位 LambdaQueryWrapper expertAvoidCompanyRemove = Wrappers.lambdaQuery(ExpertAvoidCompany.class) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingCallOrMsgHelper.java b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingCallOrMsgHelper.java index 380c950..9387640 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingCallOrMsgHelper.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingCallOrMsgHelper.java @@ -48,7 +48,7 @@ import java.util.stream.Collectors; public class MeetingCallOrMsgHelper { private final IUserInfoService userInfoService; - private final YxtCallOrSmsHelper yxtCallOrSmsHelper; + private final YxtClientHelper yxtClientHelper; private final INdWorkNoticeStagingService workNoticeStagingService; private final IDingEmployeeInfoService dingEmployeeInfoService; private final IDingOrganizationService dingOrganizationService; @@ -102,7 +102,7 @@ public class MeetingCallOrMsgHelper { SendSmsContext yxtContent = new SendSmsContext(); yxtContent.setContent(msgContent); yxtContent.setReceiveNumber(info.getMobile()); - yxtCallOrSmsHelper.sendSms(yxtContent); + yxtClientHelper.sendSms(yxtContent); // 发送工作通知 if (info.getAccountId() != null) { WorkNoticeInfo swn = getSendWorkNoticeInfo(info.getAccountId()); @@ -148,7 +148,7 @@ public class MeetingCallOrMsgHelper { } }); notifyService.saveBatch(notifies); - yxtCallOrSmsHelper.sendSms(yxtContents); + yxtClientHelper.sendSms(yxtContents); workNoticeStagingService.addByWorkNotice(workingNotices, MsgTypeEnum.EXPERT_REVIEW); } @@ -164,7 +164,7 @@ public class MeetingCallOrMsgHelper { context.setContent(content); return context; }).collect(Collectors.toList()); - yxtCallOrSmsHelper.sendSms(contexts); + yxtClientHelper.sendSms(contexts); } /** @@ -184,7 +184,7 @@ public class MeetingCallOrMsgHelper { context.setReceiveNumber(w.getMobile()); return context; }); - String submitKey = yxtCallOrSmsHelper.submitCallTask(callContexts); + String submitKey = yxtClientHelper.submitCallTask(callContexts); experts.forEach(w -> w.setSubmitKey(submitKey)); } @@ -200,7 +200,7 @@ public class MeetingCallOrMsgHelper { SendSmsContext yxtContent = new SendSmsContext(); yxtContent.setContent(msgContent); yxtContent.setReceiveNumber(info.getMobile()); - yxtCallOrSmsHelper.sendSms(yxtContent); + yxtClientHelper.sendSms(yxtContent); // 发送工作通知 if (info.getAccountId() != null) { WorkNoticeInfo swn = getSendWorkNoticeInfo(info.getAccountId()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/YxtCallOrSmsHelper.java b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/YxtCallOrSmsHelper.java deleted file mode 100644 index f8df961..0000000 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/YxtCallOrSmsHelper.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.hz.pm.api.meeting.helper; - -import com.ningdatech.yxt.client.YxtClient; -import com.ningdatech.yxt.constants.YxtSmsSignEnum; -import com.ningdatech.yxt.model.cmd.SendSmsCmd; -import com.ningdatech.yxt.model.cmd.SendSmsCmd.SendSmsContext; -import com.ningdatech.yxt.model.cmd.SubmitTaskCallResponse; -import lombok.AllArgsConstructor; -import org.springframework.stereotype.Component; - -import java.util.Collections; -import java.util.List; - -import static com.ningdatech.yxt.model.cmd.SubmitTaskCallCmd.SubmitTaskCallContext; -import static com.ningdatech.yxt.model.cmd.SubmitTaskCallCmd.of; - -/** - *

- * YxtCallOrSmsHelper - *

- * - * @author WendyYang - * @since 23:59 2022/8/31 - */ -@Component -@AllArgsConstructor -public class YxtCallOrSmsHelper { - - private final YxtClient yxtClient; - - public String submitCallTask(List callContexts) { - SubmitTaskCallResponse callResponse = yxtClient.submitTaskCall(of(callContexts)); - return callResponse.getSubmitKey(); - } - - public void sendSms(List smsList) { - SendSmsCmd cmd = new SendSmsCmd(); - cmd.setContextList(smsList); - cmd.setSmsSignEnum(YxtSmsSignEnum.LS_BIG_DATA_BUREAU); - yxtClient.submitSmsTask(cmd); - } - - public void sendSms(SendSmsContext sms) { - sendSms(Collections.singletonList(sms)); - } - -} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/YxtClientHelper.java b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/YxtClientHelper.java new file mode 100644 index 0000000..9140730 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/YxtClientHelper.java @@ -0,0 +1,47 @@ +package com.hz.pm.api.meeting.helper; + +import com.ningdatech.yxt.client.YxtClient; +import com.ningdatech.yxt.constants.YxtSmsSignEnum; +import com.ningdatech.yxt.model.cmd.SendSmsCmd; +import com.ningdatech.yxt.model.cmd.SendSmsCmd.SendSmsContext; +import com.ningdatech.yxt.model.cmd.SubmitTaskCallResponse; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Component; + +import java.util.Collections; +import java.util.List; + +import static com.ningdatech.yxt.model.cmd.SubmitTaskCallCmd.SubmitTaskCallContext; +import static com.ningdatech.yxt.model.cmd.SubmitTaskCallCmd.of; + +/** + *

+ * YxtCallOrSmsHelper + *

+ * + * @author WendyYang + * @since 23:59 2022/8/31 + */ +@Component +@AllArgsConstructor +public class YxtClientHelper { + + private final YxtClient yxtClient; + + public String submitCallTask(List callContexts) { + SubmitTaskCallResponse callResponse = yxtClient.submitTaskCall(of(callContexts)); + return callResponse.getSubmitKey(); + } + + public void sendSms(List smsList) { + SendSmsCmd cmd = new SendSmsCmd(); + cmd.setContextList(smsList); + cmd.setSmsSignEnum(YxtSmsSignEnum.LS_BIG_DATA_BUREAU); + yxtClient.submitSmsTask(cmd); + } + + public void sendSms(SendSmsContext sms) { + sendSms(Collections.singletonList(sms)); + } + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/EarlyWarningManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/EarlyWarningManage.java index 04652e8..56a150a 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/EarlyWarningManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/EarlyWarningManage.java @@ -2,7 +2,7 @@ package com.hz.pm.api.sys.manage; import com.hz.pm.api.common.enumeration.CommonEnum; import com.hz.pm.api.common.helper.UserInfoHelper; -import com.hz.pm.api.meeting.helper.YxtCallOrSmsHelper; +import com.hz.pm.api.meeting.helper.YxtClientHelper; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; import com.hz.pm.api.projectlib.model.enumeration.WarningFlowTypeEnum; @@ -20,6 +20,7 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.util.Objects; @@ -41,7 +42,7 @@ public class EarlyWarningManage { private final IEarlyWarningRecordsService earlyWarningRecordsService; - private final YxtCallOrSmsHelper yxtCallOrSmsHelper; + private final YxtClientHelper yxtClientHelper; private final INotifyService notifyService; @@ -152,30 +153,32 @@ public class EarlyWarningManage { SendSmsContext context = new SendSmsContext(); context.setReceiveNumber(user.getMobile()); context.setContent(content); - yxtCallOrSmsHelper.sendSms(context); + yxtClientHelper.sendSms(context); } } /** * 催办 * - * @param noticeMethod - * @param noticeContent - * @param adventTimeout - * @param userId - * @param project + * @param noticeMethod \ + * @param noticeContent \ + * @param adventTimeout \ + * @param userId \ + * @param project \ */ + @Transactional(rollbackFor = Exception.class) public void urging(String noticeMethod, String noticeContent, Integer adventTimeout, Integer overTimeout, Integer biz, LocalDateTime startTime, Long userId, Project project, Integer ruleType, Integer noticeType, String path, String batchEmployees, String nodeId) { //1.存入 预警记录 UserFullInfoDTO user = userInfoHelper.getUserFullInfo(userId); - WflowEarlyWarningRecords records = new WflowEarlyWarningRecords(); + WflowEarlyWarningRecords records; String content; switch (WarningRuleTypeEnum.checkByCode(ruleType)) { case PROCESS_WARNING: + records = new WflowEarlyWarningRecords(); if (Objects.isNull(noticeType)) { content = convertContent(noticeContent, project.getProjectName(), InstTypeEnum.getByCode(biz), overTimeout); @@ -189,6 +192,7 @@ public class EarlyWarningManage { records.setRuleType(WarningRuleTypeEnum.PROCESS_WARNING.getCode()); break; case DECLARED_WARNING: + records = new WflowEarlyWarningRecords(); if (Objects.isNull(noticeType)) { content = convertContent(noticeContent, project.getProjectName(), WarningFlowTypeEnum.getByCode(biz), overTimeout); @@ -202,6 +206,7 @@ public class EarlyWarningManage { records.setRuleType(WarningRuleTypeEnum.DECLARED_WARNING.getCode()); break; case OPERATION_WARNING: + records = new WflowEarlyWarningRecords(); if (Objects.isNull(noticeType)) { content = convertContent(noticeContent, project.getProjectName(), WarningOperationTypeEnum.getByCode(biz), overTimeout); @@ -215,6 +220,7 @@ public class EarlyWarningManage { records.setRuleType(WarningRuleTypeEnum.OPERATION_WARNING.getCode()); break; case RENEWAL_FUND: + records = new WflowEarlyWarningRecords(); if (Objects.isNull(noticeType)) { content = convertContent(noticeContent, project.getProjectName(), overTimeout); } else if (noticeType.equals(WarningNoticeTypeEnum.ADVENT.getCode())) { @@ -262,7 +268,7 @@ public class EarlyWarningManage { SendSmsContext context = new SendSmsContext(); context.setReceiveNumber(user.getMobile()); context.setContent(content); - yxtCallOrSmsHelper.sendSms(context); + yxtClientHelper.sendSms(context); } }