feat(pigx-flow-biz): 扩展抄送任务支持角色和岗位类型

- 在 CopyServiceTask 中新增对角色和岗位类型的抄送人员支持
- 新增 addUserIds 工具方法用于用户ID去重合并
- 优化表单数据处理逻辑,避免重复序列化操作
- 更新注释说明支持用户、部门、角色、岗位四种类型
This commit is contained in:
PIGCLOUD committed 2026-03-08 15:05:50 +08:00
1 parent ef13df4f79
commit 650d791222
5 files changed
+68 -13

No files matched your search

@@ -79,6 +79,14 @@ public interface IRemoteService {
*/
R<List<Long>> queryUserIdListByDepIdList(List<Long> depIdList);
/**
* 根据岗位ID列表查询用户ID列表
*
* @param postIdList 岗位ID列表,支持批量查询多个岗位
* @return R<List<Long>> 响应结果,包含岗位下所有用户的ID列表(已去重)
*/
R<List<Long>> queryUserIdListByPostIdList(List<Long> postIdList);
/**
* 检查用户是否为指定用户的所有下级
* <p>
@@ -172,6 +172,17 @@ public class RemoteServiceImpl implements IRemoteService {
return R.ok(list);
}
/**
* 根据岗位id集合查询用户id集合
*
* @param postIdList 岗位ID列表
* @return R<List<Long>> 拥有这些岗位的用户ID列表
*/
@Override
public R<List<Long>> queryUserIdListByPostIdList(List<Long> postIdList) {
return userService.getUserIdListByPostIdList(postIdList);
}
/**
* 检查是否是所有的子级
* <p>
@@ -30,8 +30,8 @@ import java.util.stream.Collectors;
* 抄送任务会将流程信息发送给指定的用户或部门成员,供其查看但不需要审批。
* <p>
* 主要功能:
* 1. 获取节点配置的抄送人员(支持用户和部门)
* 2. 将部门展开为具体的用户列表
* 1. 获取节点配置的抄送人员(支持用户、部门、角色、岗位)
* 2. 将部门、角色、岗位展开为具体的用户列表
* 3. 为每个抄送人创建抄送记录
* 4. 记录流程快照信息供抄送人查看
* <p>
@@ -79,18 +79,30 @@ public class CopyServiceTask implements JavaDelegate {
.toList();
if (CollUtil.isNotEmpty(deptIdList)) {
R<List<Long>> r = remoteService.queryUserIdListByDepIdList(deptIdList);
addUserIds(userIdList, r.getData());
}
List<Long> data = r.getData();
if (CollUtil.isNotEmpty(data)) {
for (Long datum : data) {
String userIdStr = Convert.toStr(datum);
if (!userIdList.contains(userIdStr)) {
userIdList.add(userIdStr);
}
}
}
// 角色ID列表
List<Long> roleIdList = userDtoList.stream()
.filter(w -> StrUtil.equals(w.getType(), NodeUserTypeEnum.ROLE.getKey()))
.map(NodeUser::getId)
.toList();
if (CollUtil.isNotEmpty(roleIdList)) {
R<List<Long>> r = remoteService.queryUserIdListByRoleIdList(roleIdList);
addUserIds(userIdList, r.getData());
}
// 岗位ID列表
List<Long> postIdList = userDtoList.stream()
.filter(w -> StrUtil.equals(w.getType(), NodeUserTypeEnum.POST.getKey()))
.map(NodeUser::getId)
.toList();
if (CollUtil.isNotEmpty(postIdList)) {
R<List<Long>> r = remoteService.queryUserIdListByPostIdList(postIdList);
addUserIds(userIdList, r.getData());
}
ObjectMapper objectMapper = SpringUtil.getBean(ObjectMapper.class);
@@ -102,6 +114,7 @@ public class CopyServiceTask implements JavaDelegate {
.get(0);
Map<String, Object> variables = execution.getVariables();
String formData = objectMapper.writeValueAsString(variables);
for (String userIds : userIdList) {
// 发送抄送任务
@@ -112,11 +125,28 @@ public class CopyServiceTask implements JavaDelegate {
processCopyDto.setProcessInstanceId(execution.getProcessInstanceId());
processCopyDto.setNodeId(nodeId);
processCopyDto.setNodeName(node.getName());
processCopyDto.setFormData(objectMapper.writeValueAsString(variables));
processCopyDto.setFormData(formData);
processCopyDto.setUserId(Long.parseLong(userIds));
remoteService.saveCC(processCopyDto);
}
}
/**
* 将用户ID列表合并到目标列表中(去重)
*
* @param targetList 目标用户ID列表
* @param sourceList 待合并的用户ID列表
*/
private void addUserIds(List<String> targetList, List<Long> sourceList) {
if (CollUtil.isNotEmpty(sourceList)) {
for (Long userId : sourceList) {
String userIdStr = Convert.toStr(userId);
if (!targetList.contains(userIdStr)) {
targetList.add(userIdStr);
}
}
}
}
}
@@ -91,6 +91,7 @@ public interface RemoteUserService {
* @param roleIdList 角色ID列表
* @return 用户ID列表
*/
@NoToken
@GetMapping("/user/getUserIdListByRoleIdList")
R<List<Long>> getUserIdListByRoleIdList(@RequestParam("roleIdList") List<Long> roleIdList);
@@ -100,6 +101,7 @@ public interface RemoteUserService {
* @param deptIdList 部门ID列表
* @return 用户ID列表
*/
@NoToken
@GetMapping("/user/getUserIdListByDeptIdList")
R<List<SysUser>> getUserIdListByDeptIdList(@RequestParam("deptIdList") List<Long> deptIdList);
@@ -109,6 +111,7 @@ public interface RemoteUserService {
* @param postIdList 岗位ID列表
* @return 用户ID列表
*/
@NoToken
@GetMapping("/user/getUserIdListByPostIdList")
R<List<Long>> getUserIdListByPostIdList(@RequestParam("postIdList") List<Long> postIdList);
@@ -118,6 +121,7 @@ public interface RemoteUserService {
* @param userName 用户名
* @return 用户列表
*/
@NoToken
@GetMapping("/user/getUserListByUserName")
R<List<SysUser>> getUserListByUserName(@RequestParam("username") String userName);
@@ -297,6 +297,7 @@ public class SysUserController {
* @param postIdList 岗位ID列表
* @return R 返回结果对象,包含根据岗位ID列表获取到的用户ID列表信息
*/
@Inner
@GetMapping("/getUserIdListByPostIdList")
public R<List<Long>> getUserIdListByPostIdList(Long[] postIdList) {
return R.ok(userService.listUserIdByPostIds(CollUtil.toList(postIdList)));
@@ -308,6 +309,7 @@ public class SysUserController {
* @param username 用户名
* @return 用户列表
*/
@Inner
@GetMapping("/getUserListByUserName")
public R<List<SysUser>> getUserListByUserName(String username) {
return R.ok(TenantBroker