站内信消息通知优化

This commit is contained in:
wangliwen 2022-05-31 10:20:20 +08:00
parent 12dcb9910d
commit 425f6d30a6
7 changed files with 56 additions and 42 deletions

View File

@ -13,9 +13,16 @@ import java.lang.annotation.*;
public @interface ActivitiNoticeOperation { public @interface ActivitiNoticeOperation {
/** /**
* 流程名称 * 节点名称
* *
* @return * @return
*/ */
String value() default ""; String value() default "";
/**
* 流程名称
*
* @return
*/
String process() default "";
} }

View File

@ -5,6 +5,7 @@ import io.renren.common.annotation.ActivitiNoticeOperation;
import io.renren.modules.notice.dto.SysNoticeDTO; import io.renren.modules.notice.dto.SysNoticeDTO;
import io.renren.modules.notice.enums.NoticeStatusEnum; import io.renren.modules.notice.enums.NoticeStatusEnum;
import io.renren.modules.notice.service.SysNoticeService; import io.renren.modules.notice.service.SysNoticeService;
import io.renren.modules.sys.dto.SysUserDTO;
import io.renren.modules.sys.service.SysUserService; import io.renren.modules.sys.service.SysUserService;
import org.activiti.engine.delegate.DelegateTask; import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener; import org.activiti.engine.delegate.TaskListener;
@ -92,10 +93,15 @@ public class ActivitiNoticeAspect {
try { try {
String finalCreator = creator; String finalCreator = creator;
CompletableFuture.runAsync(() -> { // 发起人 CompletableFuture.runAsync(() -> { // 发起人
SysUserDTO assignee = sysUserService.get(Long.valueOf(delegateTask.getAssignee()));
String content = "您发起的流程<" + activitiNoticeOperation.process() + ">当前审核节点为:" +
activitiNoticeOperation.value() +
"<br>当前审核人为\"" +
assignee.getDeptName() + "\"审核负责人\"" + assignee.getRealName();
SysNoticeDTO dto = new SysNoticeDTO(); SysNoticeDTO dto = new SysNoticeDTO();
dto.setType(2); dto.setType(2);
dto.setTitle("流程流转系统通知"); dto.setTitle("流程流转系统通知");
dto.setContent("您发起的流程当前审核节点为:" + activitiNoticeOperation.value() + "<br>当前审核人为" + sysUserService.get(Long.valueOf(delegateTask.getAssignee())).getRealName()); // 通知内容 dto.setContent(content); // 通知内容
dto.setReceiverType(1); dto.setReceiverType(1);
dto.setReceiverTypeIds(finalCreator); dto.setReceiverTypeIds(finalCreator);
dto.setStatus(NoticeStatusEnum.SEND.value()); dto.setStatus(NoticeStatusEnum.SEND.value());
@ -105,10 +111,12 @@ public class ActivitiNoticeAspect {
dto.setCreateDate(new Date()); dto.setCreateDate(new Date());
sysNoticeService.save(dto); sysNoticeService.save(dto);
}).thenRunAsync(() -> { // 审批者 }).thenRunAsync(() -> { // 审批者
SysUserDTO owner = sysUserService.get(Long.valueOf(finalCreator));
String content = owner.getRealName() + "发起的流程<" + activitiNoticeOperation.process() + ">当前审核节点为:" + activitiNoticeOperation.value() + "<br>当前审核人指派为您";
SysNoticeDTO dto = new SysNoticeDTO(); SysNoticeDTO dto = new SysNoticeDTO();
dto.setType(2); dto.setType(2);
dto.setTitle("流程流转系统通知"); dto.setTitle("流程流转系统通知");
dto.setContent(sysUserService.get(Long.valueOf(finalCreator)).getRealName() + "发起的流程当前审核节点为:" + activitiNoticeOperation.value() + "<br>当前审核人指派为您"); // 通知内容 dto.setContent(content); // 通知内容
dto.setReceiverType(1); dto.setReceiverType(1);
dto.setReceiverTypeIds(delegateTask.getAssignee()); dto.setReceiverTypeIds(delegateTask.getAssignee());
dto.setStatus(NoticeStatusEnum.SEND.value()); dto.setStatus(NoticeStatusEnum.SEND.value());
@ -117,15 +125,14 @@ public class ActivitiNoticeAspect {
dto.setCreator(sysUserService.getByUsername("admin").getId()); dto.setCreator(sysUserService.getByUsername("admin").getId());
dto.setCreateDate(new Date()); dto.setCreateDate(new Date());
sysNoticeService.save(dto); sysNoticeService.save(dto);
}) }).thenRunAsync(() -> { // 防止重放
.thenRunAsync(() -> {
new Thread(() -> { new Thread(() -> {
try { try {
Thread.sleep(200); Thread.sleep(200);
work_.remove(kv.get("id").toString());
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
work_.remove(kv.get("id").toString());
}).start(); }).start();
}); });
} catch (Exception e) { } catch (Exception e) {

View File

@ -76,7 +76,7 @@ public class DemandDataListener implements TaskListener, ExecutionListener, Acti
} }
@Override @Override
@ActivitiNoticeOperation("需求部门审批") @ActivitiNoticeOperation(value = "需求部门审批", process = "能力需求申请")
public void notify(DelegateTask delegateTask) { public void notify(DelegateTask delegateTask) {
logger.error("----------------------进入能力需求受理者1节点---------------------------"); logger.error("----------------------进入能力需求受理者1节点---------------------------");
logger.error("事件类型:" + delegateTask.getEventName()); logger.error("事件类型:" + delegateTask.getEventName());

View File

@ -67,7 +67,7 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
private TAbilityApplicationService tAbilityApplicationService; private TAbilityApplicationService tAbilityApplicationService;
@Override @Override
@ActivitiNoticeOperation("资源部门负责人审批") @ActivitiNoticeOperation(value = "资源部门负责人审批", process = "能力申请流程")
public void notify(DelegateTask delegateTask) { public void notify(DelegateTask delegateTask) {
logger.error("-------------------------进入部门动态审批人流程-------------------------------"); logger.error("-------------------------进入部门动态审批人流程-------------------------------");
final String eventName = delegateTask.getEventName(); final String eventName = delegateTask.getEventName();

View File

@ -66,7 +66,7 @@ public class DataCenterListener implements TaskListener, ExecutionListener, Acti
} }
@Override @Override
@ActivitiNoticeOperation("大数据局负责人审批") @ActivitiNoticeOperation(value = "大数据局负责人审批", process = "能力申请流程")
public void notify(DelegateTask delegateTask) { public void notify(DelegateTask delegateTask) {
logger.error("事件类型:" + delegateTask.getEventName()); logger.error("事件类型:" + delegateTask.getEventName());
final String eventName = delegateTask.getEventName(); final String eventName = delegateTask.getEventName();

View File

@ -55,7 +55,7 @@ public class ResourceUndercarriageListener implements TaskListener, ExecutionLis
private ResourceService resourceService; private ResourceService resourceService;
@Override @Override
@ActivitiNoticeOperation("资源下线前资源所属部门审批人审批") @ActivitiNoticeOperation(value = "资源下线前资源所属部门审批人审批", process = "能力资源下架")
public void notify(DelegateTask delegateTask) { public void notify(DelegateTask delegateTask) {
logger.error("----------------------进入资源所有者节点---------------------------"); logger.error("----------------------进入资源所有者节点---------------------------");
logger.error("事件类型:" + delegateTask.getEventName()); logger.error("事件类型:" + delegateTask.getEventName());

View File

@ -75,7 +75,7 @@ public class ResourceOwnerListener implements TaskListener, ExecutionListener, A
} }
@Override @Override
@ActivitiNoticeOperation("资源所属部门审批人审批") @ActivitiNoticeOperation(value = "资源所属部门审批人审批", process = "能力资源上架")
public void notify(DelegateTask delegateTask) { public void notify(DelegateTask delegateTask) {
logger.error("----------------------进入资源所有者节点---------------------------"); logger.error("----------------------进入资源所有者节点---------------------------");
logger.error("事件类型:" + delegateTask.getEventName()); logger.error("事件类型:" + delegateTask.getEventName());