ソースを参照

!1204 BPM:更多设置-自动去重
Merge pull request !1204 from Lesan/feature/bpm-自动去重

芋道源码 6 ヶ月 前
コミット
808f23ec49

+ 3 - 4
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmAutoApproveType.java

@@ -15,10 +15,9 @@ import java.util.Arrays;
 @AllArgsConstructor
 public enum BpmAutoApproveType implements IntArrayValuable {
 
-    // TODO @lesan:0、1、/2 会不会好理解一点哈。
-    NONE(1, "不自动通过"),
-    APPROVE_ALL(2, "仅审批一次,后续重复的审批节点均自动通过"),
-    APPROVE_SEQUENT(3, "仅针对连续审批的节点自动通过");
+    NONE(0, "不自动通过"),
+    APPROVE_ALL(1, "仅审批一次,后续重复的审批节点均自动通过"),
+    APPROVE_SEQUENT(2, "仅针对连续审批的节点自动通过");
 
     public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BpmAutoApproveType::getType).toArray();
 

+ 3 - 13
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java

@@ -62,8 +62,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
 import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
 import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG;
-import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.parseReasonRequire;
-import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.parseSignEnable;
+import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.*;
 
 /**
  * 流程任务实例 Service 实现类
@@ -1197,17 +1196,8 @@ public class BpmTaskServiceImpl implements BpmTaskService {
                             log.error("[processTaskAssigned][taskId({}) 没有找到流程模型({})]", task.getId(), task.getProcessDefinitionId());
                             return;
                         }
-                        // TODO @lesan:这里的逻辑,要不在 BpmnModelUtils 抽个方法???尽量收敛
-                        FlowNode taskElement = (FlowNode) BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey());
-                        List<SequenceFlow> incomingFlows = taskElement.getIncomingFlows();
-                        List<String> sourceTaskIds = new ArrayList<>();
-                        // TODO @lesan:这种 CollUtil.isnotempty 简化
-                        if (incomingFlows != null && !incomingFlows.isEmpty()) {
-                            // TODO @lesan:这种,idea 一般会告警,可以处理掉哈。一切警告,皆是错误
-                            incomingFlows.forEach(flow -> {
-                                sourceTaskIds.add(flow.getSourceRef());
-                            });
-                        }
+                        List<String> sourceTaskIds = getElementIncomingFlows(getFlowElementById(bpmnModel, task.getTaskDefinitionKey()))
+                                .stream().map(SequenceFlow::getSourceRef).toList();
                         if (sameAssigneeQuery.taskDefinitionKeys(sourceTaskIds).count() > 0) {
                             getSelf().approveTask(Long.valueOf(task.getAssignee()), new BpmTaskApproveReqVO().setId(task.getId())
                                     .setReason(BpmAutoApproveType.APPROVE_SEQUENT.getName()));