forked from aizuda/flowlong
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
184 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ing-boot-example/src/main/java/com/aizuda/bpm/spring/example/config/TestTaskReminder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
flowlong-spring-boot-starter/src/test/java/test/mysql/TestAutoSkip.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2023-2025 Licensed under the AGPL License | ||
*/ | ||
package test.mysql; | ||
|
||
import com.aizuda.bpm.engine.entity.FlwHisInstance; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* 测试自动跳转 | ||
*/ | ||
@Slf4j | ||
public class TestAutoSkip extends MysqlTest { | ||
|
||
@BeforeEach | ||
public void before() { | ||
processId = this.deployByResource("test/autoSkip.json", testCreator); | ||
} | ||
|
||
@Test | ||
public void test() { | ||
// 考勤管理员【角色】不走认领逻辑,通过任务参与者提供类直接分配处理人员 | ||
flowLongEngine.startInstanceById(processId, testCreator).ifPresent(instance -> { | ||
|
||
// 非自动完成 test002 操作执行任务 | ||
executeActiveTasks(instance.getId(), test2Creator); | ||
|
||
FlwHisInstance hisInstance = flowLongEngine.queryService().getHistInstance(instance.getId()); | ||
Assertions.assertEquals(1, hisInstance.getInstanceState()); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
flowlong-spring-boot-starter/src/test/java/test/mysql/TestParallelNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
flowlong-spring-boot-starter/src/test/java/test/mysql/config/TestTaskActorProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package test.mysql.config; | ||
|
||
import com.aizuda.bpm.engine.core.Execution; | ||
import com.aizuda.bpm.engine.core.FlowCreator; | ||
import com.aizuda.bpm.engine.core.enums.NodeSetType; | ||
import com.aizuda.bpm.engine.entity.FlwTaskActor; | ||
import com.aizuda.bpm.engine.impl.GeneralTaskActorProvider; | ||
import com.aizuda.bpm.engine.model.NodeModel; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
/** | ||
* 测试任务参与者提供处理类 | ||
*/ | ||
public class TestTaskActorProvider extends GeneralTaskActorProvider { | ||
|
||
@Override | ||
public List<FlwTaskActor> getTaskActors(NodeModel nodeModel, Execution execution) { | ||
if (NodeSetType.role.eq(nodeModel.getSetType())) { | ||
|
||
// 测试用例 TestAutoSkip 测试角色自动分配处理人员 | ||
if ("100100".equals(nodeModel.getNodeAssigneeList().get(0).getId())) { | ||
return Arrays.asList( | ||
FlwTaskActor.ofFlowCreator(FlowCreator.of("test001", "测试001")), | ||
FlwTaskActor.ofFlowCreator(FlowCreator.of("test002", "测试002")) | ||
); | ||
} | ||
} | ||
return super.getTaskActors(nodeModel, execution); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
flowlong-spring-boot-starter/src/test/java/test/mysql/config/TestTaskListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package test.mysql.config; | ||
|
||
import com.aizuda.bpm.engine.FlowLongEngine; | ||
import com.aizuda.bpm.engine.core.FlowCreator; | ||
import com.aizuda.bpm.engine.core.enums.EventType; | ||
import com.aizuda.bpm.engine.core.enums.NodeApproveSelf; | ||
import com.aizuda.bpm.engine.core.enums.NodeSetType; | ||
import com.aizuda.bpm.engine.entity.FlwTask; | ||
import com.aizuda.bpm.engine.listener.TaskListener; | ||
import com.aizuda.bpm.engine.model.NodeAssignee; | ||
import com.aizuda.bpm.engine.model.NodeModel; | ||
import lombok.AllArgsConstructor; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* 测试任务监听处理器 | ||
*/ | ||
@AllArgsConstructor | ||
public class TestTaskListener implements TaskListener { | ||
private FlowLongEngine flowLongEngine; | ||
|
||
@Override | ||
public boolean notify(EventType eventType, Supplier<FlwTask> supplier, NodeModel nodeModel, | ||
FlowCreator flowCreator) { | ||
if (EventType.create.eq(eventType)) { | ||
// 创建任务时候,判断是否自动审批通过 | ||
Integer approveSelf = nodeModel.getApproveSelf(); | ||
if (NodeApproveSelf.AutoSkip.eq(approveSelf)) { | ||
FlwTask flwTask = supplier.get(); | ||
if (NodeSetType.specifyMembers.eq(nodeModel.getSetType())) { | ||
// 普通成员情况 | ||
List<NodeAssignee> nodeAssigneeList = nodeModel.getNodeAssigneeList(); | ||
if (nodeAssigneeList.stream().anyMatch(t -> Objects.equals(t.getId(), flowCreator.getCreateId()))) { | ||
return flowLongEngine.autoJumpTask(flwTask.getId(), flowCreator); | ||
} | ||
} else if (NodeSetType.role.eq(nodeModel.getSetType())) { | ||
// 角色情况 | ||
flowLongEngine.queryService().getActiveTaskActorsByTaskId(flwTask.getId()).flatMap(flwTaskActorList -> flwTaskActorList.stream() | ||
.filter(t -> Objects.equals(t.getActorId(), flowCreator.getCreateId())) | ||
.findFirst()).ifPresent(taskActor -> flowLongEngine.autoJumpTask(taskActor.getTaskId(), flowCreator)); | ||
return true; | ||
} | ||
} | ||
} | ||
return true; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
flowlong-spring-boot-starter/src/test/resources/test/autoSkip.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"key": "autoSkip", | ||
"name": "自动跳过审批", | ||
"nodeConfig": { | ||
"nodeName": "发起人", | ||
"nodeKey": "flk1725161262899", | ||
"type": 0, | ||
"childNode": { | ||
"nodeName": "审核人", | ||
"nodeKey": "flk1724860316169", | ||
"callProcess": null, | ||
"type": 1, | ||
"setType": 3, | ||
"nodeAssigneeList": [ | ||
{ | ||
"id": "100100", | ||
"name": "考勤管理员" | ||
} | ||
], | ||
"examineLevel": 1, | ||
"directorLevel": 1, | ||
"selectMode": 1, | ||
"termAuto": false, | ||
"term": 0, | ||
"termMode": 1, | ||
"examineMode": 2, | ||
"directorMode": 0, | ||
"typeOfApprove": 1, | ||
"remind": false, | ||
"approveSelf": 1 | ||
} | ||
} | ||
} |