From df9c2bfd641832a4decd01fd10574fd68fa35831 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Wed, 17 Apr 2024 17:26:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E9=86=92=E4=BB=BB=E5=8A=A1=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../task/DeclaredRecordAbstractReminderTask.java | 80 +++++++++++----------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/DeclaredRecordAbstractReminderTask.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/DeclaredRecordAbstractReminderTask.java index 58375d9..a0d590c 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/DeclaredRecordAbstractReminderTask.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/DeclaredRecordAbstractReminderTask.java @@ -5,7 +5,6 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hz.pm.api.common.helper.UserInfoHelper; -import com.hz.pm.api.common.util.ThreadPoolUtil; import com.hz.pm.api.external.MhApiClient; import com.hz.pm.api.external.model.dto.MhZwddWorkNoticeDTO; import com.hz.pm.api.external.todo.MHTodoClient; @@ -23,10 +22,8 @@ import com.hz.pm.api.user.security.model.UserFullInfoDTO; import com.ningdatech.basic.util.CollUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.core.env.Environment; -import org.springframework.scheduling.support.CronTrigger; import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; import java.util.List; import java.util.Map; import java.util.Optional; @@ -102,51 +99,23 @@ public class DeclaredRecordAbstractReminderTask extends AbstractReminderTask { Map unitMap = CollUtils.listToMap(units, w -> String.valueOf(w.getId())); List todoRecords = todoRecordService.list(DECLARED_RECORD_APPLY, projectCodes); Map todoRecordMap = CollUtils.listToMap(todoRecords, MhTodoRecord::getBizId); - List userFullInfos = userInfoHelper.listUserFullInfoByUnitIdsAndRole(buildOrgCodes, RoleEnum.COMPANY_MANAGER); - if (userFullInfos.isEmpty()) { + List users = userInfoHelper.listUserFullInfoByUnitIdsAndRole(buildOrgCodes, RoleEnum.COMPANY_MANAGER); + if (users.isEmpty()) { return; } - Map> userMap = CollUtils.group(userFullInfos, UserFullInfoDTO::getMhUnitIdStr); + Map> userMap = CollUtils.group(users, UserFullInfoDTO::getMhUnitIdStr); for (Project project : projects) { try { String projectCode = project.getProjectCode(); Optional mhProjectId = mhProjectService.getIdByProjectCode(projectCode); - if (!mhProjectId.isPresent()) { - continue; - } - String buildOrgCode = project.getBuildOrgCode(); - UnitDTO unit = unitMap.get(buildOrgCode); - if (unit == null) { - continue; - } - List currUnitUsers = userMap.get(buildOrgCode); - if (currUnitUsers == null) { - continue; - } - String content = String.format(MSG_FMT, project.getProjectName()); - for (UserFullInfoDTO user : currUnitUsers) { - try { - if (todoRecordMap.containsKey(project.getProjectCode())) { - MhZwddWorkNoticeDTO notice = MhZwddWorkNoticeDTO.builder() - .title(DECLARED_RECORD_APPLY.getVal()) - .content(content) - .targetUser(user.getMhUserId()) - .build(); - mhApiClient.sendZwddWorkNotice(notice); - } else { - MhTodoExtraParamDTO paramObj = MhTodoExtraParamDTO.builder() - .projectId(project.getId()) - .projectCode(projectCode) - .mhProjectId(mhProjectId.get()) - .status(project.getStatus()) - .path("/declareManage/projectFilingEdit") - .userId(user.getUserId()) - .userName(user.getRealName()) - .build(); - mhTodoClient.addTodo(paramObj, user, DECLARED_RECORD_APPLY, projectCode, content); + if (mhProjectId.isPresent()) { + String buildOrgCode = project.getBuildOrgCode(); + if (unitMap.containsKey(buildOrgCode) && userMap.containsKey(buildOrgCode)) { + List currUnitUsers = userMap.get(buildOrgCode); + if (currUnitUsers == null) { + continue; } - } catch (Exception e) { - log.error("立项备案提醒发送失败:{}", project.getProjectCode(), e); + sendNoticeToAuditor(project, currUnitUsers, todoRecordMap, projectCode, mhProjectId); } } } catch (Exception e) { @@ -155,4 +124,33 @@ public class DeclaredRecordAbstractReminderTask extends AbstractReminderTask { } } + private void sendNoticeToAuditor(Project project, List currUnitUsers, Map todoRecordMap, String projectCode, Optional mhProjectId) { + String content = String.format(MSG_FMT, project.getProjectName()); + for (UserFullInfoDTO user : currUnitUsers) { + try { + if (todoRecordMap.containsKey(project.getProjectCode())) { + MhZwddWorkNoticeDTO notice = MhZwddWorkNoticeDTO.builder() + .title(DECLARED_RECORD_APPLY.getVal()) + .content(content) + .targetUser(user.getMhUserId()) + .build(); + mhApiClient.sendZwddWorkNotice(notice); + } else { + MhTodoExtraParamDTO paramObj = MhTodoExtraParamDTO.builder() + .projectId(project.getId()) + .projectCode(projectCode) + .mhProjectId(mhProjectId.get()) + .status(project.getStatus()) + .path("/declareManage/projectFilingEdit") + .userId(user.getUserId()) + .userName(user.getRealName()) + .build(); + mhTodoClient.addTodo(paramObj, user, DECLARED_RECORD_APPLY, projectCode, content); + } + } catch (Exception e) { + log.error("立项备案提醒发送失败:{}", project.getProjectCode(), e); + } + } + } + }