mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-10-08 19:16:38 +08:00
Compare commits
7 Commits
d501e82541
...
e2200bac71
Author | SHA1 | Date | |
---|---|---|---|
|
e2200bac71 | ||
|
f8950d1e20 | ||
|
9dfe9f610d | ||
|
17610e8721 | ||
|
f29b787767 | ||
|
9775283a24 | ||
|
debc73d7d4 |
@ -3,6 +3,7 @@ package org.dromara.common.core.service;
|
||||
import org.dromara.common.core.domain.dto.DeptDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 通用 部门服务
|
||||
@ -34,4 +35,12 @@ public interface DeptService {
|
||||
*/
|
||||
List<DeptDTO> selectDeptsByList();
|
||||
|
||||
/**
|
||||
* 根据部门 ID 列表查询部门名称映射关系
|
||||
*
|
||||
* @param deptIds 部门 ID 列表
|
||||
* @return Map,其中 key 为部门 ID,value 为对应的部门名称
|
||||
*/
|
||||
Map<Long, String> selectDeptNamesByIds(List<Long> deptIds);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package org.dromara.common.core.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 通用 岗位服务
|
||||
*
|
||||
@ -7,4 +10,12 @@ package org.dromara.common.core.service;
|
||||
*/
|
||||
public interface PostService {
|
||||
|
||||
/**
|
||||
* 根据岗位 ID 列表查询岗位名称映射关系
|
||||
*
|
||||
* @param postIds 岗位 ID 列表
|
||||
* @return Map,其中 key 为岗位 ID,value 为对应的岗位名称
|
||||
*/
|
||||
Map<Long, String> selectPostNamesByIds(List<Long> postIds);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package org.dromara.common.core.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 通用 角色服务
|
||||
*
|
||||
@ -7,4 +10,12 @@ package org.dromara.common.core.service;
|
||||
*/
|
||||
public interface RoleService {
|
||||
|
||||
/**
|
||||
* 根据角色 ID 列表查询角色名称映射关系
|
||||
*
|
||||
* @param roleIds 角色 ID 列表
|
||||
* @return Map,其中 key 为角色 ID,value 为对应的角色名称
|
||||
*/
|
||||
Map<Long, String> selectRoleNamesByIds(List<Long> roleIds);
|
||||
|
||||
}
|
||||
|
@ -100,28 +100,4 @@ public interface UserService {
|
||||
*/
|
||||
Map<Long, String> selectUserNamesByIds(List<Long> userIds);
|
||||
|
||||
/**
|
||||
* 根据角色 ID 列表查询角色名称映射关系
|
||||
*
|
||||
* @param roleIds 角色 ID 列表
|
||||
* @return Map,其中 key 为角色 ID,value 为对应的角色名称
|
||||
*/
|
||||
Map<Long, String> selectRoleNamesByIds(List<Long> roleIds);
|
||||
|
||||
/**
|
||||
* 根据部门 ID 列表查询部门名称映射关系
|
||||
*
|
||||
* @param deptIds 部门 ID 列表
|
||||
* @return Map,其中 key 为部门 ID,value 为对应的部门名称
|
||||
*/
|
||||
Map<Long, String> selectDeptNamesByIds(List<Long> deptIds);
|
||||
|
||||
/**
|
||||
* 根据岗位 ID 列表查询岗位名称映射关系
|
||||
*
|
||||
* @param postIds 岗位 ID 列表
|
||||
* @return Map,其中 key 为岗位 ID,value 为对应的岗位名称
|
||||
*/
|
||||
Map<Long, String> selectPostNamesByIds(List<Long> postIds);
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.dromara.demo.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.mail.utils.MailUtils;
|
||||
@ -18,7 +17,6 @@ import java.util.Arrays;
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
*/
|
||||
@SaIgnore
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@ -44,11 +42,11 @@ public class MailController {
|
||||
* @param to 接收人
|
||||
* @param subject 标题
|
||||
* @param text 内容
|
||||
* @param filePath 附件路径
|
||||
*/
|
||||
@GetMapping("/sendMessageWithAttachment")
|
||||
public R<Void> sendMessageWithAttachment(String to, String subject, String text, String filePath) {
|
||||
MailUtils.sendText(to, subject, text, new File(filePath));
|
||||
public R<Void> sendMessageWithAttachment(String to, String subject, String text) {
|
||||
// 附件路径 禁止前端传递 有任意读取系统文件风险
|
||||
MailUtils.sendText(to, subject, text, new File("/xxx/xxx"));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ -58,10 +56,11 @@ public class MailController {
|
||||
* @param to 接收人
|
||||
* @param subject 标题
|
||||
* @param text 内容
|
||||
* @param paths 附件路径
|
||||
*/
|
||||
@GetMapping("/sendMessageWithAttachments")
|
||||
public R<Void> sendMessageWithAttachments(String to, String subject, String text, String[] paths) {
|
||||
public R<Void> sendMessageWithAttachments(String to, String subject, String text) {
|
||||
// 附件路径 禁止前端传递 有任意读取系统文件风险
|
||||
String[] paths = new String[]{"/xxx/xxx", "/xxx/xxx"};
|
||||
File[] array = Arrays.stream(paths).map(File::new).toArray(File[]::new);
|
||||
MailUtils.sendText(to, subject, text, array);
|
||||
return R.ok();
|
||||
|
@ -19,6 +19,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -107,7 +108,7 @@ public class SysPostController extends BaseController {
|
||||
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{postIds}")
|
||||
public R<Void> remove(@PathVariable Long[] postIds) {
|
||||
return toAjax(postService.deletePostByIds(postIds));
|
||||
return toAjax(postService.deletePostByIds(Arrays.asList(postIds)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.mybatis.annotation.DataColumn;
|
||||
import org.dromara.common.mybatis.annotation.DataPermission;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
@ -72,6 +73,19 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo> {
|
||||
.apply(DataBaseHelper.findInSet(parentId, "ancestors")));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询某个部门及其所有子部门ID(含自身)
|
||||
*
|
||||
* @param parentId 父部门ID
|
||||
* @return 部门ID集合
|
||||
*/
|
||||
default List<Long> selectDeptAndChildById(Long parentId) {
|
||||
List<SysDept> deptList = this.selectListByParentId(parentId);
|
||||
List<Long> deptIds = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||
deptIds.add(parentId);
|
||||
return deptIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色ID查询部门树信息
|
||||
*
|
||||
|
@ -110,7 +110,7 @@ public interface ISysPostService {
|
||||
* @param postIds 需要删除的岗位ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deletePostByIds(Long[] postIds);
|
||||
int deletePostByIds(List<Long> postIds);
|
||||
|
||||
/**
|
||||
* 新增保存岗位信息
|
||||
|
@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.CacheNames;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.system.domain.SysDept;
|
||||
import org.dromara.system.domain.SysRoleDept;
|
||||
import org.dromara.system.mapper.SysDeptMapper;
|
||||
import org.dromara.system.mapper.SysRoleDeptMapper;
|
||||
@ -66,13 +65,8 @@ public class SysDataScopeServiceImpl implements ISysDataScopeService {
|
||||
if (ObjectUtil.isNull(deptId)) {
|
||||
return "-1";
|
||||
}
|
||||
List<SysDept> deptList = deptMapper.selectListByParentId(deptId);
|
||||
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||
ids.add(deptId);
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
return StreamUtils.join(ids, Convert::toStr);
|
||||
}
|
||||
return "-1";
|
||||
List<Long> deptIds = deptMapper.selectDeptAndChildById(deptId);
|
||||
return CollUtil.isNotEmpty(deptIds) ? StreamUtils.join(deptIds, Convert::toStr) : "-1";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,10 +36,7 @@ import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 部门管理 服务实现
|
||||
@ -110,10 +107,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
|
||||
//部门树搜索
|
||||
lqw.and(x -> {
|
||||
Long parentId = bo.getBelongDeptId();
|
||||
List<SysDept> deptList = baseMapper.selectListByParentId(parentId);
|
||||
List<Long> deptIds = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||
deptIds.add(parentId);
|
||||
List<Long> deptIds = baseMapper.selectDeptAndChildById(bo.getBelongDeptId());
|
||||
x.in(SysDept::getDeptId, deptIds);
|
||||
});
|
||||
}
|
||||
@ -409,4 +403,24 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
return baseMapper.deleteById(deptId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据部门 ID 列表查询部门名称映射关系
|
||||
*
|
||||
* @param deptIds 部门 ID 列表
|
||||
* @return Map,其中 key 为部门 ID,value 为对应的部门名称
|
||||
*/
|
||||
@Override
|
||||
public Map<Long, String> selectDeptNamesByIds(List<Long> deptIds) {
|
||||
if (CollUtil.isEmpty(deptIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<SysDept> list = baseMapper.selectList(
|
||||
new LambdaQueryWrapper<SysDept>()
|
||||
.select(SysDept::getDeptId, SysDept::getDeptName)
|
||||
.in(SysDept::getDeptId, deptIds)
|
||||
);
|
||||
return StreamUtils.toMap(list, SysDept::getDeptId, SysDept::getDeptName);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.system.domain.SysDept;
|
||||
import org.dromara.system.domain.SysPost;
|
||||
import org.dromara.system.domain.SysUserPost;
|
||||
import org.dromara.system.domain.bo.SysPostBo;
|
||||
@ -25,7 +24,7 @@ import org.dromara.system.mapper.SysUserPostMapper;
|
||||
import org.dromara.system.service.ISysPostService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -92,9 +91,7 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
||||
} else if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
|
||||
//部门树搜索
|
||||
wrapper.and(x -> {
|
||||
List<SysDept> deptList = deptMapper.selectListByParentId(bo.getBelongDeptId());
|
||||
List<Long> deptIds = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||
deptIds.add(bo.getBelongDeptId());
|
||||
List<Long> deptIds = deptMapper.selectDeptAndChildById(bo.getBelongDeptId());
|
||||
x.in(SysPost::getDeptId, deptIds);
|
||||
});
|
||||
}
|
||||
@ -217,14 +214,14 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostByIds(Long[] postIds) {
|
||||
for (Long postId : postIds) {
|
||||
SysPost post = baseMapper.selectById(postId);
|
||||
if (countUserPostById(postId) > 0) {
|
||||
public int deletePostByIds(List<Long> postIds) {
|
||||
List<SysPost> list = baseMapper.selectByIds(postIds);
|
||||
for (SysPost post : list) {
|
||||
if (this.countUserPostById(post.getPostId()) > 0) {
|
||||
throw new ServiceException(String.format("%1$s已分配,不能删除!", post.getPostName()));
|
||||
}
|
||||
}
|
||||
return baseMapper.deleteByIds(Arrays.asList(postIds));
|
||||
return baseMapper.deleteByIds(postIds);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -251,4 +248,23 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
||||
return baseMapper.updateById(post);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据岗位 ID 列表查询岗位名称映射关系
|
||||
*
|
||||
* @param postIds 岗位 ID 列表
|
||||
* @return Map,其中 key 为岗位 ID,value 为对应的岗位名称
|
||||
*/
|
||||
@Override
|
||||
public Map<Long, String> selectPostNamesByIds(List<Long> postIds) {
|
||||
if (CollUtil.isEmpty(postIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<SysPost> list = baseMapper.selectList(
|
||||
new LambdaQueryWrapper<SysPost>()
|
||||
.select(SysPost::getPostId, SysPost::getPostName)
|
||||
.in(SysPost::getPostId, postIds)
|
||||
);
|
||||
return StreamUtils.toMap(list, SysPost::getPostId, SysPost::getPostName);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -549,4 +549,23 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色 ID 列表查询角色名称映射关系
|
||||
*
|
||||
* @param roleIds 角色 ID 列表
|
||||
* @return Map,其中 key 为角色 ID,value 为对应的角色名称
|
||||
*/
|
||||
@Override
|
||||
public Map<Long, String> selectRoleNamesByIds(List<Long> roleIds) {
|
||||
if (CollUtil.isEmpty(roleIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<SysRole> list = baseMapper.selectList(
|
||||
new LambdaQueryWrapper<SysRole>()
|
||||
.select(SysRole::getRoleId, SysRole::getRoleName)
|
||||
.in(SysRole::getRoleId, roleIds)
|
||||
);
|
||||
return StreamUtils.toMap(list, SysRole::getRoleId, SysRole::getRoleName);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,10 @@ import org.dromara.common.core.utils.*;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.system.domain.*;
|
||||
import org.dromara.system.domain.SysRole;
|
||||
import org.dromara.system.domain.SysUser;
|
||||
import org.dromara.system.domain.SysUserPost;
|
||||
import org.dromara.system.domain.SysUserRole;
|
||||
import org.dromara.system.domain.bo.SysUserBo;
|
||||
import org.dromara.system.domain.vo.SysPostVo;
|
||||
import org.dromara.system.domain.vo.SysRoleVo;
|
||||
@ -36,7 +39,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户 业务层处理
|
||||
@ -79,10 +81,8 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
"u.create_time", params.get("beginTime"), params.get("endTime"))
|
||||
.and(ObjectUtil.isNotNull(user.getDeptId()), w -> {
|
||||
List<SysDept> deptList = deptMapper.selectListByParentId(user.getDeptId());
|
||||
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||
ids.add(user.getDeptId());
|
||||
w.in("u.dept_id", ids);
|
||||
List<Long> deptIds = deptMapper.selectDeptAndChildById(user.getDeptId());
|
||||
w.in("u.dept_id", deptIds);
|
||||
}).orderByAsc("u.user_id");
|
||||
return baseMapper.selectUserExportList(wrapper);
|
||||
}
|
||||
@ -100,9 +100,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
SysUser::getCreateTime, params.get("beginTime"), params.get("endTime"))
|
||||
.and(ObjectUtil.isNotNull(user.getDeptId()), w -> {
|
||||
List<SysDept> deptList = deptMapper.selectListByParentId(user.getDeptId());
|
||||
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||
ids.add(user.getDeptId());
|
||||
List<Long> ids = deptMapper.selectDeptAndChildById(user.getDeptId());
|
||||
w.in(SysUser::getDeptId, ids);
|
||||
}).orderByAsc(SysUser::getUserId);
|
||||
if (StringUtils.isNotBlank(user.getExcludeUserIds())) {
|
||||
@ -748,69 +746,12 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
if (CollUtil.isEmpty(userIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return baseMapper.selectList(
|
||||
List<SysUser> list = baseMapper.selectList(
|
||||
new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getUserId, SysUser::getNickName)
|
||||
.in(SysUser::getUserId, userIds)
|
||||
).stream()
|
||||
.collect(Collectors.toMap(SysUser::getUserId, SysUser::getNickName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色 ID 列表查询角色名称映射关系
|
||||
*
|
||||
* @param roleIds 角色 ID 列表
|
||||
* @return Map,其中 key 为角色 ID,value 为对应的角色名称
|
||||
*/
|
||||
@Override
|
||||
public Map<Long, String> selectRoleNamesByIds(List<Long> roleIds) {
|
||||
if (CollUtil.isEmpty(roleIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return roleMapper.selectList(
|
||||
new LambdaQueryWrapper<SysRole>()
|
||||
.select(SysRole::getRoleId, SysRole::getRoleName)
|
||||
.in(SysRole::getRoleId, roleIds)
|
||||
).stream()
|
||||
.collect(Collectors.toMap(SysRole::getRoleId, SysRole::getRoleName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门 ID 列表查询部门名称映射关系
|
||||
*
|
||||
* @param deptIds 部门 ID 列表
|
||||
* @return Map,其中 key 为部门 ID,value 为对应的部门名称
|
||||
*/
|
||||
@Override
|
||||
public Map<Long, String> selectDeptNamesByIds(List<Long> deptIds) {
|
||||
if (CollUtil.isEmpty(deptIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return deptMapper.selectList(
|
||||
new LambdaQueryWrapper<SysDept>()
|
||||
.select(SysDept::getDeptId, SysDept::getDeptName)
|
||||
.in(SysDept::getDeptId, deptIds)
|
||||
).stream()
|
||||
.collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据岗位 ID 列表查询岗位名称映射关系
|
||||
*
|
||||
* @param postIds 岗位 ID 列表
|
||||
* @return Map,其中 key 为岗位 ID,value 为对应的岗位名称
|
||||
*/
|
||||
@Override
|
||||
public Map<Long, String> selectPostNamesByIds(List<Long> postIds) {
|
||||
if (CollUtil.isEmpty(postIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return postMapper.selectList(
|
||||
new LambdaQueryWrapper<SysPost>()
|
||||
.select(SysPost::getPostId, SysPost::getPostName)
|
||||
.in(SysPost::getPostId, postIds)
|
||||
).stream()
|
||||
.collect(Collectors.toMap(SysPost::getPostId, SysPost::getPostName));
|
||||
);
|
||||
return StreamUtils.toMap(list, SysUser::getUserId, SysUser::getNickName);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -145,6 +145,7 @@ public class FlowTaskVo implements Serializable {
|
||||
/**
|
||||
* 办理人名称
|
||||
*/
|
||||
@Translation(type = TransConstant.USER_ID_TO_NICKNAME, mapper = "assigneeIds")
|
||||
private String assigneeNames;
|
||||
|
||||
/**
|
||||
|
@ -3,11 +3,14 @@ package org.dromara.workflow.handler;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.domain.dto.UserDTO;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.warm.flow.core.dto.FlowParams;
|
||||
import org.dromara.warm.flow.core.handler.PermissionHandler;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.service.IFlwCommonService;
|
||||
import org.dromara.workflow.service.IFlwTaskAssigneeService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collections;
|
||||
@ -24,7 +27,7 @@ import java.util.List;
|
||||
@Slf4j
|
||||
public class WorkflowPermissionHandler implements PermissionHandler {
|
||||
|
||||
private final IFlwCommonService flwCommonService;
|
||||
private final IFlwTaskAssigneeService flwTaskAssigneeService;
|
||||
|
||||
/**
|
||||
* 办理人权限标识,比如用户,角色,部门等,用于校验是否有权限办理任务
|
||||
@ -51,9 +54,11 @@ public class WorkflowPermissionHandler implements PermissionHandler {
|
||||
*/
|
||||
@Override
|
||||
public List<String> convertPermissions(List<String> permissions) {
|
||||
if (CollUtil.isNotEmpty(permissions)) {
|
||||
permissions = flwCommonService.buildUser(permissions);
|
||||
}
|
||||
if (CollUtil.isEmpty(permissions)) {
|
||||
return permissions;
|
||||
}
|
||||
String storageIds = CollUtil.join(permissions, StringUtils.SEPARATOR);
|
||||
List<UserDTO> users = flwTaskAssigneeService.fetchUsersByStorageIds(storageIds);
|
||||
return StreamUtils.toList(users, userDTO -> String.valueOf(userDTO.getUserId()));
|
||||
}
|
||||
}
|
||||
|
@ -9,8 +9,6 @@ import org.dromara.workflow.domain.bo.FlowTaskBo;
|
||||
import org.dromara.workflow.domain.vo.FlowHisTaskVo;
|
||||
import org.dromara.workflow.domain.vo.FlowTaskVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 任务信息Mapper接口
|
||||
@ -29,14 +27,6 @@ public interface FlwTaskMapper {
|
||||
*/
|
||||
Page<FlowTaskVo> getListRunTask(@Param("page") Page<FlowTaskVo> page, @Param(Constants.WRAPPER) Wrapper<FlowTaskBo> queryWrapper);
|
||||
|
||||
/**
|
||||
* 获取待办信息
|
||||
*
|
||||
* @param queryWrapper 条件
|
||||
* @return 结果
|
||||
*/
|
||||
List<FlowTaskVo> getListRunTask(@Param(Constants.WRAPPER) Wrapper<FlowTaskBo> queryWrapper);
|
||||
|
||||
/**
|
||||
* 获取已办
|
||||
*
|
||||
|
@ -9,14 +9,6 @@ import java.util.List;
|
||||
*/
|
||||
public interface IFlwCommonService {
|
||||
|
||||
/**
|
||||
* 构建工作流用户
|
||||
*
|
||||
* @param permissionList 办理用户
|
||||
* @return 用户
|
||||
*/
|
||||
List<String> buildUser(List<String> permissionList);
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
|
@ -141,14 +141,6 @@ public interface IFlwInstanceService {
|
||||
*/
|
||||
FlowInstance selectByTaskId(Long taskId);
|
||||
|
||||
/**
|
||||
* 按任务id查询实例
|
||||
*
|
||||
* @param taskIdList 任务id
|
||||
* @return 结果
|
||||
*/
|
||||
List<FlowInstance> selectByTaskIdList(List<Long> taskIdList);
|
||||
|
||||
/**
|
||||
* 作废流程
|
||||
*
|
||||
|
@ -14,7 +14,6 @@ import org.dromara.workflow.domain.vo.FlowHisTaskVo;
|
||||
import org.dromara.workflow.domain.vo.FlowTaskVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 任务 服务层
|
||||
@ -150,14 +149,6 @@ public interface IFlwTaskService {
|
||||
*/
|
||||
List<FlowNode> getNextNodeList(FlowNextNodeBo bo);
|
||||
|
||||
/**
|
||||
* 按照任务id查询任务
|
||||
*
|
||||
* @param taskIdList 任务id
|
||||
* @return 结果
|
||||
*/
|
||||
List<FlowHisTask> selectHisTaskByIdList(List<Long> taskIdList);
|
||||
|
||||
/**
|
||||
* 按照任务id查询任务
|
||||
*
|
||||
@ -166,14 +157,6 @@ public interface IFlwTaskService {
|
||||
*/
|
||||
FlowHisTask selectHisTaskById(Long taskId);
|
||||
|
||||
/**
|
||||
* 按照实例id查询任务
|
||||
*
|
||||
* @param instanceIdList 流程实例id
|
||||
* @return 结果
|
||||
*/
|
||||
List<FlowTask> selectByInstIdList(List<Long> instanceIdList);
|
||||
|
||||
/**
|
||||
* 按照实例id查询任务
|
||||
*
|
||||
@ -191,14 +174,6 @@ public interface IFlwTaskService {
|
||||
*/
|
||||
boolean taskOperation(TaskOperationBo bo, String taskOperation);
|
||||
|
||||
/**
|
||||
* 获取任务所有办理人
|
||||
*
|
||||
* @param taskIdList 任务id
|
||||
* @return 结果
|
||||
*/
|
||||
Map<Long, List<UserDTO>> currentTaskAllUser(List<Long> taskIdList);
|
||||
|
||||
/**
|
||||
* 获取当前任务的所有办理人
|
||||
*
|
||||
|
@ -27,8 +27,12 @@ import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.common.constant.FlowConstant;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 流程图提示信息
|
||||
@ -74,15 +78,26 @@ public class FlwChartExtServiceImpl implements ChartExtService {
|
||||
|
||||
Map<String, String> dictType = dictService.getAllDictByDictType(FlowConstant.WF_TASK_STATUS);
|
||||
|
||||
// 遍历流程定义中的每个节点,调用处理方法,将对应节点的任务列表及用户信息传入,生成扩展提示内容
|
||||
for (NodeJson nodeJson : defJson.getNodeList()) {
|
||||
// 获取当前节点对应的历史任务列表,如果没有则返回空列表避免空指针
|
||||
List<FlowHisTask> taskList = groupedByNode.get(nodeJson.getNodeCode());
|
||||
if (CollUtil.isEmpty(taskList)) {
|
||||
continue;
|
||||
}
|
||||
// 处理当前节点的扩展信息,包括构建审批人提示内容等
|
||||
this.processNodeExtInfo(nodeJson, taskList, userMap, dictType);
|
||||
|
||||
// 按审批人分组去重,保留最新处理记录,最终转换成 List
|
||||
List<FlowHisTask> latestPerApprover = taskList.stream()
|
||||
.collect(Collectors.collectingAndThen(
|
||||
Collectors.toMap(
|
||||
FlowHisTask::getApprover,
|
||||
Function.identity(),
|
||||
(oldTask, newTask) -> newTask.getUpdateTime().after(oldTask.getUpdateTime()) ? newTask : oldTask,
|
||||
LinkedHashMap::new
|
||||
),
|
||||
map -> new ArrayList<>(map.values())
|
||||
));
|
||||
|
||||
// 处理当前节点的扩展信息
|
||||
this.processNodeExtInfo(nodeJson, latestPerApprover, userMap, dictType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,7 +255,7 @@ public class FlwChartExtServiceImpl implements ChartExtService {
|
||||
LambdaQueryWrapper<FlowHisTask> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(FlowHisTask::getInstanceId, instanceId)
|
||||
.eq(FlowHisTask::getNodeType, NodeType.BETWEEN.getKey())
|
||||
.orderByDesc(FlowHisTask::getCreateTime, FlowHisTask::getUpdateTime);
|
||||
.orderByDesc(FlowHisTask::getUpdateTime);
|
||||
return flowHisTaskMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@ import org.dromara.warm.flow.orm.entity.FlowTask;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.common.enums.MessageTypeEnum;
|
||||
import org.dromara.workflow.service.IFlwCommonService;
|
||||
import org.dromara.workflow.service.IFlwTaskAssigneeService;
|
||||
import org.dromara.workflow.service.IFlwTaskService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -40,26 +39,6 @@ import java.util.stream.Collectors;
|
||||
public class FlwCommonServiceImpl implements IFlwCommonService {
|
||||
private final NodeService nodeService;
|
||||
|
||||
/**
|
||||
* 构建工作流用户
|
||||
*
|
||||
* @param permissionList 办理用户
|
||||
* @return 用户
|
||||
*/
|
||||
@Override
|
||||
public List<String> buildUser(List<String> permissionList) {
|
||||
if (CollUtil.isEmpty(permissionList)) {
|
||||
return List.of();
|
||||
}
|
||||
IFlwTaskAssigneeService taskAssigneeService = SpringUtils.getBean(IFlwTaskAssigneeService.class);
|
||||
String processedBys = CollUtil.join(permissionList, StringUtils.SEPARATOR);
|
||||
// 根据 processedBy 前缀判断处理人类型,分别获取用户列表
|
||||
List<UserDTO> users = taskAssigneeService.fetchUsersByStorageIds(processedBys);
|
||||
|
||||
return StreamUtils.toList(users, userDTO -> String.valueOf(userDTO.getUserId()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
|
@ -11,7 +11,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.domain.dto.UserDTO;
|
||||
import org.dromara.common.core.enums.BusinessStatusEnum;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
@ -19,11 +18,13 @@ import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.warm.flow.core.FlowEngine;
|
||||
import org.dromara.warm.flow.core.constant.ExceptionCons;
|
||||
import org.dromara.warm.flow.core.dto.FlowParams;
|
||||
import org.dromara.warm.flow.core.entity.Definition;
|
||||
import org.dromara.warm.flow.core.entity.Instance;
|
||||
import org.dromara.warm.flow.core.entity.Task;
|
||||
import org.dromara.warm.flow.core.entity.User;
|
||||
import org.dromara.warm.flow.core.enums.NodeType;
|
||||
import org.dromara.warm.flow.core.service.DefService;
|
||||
import org.dromara.warm.flow.core.service.InsService;
|
||||
@ -49,7 +50,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* 流程实例 服务层实现
|
||||
@ -203,9 +204,11 @@ public class FlwInstanceServiceImpl implements IFlwInstanceService {
|
||||
return false;
|
||||
}
|
||||
// 获取定义信息
|
||||
Map<Long, Definition> definitionMap = defService.getByIds(
|
||||
StreamUtils.toList(instances, Instance::getDefinitionId)
|
||||
).stream().collect(Collectors.toMap(Definition::getId, definition -> definition));
|
||||
Map<Long, Definition> definitionMap = StreamUtils.toMap(
|
||||
defService.getByIds(StreamUtils.toList(instances, Instance::getDefinitionId)),
|
||||
Definition::getId,
|
||||
Function.identity()
|
||||
);
|
||||
|
||||
// 逐一触发删除事件
|
||||
instances.forEach(instance -> {
|
||||
@ -281,37 +284,50 @@ public class FlwInstanceServiceImpl implements IFlwInstanceService {
|
||||
throw new ServiceException(ExceptionCons.NOT_FOUNT_INSTANCE);
|
||||
}
|
||||
Long instanceId = flowInstance.getId();
|
||||
//运行中的任务
|
||||
List<FlowHisTaskVo> list = new ArrayList<>();
|
||||
List<FlowTask> flowTaskList = flwTaskService.selectByInstId(instanceId);
|
||||
if (CollUtil.isNotEmpty(flowTaskList)) {
|
||||
List<FlowHisTaskVo> flowHisTaskVos = BeanUtil.copyToList(flowTaskList, FlowHisTaskVo.class);
|
||||
for (FlowHisTaskVo flowHisTaskVo : flowHisTaskVos) {
|
||||
flowHisTaskVo.setFlowStatus(TaskStatusEnum.WAITING.getStatus());
|
||||
flowHisTaskVo.setUpdateTime(null);
|
||||
flowHisTaskVo.setRunDuration(null);
|
||||
List<UserDTO> allUser = flwTaskService.currentTaskAllUser(flowHisTaskVo.getId());
|
||||
if (CollUtil.isNotEmpty(allUser)) {
|
||||
String join = StreamUtils.join(allUser, e -> String.valueOf(e.getUserId()));
|
||||
flowHisTaskVo.setApprover(join);
|
||||
|
||||
// 先组装待审批任务(运行中的任务)
|
||||
List<FlowHisTaskVo> runningTaskVos = new ArrayList<>();
|
||||
List<FlowTask> runningTasks = flwTaskService.selectByInstId(instanceId);
|
||||
if (CollUtil.isNotEmpty(runningTasks)) {
|
||||
runningTaskVos = BeanUtil.copyToList(runningTasks, FlowHisTaskVo.class);
|
||||
|
||||
List<User> associatedUsers = FlowEngine.userService()
|
||||
.getByAssociateds(StreamUtils.toList(runningTasks, FlowTask::getId));
|
||||
Map<Long, List<User>> taskUserMap = StreamUtils.groupByKey(associatedUsers, User::getAssociated);
|
||||
|
||||
for (FlowHisTaskVo vo : runningTaskVos) {
|
||||
vo.setFlowStatus(TaskStatusEnum.WAITING.getStatus());
|
||||
vo.setUpdateTime(null);
|
||||
vo.setRunDuration(null);
|
||||
|
||||
List<User> users = taskUserMap.get(vo.getId());
|
||||
if (CollUtil.isNotEmpty(users)) {
|
||||
vo.setApprover(StreamUtils.join(users, User::getProcessedBy));
|
||||
}
|
||||
if (BusinessStatusEnum.isDraftOrCancelOrBack(flowInstance.getFlowStatus())) {
|
||||
flowHisTaskVo.setApprover(LoginHelper.getUserIdStr());
|
||||
flowHisTaskVo.setApproveName(LoginHelper.getLoginUser().getNickname());
|
||||
vo.setApprover(LoginHelper.getUserIdStr());
|
||||
}
|
||||
}
|
||||
list.addAll(flowHisTaskVos);
|
||||
}
|
||||
//历史任务
|
||||
LambdaQueryWrapper<FlowHisTask> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(FlowHisTask::getInstanceId, instanceId)
|
||||
|
||||
// 再组装历史任务(已处理任务)
|
||||
List<FlowHisTaskVo> hisTaskVos = new ArrayList<>();
|
||||
List<FlowHisTask> hisTasks = flowHisTaskMapper.selectList(
|
||||
new LambdaQueryWrapper<FlowHisTask>()
|
||||
.eq(FlowHisTask::getInstanceId, instanceId)
|
||||
.eq(FlowHisTask::getNodeType, NodeType.BETWEEN.getKey())
|
||||
.orderByDesc(FlowHisTask::getCreateTime, FlowHisTask::getUpdateTime);
|
||||
List<FlowHisTask> flowHisTasks = flowHisTaskMapper.selectList(wrapper);
|
||||
if (CollUtil.isNotEmpty(flowHisTasks)) {
|
||||
list.addAll(BeanUtil.copyToList(flowHisTasks, FlowHisTaskVo.class));
|
||||
.orderByDesc(FlowHisTask::getUpdateTime)
|
||||
);
|
||||
if (CollUtil.isNotEmpty(hisTasks)) {
|
||||
hisTaskVos = BeanUtil.copyToList(hisTasks, FlowHisTaskVo.class);
|
||||
}
|
||||
return Map.of("list", list, "instanceId", instanceId);
|
||||
|
||||
// 结果列表,待审批任务在前,历史任务在后
|
||||
List<FlowHisTaskVo> combinedList = new ArrayList<>();
|
||||
combinedList.addAll(runningTaskVos);
|
||||
combinedList.addAll(hisTaskVos);
|
||||
|
||||
return Map.of("list", combinedList, "instanceId", instanceId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -377,31 +393,6 @@ public class FlwInstanceServiceImpl implements IFlwInstanceService {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按任务id查询实例
|
||||
*
|
||||
* @param taskIdList 任务id
|
||||
*/
|
||||
@Override
|
||||
public List<FlowInstance> selectByTaskIdList(List<Long> taskIdList) {
|
||||
if (CollUtil.isEmpty(taskIdList)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Set<Long> instanceIds = new HashSet<>();
|
||||
List<FlowTask> flowTaskList = flwTaskService.selectByIdList(taskIdList);
|
||||
for (FlowTask flowTask : flowTaskList) {
|
||||
instanceIds.add(flowTask.getInstanceId());
|
||||
}
|
||||
List<FlowHisTask> flowHisTaskList = flwTaskService.selectHisTaskByIdList(taskIdList);
|
||||
for (FlowHisTask flowHisTask : flowHisTaskList) {
|
||||
instanceIds.add(flowHisTask.getInstanceId());
|
||||
}
|
||||
if (!instanceIds.isEmpty()) {
|
||||
return this.selectInstListByIdList(new ArrayList<>(instanceIds));
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 作废流程
|
||||
*
|
||||
|
@ -12,9 +12,7 @@ import org.dromara.common.core.domain.dto.TaskAssigneeDTO;
|
||||
import org.dromara.common.core.domain.dto.UserDTO;
|
||||
import org.dromara.common.core.domain.model.TaskAssigneeBody;
|
||||
import org.dromara.common.core.enums.FormatsType;
|
||||
import org.dromara.common.core.service.DeptService;
|
||||
import org.dromara.common.core.service.TaskAssigneeService;
|
||||
import org.dromara.common.core.service.UserService;
|
||||
import org.dromara.common.core.service.*;
|
||||
import org.dromara.common.core.utils.DateUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.warm.flow.ui.dto.HandlerFunDto;
|
||||
@ -45,6 +43,8 @@ public class FlwTaskAssigneeServiceImpl implements IFlwTaskAssigneeService, Hand
|
||||
private final TaskAssigneeService taskAssigneeService;
|
||||
private final UserService userService;
|
||||
private final DeptService deptService;
|
||||
private final RoleService roleService;
|
||||
private final PostService postService;
|
||||
|
||||
/**
|
||||
* 获取办理人权限设置列表tabs页签
|
||||
@ -216,9 +216,9 @@ public class FlwTaskAssigneeServiceImpl implements IFlwTaskAssigneeService, Hand
|
||||
private Map<Long, String> getNamesByType(TaskAssigneeEnum type, List<Long> ids) {
|
||||
return switch (type) {
|
||||
case USER -> userService.selectUserNamesByIds(ids);
|
||||
case ROLE -> userService.selectRoleNamesByIds(ids);
|
||||
case DEPT -> userService.selectDeptNamesByIds(ids);
|
||||
case POST -> userService.selectPostNamesByIds(ids);
|
||||
case ROLE -> roleService.selectRoleNamesByIds(ids);
|
||||
case DEPT -> deptService.selectDeptNamesByIds(ids);
|
||||
case POST -> postService.selectPostNamesByIds(ids);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.dromara.workflow.common.constant.FlowConstant.*;
|
||||
|
||||
@ -252,14 +251,12 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
hisTask.setCreateTime(updateTime);
|
||||
hisTask.setUpdateTime(updateTime);
|
||||
hisTaskService.save(hisTask);
|
||||
List<User> userList = flowCopyList.stream()
|
||||
.map(flowCopy -> {
|
||||
FlowUser flowUser = new FlowUser();
|
||||
flowUser.setType(TaskAssigneeType.COPY.getCode());
|
||||
flowUser.setProcessedBy(String.valueOf(flowCopy.getUserId()));
|
||||
flowUser.setAssociated(taskId);
|
||||
return flowUser;
|
||||
}).collect(Collectors.toList());
|
||||
List<User> userList = StreamUtils.toList(flowCopyList, x ->
|
||||
new FlowUser()
|
||||
.setType(TaskAssigneeType.COPY.getCode())
|
||||
.setProcessedBy(String.valueOf(x.getUserId()))
|
||||
.setAssociated(taskId)
|
||||
);
|
||||
// 批量保存抄送人员
|
||||
FlowEngine.userService().saveBatch(userList);
|
||||
}
|
||||
@ -276,7 +273,8 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
queryWrapper.eq("t.node_type", NodeType.BETWEEN.getKey());
|
||||
queryWrapper.in("t.processed_by", LoginHelper.getUserIdStr());
|
||||
queryWrapper.in("t.flow_status", BusinessStatusEnum.WAITING.getStatus());
|
||||
Page<FlowTaskVo> page = this.getFlowTaskVoPage(pageQuery, queryWrapper);
|
||||
Page<FlowTaskVo> page = flwTaskMapper.getListRunTask(pageQuery.build(), queryWrapper);
|
||||
this.wrapAssigneeInfo(page.getRecords());
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
@ -306,25 +304,28 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
public TableDataInfo<FlowTaskVo> pageByAllTaskWait(FlowTaskBo flowTaskBo, PageQuery pageQuery) {
|
||||
QueryWrapper<FlowTaskBo> queryWrapper = buildQueryWrapper(flowTaskBo);
|
||||
queryWrapper.eq("t.node_type", NodeType.BETWEEN.getKey());
|
||||
Page<FlowTaskVo> page = getFlowTaskVoPage(pageQuery, queryWrapper);
|
||||
Page<FlowTaskVo> page = flwTaskMapper.getListRunTask(pageQuery.build(), queryWrapper);
|
||||
this.wrapAssigneeInfo(page.getRecords());
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
private Page<FlowTaskVo> getFlowTaskVoPage(PageQuery pageQuery, QueryWrapper<FlowTaskBo> queryWrapper) {
|
||||
Page<FlowTaskVo> page = flwTaskMapper.getListRunTask(pageQuery.build(), queryWrapper);
|
||||
List<FlowTaskVo> records = page.getRecords();
|
||||
if (CollUtil.isNotEmpty(records)) {
|
||||
List<Long> taskIds = StreamUtils.toList(records, FlowTaskVo::getId);
|
||||
Map<Long, List<UserDTO>> listMap = currentTaskAllUser(taskIds);
|
||||
records.forEach(t -> {
|
||||
List<UserDTO> userList = listMap.getOrDefault(t.getId(), Collections.emptyList());
|
||||
if (CollUtil.isNotEmpty(userList)) {
|
||||
t.setAssigneeIds(StreamUtils.join(userList, e -> String.valueOf(e.getUserId())));
|
||||
t.setAssigneeNames(StreamUtils.join(userList, UserDTO::getNickName));
|
||||
/**
|
||||
* 为流程任务列表封装处理人 ID(assigneeIds)
|
||||
*
|
||||
* @param taskList 流程任务列表
|
||||
*/
|
||||
private void wrapAssigneeInfo(List<FlowTaskVo> taskList) {
|
||||
if (CollUtil.isEmpty(taskList)) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
List<User> associatedUsers = FlowEngine.userService()
|
||||
.getByAssociateds(StreamUtils.toList(taskList, FlowTaskVo::getId));
|
||||
Map<Long, List<User>> taskUserMap = StreamUtils.groupByKey(associatedUsers, User::getAssociated);
|
||||
// 组装用户数据回任务列表
|
||||
for (FlowTaskVo task : taskList) {
|
||||
List<User> users = taskUserMap.get(task.getId());
|
||||
task.setAssigneeIds(StreamUtils.join(users, User::getProcessedBy));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -548,18 +549,6 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
return nextFlowNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照任务id查询任务
|
||||
*
|
||||
* @param taskIdList 任务id
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public List<FlowHisTask> selectHisTaskByIdList(List<Long> taskIdList) {
|
||||
return flowHisTaskMapper.selectList(new LambdaQueryWrapper<>(FlowHisTask.class)
|
||||
.in(FlowHisTask::getId, taskIdList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照任务id查询任务
|
||||
*
|
||||
@ -572,17 +561,6 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
.eq(FlowHisTask::getId, taskId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照实例id查询任务
|
||||
*
|
||||
* @param instanceIdList 流程实例id
|
||||
*/
|
||||
@Override
|
||||
public List<FlowTask> selectByInstIdList(List<Long> instanceIdList) {
|
||||
return flowTaskMapper.selectList(new LambdaQueryWrapper<>(FlowTask.class)
|
||||
.in(FlowTask::getInstanceId, instanceIdList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照实例id查询任务
|
||||
*
|
||||
@ -683,15 +661,12 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
// 批量删除现有任务的办理人记录
|
||||
if (CollUtil.isNotEmpty(flowTasks)) {
|
||||
FlowEngine.userService().deleteByTaskIds(StreamUtils.toList(flowTasks, FlowTask::getId));
|
||||
List<User> userList = flowTasks.stream()
|
||||
.map(flowTask -> {
|
||||
FlowUser flowUser = new FlowUser();
|
||||
flowUser.setType(TaskAssigneeType.APPROVER.getCode());
|
||||
flowUser.setProcessedBy(userId);
|
||||
flowUser.setAssociated(flowTask.getId());
|
||||
return flowUser;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
List<User> userList = StreamUtils.toList(flowTasks, flowTask ->
|
||||
new FlowUser()
|
||||
.setType(TaskAssigneeType.APPROVER.getCode())
|
||||
.setProcessedBy(userId)
|
||||
.setAssociated(flowTask.getId())
|
||||
);
|
||||
if (CollUtil.isNotEmpty(userList)) {
|
||||
FlowEngine.userService().saveBatch(userList);
|
||||
}
|
||||
@ -703,27 +678,6 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务所有办理人
|
||||
*
|
||||
* @param taskIdList 任务id
|
||||
*/
|
||||
@Override
|
||||
public Map<Long, List<UserDTO>> currentTaskAllUser(List<Long> taskIdList) {
|
||||
Map<Long, List<UserDTO>> map = new HashMap<>();
|
||||
// 获取与当前任务关联的用户列表
|
||||
List<User> associatedUsers = FlowEngine.userService().getByAssociateds(taskIdList);
|
||||
Map<Long, List<User>> listMap = StreamUtils.groupByKey(associatedUsers, User::getAssociated);
|
||||
for (Map.Entry<Long, List<User>> entry : listMap.entrySet()) {
|
||||
List<User> value = entry.getValue();
|
||||
if (CollUtil.isNotEmpty(value)) {
|
||||
List<UserDTO> userDtoList = userService.selectListByIds(StreamUtils.toList(value, e -> Convert.toLong(e.getProcessedBy())));
|
||||
map.put(entry.getKey(), userDtoList);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前任务的所有办理人
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user