!19 wsm-添加适配会签任务内再次会签的变量获取方法

Merge pull request !19 from new_new_new/feature/different-level-get-veriable
This commit is contained in:
new_new_new
2026-05-07 02:38:25 +00:00
committed by Gitee
9 changed files with 129 additions and 1 deletions
@@ -29,5 +29,7 @@ public class XiSpeakConfig {
private String implDeptKey;
/** 对应impl-dept-collection-used*/
private String implDeptCollectionUsedKey;
/** 对应sdw-role-id*/
private String sdwRoleId;
}
}
@@ -40,6 +40,26 @@ public class XiSpeakFlow {
return userList;
}
public List<String> getSDWLeader() {
// 1. 安全获取配置,防止 NPE
XiSpeakConfig.XiSpeakProperties props = xiSpeakConfig.getXiSpeak();
if (props == null || !StringUtils.hasText(props.getSdwRoleId())) {
log.error("流程配置缺失: [flow-biz.xi-speak.sdw-role-id] 未在 YAML 中定义");
return Collections.emptyList();
}
// 2. 调用接口获取数据
log.info("正在查询sdw:{}角色下的用户列表",props.getSdwRoleId());
List<String> userList = iSysBaseAPI.getUserByRoleIdLocalApi(props.getSdwRoleId());
log.info("查询到的用户为: {}", userList);
return userList;
}
public int getSDWLeaderLength() {
return this.getSDWLeader().size();
}
public int getBgDeptLdUserIdListLength() {
return getBgDeptLdUserIdList().size();
}
@@ -6,3 +6,4 @@ flow-biz:
json-data-key: "json_data"
impl-dept-key: "implDept"
impl-dept-collection-used-key: "impl_dept_id"
sdw-role-id: "2044676455280570370"
@@ -304,6 +304,8 @@ public class FlowNodeExpression {
return Collections.emptyList();
}
//
// /**
// * 从当前流程实例的所有执行实例中获取指定的局部变量
@@ -377,6 +379,84 @@ public class FlowNodeExpression {
}
/**
* Get subprocess variable.
* Example: ${flowNodeExpression.getSonProcessVariable(execution, 'subApproveUser')}
*
* @param execution current execution
* @param variableName subprocess variable name
* @return username list
*/
public List<String> getSonProcessHqVariableList(DelegateExecution execution, String variableName) {
if (execution == null || StringUtils.isBlank(variableName)) {
return Collections.emptyList();
}
try {
String parentExecutionId = execution.getParentId();
if(StringUtils.isBlank(parentExecutionId)){
return Collections.emptyList();
}
if (execution.hasVariableLocal(variableName)) {
return splitUsernames(execution.getVariableLocal(variableName));
}
List<Execution> executions = runtimeService.createExecutionQuery()
.processInstanceId(parentExecutionId)
.list();
for (Execution childExecution : executions) {
if (execution.getId().equals(childExecution.getId())) {
continue;
}
Object localVariable = runtimeService.getVariableLocal(childExecution.getId(), variableName);
if (localVariable != null) {
return splitUsernames(localVariable);
}
}
Object variable = execution.getVariable(variableName);
if (variable != null) {
return splitUsernames(variable);
}
} catch (Exception e) {
log.warn("getSonProcessVariable failed, executionId={}, variableName={}",
execution.getId(), variableName, e);
}
return Collections.emptyList();
}
public int getSonProcessHqVariableListLength(DelegateExecution execution, String variableName) {
return this.getSonProcessHqVariableList(execution,variableName).size();
}
public String getSonProcessHqVariableString(DelegateExecution execution, String variableName) {
if(execution == null || StringUtils.isBlank(variableName) || getSonProcessHqVariableList(execution, variableName).isEmpty()) return StringUtils.EMPTY;
return getSonProcessHqVariableList(execution, variableName).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) {
@@ -566,4 +566,6 @@ public interface ISysBaseAPI extends CommonAPI {
List<String> getUsersListByJsonLocalAPI(Object jsonData, String deptKeyName, String roleId);
List<String> getUsersListByDeptIdAndRoleIdLocalApi(String deptId, String roleId);
}
List<String> getUserByRoleIdLocalApi(String roleId);
}
@@ -244,4 +244,11 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
* @return
*/
List<SysUser> queryUserByDeptAndROle( String deptId, String roleId, Integer secretLevel);
/**
* 通过角色id获取用户
* @param roleId
* @return
*/
List<SysUser> getUserByRoleId(String roleId);
}
@@ -496,4 +496,6 @@ public interface ISysUserService extends IService<SysUser> {
void updatePasswordNotBindPhone(String oldPassword, String password, String username);
List<String> queryUserByDeptAndROle(@NotBlank(message = "deptId不为空") String deptId, @NotBlank(message = "角色id不为空") String roleId, @NotBlank(message = "secretLevel不为空") Integer secretLevel);
List<String> getUserByRoleId(String roleId);
}
@@ -2152,4 +2152,13 @@ public class SysBaseApiImpl implements ISysBaseAPI {
.stream()
.collect(Collectors.toList());
}
@Override
public List<String> getUserByRoleIdLocalApi(String roleId){
List<String> sysUserList = sysUserService.getUserByRoleId(roleId);
return Optional.ofNullable(sysUserList)
.orElse(Collections.emptyList())
.stream()
.collect(Collectors.toList());
}
}
@@ -2419,4 +2419,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
public List<String> queryUserByDeptAndROle(@NotBlank(message = "deptId不为空") String deptId, @NotBlank(message = "角色id不为空") String roleId, @NotBlank(message = "secretLevel不为空") Integer secretLevel){
return sysUserMapper.queryUserByDeptAndROle(deptId,roleId,secretLevel).stream().map(SysUser::getUsername).collect(Collectors.toList()) ;
}
@Override
public List<String> getUserByRoleId(String roleId){
return sysUserMapper.getUserByRoleId(roleId).stream().map(SysUser::getUsername).collect(Collectors.toList()) ;
}
}