Explorar el Código

提醒任务修改

tags/24080901
WendyYang hace 6 meses
padre
commit
df9c2bfd64
Se han modificado 1 ficheros con 39 adiciones y 41 borrados
  1. +39
    -41
      hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/DeclaredRecordAbstractReminderTask.java

+ 39
- 41
hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/DeclaredRecordAbstractReminderTask.java Ver fichero

@@ -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<String, UnitDTO> unitMap = CollUtils.listToMap(units, w -> String.valueOf(w.getId()));
List<MhTodoRecord> todoRecords = todoRecordService.list(DECLARED_RECORD_APPLY, projectCodes);
Map<String, MhTodoRecord> todoRecordMap = CollUtils.listToMap(todoRecords, MhTodoRecord::getBizId);
List<UserFullInfoDTO> userFullInfos = userInfoHelper.listUserFullInfoByUnitIdsAndRole(buildOrgCodes, RoleEnum.COMPANY_MANAGER);
if (userFullInfos.isEmpty()) {
List<UserFullInfoDTO> users = userInfoHelper.listUserFullInfoByUnitIdsAndRole(buildOrgCodes, RoleEnum.COMPANY_MANAGER);
if (users.isEmpty()) {
return;
}
Map<String, List<UserFullInfoDTO>> userMap = CollUtils.group(userFullInfos, UserFullInfoDTO::getMhUnitIdStr);
Map<String, List<UserFullInfoDTO>> userMap = CollUtils.group(users, UserFullInfoDTO::getMhUnitIdStr);
for (Project project : projects) {
try {
String projectCode = project.getProjectCode();
Optional<Long> mhProjectId = mhProjectService.getIdByProjectCode(projectCode);
if (!mhProjectId.isPresent()) {
continue;
}
String buildOrgCode = project.getBuildOrgCode();
UnitDTO unit = unitMap.get(buildOrgCode);
if (unit == null) {
continue;
}
List<UserFullInfoDTO> 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<UserFullInfoDTO> 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<UserFullInfoDTO> currUnitUsers, Map<String, MhTodoRecord> todoRecordMap, String projectCode, Optional<Long> 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);
}
}
}

}

Cargando…
Cancelar
Guardar