捕获站内信通知异常

This commit is contained in:
wangliwen 2022-07-07 14:58:09 +08:00
parent 2041c6b558
commit ca667cb116
1 changed files with 41 additions and 33 deletions

View File

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