fix(bpm):解决包容网关存在多个激活分支时,分支上节点进行退回到包容网关前节点操作时多个execution退回导致的在目标节点创建多个任务问题
This commit is contained in:
parent
bb236af631
commit
aebd2499bb
|
@ -0,0 +1,33 @@
|
|||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener;
|
||||
|
||||
/**
|
||||
* @Author whc
|
||||
* @Date 2025/5/21 11:30
|
||||
*/
|
||||
import org.flowable.common.engine.impl.interceptor.Command;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.flowable.engine.impl.persistence.entity.ExecutionEntityManager;
|
||||
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||
|
||||
public class DeleteExecutionCommand implements Command<Void> {
|
||||
|
||||
private final String executionId;
|
||||
private final String reason;
|
||||
|
||||
public DeleteExecutionCommand(String executionId, String reason) {
|
||||
this.executionId = executionId;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void execute(CommandContext commandContext) {
|
||||
ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext);
|
||||
ExecutionEntity execution = executionEntityManager.findById(executionId);
|
||||
if (execution != null) {
|
||||
executionEntityManager.deleteExecutionAndRelatedData(execution, reason, false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@ import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskSignTypeEnum;
|
|||
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.DeleteExecutionCommand;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmHttpRequestUtils;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
|
||||
|
@ -906,9 +907,16 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||
// 4. 执行驳回
|
||||
// 使用 moveExecutionsToSingleActivityId 替换 moveActivityIdsToSingleActivityId 原因:
|
||||
// 当多实例任务回退的时候有问题。相关 issue: https://github.com/flowable/flowable-engine/issues/3944
|
||||
// 选择一个主 execution
|
||||
String mainExecutionId = runExecutionIds.get(0);
|
||||
// 删除其他 execution 解决多个execution会在移动的目标节点创建出多个任务的问题
|
||||
for (int i = 1; i < runExecutionIds.size(); i++) {
|
||||
String redundantId = runExecutionIds.get(i);
|
||||
managementService.executeCommand(new DeleteExecutionCommand(redundantId, "退回清理冗余路径"));
|
||||
}
|
||||
runtimeService.createChangeActivityStateBuilder()
|
||||
.processInstanceId(currentTask.getProcessInstanceId())
|
||||
.moveExecutionsToSingleActivityId(runExecutionIds, reqVO.getTargetTaskDefinitionKey())
|
||||
.moveExecutionToActivityId(mainExecutionId, reqVO.getTargetTaskDefinitionKey())
|
||||
.changeState();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue