Commit 6c6992c86a9f64b78e23c622a6f6204cd424e6ef

Authored by lizhixian
1 parent db6d7a74

feat:TODO List

yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
... ... @@ -525,6 +525,10 @@ public class BpmTaskServiceImpl implements BpmTaskService {
525 525 if (CollUtil.isNotEmpty(reqVO.getVariables())) {
526 526 Map<String, Object> variables = FlowableUtils.filterTaskFormVariable(reqVO.getVariables());
527 527 // 校验传递的参数中是否存在不是下一个执行的节点
  528 + // 当前执行的流程节点,需根据该节点寻找下一个节点
  529 + String taskDefinitionKey = task.getTaskDefinitionKey();
  530 + List<FlowNode> nextFlowNodes = getNextFlowNodes(taskDefinitionKey, bpmnModel, variables);
  531 + System.out.println(nextFlowNodes);
528 532 validateNextAssignees(userId, reqVO.getVariables(), task.getProcessInstanceId(), reqVO.getNextAssignees());
529 533 // 下个节点审批人如果不存在,则由前端传递
530 534 if (CollUtil.isNotEmpty(reqVO.getNextAssignees())) {
... ... @@ -544,6 +548,41 @@ public class BpmTaskServiceImpl implements BpmTaskService {
544 548 }
545 549  
546 550 /**
  551 + *
  552 + * @param taskDefinitionKey 当前节点id
  553 + * @param bpmnModel bpmnModel
  554 + */
  555 + private List<FlowNode> getNextFlowNodes(String taskDefinitionKey, BpmnModel bpmnModel, Map<String, Object> variables){
  556 + FlowNode flowElement = (FlowNode) bpmnModel.getFlowElement(taskDefinitionKey);
  557 + // 存储下一个执行的节点
  558 + List<FlowNode> nextFlowNodes = new ArrayList<>();
  559 + resolveNextNodes(flowElement, bpmnModel, variables, nextFlowNodes);
  560 + return nextFlowNodes;
  561 + }
  562 +
  563 + private void resolveNextNodes(FlowNode currentNode, BpmnModel bpmnModel, Map<String, Object> variables, List<FlowNode> nextFlowNodes) {
  564 + List<SequenceFlow> outgoingFlows = currentNode.getOutgoingFlows();
  565 + for (SequenceFlow sequenceFlow : outgoingFlows) {
  566 + // 如果是排他网关,需要根据条件表达式判断
  567 + if (currentNode instanceof ExclusiveGateway) {
  568 + String conditionExpression = sequenceFlow.getConditionExpression();
  569 + if (conditionExpression != null && !BpmnModelUtils.evalConditionExpress(variables,conditionExpression)) {
  570 + continue;
  571 + }
  572 + }
  573 + FlowElement targetElement = bpmnModel.getFlowElement(sequenceFlow.getTargetRef());
  574 + if (targetElement instanceof FlowNode targetNode) {
  575 + if (targetNode instanceof Gateway) {
  576 + // 如果目标节点还是网关,递归处理
  577 + resolveNextNodes(targetNode, bpmnModel, variables, nextFlowNodes);
  578 + } else {
  579 + nextFlowNodes.add(targetNode);
  580 + }
  581 + }
  582 + }
  583 + }
  584 +
  585 + /**
547 586 * 校验传递的参数中是否存在不是下一个执行的节点
548 587 *
549 588 * @param loginUserId 流程发起人
... ... @@ -559,6 +598,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
559 598 List<BpmApprovalDetailRespVO.ActivityNode> activityNodes = approvalDetail.getActivityNodes();
560 599 if (CollUtil.isNotEmpty(activityNodes)) {
561 600 // 2.1、获取节点中的审批人策略为【发起人自选】且状态为【未执行】的节点
  601 + // TODO 获取下一个执行节点
562 602 List<BpmApprovalDetailRespVO.ActivityNode> notStartActivityNodes = activityNodes.stream().filter(node ->
563 603 BpmTaskCandidateStrategyEnum.START_USER_SELECT.getStrategy().equals(node.getCandidateStrategy())
564 604 && BpmTaskStatusEnum.NOT_START.getStatus().equals(node.getStatus())
... ...