fix:更新获取可驳回的前置节点,根据流程变量过滤

This commit is contained in:
描述不符 2026-06-22 10:58:00 +08:00
parent 8136a0191a
commit c7c0a3d6bc

View File

@ -64,6 +64,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
import static org.dromara.workflow.common.constant.FlowConstant.*;
@ -544,27 +545,31 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
return nodeService.getByNodeCodes(Collections.singletonList(node.getAnyNodeSkip()), task.getDefinitionId());
}
//获取可驳回的前置节点
List<Node> nodes = nodeService.previousNodeList(task.getDefinitionId(), nowNodeCode);
List<HisTask> hisTaskList = hisTaskService.getByInsId(task.getInstanceId());
Instance instance = insService.getById(task.getInstanceId());
List<Node> allPreNodes = nodeService.previousNodeList(task.getDefinitionId(), nowNodeCode);
Node startNode = nodeService.getStartNode(task.getDefinitionId());
List<Node> allPreNodes2 = new ArrayList<>();
getBackTaskNodes(allPreNodes2, instance, CollUtil.toList(startNode));
List<Node> nodes = allPreNodes.stream().filter(allPreNodes2::contains).collect(Collectors.toList());
Map<String, Node> nodeMap = StreamUtils.toIdentityMap(nodes, Node::getNodeCode);
Set<String> added = new HashSet<>();
List<Node> backNodeList = new ArrayList<>();
for (HisTask hisTask : hisTaskList) {
Node nodeValue = nodeMap.get(hisTask.getNodeCode());
if (nodeValue != null
&& NodeType.BETWEEN.getKey().equals(nodeValue.getNodeType())
&& added.add(nodeValue.getNodeCode())) {
backNodeList.add(nodeValue);
}
}
if (CollUtil.isNotEmpty(backNodeList)) {
Collections.reverse(backNodeList);
return backNodeList;
if (CollUtil.isNotEmpty(nodes)) {
return StreamUtils.filter(nodes, e -> NodeType.BETWEEN.getKey().equals(e.getNodeType()));
}
return nodes;
}
private void getBackTaskNodes(List<Node> nodes, Instance instance, List<Node> startNodes) {
nodes.addAll(startNodes);
for (Node startNode : startNodes) {
try {
List<Node> temp = nodeService.getNextNodeList(instance.getDefinitionId(), startNode.getNodeCode(), null, SkipType.PASS.getKey(), instance.getVariableMap());
getBackTaskNodes(nodes, instance, temp);
}catch(Exception e){
// log.info();
}
}
}
/**
* 终止任务
*