优化监听器事件,移除错误的流程始末事件
This commit is contained in:
@@ -93,9 +93,8 @@ public abstract class FlowableManager {
|
||||
.extra(extra)
|
||||
.build();
|
||||
repository.saveInstance(instance);
|
||||
callListeners(node.getListeners(), listener -> listener.onFlowStart(instance, node));
|
||||
if (FlowableNode.Type.AUTOMATIC.equals(node.getType())) {
|
||||
automaticAction(instance, node);
|
||||
automaticAction(instance);
|
||||
}
|
||||
return instance.getInstanceId();
|
||||
}
|
||||
@@ -141,15 +140,15 @@ public abstract class FlowableManager {
|
||||
if (MapHelper.isNotEmpty(metadata)) {
|
||||
instance.getMetadata().putAll(metadata);
|
||||
}
|
||||
action(instance, action, comment);
|
||||
}
|
||||
|
||||
private void automaticAction(FlowableInstance instance) {
|
||||
action(instance, null, "系统自动执行");
|
||||
}
|
||||
|
||||
private void action(FlowableInstance instance, final FlowableAction inputAction, String comment) {
|
||||
FlowableNode node = repository.getNode(instance.getCurrentNodeId());
|
||||
action(instance, node, action, comment);
|
||||
}
|
||||
|
||||
private void automaticAction(FlowableInstance instance, FlowableNode node) {
|
||||
action(instance, node, null, "系统自动执行");
|
||||
}
|
||||
|
||||
private void action(FlowableInstance instance, FlowableNode node, final FlowableAction inputAction, String comment) {
|
||||
String handlerClass = node.getHandler();
|
||||
if (StringHelper.isBlank(handlerClass)) {
|
||||
throw new IllegalArgumentException("节点执行器为空");
|
||||
@@ -185,14 +184,14 @@ public abstract class FlowableManager {
|
||||
|
||||
if (FlowableAction.TERMINAL.equals(action)) {
|
||||
saveInstance(instance, FlowableInstance.Status.TERMINAL, action, comment);
|
||||
callListeners(node.getListeners(), listener -> listener.onFlowEnd(instance, node, action));
|
||||
callListeners(node.getListeners(), listener -> listener.onActionComplete(instance, node, action));
|
||||
return;
|
||||
}
|
||||
if (Objects.isNull(node.getTargets())
|
||||
|| !node.getTargets().containsKey(action)
|
||||
|| StringHelper.isBlank(node.getTargets().get(action))) {
|
||||
saveInstance(instance, FlowableInstance.Status.COMPLETED, action, comment);
|
||||
callListeners(node.getListeners(), listener -> listener.onFlowEnd(instance, node, action));
|
||||
callListeners(node.getListeners(), listener -> listener.onActionComplete(instance, node, action));
|
||||
return;
|
||||
}
|
||||
String nextNodeId = node.getTargets().get(action);
|
||||
@@ -202,7 +201,7 @@ public abstract class FlowableManager {
|
||||
|
||||
callListeners(node.getListeners(), listener -> listener.onActionComplete(instance, node, action));
|
||||
if (FlowableNode.Type.AUTOMATIC.equals(nextNode.getType())) {
|
||||
automaticAction(instance, nextNode);
|
||||
automaticAction(instance);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,6 @@ package com.lanyuanxiaoyao.flowable.core.model;
|
||||
* @version 20241231
|
||||
*/
|
||||
public interface FlowableListener {
|
||||
void onFlowStart(FlowableInstance instance, FlowableNode node);
|
||||
|
||||
void onFlowEnd(FlowableInstance instance, FlowableNode node, FlowableAction action);
|
||||
|
||||
void onActionStart(FlowableInstance instance, FlowableNode node, FlowableAction action);
|
||||
|
||||
void onAction(FlowableInstance instance, FlowableNode node, FlowableAction action);
|
||||
@@ -18,14 +14,6 @@ public interface FlowableListener {
|
||||
void onActionComplete(FlowableInstance instance, FlowableNode node, FlowableAction action);
|
||||
|
||||
abstract class AbstractFlowableListener implements FlowableListener {
|
||||
@Override
|
||||
public void onFlowStart(FlowableInstance instance, FlowableNode node) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFlowEnd(FlowableInstance instance, FlowableNode node, FlowableAction action) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActionStart(FlowableInstance instance, FlowableNode node, FlowableAction action) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user