fix: 存在子流程情况下的取消逻辑优化

This commit is contained in:
Lesan
2025-03-25 10:24:34 +08:00
parent 4fbe9fa480
commit e14716a307
5 changed files with 15 additions and 2 deletions

View File

@@ -148,7 +148,6 @@ public class BpmProcessInstanceController {
processDefinition, processDefinitionInfo, startUser, dept));
}
// TODO @lesan【子流程】子流程如果取消主流程应该是通过、还是不通过哈还是禁用掉子流程的取消
@DeleteMapping("/cancel-by-start-user")
@Operation(summary = "用户取消流程实例", description = "取消发起的流程")
@PreAuthorize("@ss.hasPermission('bpm:process-instance:cancel')")

View File

@@ -813,7 +813,6 @@ public class SimpleModelUtils {
callActivity.setCalledElementType("key");
// 1. 是否异步
if (node.getChildProcessSetting().getAsync()) {
// TODO @lesan: 这里目前测试没有跳过执行call activity 后面的节点
callActivity.setAsynchronous(true);
}

View File

@@ -823,6 +823,10 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
&& Boolean.FALSE.equals(processDefinitionInfo.getAllowCancelRunningProcess())) {
throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_ALLOW);
}
// 1.4 子流程不允许取消
if (StrUtil.isNotBlank(instance.getSuperExecutionId())) {
throw exception(CHILD_PROCESS_INSTANCE_CANCEL_FAIL_NOT_ALLOW);
}
// 2. 取消流程
updateProcessInstanceCancel(cancelReqVO.getId(),
@@ -851,6 +855,15 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
// 2. 结束流程
taskService.moveTaskToEnd(id, reason);
// 3. 取消所有子流程
List<ProcessInstance> subProcessInstances = runtimeService.createProcessInstanceQuery()
.superProcessInstanceId(id)
.list();
subProcessInstances.forEach(processInstance -> {
updateProcessInstanceCancel(processInstance.getProcessInstanceId(),
BpmReasonEnum.CANCEL_CHILD_PROCESS_INSTANCE_BY_MAIN_PROCESS.getReason());
});
}
@Override