yxk-20260506-自定义监听class:
SaveCurrentTaskAssigneeLocalListener保存当前节点办理人到子流程的局部变量中去
This commit is contained in:
+19
-3
@@ -4,9 +4,13 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.delegate.TaskListener;
|
||||
import org.flowable.engine.runtime.Execution;
|
||||
import org.flowable.task.service.delegate.DelegateTask;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Save the current task assignee as an execution local variable.
|
||||
*/
|
||||
@@ -37,8 +41,20 @@ public class SaveCurrentTaskAssigneeLocalListener implements TaskListener {
|
||||
delegateTask.getId(), delegateTask.getTaskDefinitionKey());
|
||||
return;
|
||||
}
|
||||
runtimeService.setVariableLocal(delegateTask.getExecutionId(), VARIABLE_NAME, assignee);
|
||||
log.info("SaveCurrentTaskAssigneeLocalListener success, taskId={}, taskDefinitionKey={}, variableName={}, assignee={}",
|
||||
delegateTask.getId(), delegateTask.getTaskDefinitionKey(), VARIABLE_NAME, assignee);
|
||||
Set<String> executionIds = new LinkedHashSet<>();
|
||||
executionIds.add(delegateTask.getExecutionId());
|
||||
|
||||
Execution execution = runtimeService.createExecutionQuery()
|
||||
.executionId(delegateTask.getExecutionId())
|
||||
.singleResult();
|
||||
if (execution != null && StringUtils.isNotBlank(execution.getParentId())) {
|
||||
executionIds.add(execution.getParentId());
|
||||
}
|
||||
|
||||
for (String executionId : executionIds) {
|
||||
runtimeService.setVariableLocal(executionId, VARIABLE_NAME, assignee);
|
||||
}
|
||||
log.info("SaveCurrentTaskAssigneeLocalListener success, taskId={}, taskDefinitionKey={}, variableName={}, assignee={}, executionIds={}",
|
||||
delegateTask.getId(), delegateTask.getTaskDefinitionKey(), VARIABLE_NAME, assignee, executionIds);
|
||||
}
|
||||
}
|
||||
|
||||
+15
-3
@@ -342,9 +342,21 @@ public class FlowNodeExpression {
|
||||
task.getId(), task.getTaskDefinitionKey());
|
||||
return;
|
||||
}
|
||||
runtimeService.setVariableLocal(task.getExecutionId(), variableName, assignee);
|
||||
log.info("saveCurrentTaskAssigneeLocal success, taskId={}, taskDefinitionKey={}, variableName={}, assignee={}",
|
||||
task.getId(), task.getTaskDefinitionKey(), variableName, assignee);
|
||||
Set<String> executionIds = new LinkedHashSet<>();
|
||||
executionIds.add(task.getExecutionId());
|
||||
|
||||
Execution execution = runtimeService.createExecutionQuery()
|
||||
.executionId(task.getExecutionId())
|
||||
.singleResult();
|
||||
if (execution != null && StringUtils.isNotBlank(execution.getParentId())) {
|
||||
executionIds.add(execution.getParentId());
|
||||
}
|
||||
|
||||
for (String executionId : executionIds) {
|
||||
runtimeService.setVariableLocal(executionId, variableName, assignee);
|
||||
}
|
||||
log.info("saveCurrentTaskAssigneeLocal success, taskId={}, taskDefinitionKey={}, variableName={}, assignee={}, executionIds={}",
|
||||
task.getId(), task.getTaskDefinitionKey(), variableName, assignee, executionIds);
|
||||
}
|
||||
|
||||
private List<String> splitUsernames(Object value) {
|
||||
|
||||
Reference in New Issue
Block a user