Commit a1cb21f3b1daa9a6bb74e6cab64afdd231376251
Merge branch 'develop' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into master-jdk17
# Conflicts: # yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
Showing
2 changed files
with
15 additions
and
17 deletions
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java
| ... | ... | @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.bpm.service.task; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.collection.ListUtil; |
| 5 | -import cn.hutool.core.date.DatePattern; | |
| 6 | 5 | import cn.hutool.core.date.DateUtil; |
| 7 | 6 | import cn.hutool.core.lang.Assert; |
| 8 | 7 | import cn.hutool.core.map.MapUtil; |
| ... | ... | @@ -14,7 +13,6 @@ import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 14 | 13 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| 15 | 14 | import cn.iocoder.yudao.framework.common.util.object.PageUtils; |
| 16 | 15 | import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; |
| 17 | -import cn.iocoder.yudao.module.bpm.controller.admin.base.user.UserSimpleBaseVO; | |
| 18 | 16 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelMetaInfoVO; |
| 19 | 17 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO; |
| 20 | 18 | import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*; |
| ... | ... | @@ -73,7 +71,6 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU |
| 73 | 71 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; |
| 74 | 72 | import static cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmApprovalDetailRespVO.ActivityNode; |
| 75 | 73 | import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; |
| 76 | -import static cn.iocoder.yudao.module.bpm.enums.task.BpmReasonEnum.REJECT_CHILD_PROCESS; | |
| 77 | 74 | import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.START_USER_NODE_ID; |
| 78 | 75 | import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_PREFIX; |
| 79 | 76 | import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.parseNodeType; |
| ... | ... | @@ -237,8 +234,9 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 237 | 234 | needSimulateTaskDefKeysByReturn.add(StrUtil.removePrefix(key, PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_PREFIX))); |
| 238 | 235 | } |
| 239 | 236 | // 移除运行中的节点,运行中的节点无需预测 |
| 240 | - // TODO @jason:是不是 foreach runActivityNodes,然后移除 needSimulateTaskDefKeysByReturn 更好?(理解成本低一点) | |
| 241 | - CollectionUtils.convertList(runActivityNodes, ActivityNode::getId).forEach(needSimulateTaskDefKeysByReturn::remove); | |
| 237 | + if (CollUtil.isNotEmpty(runActivityNodes)) { | |
| 238 | + runActivityNodes.forEach( activityNode -> needSimulateTaskDefKeysByReturn.remove(activityNode.getId())); | |
| 239 | + } | |
| 242 | 240 | |
| 243 | 241 | // 3.3 预测未运行节点的审批信息 |
| 244 | 242 | List<ActivityNode> simulateActivityNodes = getSimulateApproveNodeList(startUserId, bpmnModel, | ... | ... |
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
| ... | ... | @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.bpm.service.task; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.convert.Convert; |
| 5 | -import cn.hutool.core.date.DateUtil; | |
| 6 | 5 | import cn.hutool.core.lang.Assert; |
| 7 | 6 | import cn.hutool.core.util.*; |
| 8 | 7 | import cn.hutool.extra.spring.SpringUtil; |
| ... | ... | @@ -939,9 +938,10 @@ public class BpmTaskServiceImpl implements BpmTaskService { |
| 939 | 938 | |
| 940 | 939 | // 3. 构建需要预测的任务流程变量 |
| 941 | 940 | // TODO @jason:【驳回预测相关】是不是搞成一个变量,里面是 set 更简洁一点呀? |
| 942 | - Set<String> taskDefinitionKeyList = getNeedSimulateTaskDefinitionKeys(bpmnModel, currentTask, targetElement); | |
| 943 | - Map<String, Object> needSimulateVariables = convertMap(taskDefinitionKeyList, | |
| 944 | - taskId -> StrUtil.concat(false, BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_PREFIX, taskId), item -> Boolean.TRUE); | |
| 941 | + Set<String> needSimulateTaskDefinitionKeys = getNeedSimulateTaskDefinitionKeys(bpmnModel, currentTask, targetElement); | |
| 942 | + Map<String, Object> needSimulateVariables = convertMap(needSimulateTaskDefinitionKeys, | |
| 943 | + key -> StrUtil.concat(false, PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_PREFIX, key), item -> Boolean.TRUE); | |
| 944 | + | |
| 945 | 945 | |
| 946 | 946 | // 4. 执行驳回 |
| 947 | 947 | // 使用 moveExecutionsToSingleActivityId 替换 moveActivityIdsToSingleActivityId 原因: |
| ... | ... | @@ -962,22 +962,22 @@ public class BpmTaskServiceImpl implements BpmTaskService { |
| 962 | 962 | // 1. 获取需要预测的任务的 definition key。因为当前任务还没完成,也需要预测 |
| 963 | 963 | Set<String> taskDefinitionKeys = CollUtil.newHashSet(currentTask.getTaskDefinitionKey()); |
| 964 | 964 | |
| 965 | - // 2.1 从已结束任务中找到要回退的目标任务,按时间倒序最近的一个目标任务 | |
| 965 | + // 2.1 获取已结束任务按时间倒序排序 | |
| 966 | 966 | List<HistoricTaskInstance> endTaskList = CollectionUtils.filterList( |
| 967 | 967 | getTaskListByProcessInstanceId(currentTask.getProcessInstanceId(), Boolean.FALSE), |
| 968 | 968 | item -> item.getEndTime() != null); |
| 969 | - // 2.2 遍历已结束的任务,找到在 targetTask 之后生成的任务,且串行可达的任务 | |
| 969 | + // 2.2 从结束任务中找到最近一个的目标任务 | |
| 970 | 970 | HistoricTaskInstance targetTask = findFirst(endTaskList, |
| 971 | 971 | item -> item.getTaskDefinitionKey().equals(targetElement.getId())); |
| 972 | - // TODO @jason:【驳回预测相关】是不是 if targetTask 先判空? | |
| 972 | + if (targetTask == null) { | |
| 973 | + return taskDefinitionKeys; | |
| 974 | + } | |
| 975 | + // 2.3 遍历已结束的任务,找到在 targetTask 之后生成的任务,且串行可达的任务 | |
| 973 | 976 | endTaskList.forEach(item -> { |
| 974 | 977 | FlowElement element = getFlowElementById(bpmnModel, item.getTaskDefinitionKey()); |
| 975 | - // 如果已结束的任务在回退目标节点之后生成,且串行可达,则标记为需要预算节点 | |
| 978 | + // 如果已结束的任务在回退目标节点之后生成,且串行可达,则加到需要预测节点中 | |
| 976 | 979 | // TODO 串行可达的方法需要和判断可回退节点 validateTargetTaskCanReturn 分开吗? 并行网关可能会有问题。 |
| 977 | - // TODO @jason:【驳回预测相关】这里是不是判断 element 哈? | |
| 978 | - if (targetTask != null | |
| 979 | - // TODO @jason:【驳回预测相关】这里直接 createTime 的 compare 更简单?因为不太会出现空哈。 | |
| 980 | - && DateUtil.compare(item.getCreateTime(), targetTask.getCreateTime()) > 0 | |
| 980 | + if (item.getCreateTime().compareTo(targetTask.getCreateTime()) > 0 | |
| 981 | 981 | && BpmnModelUtils.isSequentialReachable(element, targetElement, null)) { |
| 982 | 982 | taskDefinitionKeys.add(item.getTaskDefinitionKey()); |
| 983 | 983 | } | ... | ... |