From ca667cb116b1d5c9b242265edb268a9e14ac72ec Mon Sep 17 00:00:00 2001 From: wangliwen Date: Thu, 7 Jul 2022 14:58:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8D=95=E8=8E=B7=E7=AB=99=E5=86=85=E4=BF=A1?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/aspect/ActivitiNoticeAspect.java | 74 ++++++++++--------- 1 file changed, 41 insertions(+), 33 deletions(-) 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);