diff --git a/renren-admin/src/main/java/io/renren/common/aspect/ActivitiNoticeAspect.java b/renren-admin/src/main/java/io/renren/common/aspect/ActivitiNoticeAspect.java index 8d0aba13..ccd584b8 100644 --- a/renren-admin/src/main/java/io/renren/common/aspect/ActivitiNoticeAspect.java +++ b/renren-admin/src/main/java/io/renren/common/aspect/ActivitiNoticeAspect.java @@ -44,7 +44,7 @@ import java.util.concurrent.Executors; @Component public class ActivitiNoticeAspect { private static Integer cpuNUm = Runtime.getRuntime().availableProcessors(); - private static final ExecutorService executor = Executors.newFixedThreadPool(cpuNUm); + private static final ExecutorService executor = Executors.newWorkStealingPool(cpuNUm * 3); private static Logger logger = LoggerFactory.getLogger(ActivitiNoticeAspect.class); @Autowired private SysNoticeService sysNoticeService; @@ -327,39 +327,47 @@ public class ActivitiNoticeAspect { try { String finalCreator = creator; CompletableFuture.runAsync(() -> { // 发起人 - SysUserDTO assignee = sysUserService.get(Long.valueOf(delegateTask.getAssignee())); - logger.error("审核人:" + assignee.getId()); - String content = "【通知】您发起的流程 " + activitiNoticeOperation.process() + " 当前审核节点为:" + activitiNoticeOperation.value() + ";当前审核人为:\"" + assignee.getDeptName() + "\"审核负责人\"" + assignee.getRealName() + "\""; - logger.info("通知内容:" + content); - SysNoticeDTO dto = new SysNoticeDTO(); - dto.setType(2); - dto.setTitle("流程流转系统通知"); - dto.setContent(content); // 通知内容 - dto.setReceiverType(1); - dto.setReceiverTypeIds(finalCreator); - dto.setStatus(NoticeStatusEnum.SEND.value()); - dto.setSenderName("流程系统"); - dto.setSenderDate(new Date()); - dto.setCreator(sysUserService.getByUsername("admin").getId()); - dto.setCreateDate(new Date()); - dto.setFrom("通知"); - sysNoticeService.save(dto); + try { + SysUserDTO assignee = sysUserService.get(Long.valueOf(delegateTask.getAssignee())); + logger.error("审核人:" + assignee.getId()); + String content = "【通知】您发起的流程 " + activitiNoticeOperation.process() + " 当前审核节点为:" + activitiNoticeOperation.value() + ";当前审核人为:\"" + assignee.getDeptName() + "\"审核负责人\"" + assignee.getRealName() + "\""; + logger.info("通知内容:" + content); + SysNoticeDTO dto = new SysNoticeDTO(); + dto.setType(2); + dto.setTitle("流程流转系统通知"); + dto.setContent(content); // 通知内容 + dto.setReceiverType(1); + dto.setReceiverTypeIds(finalCreator); + dto.setStatus(NoticeStatusEnum.SEND.value()); + dto.setSenderName("流程系统"); + dto.setSenderDate(new Date()); + dto.setCreator(sysUserService.getByUsername("admin").getId()); + dto.setCreateDate(new Date()); + dto.setFrom("通知"); + sysNoticeService.save(dto); + } catch (Exception exception) { + logger.error("通知发起人失败", exception); + } }, executor).thenRunAsync(() -> { // 审批者 - SysUserDTO owner = sysUserService.get(Long.valueOf(finalCreator)); - String content = "【通知】" + owner.getRealName() + "发起的流程" + activitiNoticeOperation.process() + "已进入审核节点:" + activitiNoticeOperation.value() + ";当前审核人指派为您"; - SysNoticeDTO dto = new SysNoticeDTO(); - dto.setType(2); - dto.setTitle("流程流转系统通知"); - dto.setContent(content); // 通知内容 - dto.setReceiverType(1); - dto.setReceiverTypeIds(delegateTask.getAssignee()); - dto.setStatus(NoticeStatusEnum.SEND.value()); - dto.setSenderName("流程系统"); - dto.setSenderDate(new Date()); - dto.setCreator(sysUserService.getByUsername("admin").getId()); - dto.setCreateDate(new Date()); - dto.setFrom("通知"); - sysNoticeService.save(dto); + try { + SysUserDTO owner = sysUserService.get(Long.valueOf(finalCreator)); + String content = "【通知】" + owner.getRealName() + "发起的流程" + activitiNoticeOperation.process() + "已进入审核节点:" + activitiNoticeOperation.value() + ";当前审核人指派为您"; + SysNoticeDTO dto = new SysNoticeDTO(); + dto.setType(2); + dto.setTitle("流程流转系统通知"); + dto.setContent(content); // 通知内容 + dto.setReceiverType(1); + dto.setReceiverTypeIds(delegateTask.getAssignee()); + dto.setStatus(NoticeStatusEnum.SEND.value()); + dto.setSenderName("流程系统"); + dto.setSenderDate(new Date()); + dto.setCreator(sysUserService.getByUsername("admin").getId()); + dto.setCreateDate(new Date()); + dto.setFrom("通知"); + sysNoticeService.save(dto); + } catch (Exception exception) { + logger.error("通知审批人失败", exception); + } }, executor); } catch (Exception e) { logger.error("发送通知消息异常", e);