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.apache.commons.lang.StringUtils;
|
||||||
import org.flowable.engine.RuntimeService;
|
import org.flowable.engine.RuntimeService;
|
||||||
import org.flowable.engine.delegate.TaskListener;
|
import org.flowable.engine.delegate.TaskListener;
|
||||||
|
import org.flowable.engine.runtime.Execution;
|
||||||
import org.flowable.task.service.delegate.DelegateTask;
|
import org.flowable.task.service.delegate.DelegateTask;
|
||||||
import org.jeecg.common.util.SpringContextUtils;
|
import org.jeecg.common.util.SpringContextUtils;
|
||||||
|
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the current task assignee as an execution local variable.
|
* Save the current task assignee as an execution local variable.
|
||||||
*/
|
*/
|
||||||
@@ -37,8 +41,20 @@ public class SaveCurrentTaskAssigneeLocalListener implements TaskListener {
|
|||||||
delegateTask.getId(), delegateTask.getTaskDefinitionKey());
|
delegateTask.getId(), delegateTask.getTaskDefinitionKey());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
runtimeService.setVariableLocal(delegateTask.getExecutionId(), VARIABLE_NAME, assignee);
|
Set<String> executionIds = new LinkedHashSet<>();
|
||||||
log.info("SaveCurrentTaskAssigneeLocalListener success, taskId={}, taskDefinitionKey={}, variableName={}, assignee={}",
|
executionIds.add(delegateTask.getExecutionId());
|
||||||
delegateTask.getId(), delegateTask.getTaskDefinitionKey(), VARIABLE_NAME, assignee);
|
|
||||||
|
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());
|
task.getId(), task.getTaskDefinitionKey());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
runtimeService.setVariableLocal(task.getExecutionId(), variableName, assignee);
|
Set<String> executionIds = new LinkedHashSet<>();
|
||||||
log.info("saveCurrentTaskAssigneeLocal success, taskId={}, taskDefinitionKey={}, variableName={}, assignee={}",
|
executionIds.add(task.getExecutionId());
|
||||||
task.getId(), task.getTaskDefinitionKey(), variableName, assignee);
|
|
||||||
|
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) {
|
private List<String> splitUsernames(Object value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user