Commit 9cd964a9d800409ac464372a2c9dcc9e3775c0b0

Authored by jason
1 parent d37bc069

feat: flowable 升级 8.0.0。 并修复并行分支回退到并行节点前的问题

yudao-dependencies/pom.xml
... ... @@ -46,7 +46,7 @@
46 46 <jedis-mock.version>1.1.12</jedis-mock.version>
47 47 <mockito-inline.version>5.2.0</mockito-inline.version>
48 48 <!-- Bpm 工作流相关 -->
49   - <flowable.version>7.2.0</flowable.version>
  49 + <flowable.version>8.0.0</flowable.version>
50 50 <!-- 工具类相关 -->
51 51 <anji-plus-captcha.version>1.4.0</anji-plus-captcha.version>
52 52 <jsoup.version>1.22.2</jsoup.version>
... ...
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
... ... @@ -943,7 +943,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
943 943 * @param reqVO 前端参数封装
944 944 */
945 945 public void returnTask(Long userId, BpmnModel bpmnModel, Task currentTask, FlowElement targetElement, BpmTaskReturnReqVO reqVO) {
946   - // 1. 获得所有需要回撤的任务 taskDefinitionKey,用于稍后的 moveExecutionsToSingleActivityId 回撤
  946 + // 1. 获得所有需要回撤的任务 taskDefinitionKey,用于稍后的 moveActivityIdsToSingleActivityId 回撤
947 947 // 1.1 获取所有正常进行的任务节点 Key
948 948 List<Task> taskList = taskService.createTaskQuery().processInstanceId(currentTask.getProcessInstanceId()).list();
949 949 List<String> runTaskKeyList = convertList(taskList, Task::getTaskDefinitionKey);
... ... @@ -951,16 +951,12 @@ public class BpmTaskServiceImpl implements BpmTaskService {
951 951 // 为什么不直接使用 runTaskKeyList 呢?因为可能存在多个审批分支,例如说:A -> B -> C 和 D -> F,而只要 C 撤回到 A,需要排除掉 F
952 952 List<UserTask> returnUserTaskList = BpmnModelUtils.iteratorFindChildUserTasks(targetElement, runTaskKeyList, null, null);
953 953 List<String> returnTaskKeyList = convertList(returnUserTaskList, UserTask::getId);
954   - List<String> runExecutionIds = new ArrayList<>();
955 954 // 2. 给当前要被退回的 task 数组,设置退回意见
956 955 taskList.forEach(task -> {
957 956 // 需要排除掉,不需要设置退回意见的任务
958 957 if (!returnTaskKeyList.contains(task.getTaskDefinitionKey())) {
959 958 return;
960 959 }
961   - if (task.getExecutionId() != null) {
962   - runExecutionIds.add(task.getExecutionId());
963   - }
964 960 // 判断是否分配给自己任务,因为会签任务,一个节点会有多个任务
965 961 if (isAssignUserTask(userId, task)) { // 情况一:自己的任务,进行 RETURN 标记
966 962 // 2.1.1 添加评论
... ... @@ -977,21 +973,17 @@ public class BpmTaskServiceImpl implements BpmTaskService {
977 973 Set<String> needSimulateTaskDefinitionKeys = getNeedSimulateTaskDefinitionKeys(bpmnModel, currentTask, targetElement);
978 974  
979 975 // 4. 执行驳回
980   - // 4.1 校验是否有可回撤的 execution,避免 moveExecutionsToSingleActivityId 传入空集合时 Flowable 内部报错
981   - if (CollUtil.isEmpty(runExecutionIds)) {
982   - throw exception(TASK_RETURN_FAIL_SOURCE_TARGET_ERROR);
983   - }
984   - // 4.2 执行驳回
985 976 // ① 使用 moveExecutionsToSingleActivityId 替换 moveActivityIdsToSingleActivityId。原因:当多实例任务回退的时候有问题。
986 977 // 相关 issue: https://github.com/flowable/flowable-engine/issues/3944
987 978 // ② flowable 7.2.0 版本后,继续使用 moveActivityIdsToSingleActivityId 方法。原因:flowable 7.2.0 版本修复了该问题。
988 979 // 相关 issue:https://github.com/YunaiV/ruoyi-vue-pro/issues/1018
989 980 // ③ moveActivityIdsToSingleActivityId 使用遇到问题, 相关 issue https://gitee.com/zhijiantianya/yudao-cloud/issues/IJM8MS
990 981 // 改成 moveExecutionsToSingleActivityId 好像并没有遇到 ② 提到的超时提醒失效的问题。暂时先改回 moveExecutionsToSingleActivityId
991   - // 目前还有的相关问题 https://t.zsxq.com/z4d9i。 估计需要升级 flowable 8 版本试试
  982 + // ④ moveExecutionsToSingleActivityId 回退多实例的时候不会去删除多实例根, 应改成 moveActivityIdsToSingleActivityId
  983 + // flowable 8.0.0 修复上面相关问题, 还修复了并行分支回退的问题 https://t.zsxq.com/z4d9i。
992 984 runtimeService.createChangeActivityStateBuilder()
993 985 .processInstanceId(currentTask.getProcessInstanceId())
994   - .moveExecutionsToSingleActivityId(runExecutionIds, reqVO.getTargetTaskDefinitionKey())
  986 + .moveActivityIdsToSingleActivityId(returnTaskKeyList, reqVO.getTargetTaskDefinitionKey())
995 987 // 设置需要预测的任务 ids 的流程变量,用于辅助预测
996 988 .processVariable(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskDefinitionKeys)
997 989 // 设置流程变量节点退回标记, 用于退回到节点,不执行 BpmUserTaskAssignStartUserHandlerTypeEnum 策略,导致自动通过
... ...