Commit 045fb584d25b0109c31e8822c6f567d4fa6756b3
1 parent
4364ef09
【代码评审】BPM:子流程的想法
Showing
3 changed files
with
11 additions
and
4 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java
| ... | ... | @@ -148,6 +148,7 @@ public class BpmProcessInstanceController { |
| 148 | 148 | processDefinition, processDefinitionInfo, startUser, dept)); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | + // TODO @lesan:【子流程】子流程如果取消,主流程应该是通过、还是不通过哈?还是禁用掉子流程的取消? | |
| 151 | 152 | @DeleteMapping("/cancel-by-start-user") |
| 152 | 153 | @Operation(summary = "用户取消流程实例", description = "取消发起的流程") |
| 153 | 154 | @PreAuthorize("@ss.hasPermission('bpm:process-instance:cancel')") | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateInvoker.java
| ... | ... | @@ -19,6 +19,7 @@ import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 19 | 19 | import com.google.common.annotations.VisibleForTesting; |
| 20 | 20 | import lombok.extern.slf4j.Slf4j; |
| 21 | 21 | import org.flowable.bpmn.model.BpmnModel; |
| 22 | +import org.flowable.bpmn.model.CallActivity; | |
| 22 | 23 | import org.flowable.bpmn.model.FlowElement; |
| 23 | 24 | import org.flowable.bpmn.model.UserTask; |
| 24 | 25 | import org.flowable.engine.delegate.DelegateExecution; |
| ... | ... | @@ -129,8 +130,12 @@ public class BpmTaskCandidateInvoker { |
| 129 | 130 | |
| 130 | 131 | public Set<Long> calculateUsersByActivity(BpmnModel bpmnModel, String activityId, |
| 131 | 132 | Long startUserId, String processDefinitionId, Map<String, Object> processVariables) { |
| 132 | - // 审批类型非人工审核时,不进行计算候选人。原因是:后续会自动通过、不通过 | |
| 133 | + // 如果是 CallActivity 子流程,不进行计算候选人 | |
| 133 | 134 | FlowElement flowElement = BpmnModelUtils.getFlowElementById(bpmnModel, activityId); |
| 135 | + if (flowElement instanceof CallActivity) { | |
| 136 | + return new HashSet<>(); | |
| 137 | + } | |
| 138 | + // 审批类型非人工审核时,不进行计算候选人。原因是:后续会自动通过、不通过 | |
| 134 | 139 | Integer approveType = BpmnModelUtils.parseApproveType(flowElement); |
| 135 | 140 | if (ObjectUtils.equalsAny(approveType, |
| 136 | 141 | BpmUserTaskApproveTypeEnum.AUTO_APPROVE.getType(), | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java
| ... | ... | @@ -390,9 +390,9 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 390 | 390 | HistoricProcessInstance historicProcessInstance, Integer processInstanceStatus, |
| 391 | 391 | List<HistoricActivityInstance> activities, List<HistoricTaskInstance> tasks) { |
| 392 | 392 | // 遍历 tasks 列表,只处理已结束的 UserTask |
| 393 | - // 为什么不通过 activities 呢?因为,加签场景下,它只存在于 tasks,没有 activities,导致如果遍历 activities | |
| 394 | - // 的话,它无法成为一个节点 | |
| 395 | - // TODO @芋艿:子流程只有activity,这里获取不到已结束的子流程;TODO @lesan:这个会导致timeline不会展示已结束的子流程 | |
| 393 | + // 为什么不通过 activities 呢?因为,加签场景下,它只存在于 tasks,没有 activities,导致如果遍历 activities 的话,它无法成为一个节点 | |
| 394 | + // TODO @芋艿:子流程只有activity,这里获取不到已结束的子流程; | |
| 395 | + // TODO @lesan:【子流程】基于 activities 查询出 usertask、callactivity,然后拼接?如果是子流程,就是可以点击过去? | |
| 396 | 396 | List<HistoricTaskInstance> endTasks = filterList(tasks, task -> task.getEndTime() != null); |
| 397 | 397 | List<ActivityNode> approvalNodes = convertList(endTasks, task -> { |
| 398 | 398 | FlowElement flowNode = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey()); |
| ... | ... | @@ -468,6 +468,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 468 | 468 | HistoricActivityInstance::getActivityId); |
| 469 | 469 | |
| 470 | 470 | // 按照 activityId 分组,构建 ApprovalNodeInfo 节点 |
| 471 | + // TODO @lesan:【子流程】在子流程进行审批的时候,HistoricActivityInstance 里面可以拿到 runActivities.get(0).getCalledProcessInstanceId()。要不要支持跳转??? | |
| 471 | 472 | Map<String, HistoricTaskInstance> taskMap = convertMap(tasks, HistoricTaskInstance::getId); |
| 472 | 473 | return convertList(runningTaskMap.entrySet(), entry -> { |
| 473 | 474 | String activityId = entry.getKey(); | ... | ... |