yxk-20260506-自定义流程表达式:
1、saveCurrentTaskAssigneeLocal保存当前节点办理人到子流程的局部变量中去 2、getSonProcessVariableString获取子流程变量,返回类型是String
This commit is contained in:
+44
@@ -8,6 +8,7 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.flowable.engine.runtime.Execution;
|
||||
import org.flowable.task.service.delegate.DelegateTask;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -152,6 +153,49 @@ public class FlowNodeExpression {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get first subprocess variable username.
|
||||
* Example: ${flowNodeExpression.getSonProcessVariableString(execution, 'subApproveUser')}
|
||||
*
|
||||
* @param execution current execution
|
||||
* @param variableName subprocess variable name
|
||||
* @return username
|
||||
*/
|
||||
public String getSonProcessVariableString(DelegateExecution execution, String variableName) {
|
||||
List<String> usernames = getSonProcessVariable(execution, variableName);
|
||||
if (CollectionUtils.isEmpty(usernames)) {
|
||||
return null;
|
||||
}
|
||||
return usernames.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save current task assignee as execution local variable.
|
||||
* Example: ${flowNodeExpression.saveCurrentTaskAssigneeLocal(task, 'subApproveUser')}
|
||||
*
|
||||
* @param task current task
|
||||
* @param variableName local variable name
|
||||
*/
|
||||
public void saveCurrentTaskAssigneeLocal(DelegateTask task, String variableName) {
|
||||
if (task == null || StringUtils.isBlank(variableName)) {
|
||||
return;
|
||||
}
|
||||
String assignee = task.getAssignee();
|
||||
if (StringUtils.isBlank(assignee)) {
|
||||
log.warn("saveCurrentTaskAssigneeLocal skipped, taskId={}, taskDefinitionKey={}, assignee is blank",
|
||||
task.getId(), task.getTaskDefinitionKey());
|
||||
return;
|
||||
}
|
||||
if (StringUtils.isBlank(task.getExecutionId())) {
|
||||
log.warn("saveCurrentTaskAssigneeLocal skipped, taskId={}, taskDefinitionKey={}, executionId is blank",
|
||||
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);
|
||||
}
|
||||
|
||||
private List<String> splitUsernames(Object value) {
|
||||
if (value == null) {
|
||||
return Collections.emptyList();
|
||||
|
||||
Reference in New Issue
Block a user