实现根据输入的jsonData,deptId,以及roleId查询uesrNameList
This commit is contained in:
@@ -98,6 +98,15 @@
|
||||
<artifactId>flowable-json-converter</artifactId>
|
||||
<version>${flowable.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-system-local-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.flowable</groupId>
|
||||
<artifactId>flowable-json-converter</artifactId>
|
||||
<version>${flowable.version}</version>
|
||||
</dependency>
|
||||
<!-- flowable6.4以上添加这个依赖,用于解决流程图预览,发布报错问题-->
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
|
||||
+34
-10
@@ -1,6 +1,8 @@
|
||||
package org.jeecg.modules.extbpm.process.common.expression;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
@@ -10,23 +12,29 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service("flowNodeExpression")
|
||||
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||
public class FlowNodeExpression {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ISysBaseAPI sysbase;
|
||||
// 自动注入
|
||||
private final ISysBaseAPI ISysBaseAPI;
|
||||
|
||||
// 自动注入 + 自动延迟加载(解决循环依赖)
|
||||
private final @Lazy ISysBaseAPI sysbase;
|
||||
|
||||
|
||||
/**
|
||||
* 查找当前部门负责人
|
||||
* ${flowNodeExpression.getDepartLeaders(applyUserId)}
|
||||
*
|
||||
* @param applyUserId
|
||||
* @return
|
||||
*/
|
||||
public List<String> getDepartLeaders(String applyUserId){
|
||||
public List<String> getDepartLeaders(String applyUserId) {
|
||||
List<String> depIds = sysbase.getDepartIdsByUsername(applyUserId);
|
||||
if (CollectionUtils.isEmpty(depIds)) {
|
||||
return null;
|
||||
@@ -38,11 +46,12 @@ public class FlowNodeExpression {
|
||||
/**
|
||||
* 根据字段名称取json_data查询对应业务表单的数据
|
||||
* ${flowNodeExpression.getJsondatastring(jsonData,'supDeptleaderid')}
|
||||
*
|
||||
* @param jsonData
|
||||
* @param codeName
|
||||
* @return
|
||||
*/
|
||||
public String getJsondatastring(Object jsonData, String codeName){
|
||||
public String getJsondatastring(Object jsonData, String codeName) {
|
||||
if (jsonData == null || StringUtils.isBlank(codeName)) {
|
||||
return null;
|
||||
}
|
||||
@@ -66,13 +75,26 @@ public class FlowNodeExpression {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字段名称取json_data查询对应业务表单的数据
|
||||
* ${flowNodeExpression.getJsondatastring(jsonData,'supDeptleaderid')}
|
||||
*
|
||||
* @param jsonData
|
||||
* @param deptKeyName
|
||||
* @return roleId
|
||||
*/
|
||||
public List<String> getUsersListByJson(Object jsonData, String deptKeyName, String roleId) {
|
||||
return ISysBaseAPI.getUsersListByJsonLocalAPI(jsonData,deptKeyName,roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找上一级部门负责人
|
||||
* ${flowNodeExpression.getLevel1DepartLeaders(applyUserId)}
|
||||
*
|
||||
* @param applyUserId
|
||||
* @return
|
||||
*/
|
||||
public List<String> getLevel1DepartLeaders(String applyUserId){
|
||||
public List<String> getLevel1DepartLeaders(String applyUserId) {
|
||||
//1.获取上一级部门ID
|
||||
Set<String> level1DepParentIds = sysbase.getDepartParentIdsByUsername(applyUserId);
|
||||
if (CollectionUtils.isEmpty(level1DepParentIds)) {
|
||||
@@ -85,10 +107,11 @@ public class FlowNodeExpression {
|
||||
/**
|
||||
* 查找上二级部门负责人
|
||||
* ${flowNodeExpression.getLevel2DepartLeaders(applyUserId)}
|
||||
*
|
||||
* @param applyUserId
|
||||
* @return
|
||||
*/
|
||||
public List<String> getLevel2DepartLeaders(String applyUserId){
|
||||
public List<String> getLevel2DepartLeaders(String applyUserId) {
|
||||
//1.获取上一级部门ID
|
||||
Set<String> level1DepParentIds = sysbase.getDepartParentIdsByUsername(applyUserId);
|
||||
log.info("level1DepParentIds = {}", level1DepParentIds);
|
||||
@@ -111,10 +134,11 @@ public class FlowNodeExpression {
|
||||
/**
|
||||
* 查找上三级部门负责人
|
||||
* ${flowNodeExpression.getLevel3DepartLeaders(applyUserId)}
|
||||
*
|
||||
* @param applyUserId
|
||||
* @return
|
||||
*/
|
||||
public List<String> getLevel3DepartLeaders(String applyUserId){
|
||||
public List<String> getLevel3DepartLeaders(String applyUserId) {
|
||||
//1.获取上一级部门ID
|
||||
Set<String> level1DepParentIds = sysbase.getDepartParentIdsByUsername(applyUserId);
|
||||
log.info("level1DepParentIds = {}", level1DepParentIds);
|
||||
|
||||
+27
@@ -2,6 +2,7 @@ package org.jeecg.modules.extbpm.process.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -10,9 +11,11 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.util.SqlInjectionUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.extbpm.process.common.expression.FlowNodeExpression;
|
||||
import org.jeecg.modules.extbpm.process.entity.ExtActExpression;
|
||||
import org.jeecg.modules.extbpm.process.service.IExtActExpressionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -26,6 +29,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
@@ -37,11 +43,32 @@ import lombok.extern.slf4j.Slf4j;
|
||||
*/
|
||||
@RestController("extActExpressionController")
|
||||
@RequestMapping("/act/process/extActExpression")
|
||||
@Tag(name = "流程表达式测试接口")
|
||||
@Slf4j
|
||||
public class ExtActExpressionController {
|
||||
@Autowired
|
||||
private IExtActExpressionService extActExpressionService;
|
||||
|
||||
@Autowired
|
||||
FlowNodeExpression flowNodeExpression;
|
||||
@GetMapping(value = "/testQueryUsers")
|
||||
@Operation(summary = "获取json内数据测试接口") // 接口说明(必填)
|
||||
public Result<List<String>> queryPageList(
|
||||
@RequestParam(name="jsonData") String jsonData,
|
||||
@RequestParam(name="deptKeyName") String deptKeyName,
|
||||
@RequestParam(name="roleId") String roleId
|
||||
) {
|
||||
// 1. 调用业务方法
|
||||
List<String> usernameList = flowNodeExpression.getUsersListByJson(jsonData, deptKeyName, roleId);
|
||||
|
||||
// 2. 优雅判空 + 提前返回(大厂最爱:卫语句)
|
||||
if (CollectionUtils.isEmpty(usernameList)) {
|
||||
return Result.error("根据 jsonData、部门字段、角色ID未查询到用户");
|
||||
}
|
||||
|
||||
// 3. 成功直接返回数据(标准接口格式)
|
||||
return Result.OK("查询成功", usernameList);
|
||||
}
|
||||
/**
|
||||
* 分页列表查询
|
||||
* @param extActExpression
|
||||
|
||||
+2
@@ -562,4 +562,6 @@ public interface ISysBaseAPI extends CommonAPI {
|
||||
Map<String, Object> queryFileMapById(String id);
|
||||
|
||||
String updateBusinessId(String businessId, List<String> deliverablesList);
|
||||
|
||||
List<String> getUsersListByJsonLocalAPI(Object jsonData, String deptKeyName, String roleId);
|
||||
}
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package org.jeecg.modules.system.constant;
|
||||
|
||||
/**
|
||||
* 用户密级常量
|
||||
*/
|
||||
public final class UserSecretLevel {
|
||||
|
||||
private UserSecretLevel() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 非密
|
||||
*/
|
||||
public static final Integer SECRET_LEVEL_NONE = 3;
|
||||
|
||||
/**
|
||||
* 一般
|
||||
*/
|
||||
public static final Integer SECRET_LEVEL_NORMAL = 4;
|
||||
|
||||
/**
|
||||
* 重要
|
||||
*/
|
||||
public static final Integer SECRET_LEVEL_IMPORTANT = 5;
|
||||
}
|
||||
+39
@@ -50,6 +50,7 @@ import org.jeecg.modules.message.handle.impl.QywxSendMsgHandle;
|
||||
import org.jeecg.modules.message.handle.impl.SystemSendMsgHandle;
|
||||
import org.jeecg.modules.message.service.ISysMessageTemplateService;
|
||||
import org.jeecg.modules.message.websocket.WebSocket;
|
||||
import org.jeecg.modules.system.constant.UserSecretLevel;
|
||||
import org.jeecg.modules.system.entity.*;
|
||||
import org.jeecg.modules.system.mapper.*;
|
||||
import org.jeecg.modules.system.service.*;
|
||||
@@ -2099,4 +2100,42 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
return "";
|
||||
}
|
||||
|
||||
public List<String> getUsersListByJsonLocalAPI(Object jsonData, String deptKeyName, String roleId) {
|
||||
if (jsonData == null || StringUtils.isEmpty(deptKeyName) || StringUtils.isEmpty(roleId)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 统一转成 JSONObject(一步到位,不用来回转字符串)
|
||||
JSONObject json;
|
||||
if (jsonData instanceof String) {
|
||||
json = JSON.parseObject((String) jsonData);
|
||||
} else if (jsonData instanceof JSONObject) {
|
||||
json = (JSONObject) jsonData;
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 关键参数无效 → 直接返回空
|
||||
if (json == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
String deptId = json.getString(deptKeyName);
|
||||
if (StringUtils.isEmpty(deptId)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<SysUser> sysUserList = sysUserService.queryUserByDeptAndROle(
|
||||
deptId,
|
||||
roleId,
|
||||
UserSecretLevel.SECRET_LEVEL_NONE
|
||||
);
|
||||
|
||||
return Optional.ofNullable(sysUserList)
|
||||
.orElse(Collections.emptyList())
|
||||
.stream()
|
||||
.map(SysUser::getUsername)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user