捕获站内信通知异常

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
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);