This commit is contained in:
sxu 2025-03-14 14:19:02 +08:00
parent d6517cfcb8
commit e4d8dc7cad
10 changed files with 201 additions and 19 deletions

View File

@ -5,6 +5,8 @@ import com.google.common.collect.Maps;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import lombok.Generated;
import net.xnzn.framework.flow.exception.TerminateStateException;
import net.xnzn.framework.flow.exception.UnmatchedScopeException;
import net.xnzn.framework.flow.instance.Event;
@ -25,6 +27,7 @@ import org.springframework.stereotype.Service;
@Service
public class Flow implements BeanPostProcessor {
@Generated
private static final Logger log = LoggerFactory.getLogger(Flow.class);
private static final ExpressionParser EXPRESSION_PARSER = new SpelExpressionParser();
private static final Map<String, EventCallback> EVENT_CALLBACK = Maps.newHashMap();
@ -146,12 +149,20 @@ public class Flow implements BeanPostProcessor {
}
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof RedissonClient) {
redissonClient = (RedissonClient)bean;
} else if (bean instanceof FlowService) {
flowService = (FlowService)bean;
} else if (bean instanceof EventCallback) {
EVENT_CALLBACK.put(((EventCallback)bean).supportedType(), (EventCallback)bean);
Objects.requireNonNull(bean);
byte var4 = 0;
switch (((Class)bean).typeSwitch<invokedynamic>(bean, var4)) {
case 0:
RedissonClient client = (RedissonClient)bean;
redissonClient = client;
break;
case 1:
FlowService service = (FlowService)bean;
flowService = service;
break;
case 2:
EventCallback eventCallback = (EventCallback)bean;
EVENT_CALLBACK.put(eventCallback.supportedType(), eventCallback);
}
return super.postProcessAfterInitialization(bean, beanName);

View File

@ -1,6 +1,7 @@
package net.xnzn.framework.flow;
import java.util.List;
import lombok.Generated;
public class FlowNode {
private long flowId;
@ -36,78 +37,95 @@ public class FlowNode {
return this.isTask() ? this.logical : null;
}
@Generated
public FlowNode() {
this.logical = AuditLogical.OR;
}
@Generated
public long getFlowId() {
return this.flowId;
}
@Generated
public Long getId() {
return this.id;
}
@Generated
public String getName() {
return this.name;
}
@Generated
public NodeType getType() {
return this.type;
}
@Generated
public String getExpression() {
return this.expression;
}
@Generated
public Long getTo() {
return this.to;
}
@Generated
public List<Scope> getScope() {
return this.scope;
}
@Generated
public FlowNode setFlowId(final long flowId) {
this.flowId = flowId;
return this;
}
@Generated
public FlowNode setId(final Long id) {
this.id = id;
return this;
}
@Generated
public FlowNode setName(final String name) {
this.name = name;
return this;
}
@Generated
public FlowNode setType(final NodeType type) {
this.type = type;
return this;
}
@Generated
public FlowNode setExpression(final String expression) {
this.expression = expression;
return this;
}
@Generated
public FlowNode setTo(final Long to) {
this.to = to;
return this;
}
@Generated
public FlowNode setScope(final List<Scope> scope) {
this.scope = scope;
return this;
}
@Generated
public FlowNode setLogical(final AuditLogical logical) {
this.logical = logical;
return this;
}
@Generated
public boolean equals(final Object o) {
if (o == this) {
return true;
@ -203,10 +221,12 @@ public class FlowNode {
}
}
@Generated
protected boolean canEqual(final Object other) {
return other instanceof FlowNode;
}
@Generated
public int hashCode() {
int PRIME = true;
int result = 1;
@ -229,6 +249,7 @@ public class FlowNode {
return result;
}
@Generated
public String toString() {
long var10000 = this.getFlowId();
return "FlowNode(flowId=" + var10000 + ", id=" + this.getId() + ", name=" + this.getName() + ", type=" + String.valueOf(this.getType()) + ", expression=" + this.getExpression() + ", to=" + this.getTo() + ", scope=" + String.valueOf(this.getScope()) + ", logical=" + String.valueOf(this.getLogical()) + ")";
@ -258,42 +279,51 @@ public class FlowNode {
this.scope = scope;
}
@Generated
public Long getFlowId() {
return this.flowId;
}
@Generated
public Long getNodeId() {
return this.nodeId;
}
@Generated
public String getName() {
return this.name;
}
@Generated
public String getScope() {
return this.scope;
}
@Generated
public Scope setFlowId(final Long flowId) {
this.flowId = flowId;
return this;
}
@Generated
public Scope setNodeId(final Long nodeId) {
this.nodeId = nodeId;
return this;
}
@Generated
public Scope setName(final String name) {
this.name = name;
return this;
}
@Generated
public Scope setScope(final String scope) {
this.scope = scope;
return this;
}
@Generated
public boolean equals(final Object o) {
if (o == this) {
return true;
@ -353,10 +383,12 @@ public class FlowNode {
}
}
@Generated
protected boolean canEqual(final Object other) {
return other instanceof Scope;
}
@Generated
public int hashCode() {
int PRIME = true;
int result = 1;
@ -371,14 +403,17 @@ public class FlowNode {
return result;
}
@Generated
public String toString() {
Long var10000 = this.getFlowId();
return "FlowNode.Scope(flowId=" + var10000 + ", nodeId=" + this.getNodeId() + ", name=" + this.getName() + ", scope=" + this.getScope() + ")";
}
@Generated
public Scope() {
}
@Generated
public Scope(final Long flowId, final Long nodeId, final String name, final String scope) {
this.flowId = flowId;
this.nodeId = nodeId;

View File

@ -10,6 +10,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.Generated;
import net.xnzn.framework.flow.definition.Definition;
import net.xnzn.framework.flow.definition.DefinitionFilter;
import net.xnzn.framework.flow.definition.DefinitionMapper;
@ -28,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class FlowService {
@Generated
private static final Logger log = LoggerFactory.getLogger(FlowService.class);
@Autowired
InstanceMapper instanceMapper;

View File

@ -2,6 +2,7 @@ package net.xnzn.framework.flow.definition;
import java.time.LocalDateTime;
import java.util.List;
import lombok.Generated;
public class Definition {
private Long id;
@ -10,51 +11,62 @@ public class Definition {
private LocalDateTime createTime;
private List<Node> node;
@Generated
public Long getId() {
return this.id;
}
@Generated
public String getName() {
return this.name;
}
@Generated
public String getType() {
return this.type;
}
@Generated
public LocalDateTime getCreateTime() {
return this.createTime;
}
@Generated
public List<Node> getNode() {
return this.node;
}
@Generated
public Definition setId(final Long id) {
this.id = id;
return this;
}
@Generated
public Definition setName(final String name) {
this.name = name;
return this;
}
@Generated
public Definition setType(final String type) {
this.type = type;
return this;
}
@Generated
public Definition setCreateTime(final LocalDateTime createTime) {
this.createTime = createTime;
return this;
}
@Generated
public Definition setNode(final List<Node> node) {
this.node = node;
return this;
}
@Generated
public boolean equals(final Object o) {
if (o == this) {
return true;
@ -128,10 +140,12 @@ public class Definition {
}
}
@Generated
protected boolean canEqual(final Object other) {
return other instanceof Definition;
}
@Generated
public int hashCode() {
int PRIME = true;
int result = 1;
@ -148,6 +162,7 @@ public class Definition {
return result;
}
@Generated
public String toString() {
Long var10000 = this.getId();
return "Definition(id=" + var10000 + ", name=" + this.getName() + ", type=" + this.getType() + ", createTime=" + String.valueOf(this.getCreateTime()) + ", node=" + String.valueOf(this.getNode()) + ")";

View File

@ -1,27 +1,33 @@
package net.xnzn.framework.flow.definition;
import java.util.Set;
import lombok.Generated;
public class DefinitionFilter {
private String name;
private Set<String> types;
@Generated
public String getName() {
return this.name;
}
@Generated
public Set<String> getTypes() {
return this.types;
}
@Generated
public void setName(final String name) {
this.name = name;
}
@Generated
public void setTypes(final Set<String> types) {
this.types = types;
}
@Generated
public boolean equals(final Object o) {
if (o == this) {
return true;
@ -57,10 +63,12 @@ public class DefinitionFilter {
}
}
@Generated
protected boolean canEqual(final Object other) {
return other instanceof DefinitionFilter;
}
@Generated
public int hashCode() {
int PRIME = true;
int result = 1;
@ -71,6 +79,7 @@ public class DefinitionFilter {
return result;
}
@Generated
public String toString() {
String var10000 = this.getName();
return "DefinitionFilter(name=" + var10000 + ", types=" + String.valueOf(this.getTypes()) + ")";

View File

@ -1,5 +1,6 @@
package net.xnzn.framework.flow.definition;
import lombok.Generated;
import net.xnzn.framework.flow.FlowNode;
public class Node extends FlowNode {
@ -14,6 +15,7 @@ public class Node extends FlowNode {
return !this.isTask() && !this.isForward() ? null : this.participantFrom;
}
@Generated
public boolean equals(final Object o) {
if (o == this) {
return true;
@ -51,10 +53,12 @@ public class Node extends FlowNode {
}
}
@Generated
protected boolean canEqual(final Object other) {
return other instanceof Node;
}
@Generated
public int hashCode() {
int PRIME = true;
int result = super.hashCode();
@ -65,20 +69,24 @@ public class Node extends FlowNode {
return result;
}
@Generated
public Node() {
this.participantDirection = Node.ParticipantDirection.BOTTOM_TO_TOP;
}
@Generated
public Node setParticipantFrom(final String participantFrom) {
this.participantFrom = participantFrom;
return this;
}
@Generated
public Node setParticipantDirection(final ParticipantDirection participantDirection) {
this.participantDirection = participantDirection;
return this;
}
@Generated
public String toString() {
String var10000 = this.getParticipantFrom();
return "Node(participantFrom=" + var10000 + ", participantDirection=" + String.valueOf(this.getParticipantDirection()) + ")";

View File

@ -2,6 +2,7 @@ package net.xnzn.framework.flow.instance;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import lombok.Generated;
import net.xnzn.framework.flow.FlowNode;
public class Event {
@ -28,75 +29,91 @@ public class Event {
return this.triggerNode.isState() ? null : this.operatorName;
}
@Generated
public Long getId() {
return this.id;
}
@Generated
public Long getInstanceId() {
return this.instanceId;
}
@Generated
public FlowNode getTriggerNode() {
return this.triggerNode;
}
@Generated
public FlowNode getNextNode() {
return this.nextNode;
}
@Generated
public Operation getOperatorResult() {
return this.operatorResult;
}
@Generated
public LocalDateTime getOperatorTime() {
return this.operatorTime;
}
@Generated
public Event setId(final Long id) {
this.id = id;
return this;
}
@Generated
public Event setInstanceId(final Long instanceId) {
this.instanceId = instanceId;
return this;
}
@Generated
public Event setTriggerNode(final FlowNode triggerNode) {
this.triggerNode = triggerNode;
return this;
}
@Generated
public Event setNextNode(final FlowNode nextNode) {
this.nextNode = nextNode;
return this;
}
@Generated
public Event setOperatorResult(final Operation operatorResult) {
this.operatorResult = operatorResult;
return this;
}
@Generated
public Event setOperatorRemark(final String operatorRemark) {
this.operatorRemark = operatorRemark;
return this;
}
@Generated
public Event setOperatorId(final Long operatorId) {
this.operatorId = operatorId;
return this;
}
@Generated
public Event setOperatorName(final String operatorName) {
this.operatorName = operatorName;
return this;
}
@Generated
public Event setOperatorTime(final LocalDateTime operatorTime) {
this.operatorTime = operatorTime;
return this;
}
@Generated
public boolean equals(final Object o) {
if (o == this) {
return true;
@ -222,10 +239,12 @@ public class Event {
}
}
@Generated
protected boolean canEqual(final Object other) {
return other instanceof Event;
}
@Generated
public int hashCode() {
int PRIME = true;
int result = 1;
@ -250,11 +269,13 @@ public class Event {
return result;
}
@Generated
public String toString() {
Long var10000 = this.getId();
return "Event(id=" + var10000 + ", instanceId=" + this.getInstanceId() + ", triggerNode=" + String.valueOf(this.getTriggerNode()) + ", nextNode=" + String.valueOf(this.getNextNode()) + ", operatorResult=" + String.valueOf(this.getOperatorResult()) + ", operatorRemark=" + this.getOperatorRemark() + ", operatorId=" + this.getOperatorId() + ", operatorName=" + this.getOperatorName() + ", operatorTime=" + String.valueOf(this.getOperatorTime()) + ")";
}
@Generated
public Event() {
this.operatorResult = Event.Operation.PASS;
}

View File

@ -10,11 +10,13 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.Generated;
import net.xnzn.framework.flow.FlowNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Instance {
@Generated
private static final Logger log = LoggerFactory.getLogger(Instance.class);
@TableId
private Long id;
@ -99,182 +101,222 @@ public class Instance {
return flowNode;
}
@Generated
public Instance() {
this.state = Instance.State.DRAFT;
}
@Generated
public Long getId() {
return this.id;
}
@Generated
public String getName() {
return this.name;
}
@Generated
public String getType() {
return this.type;
}
@Generated
public Long getCurrentNodeId() {
return this.currentNodeId;
}
@Generated
public List<Context> getContext() {
return this.context;
}
@Generated
public List<? extends FlowNode> getNode() {
return this.node;
}
@Generated
public Long getCreatorId() {
return this.creatorId;
}
@Generated
public String getCreatorName() {
return this.creatorName;
}
@Generated
public LocalDateTime getCreateTime() {
return this.createTime;
}
@Generated
public Long getUpdatorId() {
return this.updatorId;
}
@Generated
public String getUpdatorName() {
return this.updatorName;
}
@Generated
public LocalDateTime getUpdateTime() {
return this.updateTime;
}
@Generated
public List<Event> getEvent() {
return this.event;
}
@Generated
public State getState() {
return this.state;
}
@Generated
public Boolean getCreated() {
return this.created;
}
@Generated
public Boolean getWaiting() {
return this.waiting;
}
@Generated
public Boolean getProcessed() {
return this.processed;
}
@Generated
public Boolean getUpComing() {
return this.upComing;
}
@Generated
public Boolean getForward() {
return this.forward;
}
@Generated
public Instance setId(final Long id) {
this.id = id;
return this;
}
@Generated
public Instance setName(final String name) {
this.name = name;
return this;
}
@Generated
public Instance setType(final String type) {
this.type = type;
return this;
}
@JsonIgnore
@Generated
public Instance setCurrentNodeId(final Long currentNodeId) {
this.currentNodeId = currentNodeId;
return this;
}
@Generated
public Instance setContext(final List<Context> context) {
this.context = context;
return this;
}
@Generated
public Instance setNode(final List<? extends FlowNode> node) {
this.node = node;
return this;
}
@Generated
public Instance setCreatorId(final Long creatorId) {
this.creatorId = creatorId;
return this;
}
@Generated
public Instance setCreatorName(final String creatorName) {
this.creatorName = creatorName;
return this;
}
@Generated
public Instance setCreateTime(final LocalDateTime createTime) {
this.createTime = createTime;
return this;
}
@Generated
public Instance setUpdatorId(final Long updatorId) {
this.updatorId = updatorId;
return this;
}
@Generated
public Instance setUpdatorName(final String updatorName) {
this.updatorName = updatorName;
return this;
}
@Generated
public Instance setUpdateTime(final LocalDateTime updateTime) {
this.updateTime = updateTime;
return this;
}
@Generated
public Instance setEvent(final List<Event> event) {
this.event = event;
return this;
}
@Generated
public Instance setState(final State state) {
this.state = state;
return this;
}
@Generated
public Instance setCreated(final Boolean created) {
this.created = created;
return this;
}
@Generated
public Instance setWaiting(final Boolean waiting) {
this.waiting = waiting;
return this;
}
@Generated
public Instance setProcessed(final Boolean processed) {
this.processed = processed;
return this;
}
@Generated
public Instance setUpComing(final Boolean upComing) {
this.upComing = upComing;
return this;
}
@Generated
public Instance setForward(final Boolean forward) {
this.forward = forward;
return this;
}
@Generated
public boolean equals(final Object o) {
if (o == this) {
return true;
@ -516,10 +558,12 @@ public class Instance {
}
}
@Generated
protected boolean canEqual(final Object other) {
return other instanceof Instance;
}
@Generated
public int hashCode() {
int PRIME = true;
int result = 1;
@ -564,6 +608,7 @@ public class Instance {
return result;
}
@Generated
public String toString() {
Long var10000 = this.getId();
return "Instance(id=" + var10000 + ", name=" + this.getName() + ", type=" + this.getType() + ", currentNodeId=" + this.getCurrentNodeId() + ", context=" + String.valueOf(this.getContext()) + ", node=" + String.valueOf(this.getNode()) + ", creatorId=" + this.getCreatorId() + ", creatorName=" + this.getCreatorName() + ", createTime=" + String.valueOf(this.getCreateTime()) + ", updatorId=" + this.getUpdatorId() + ", updatorName=" + this.getUpdatorName() + ", updateTime=" + String.valueOf(this.getUpdateTime()) + ", event=" + String.valueOf(this.getEvent()) + ", state=" + String.valueOf(this.getState()) + ", created=" + this.getCreated() + ", waiting=" + this.getWaiting() + ", processed=" + this.getProcessed() + ", upComing=" + this.getUpComing() + ", forward=" + this.getForward() + ")";
@ -582,6 +627,7 @@ public class Instance {
this.terminal = terminal;
}
@Generated
public boolean isTerminal() {
return this.terminal;
}
@ -597,33 +643,40 @@ public class Instance {
private String key;
private String value;
@Generated
public Long getInstanceId() {
return this.instanceId;
}
@Generated
public String getKey() {
return this.key;
}
@Generated
public String getValue() {
return this.value;
}
@Generated
public Context setInstanceId(final Long instanceId) {
this.instanceId = instanceId;
return this;
}
@Generated
public Context setKey(final String key) {
this.key = key;
return this;
}
@Generated
public Context setValue(final String value) {
this.value = value;
return this;
}
@Generated
public boolean equals(final Object o) {
if (o == this) {
return true;
@ -673,10 +726,12 @@ public class Instance {
}
}
@Generated
protected boolean canEqual(final Object other) {
return other instanceof Context;
}
@Generated
public int hashCode() {
int PRIME = true;
int result = 1;
@ -689,17 +744,20 @@ public class Instance {
return result;
}
@Generated
public String toString() {
Long var10000 = this.getInstanceId();
return "Instance.Context(instanceId=" + var10000 + ", key=" + this.getKey() + ", value=" + this.getValue() + ")";
}
@Generated
public Context(final Long instanceId, final String key, final String value) {
this.instanceId = instanceId;
this.key = key;
this.value = value;
}
@Generated
public Context() {
}
}

View File

@ -5,6 +5,7 @@ import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Set;
import lombok.Generated;
public class InstanceFilter {
private List<Long> instanceIds;
@ -19,94 +20,117 @@ public class InstanceFilter {
private LocalDateTime updateTimeStart;
private LocalDateTime updateTimeEnd;
@Generated
public List<Long> getInstanceIds() {
return this.instanceIds;
}
@Generated
public Map<String, String> getContext() {
return this.context;
}
@Generated
public Long getOperatorId() {
return this.operatorId;
}
@Generated
public Set<State> getInvolvedStates() {
return this.involvedStates;
}
@Generated
public Set<String> getType() {
return this.type;
}
@Generated
public Set<Instance.State> getState() {
return this.state;
}
@Generated
public boolean isAsc() {
return this.asc;
}
@Generated
public LocalDateTime getCreateTimeStart() {
return this.createTimeStart;
}
@Generated
public LocalDateTime getCreateTimeEnd() {
return this.createTimeEnd;
}
@Generated
public LocalDateTime getUpdateTimeStart() {
return this.updateTimeStart;
}
@Generated
public LocalDateTime getUpdateTimeEnd() {
return this.updateTimeEnd;
}
@Generated
public void setInstanceIds(final List<Long> instanceIds) {
this.instanceIds = instanceIds;
}
@Generated
public void setContext(final Map<String, String> context) {
this.context = context;
}
@Generated
public void setOperatorId(final Long operatorId) {
this.operatorId = operatorId;
}
@Generated
public void setInvolvedStates(final Set<State> involvedStates) {
this.involvedStates = involvedStates;
}
@Generated
public void setType(final Set<String> type) {
this.type = type;
}
@Generated
public void setState(final Set<Instance.State> state) {
this.state = state;
}
@Generated
public void setAsc(final boolean asc) {
this.asc = asc;
}
@Generated
public void setCreateTimeStart(final LocalDateTime createTimeStart) {
this.createTimeStart = createTimeStart;
}
@Generated
public void setCreateTimeEnd(final LocalDateTime createTimeEnd) {
this.createTimeEnd = createTimeEnd;
}
@Generated
public void setUpdateTimeStart(final LocalDateTime updateTimeStart) {
this.updateTimeStart = updateTimeStart;
}
@Generated
public void setUpdateTimeEnd(final LocalDateTime updateTimeEnd) {
this.updateTimeEnd = updateTimeEnd;
}
@Generated
public boolean equals(final Object o) {
if (o == this) {
return true;
@ -236,10 +260,12 @@ public class InstanceFilter {
}
}
@Generated
protected boolean canEqual(final Object other) {
return other instanceof InstanceFilter;
}
@Generated
public int hashCode() {
int PRIME = true;
int result = 1;
@ -267,6 +293,7 @@ public class InstanceFilter {
return result;
}
@Generated
public String toString() {
String var10000 = String.valueOf(this.getInstanceIds());
return "InstanceFilter(instanceIds=" + var10000 + ", context=" + String.valueOf(this.getContext()) + ", operatorId=" + this.getOperatorId() + ", involvedStates=" + String.valueOf(this.getInvolvedStates()) + ", type=" + String.valueOf(this.getType()) + ", state=" + String.valueOf(this.getState()) + ", asc=" + this.isAsc() + ", createTimeStart=" + String.valueOf(this.getCreateTimeStart()) + ", createTimeEnd=" + String.valueOf(this.getCreateTimeEnd()) + ", updateTimeStart=" + String.valueOf(this.getUpdateTimeStart()) + ", updateTimeEnd=" + String.valueOf(this.getUpdateTimeEnd()) + ")";

View File

@ -2,30 +2,26 @@ package net.xnzn.framework.flow.instance;
import net.xnzn.framework.flow.Flow;
public class InstanceHolder {
private final long id;
private final Long operatorId;
private final String operatorName;
public void next() {
Flow.next(this.id, (String)null, this.operatorId, this.operatorName);
}
public InstanceHolder(final long id, final Long operatorId, final String operatorName) {
public record InstanceHolder(long id, Long operatorId, String operatorName) {
public InstanceHolder(long id, Long operatorId, String operatorName) {
this.id = id;
this.operatorId = operatorId;
this.operatorName = operatorName;
}
public long getId() {
public void next() {
Flow.next(this.id, (String)null, this.operatorId, this.operatorName);
}
public long id() {
return this.id;
}
public Long getOperatorId() {
public Long operatorId() {
return this.operatorId;
}
public String getOperatorName() {
public String operatorName() {
return this.operatorName;
}
}