fix: gitee issues/I8K4QN

This commit is contained in:
hubin 2023-11-28 22:52:21 +08:00
parent 567ec3334e
commit 26dbc5eb63
7 changed files with 41 additions and 56 deletions

View File

@ -97,9 +97,9 @@ subprojects {
useJUnitPlatform()
}
// JDK1.8
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
// JDK11
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
publishing {
publications {

View File

@ -9,7 +9,6 @@ import com.flowlong.bpm.engine.core.FlowLongContext;
import com.flowlong.bpm.engine.core.enums.FlowState;
import com.flowlong.bpm.engine.exception.FlowLongException;
import com.flowlong.bpm.engine.handler.impl.EndProcessHandler;
import com.flowlong.bpm.engine.model.ModelHelper;
import com.flowlong.bpm.engine.model.NodeModel;
import com.flowlong.bpm.engine.model.ProcessModel;
import lombok.Getter;
@ -104,35 +103,22 @@ public class FlwProcess extends FlowEntity {
this.processModelParser(processModel -> {
NodeModel nodeModel = processModel.getNode(nodeName);
Assert.isNull(nodeModel, "流程模型中未发现,流程节点" + nodeName);
NodeModel executeNode = nodeModel.getChildNode();
if (null == executeNode) {
// 如果当前节点完成并且该节点为条件节点找到主干执行节点继续执行
executeNode = ModelHelper.findNextNode(nodeModel);
}
/**
* 执行节点任务
*/
if (null != executeNode) {
nodeModel.nextNode().ifPresentOrElse(executeNode -> {
// 执行流程节点
executeNode.execute(flowLongContext, execution);
/**
* 不存在子节点不存在其它分支节点当前执行节点为最后节点 并且当前节点不是审批节点
* 执行结束流程处理器
*/
if (null == executeNode.getChildNode() && null == executeNode.getConditionNodes()) {
NodeModel nextNode = ModelHelper.findNextNode(executeNode);
if (null == nextNode && executeNode.getType() != 1) {
if (!executeNode.nextNode().isPresent() && executeNode.getType() != 1) {
new EndProcessHandler().handle(flowLongContext, execution);
}
}
} else {
/**
* 无执行节点流程结束
*/
new EndProcessHandler().handle(flowLongContext, execution);
}
}, () -> new EndProcessHandler().handle(flowLongContext, execution));
});
}

View File

@ -151,7 +151,16 @@ public class NodeModel implements ModelInstance, Serializable {
/**
* 执行创建条件任务
*/
this.createTask(conditionNodeOptional.get().getChildNode(), flowLongContext, execution);
conditionNodeOptional.ifPresent(conditionNode -> {
NodeModel childNode = conditionNode.getChildNode();
if (null == childNode) {
// 当前条件节点无执行节点进入当前执行条件节点的下一个节点
childNode = this.getChildNode();
}
if (null != childNode) {
this.createTask(childNode, flowLongContext, execution);
}
});
}
/**
@ -212,6 +221,18 @@ public class NodeModel implements ModelInstance, Serializable {
return null;
}
/**
* 下一个执行节点
*/
public Optional<NodeModel> nextNode() {
NodeModel nextNode = this.getChildNode();
if (null == nextNode) {
// 如果当前节点完成并且该节点为条件节点找到主干执行节点继续执行
nextNode = ModelHelper.findNextNode(this);
}
return Optional.ofNullable(nextNode);
}
/**
* 判断是否为条件节点
*/

View File

@ -459,16 +459,7 @@ public class TaskServiceImpl implements TaskService {
/**
* 可能存在子节点
*/
NodeModel nextNode = nodeModel.getChildNode();
if (null == nextNode) {
// 如果当前节点完成并且该节点为条件节点找到主干执行节点继续执行
nextNode = ModelHelper.findNextNode(nodeModel);
}
// 执行可能存在的主线业务逻辑
if (null != nextNode) {
this.createTask(nextNode, execution);
}
nodeModel.nextNode().ifPresent(nextNode -> this.createTask(nextNode, execution));
} else if (3 == nodeType) {
/**
* 3条件审批

View File

@ -29,7 +29,7 @@ public class TestProcess extends MysqlTest {
*/
@Test
public void testComplete() {
this.testProcess(false);
this.testProcess(false, 8);
}
/**
@ -37,10 +37,15 @@ public class TestProcess extends MysqlTest {
*/
@Test
public void testReject() {
this.testProcess(true);
this.testProcess(true, 8);
}
public void testProcess(boolean reject) {
@Test
public void testDay() {
this.testProcess(false, 3);
}
public void testProcess(boolean reject, int day) {
ProcessService processService = flowLongEngine.processService();
// 根据流程定义ID查询
@ -52,7 +57,7 @@ public class TestProcess extends MysqlTest {
// 启动指定流程定义ID启动流程实例
Map<String, Object> args = new HashMap<>();
args.put("day", 8);
args.put("day", day);
args.put("assignee", testUser1);
flowLongEngine.startInstanceById(processId, testCreator, args).ifPresent(instance -> {

View File

@ -50,25 +50,7 @@
"type": 3,
"priorityLevel": 2,
"conditionMode": 1,
"conditionList": [],
"childNode": {
"nodeName": "直接主管审批",
"type": 1,
"setType": 2,
"nodeUserList": [{
"id": "zg0001",
"name": "张三"
}],
"nodeRoleList": [],
"examineLevel": 1,
"directorLevel": 1,
"selectMode": 1,
"termAuto": false,
"term": 0,
"termMode": 1,
"examineMode": 1,
"directorMode": 0
}
"conditionList": []
}
],
"childNode": {

View File

@ -15,8 +15,8 @@
</modules>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<spring-boot.version>2.7.0</spring-boot.version>
<mybatis.plus-version>3.5.3.2</mybatis.plus-version>
<mysql.version>8.0.32</mysql.version>