add - 新增"接收任务"和"服务任务"的节点推测功能

This commit is contained in:
wangli 2023-11-28 18:56:40 +08:00
parent 9c9046db5b
commit 491d064c01
5 changed files with 59 additions and 28 deletions

View File

@ -3,11 +3,8 @@ package cn.axzo.workflow.core.service.support.forecast.impl;
import cn.axzo.workflow.core.service.support.forecast.AbstractForecast;
import org.flowable.bpmn.model.ExclusiveGateway;
import org.flowable.bpmn.model.FlowElement;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.Collections;
import java.util.List;
/**
@ -28,15 +25,4 @@ public class ExclusiveGatewayForecasting extends AbstractForecast<ExclusiveGatew
return flowElement.getOutgoingFlows();
}
@Override
public List<? extends FlowElement> calcRealOutgoingNodes(List<ExclusiveGateway> flowElements,
ProcessInstance instance) {
if (CollectionUtils.isEmpty(flowElements)) {
return Collections.emptyList();
}
if (flowElements.size() == 1) {
return flowElements;
}
return super.calcRealOutgoingNodes(flowElements, instance);
}
}

View File

@ -0,0 +1,29 @@
package cn.axzo.workflow.core.service.support.forecast.impl;
import cn.axzo.workflow.core.service.support.forecast.AbstractForecast;
import com.google.common.collect.Lists;
import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.ReceiveTask;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 接收任务
*
* @author wangli
* @since 2023/11/28 15:07
*/
@Component
public class ReceiveTaskForecasting extends AbstractForecast<ReceiveTask> {
@Override
public Boolean support(FlowElement flowElement) {
return flowElement instanceof ReceiveTask;
}
@Override
protected List<? extends FlowElement> getOutgoing(ReceiveTask flowElement) {
return Lists.newArrayList(flowElement.getOutgoingFlows());
}
}

View File

@ -11,6 +11,7 @@ import org.springframework.util.StringUtils;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@ -49,7 +50,7 @@ public class SequenceFlowForecasting extends AbstractForecast<SequenceFlow> {
// 如果 conditionExpression 为空, 则认为是默认流
List<SequenceFlow> defaultFlows =
flowElements.stream().filter(i -> !StringUtils.hasLength(i.getConditionExpression())).collect(Collectors.toList());
flowElements.stream().filter(i -> Objects.isNull(i.getConditionExpression())).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(defaultFlows) && defaultFlows.size() == 1) {
return Lists.newArrayList(defaultFlows.get(0));
}

View File

@ -0,0 +1,28 @@
package cn.axzo.workflow.core.service.support.forecast.impl;
import cn.axzo.workflow.core.service.support.forecast.AbstractForecast;
import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.ServiceTask;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 服务任务 [抄送节点使用的是该 task 类型]
*
* @author wangli
* @since 2023/11/28 15:16
*/
@Component
public class ServiceTaskForecasting extends AbstractForecast<ServiceTask> {
@Override
public Boolean support(FlowElement flowElement) {
return flowElement instanceof ServiceTask;
}
@Override
protected List<? extends FlowElement> getOutgoing(ServiceTask flowElement) {
return flowElement.getOutgoingFlows();
}
}

View File

@ -3,11 +3,8 @@ package cn.axzo.workflow.core.service.support.forecast.impl;
import cn.axzo.workflow.core.service.support.forecast.AbstractForecast;
import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.UserTask;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.Collections;
import java.util.List;
/**
@ -28,14 +25,4 @@ public class UserTaskForecasting extends AbstractForecast<UserTask> {
return flowElement.getOutgoingFlows();
}
@Override
public List<? extends FlowElement> calcRealOutgoingNodes(List<UserTask> flowElements, ProcessInstance instance) {
if (CollectionUtils.isEmpty(flowElements)) {
return Collections.emptyList();
}
if (flowElements.size() == 1) {
return flowElements;
}
return super.calcRealOutgoingNodes(flowElements, instance);
}
}