From 6b13839488edcd06046e26a41fe897358176689c Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期五, 13 十二月 2024 17:56:41 +0800
Subject: [PATCH] 采集质量

---
 iailab-module-bpm/iailab-module-bpm-biz/src/main/java/com/iailab/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateStartUserDeptLeaderMultiStrategy.java |   70 +++++++++++++++++++++++++++++++++++
 1 files changed, 70 insertions(+), 0 deletions(-)

diff --git a/iailab-module-bpm/iailab-module-bpm-biz/src/main/java/com/iailab/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateStartUserDeptLeaderMultiStrategy.java b/iailab-module-bpm/iailab-module-bpm-biz/src/main/java/com/iailab/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateStartUserDeptLeaderMultiStrategy.java
new file mode 100644
index 0000000..a041dbb
--- /dev/null
+++ b/iailab-module-bpm/iailab-module-bpm-biz/src/main/java/com/iailab/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateStartUserDeptLeaderMultiStrategy.java
@@ -0,0 +1,70 @@
+package com.iailab.module.bpm.framework.flowable.core.candidate.strategy.dept;
+
+import cn.hutool.core.lang.Assert;
+import com.iailab.framework.common.util.number.NumberUtils;
+import com.iailab.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
+import com.iailab.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
+import com.iailab.module.bpm.service.task.BpmProcessInstanceService;
+import com.iailab.module.system.api.dept.dto.DeptRespDTO;
+import org.flowable.bpmn.model.BpmnModel;
+import org.flowable.engine.delegate.DelegateExecution;
+import org.flowable.engine.runtime.ProcessInstance;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import static cn.hutool.core.collection.ListUtil.toList;
+
+/**
+ * 发起人连续多级部门的负责人 {@link BpmTaskCandidateStrategy} 实现类
+ *
+ * @author hou
+ */
+@Component
+public class BpmTaskCandidateStartUserDeptLeaderMultiStrategy extends AbstractBpmTaskCandidateDeptLeaderStrategy {
+
+    @Resource
+    @Lazy
+    private BpmProcessInstanceService processInstanceService;
+
+    @Override
+    public BpmTaskCandidateStrategyEnum getStrategy() {
+        return BpmTaskCandidateStrategyEnum.START_USER_DEPT_LEADER_MULTI;
+    }
+
+    @Override
+    public void validateParam(String param) {
+        int level = Integer.parseInt(param); // 参数是部门的层级
+        Assert.isTrue(level > 0, "部门的层级必须大于 0");
+    }
+
+    @Override
+    public Set<Long> calculateUsersByTask(DelegateExecution execution, String param) {
+        int level = Integer.parseInt(param); // 参数是部门的层级
+        // 获得流程发起人
+        ProcessInstance processInstance = processInstanceService.getProcessInstance(execution.getProcessInstanceId());
+        Long startUserId = NumberUtils.parseLong(processInstance.getStartUserId());
+        // 获取发起人的 multi 部门负责人
+        DeptRespDTO dept = super.getStartUserDept(startUserId);
+        if (dept == null) {
+            return new HashSet<>();
+        }
+        return super.getMultiLevelDeptLeaderIds(toList(dept.getId()), level);
+    }
+
+    @Override
+    public Set<Long> calculateUsersByActivity(BpmnModel bpmnModel, String activityId, String param,
+                                              Long startUserId, String processDefinitionId, Map<String, Object> processVariables) {
+        int level = Integer.parseInt(param); // 参数是部门的层级
+        DeptRespDTO dept = super.getStartUserDept(startUserId);
+        if (dept == null) {
+            return new HashSet<>();
+        }
+        return super.getMultiLevelDeptLeaderIds(toList(dept.getId()), level);
+    }
+
+}

--
Gitblit v1.9.3