Skip to content

fix flow bug #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/example-app/example-app-cmd-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.11</version>
<version>3.4.12</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/example-app-cmd-meta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.11</version>
<version>3.4.12</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/example-app-query/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.11</version>
<version>3.4.12</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.11</version>
<version>3.4.12</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/example-domain-leave/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-domain</artifactId>
<version>3.4.11</version>
<version>3.4.12</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/example-domain-user/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-domain</artifactId>
<version>3.4.11</version>
<version>3.4.12</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.11</version>
<version>3.4.12</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-flow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.11</version>
<version>3.4.12</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.11</version>
<version>3.4.12</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.11</version>
<version>3.4.12</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.11</version>
<version>3.4.12</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion example/example-interface/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.11</version>
<version>3.4.12</version>
</parent>

<artifactId>example-interface</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion example/example-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>springboot-example</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.11</version>
<version>3.4.12</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</parent>

<artifactId>springboot-example</artifactId>
<version>3.4.11</version>
<version>3.4.12</version>

<name>springboot-example</name>
<description>springboot-example project for Spring Boot</description>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.4.11</version>
<version>3.4.12</version>

<url>https://github.com/codingapi/springboot-framewrok</url>
<name>springboot-parent</name>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-data-authorization/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.4.11</version>
<version>3.4.12</version>
</parent>

<name>springboot-starter-data-authorization</name>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-data-fast/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>springboot-parent</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.11</version>
<version>3.4.12</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-flow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>springboot-parent</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.11</version>
<version>3.4.12</version>
</parent>

<name>springboot-starter-flow</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,10 @@ public FlowNode getStartNode() {
/**
* 是否存在退回关系
*/
public boolean hasBackRelation() {
return relations.stream().anyMatch(FlowRelation::isBack);
public boolean hasBackRelation(String sourceCode) {
return relations.stream()
.filter(relation -> relation.getSource().getCode().equals(sourceCode))
.anyMatch(FlowRelation::isBack);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,4 @@ public boolean isPassRecord() {
return flowSourceDirection == FlowSourceDirection.PASS;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -100,39 +100,60 @@ public void skipCirculate() {
/**
* 加载默认回退节点
*/
public void loadDefaultBackNode(FlowRecord currentRecord) {
public void loadDefaultBackNode(FlowNode flowNode, FlowRecord currentRecord) {
// 如果退回设置了回退关系,则需要根据关系匹配下一个节点
if (flowWork.hasBackRelation(flowNode.getCode())) {
FlowNode nextNode = this.matcherNextNode(flowNode, true);
if (nextNode == null) {
throw new IllegalArgumentException("next node not found");
}
long parentRecordId = currentRecord.getPreId();
FlowRecord preFlowRecord = flowRecordRepository.getFlowRecordById(parentRecordId);
IFlowOperator flowOperator = currentOperator;
if (nextNode.isAnyOperatorMatcher()) {
while (preFlowRecord.isTransfer() || !preFlowRecord.getNodeCode().equals(nextNode.getCode())) {
preFlowRecord = flowRecordRepository.getFlowRecordById(preFlowRecord.getPreId());
}
flowOperator = preFlowRecord.getCurrentOperator();
}
this.nextNode = nextNode;
this.nextOperator = flowOperator;
this.backOperator = null;
return;
}

// 如果没有设置回退关系,则需要根据流程记录来匹配下一个节点
List<FlowRecord> historyRecords =
flowRecordRepository.findFlowRecordByProcessId(currentRecord.getProcessId())
.stream()
.sorted((o1, o2) -> (int) (o2.getId() - o1.getId()))
.filter(record -> record.getId() < currentRecord.getId())
.toList();

int index = 0;
while (true) {
if (index >= historyRecords.size()) {
throw new IllegalArgumentException("back node not found");
}
FlowRecord record = historyRecords.get(index);
if (record.isDone() && record.getId()== currentRecord.getPreId()) {
if (record.isDone() && record.getId() == currentRecord.getPreId()) {
// 是连续的回退节点时,则根据流程记录的状态来判断
if(record.isReject()){
if (record.isReject()) {
boolean startRemove = false;
for(FlowRecord historyRecord: historyRecords){
if(startRemove){
if(historyRecord.getNodeCode().equals(currentRecord.getNodeCode())){
for (FlowRecord historyRecord : historyRecords) {
if (startRemove) {
if (historyRecord.getNodeCode().equals(currentRecord.getNodeCode())) {
continue;
}
this.nextNode = flowWork.getNodeByCode(historyRecord.getNodeCode());
this.nextOperator = historyRecord.getCurrentOperator();
this.backOperator = historyRecord.getCurrentOperator();
return;
}
if(historyRecord.getNodeCode().equals(currentRecord.getNodeCode())){
if (historyRecord.getNodeCode().equals(currentRecord.getNodeCode())) {
startRemove = true;
}
}
}else {
} else {
this.nextNode = flowWork.getNodeByCode(record.getNodeCode());
this.nextOperator = record.getCurrentOperator();
this.backOperator = record.getCurrentOperator();
Expand All @@ -144,23 +165,22 @@ public void loadDefaultBackNode(FlowRecord currentRecord) {
}



/**
* 获取下一个节点
*
* @return 下一个节点
*/
private FlowNode matcherNextNode(FlowNode flowNode, boolean back) {
List<FlowRelation> currentRelations = new ArrayList<>(flowWork.getRelations());
if(back){
if (back) {
String preCode = FlowNode.CODE_START;
if(flowRecord.getPreId()!=0){
if (flowRecord.getPreId() != 0) {
FlowRecord preRecord = flowRecordRepository.getFlowRecordById(flowRecord.getPreId());
if(preRecord!=null){
if (preRecord != null) {
preCode = preRecord.getNodeCode();
while (preCode.equals(flowRecord.getNodeCode())){
while (preCode.equals(flowRecord.getNodeCode())) {
preRecord = flowRecordRepository.getFlowRecordById(preRecord.getPreId());
if(preRecord==null){
if (preRecord == null) {
break;
}
preCode = preRecord.getNodeCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private void loadNextNode(List<FlowRecord> historyRecords) {
if (flowDirectionService.isPassRecord()) {
flowNodeService.loadNextPassNode(flowNode);
} else {
flowNodeService.loadDefaultBackNode(flowRecord);
flowNodeService.loadDefaultBackNode(flowNode,flowRecord);
}
this.nextNode = flowNodeService.getNextNode();
}
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy