|
@@ -137,42 +137,24 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
|
|
@Override
|
|
@Override
|
|
public void afterCommit() {
|
|
public void afterCommit() {
|
|
Notify notify = new Notify();
|
|
Notify notify = new Notify();
|
|
- // notify.setContent(String.format("您有一条待处理的审批任务【%s】,请及时处理。", entity.getName()));
|
|
|
|
String instanceId = entity.getProcessInstanceId();
|
|
String instanceId = entity.getProcessInstanceId();
|
|
FormInfo form = flowInstanceService.getForm(instanceId);
|
|
FormInfo form = flowInstanceService.getForm(instanceId);
|
|
String fromName = form.getFlowDefine().getName();
|
|
String fromName = form.getFlowDefine().getName();
|
|
String startUserId = form.getStartUserId();
|
|
String startUserId = form.getStartUserId();
|
|
|
|
|
|
notify.setSubject("新的审批任务" + "-" + fromName);
|
|
notify.setSubject("新的审批任务" + "-" + fromName);
|
|
-
|
|
|
|
- // 审批节点
|
|
|
|
notify.setContent(fromName + "-" + entity.getName());
|
|
notify.setContent(fromName + "-" + entity.getName());
|
|
|
|
|
|
- // 获取流程定义-判断是否为最后一个节点
|
|
|
|
- ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
|
|
|
|
- .processDefinitionId(execution.getProcessDefinitionId())
|
|
|
|
- .singleResult();
|
|
|
|
-
|
|
|
|
- // 获取流程定义中的所有流元素-判断是否为最后一个节点
|
|
|
|
- BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
|
|
|
|
- Collection<FlowElement> flowElements = bpmnModel.getMainProcess().getFlowElements();
|
|
|
|
-
|
|
|
|
- // 获取最后一个节点(结束事件)的 ID
|
|
|
|
- String endActivityId = null;
|
|
|
|
- for (FlowElement flowElement : flowElements) {
|
|
|
|
- if (flowElement instanceof EndEvent) {
|
|
|
|
- endActivityId = flowElement.getId();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- log.info("flowElement.getId: {}", endActivityId);
|
|
|
|
- log.info("currentFlowElement.getId: {}", currentFlowElement.getId());
|
|
|
|
|
|
+ // 获取 BPMN 模型
|
|
|
|
+ BpmnModel bpmnModel = repositoryService.getBpmnModel(execution.getProcessDefinitionId());
|
|
|
|
+ // 获取当前节点
|
|
|
|
+ FlowElement currentFlowElement = bpmnModel.getFlowElement(execution.getCurrentActivityId());
|
|
|
|
|
|
- // 判断是否是最后一个节点
|
|
|
|
- if ("end".equals(endActivityId)) {
|
|
|
|
|
|
+ // 判断是否是最后一个节点(结束事件)
|
|
|
|
+ if (currentFlowElement instanceof EndEvent) {
|
|
// 最后一个节点,消息发送人为当前登录用户
|
|
// 最后一个节点,消息发送人为当前登录用户
|
|
String username = Objects.requireNonNull(SecurityContextUtil.getUserInfo()).getUsername();
|
|
String username = Objects.requireNonNull(SecurityContextUtil.getUserInfo()).getUsername();
|
|
- log.info("这是最后一个节点,登录用户{}", username);
|
|
|
|
|
|
+ log.info("这是最后一个节点,登录用户: {}", username);
|
|
notify.setSender(username);
|
|
notify.setSender(username);
|
|
} else {
|
|
} else {
|
|
// 其余节点,消息发送人为发起人
|
|
// 其余节点,消息发送人为发起人
|
|
@@ -180,17 +162,13 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
|
|
}
|
|
}
|
|
|
|
|
|
notify.setType(NotifyEnum.TODO);
|
|
notify.setType(NotifyEnum.TODO);
|
|
- // 接收者 entity.getAssignee() 下一节点的审批人
|
|
|
|
notify.setReceiver(entity.getAssignee());
|
|
notify.setReceiver(entity.getAssignee());
|
|
notify.setReceivingTime(LocalDateTime.now());
|
|
notify.setReceivingTime(LocalDateTime.now());
|
|
notify.setUrl("/flow/todo");
|
|
notify.setUrl("/flow/todo");
|
|
notifyService.notify(notify);
|
|
notifyService.notify(notify);
|
|
|
|
|
|
- log.info("登录用户:{}", SecurityContextUtil.getUserId());
|
|
|
|
- log.info("Assignee:{}", entity.getAssignee());
|
|
|
|
- log.info("Owner:{}", entity.getOwner());
|
|
|
|
- log.info("LocalizedName:{}", entity.getLocalizedName());
|
|
|
|
- log.info("EventName:{}", entity.getEventName());
|
|
|
|
|
|
+ log.info("当前节点 ID: {}", execution.getCurrentActivityId());
|
|
|
|
+ log.info("当前节点类型: {}", currentFlowElement.getClass().getSimpleName());
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|