提交 | 用户 | 时间
|
bb2880
|
1 |
package com.iailab.module.bpm.framework.flowable.core.listener; |
H |
2 |
|
|
3 |
import cn.hutool.core.collection.CollUtil; |
|
4 |
import com.iailab.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker; |
|
5 |
import com.iailab.module.bpm.service.task.BpmProcessInstanceCopyService; |
|
6 |
import org.flowable.bpmn.model.FlowElement; |
|
7 |
import org.flowable.engine.delegate.DelegateExecution; |
|
8 |
import org.flowable.engine.delegate.JavaDelegate; |
|
9 |
import org.springframework.stereotype.Component; |
|
10 |
|
|
11 |
import javax.annotation.Resource; |
|
12 |
import java.util.Set; |
|
13 |
|
|
14 |
/** |
|
15 |
* 处理抄送用户的 {@link JavaDelegate} 的实现类 |
|
16 |
* <p> |
|
17 |
* 目前只有仿钉钉/飞书模式的【抄送节点】使用 |
|
18 |
* |
|
19 |
* @author hou |
|
20 |
*/ |
|
21 |
@Component(BpmCopyTaskDelegate.BEAN_NAME) |
|
22 |
public class BpmCopyTaskDelegate implements JavaDelegate { |
|
23 |
|
|
24 |
public static final String BEAN_NAME = "bpmCopyTaskDelegate"; |
|
25 |
|
|
26 |
@Resource |
|
27 |
private BpmTaskCandidateInvoker taskCandidateInvoker; |
|
28 |
|
|
29 |
@Resource |
|
30 |
private BpmProcessInstanceCopyService processInstanceCopyService; |
|
31 |
|
|
32 |
@Override |
|
33 |
public void execute(DelegateExecution execution) { |
|
34 |
// 1. 获得抄送人 |
|
35 |
Set<Long> userIds = taskCandidateInvoker.calculateUsersByTask(execution); |
|
36 |
if (CollUtil.isEmpty(userIds)) { |
|
37 |
return; |
|
38 |
} |
|
39 |
// 2. 执行抄送 |
|
40 |
FlowElement currentFlowElement = execution.getCurrentFlowElement(); |
|
41 |
processInstanceCopyService.createProcessInstanceCopy(userIds, null, execution.getProcessInstanceId(), |
|
42 |
currentFlowElement.getId(), currentFlowElement.getName(), null); |
|
43 |
} |
|
44 |
|
|
45 |
} |