优化抄送任务并行分支执行逻辑
This commit is contained in:
parent
c782a1ee93
commit
9e0a9d8b32
@ -53,6 +53,14 @@ public interface QueryService {
|
|||||||
*/
|
*/
|
||||||
boolean existActiveSubProcess(Long instanceId);
|
boolean existActiveSubProcess(Long instanceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断流程实例下是否存在活跃任务
|
||||||
|
*
|
||||||
|
* @param instanceId 流程实例ID
|
||||||
|
* @return true 存在 false 不存在
|
||||||
|
*/
|
||||||
|
boolean existActiveTask(Long instanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据任务ID获取任务对象
|
* 根据任务ID获取任务对象
|
||||||
*
|
*
|
||||||
|
@ -42,6 +42,8 @@ public interface FlwTaskDao {
|
|||||||
|
|
||||||
Long selectCountByParentTaskId(Long parentTaskId);
|
Long selectCountByParentTaskId(Long parentTaskId);
|
||||||
|
|
||||||
|
Long selectCountByInstanceId(Long instanceId);
|
||||||
|
|
||||||
List<FlwTask> selectListByInstanceId(Long instanceId);
|
List<FlwTask> selectListByInstanceId(Long instanceId);
|
||||||
|
|
||||||
List<FlwTask> selectListByInstanceIdAndTaskName(Long instanceId, String taskName);
|
List<FlwTask> selectListByInstanceIdAndTaskName(Long instanceId, String taskName);
|
||||||
|
@ -67,6 +67,11 @@ public class QueryServiceImpl implements QueryService {
|
|||||||
return instanceDao.selectCountByParentInstanceId(instanceId) > 0;
|
return instanceDao.selectCountByParentInstanceId(instanceId) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean existActiveTask(Long instanceId) {
|
||||||
|
return taskDao.selectCountByInstanceId(instanceId) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FlwHisTask getHistTask(Long taskId) {
|
public FlwHisTask getHistTask(Long taskId) {
|
||||||
return hisTaskDao.selectById(taskId);
|
return hisTaskDao.selectById(taskId);
|
||||||
|
@ -926,8 +926,20 @@ public class TaskServiceImpl implements TaskService {
|
|||||||
*/
|
*/
|
||||||
Optional<NodeModel> nextNodeOptional = nodeModel.nextNode();
|
Optional<NodeModel> nextNodeOptional = nodeModel.nextNode();
|
||||||
if (nextNodeOptional.isPresent()) {
|
if (nextNodeOptional.isPresent()) {
|
||||||
// 执行下一个节点
|
// 下一个节点如果在并行分支,判断是否并行分支都执行结束
|
||||||
nextNodeOptional.get().execute(execution.getEngine().getContext(), execution);
|
boolean _exec = true;
|
||||||
|
NodeModel ccNextNode = nextNodeOptional.get();
|
||||||
|
NodeModel _cnn = execution.getProcessModel().getNode(ccNextNode.getNodeKey());
|
||||||
|
if (_cnn.getParentNode().parallelNode()) {
|
||||||
|
// 抄送节点独立占据一个分支或者存在执行任务
|
||||||
|
if (ccNextNode.getParentNode().parallelNode() || taskDao.selectCountByInstanceId(flwTask.getInstanceId()) > 0) {
|
||||||
|
_exec = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_exec) {
|
||||||
|
// 执行下一个节点
|
||||||
|
ccNextNode.execute(execution.getEngine().getContext(), execution);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 不存在任何子节点结束流程
|
// 不存在任何子节点结束流程
|
||||||
execution.endInstance(nodeModel);
|
execution.endInstance(nodeModel);
|
||||||
|
@ -65,6 +65,12 @@ public class FlwTaskDaoImpl implements FlwTaskDao {
|
|||||||
.eq(FlwTask::getParentTaskId, parentTaskId));
|
.eq(FlwTask::getParentTaskId, parentTaskId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long selectCountByInstanceId(Long instanceId) {
|
||||||
|
return taskMapper.selectCount(Wrappers.<FlwTask>lambdaQuery()
|
||||||
|
.eq(FlwTask::getInstanceId, instanceId));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FlwTask> selectListByInstanceId(Long instanceId) {
|
public List<FlwTask> selectListByInstanceId(Long instanceId) {
|
||||||
return taskMapper.selectList(Wrappers.<FlwTask>lambdaQuery()
|
return taskMapper.selectList(Wrappers.<FlwTask>lambdaQuery()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package test.mysql;
|
package test.mysql;
|
||||||
|
|
||||||
import com.aizuda.bpm.engine.assist.Assert;
|
import com.aizuda.bpm.engine.assist.Assert;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,4 +49,13 @@ public class TestParallelNode extends MysqlTest {
|
|||||||
.ifPresent(flwTasks -> Assert.isFalse(flwTasks.isEmpty(), "task size should be zero"));
|
.ifPresent(flwTasks -> Assert.isFalse(flwTasks.isEmpty(), "task size should be zero"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCcTaskParallel() {
|
||||||
|
processId = this.deployByResource("test/ccTaskParallel.json", testCreator);
|
||||||
|
flowLongEngine.startInstanceById(processId, testCreator).flatMap(instance ->
|
||||||
|
flowLongEngine.queryService().getActiveTasksByInstanceId(instance.getId()))
|
||||||
|
.ifPresent(t -> Assertions.assertEquals(1, t.size()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,112 @@
|
|||||||
|
{
|
||||||
|
"id": 11010,
|
||||||
|
"key": "ccTaskParallel",
|
||||||
|
"name": "抄送任务并行分支",
|
||||||
|
"nodeConfig": {
|
||||||
|
"nodeName": "发起人",
|
||||||
|
"nodeKey": "flk1736056686549",
|
||||||
|
"type": 0,
|
||||||
|
"childNode": {
|
||||||
|
"nodeName": "并行路由",
|
||||||
|
"nodeKey": "flk1736056692729",
|
||||||
|
"type": 8,
|
||||||
|
"parallelNodes": [
|
||||||
|
{
|
||||||
|
"nodeName": "分支1",
|
||||||
|
"nodeKey": "flk17360566927291",
|
||||||
|
"type": 3,
|
||||||
|
"childNode": {
|
||||||
|
"nodeName": "抄送人",
|
||||||
|
"nodeKey": "flk1736056695797",
|
||||||
|
"type": 2,
|
||||||
|
"nodeAssigneeList": [
|
||||||
|
{
|
||||||
|
"id": "test001",
|
||||||
|
"name": "CEO"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"allowSelection": true,
|
||||||
|
"childNode": {
|
||||||
|
"nodeName": "审核人",
|
||||||
|
"nodeKey": "flk1736056818736",
|
||||||
|
"type": 1,
|
||||||
|
"setType": 1,
|
||||||
|
"nodeCandidate": {
|
||||||
|
"type": 1
|
||||||
|
},
|
||||||
|
"examineLevel": 1,
|
||||||
|
"examineMode": 1,
|
||||||
|
"directorLevel": 1,
|
||||||
|
"directorMode": 0,
|
||||||
|
"selectMode": 1,
|
||||||
|
"termAuto": false,
|
||||||
|
"term": 0,
|
||||||
|
"termMode": 1,
|
||||||
|
"typeOfApprove": 1,
|
||||||
|
"rejectStrategy": 2,
|
||||||
|
"rejectStart": 1,
|
||||||
|
"remind": false,
|
||||||
|
"approveSelf": 0,
|
||||||
|
"nodeAssigneeList": [
|
||||||
|
{
|
||||||
|
"id": "test002",
|
||||||
|
"name": "夏小华"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nodeName": "分支2",
|
||||||
|
"nodeKey": "flk17360566927292",
|
||||||
|
"type": 3,
|
||||||
|
"childNode": {
|
||||||
|
"nodeName": "抄送人",
|
||||||
|
"nodeKey": "flk1736056697926",
|
||||||
|
"type": 2,
|
||||||
|
"nodeAssigneeList": [
|
||||||
|
{
|
||||||
|
"id": "test001",
|
||||||
|
"name": "CEO"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"allowSelection": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"childNode": {
|
||||||
|
"nodeName": "审核人",
|
||||||
|
"nodeKey": "flk1736056705898",
|
||||||
|
"type": 1,
|
||||||
|
"setType": 1,
|
||||||
|
"nodeCandidate": {
|
||||||
|
"type": 1
|
||||||
|
},
|
||||||
|
"examineLevel": 1,
|
||||||
|
"examineMode": 1,
|
||||||
|
"directorLevel": 1,
|
||||||
|
"directorMode": 0,
|
||||||
|
"selectMode": 1,
|
||||||
|
"termAuto": false,
|
||||||
|
"term": 0,
|
||||||
|
"termMode": 1,
|
||||||
|
"typeOfApprove": 1,
|
||||||
|
"rejectStrategy": 2,
|
||||||
|
"rejectStart": 1,
|
||||||
|
"remind": false,
|
||||||
|
"approveSelf": 0,
|
||||||
|
"childNode": {
|
||||||
|
"nodeName": "结束",
|
||||||
|
"nodeKey": "flk17360566865491",
|
||||||
|
"type": -1
|
||||||
|
},
|
||||||
|
"nodeAssigneeList": [
|
||||||
|
{
|
||||||
|
"id": "test003",
|
||||||
|
"name": "陈小辉"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user