yxk-20260729

改善提案
新增流程表达式getRequiredUsersListByRole
根据角色找人
This commit is contained in:
ye1023
2026-07-29 09:38:52 +08:00
parent 58da0788bb
commit 3343d66093
8 changed files with 89 additions and 2 deletions
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.exception.JeecgBootException;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.runtime.Execution;
@@ -276,6 +277,28 @@ public class FlowNodeExpression {
return sysbase.getUserByRoleIdLocalApi(roleId);
}
/**
* Get required usernames for a Flowable multi-instance task.
* An empty collection would otherwise make Flowable skip the task, so fail fast instead.
* Example: ${flowNodeExpression.getRequiredUsersListByRole('roleIdValue')}
*
* @param roleId system role id
* @return non-empty username list
*/
public List<String> getRequiredUsersListByRole(String roleId) {
if (StringUtils.isBlank(roleId)) {
throw new JeecgBootException("流程角色ID不能为空");
}
List<String> usernames = ISysBaseAPI.getUsernamesByRoleIdLocalApi(roleId);
log.info("流程多实例按角色取人,roleId={}, usernames={}, count={}", roleId, usernames,
usernames == null ? 0 : usernames.size());
if (CollectionUtils.isEmpty(usernames)) {
throw new JeecgBootException("角色[" + roleId + "]未配置有效用户,流程无法继续");
}
return usernames;
}
/**
* Get subprocess variable.
* Example: ${flowNodeExpression.getSonProcessVariable(execution, 'subApproveUser')}