Explorar el Código

仿钉钉流程设计- 增加发起人自己候选人策略

jason hace 1 año
padre
commit
afad8ac619

+ 50 - 0
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateStartUserStrategy.java

@@ -0,0 +1,50 @@
+package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy;
+
+import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
+import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
+import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
+import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
+import jakarta.annotation.Resource;
+import org.flowable.engine.delegate.DelegateExecution;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Component;
+
+import java.util.Set;
+
+/**
+ * 发起人自己 {@link BpmTaskCandidateUserStrategy} 实现类。 用于需要发起人信息复核等场景
+ *
+ * @author jason
+ */
+@Component
+public class BpmTaskCandidateStartUserStrategy implements BpmTaskCandidateStrategy {
+
+    @Resource
+    @Lazy // 延迟加载,避免循环依赖
+    private BpmProcessInstanceService processInstanceService;
+
+    @Override
+    public BpmTaskCandidateStrategyEnum getStrategy() {
+        return BpmTaskCandidateStrategyEnum.START_USER;
+    }
+
+    /**
+     * 无需校验参数
+     */
+    @Override
+    public void validateParam(String param) {}
+
+    @Override
+    public Set<Long> calculateUsers(DelegateExecution execution, String param) {
+        String startUserId = processInstanceService.getProcessInstance(execution.getProcessInstanceId()).getStartUserId();
+        return SetUtils.asSet(Long.valueOf(startUserId));
+    }
+
+    /**
+     * 不需要参数
+     */
+    @Override
+    public boolean isParamRequired() {
+        return false;
+    }
+}

+ 1 - 0
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmTaskCandidateStrategyEnum.java

@@ -21,6 +21,7 @@ public enum BpmTaskCandidateStrategyEnum {
     POST(22, "岗位"),
     USER(30, "用户"),
     START_USER_SELECT(35, "发起人自选"), // 申请人自己,可在提交申请时选择此节点的审批人
+    START_USER(36, "发起人自己"), // 申请人自己, 一般紧挨开始节点,常用于发起人信息审核场景
     USER_GROUP(40, "用户组"),
     EXPRESSION(60, "流程表达式"), // 表达式 ExpressionManager
     ;