update 优化获取办理人
This commit is contained in:
parent
71a4577995
commit
4b6493cfd5
@ -8,11 +8,6 @@ package org.dromara.workflow.common.constant;
|
|||||||
*/
|
*/
|
||||||
public interface FlowConstant {
|
public interface FlowConstant {
|
||||||
|
|
||||||
/**
|
|
||||||
* 任务Id转任务办理人名称
|
|
||||||
*/
|
|
||||||
String TASK_ID_TO_ASSIGNEE = "task_id_to_assignee";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 流程发起人
|
* 流程发起人
|
||||||
*/
|
*/
|
||||||
|
@ -10,7 +10,6 @@ import org.dromara.common.log.enums.BusinessType;
|
|||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
import org.dromara.common.web.core.BaseController;
|
import org.dromara.common.web.core.BaseController;
|
||||||
import org.dromara.warm.flow.core.entity.HisTask;
|
|
||||||
import org.dromara.warm.flow.orm.entity.FlowHisTask;
|
import org.dromara.warm.flow.orm.entity.FlowHisTask;
|
||||||
import org.dromara.workflow.domain.bo.*;
|
import org.dromara.workflow.domain.bo.*;
|
||||||
import org.dromara.workflow.domain.vo.FlowHisTaskVo;
|
import org.dromara.workflow.domain.vo.FlowHisTaskVo;
|
||||||
|
@ -4,7 +4,6 @@ import lombok.Data;
|
|||||||
import org.dromara.common.translation.annotation.Translation;
|
import org.dromara.common.translation.annotation.Translation;
|
||||||
import org.dromara.common.translation.constant.TransConstant;
|
import org.dromara.common.translation.constant.TransConstant;
|
||||||
import org.dromara.warm.flow.core.entity.User;
|
import org.dromara.warm.flow.core.entity.User;
|
||||||
import org.dromara.workflow.common.constant.FlowConstant;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@ -121,11 +120,15 @@ public class FlowTaskVo implements Serializable {
|
|||||||
@Translation(type = TransConstant.DICT_TYPE_TO_LABEL, mapper = "flowStatus", other = "wf_business_status")
|
@Translation(type = TransConstant.DICT_TYPE_TO_LABEL, mapper = "flowStatus", other = "wf_business_status")
|
||||||
private String flowStatusName;
|
private String flowStatusName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 办理人ids
|
||||||
|
*/
|
||||||
|
private String assigneeIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 办理人名称
|
* 办理人名称
|
||||||
*/
|
*/
|
||||||
@Translation(type = FlowConstant.TASK_ID_TO_ASSIGNEE, mapper = "id")
|
private String assigneeNames;
|
||||||
private String transactorNames;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 抄送人id
|
* 抄送人id
|
||||||
|
@ -114,22 +114,6 @@ public interface IFlwTaskService {
|
|||||||
*/
|
*/
|
||||||
boolean terminationTask(FlowTerminationBo bo);
|
boolean terminationTask(FlowTerminationBo bo);
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过taskId查询对应的任务办理人
|
|
||||||
*
|
|
||||||
* @param taskIds taskId串逗号分隔
|
|
||||||
* @return 任务办理人名称串逗号分隔
|
|
||||||
*/
|
|
||||||
String selectAssigneeNamesByIds(String taskIds);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过taskId查询对应的任务办理人列表
|
|
||||||
*
|
|
||||||
* @param taskIdList 任务id
|
|
||||||
* @return 列表
|
|
||||||
*/
|
|
||||||
List<UserDTO> selectAssigneeByIds(List<Long> taskIdList);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按照任务id查询任务
|
* 按照任务id查询任务
|
||||||
*
|
*
|
||||||
@ -187,6 +171,14 @@ public interface IFlwTaskService {
|
|||||||
*/
|
*/
|
||||||
boolean taskOperation(TaskOperationBo bo, String taskOperation);
|
boolean taskOperation(TaskOperationBo bo, String taskOperation);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取任务所有办理人
|
||||||
|
*
|
||||||
|
* @param taskIdList 任务id
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
Map<Long, List<UserDTO>> currentTaskAllUser(List<Long> taskIdList);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前任务的所有办理人
|
* 获取当前任务的所有办理人
|
||||||
*
|
*
|
||||||
|
@ -2,7 +2,6 @@ package org.dromara.workflow.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||||
@ -76,6 +75,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
private final HisTaskService hisTaskService;
|
private final HisTaskService hisTaskService;
|
||||||
private final IdentifierGenerator identifierGenerator;
|
private final IdentifierGenerator identifierGenerator;
|
||||||
private final NodeService nodeService;
|
private final NodeService nodeService;
|
||||||
|
private final org.dromara.common.core.service.UserService sysUserService = SpringUtils.getBean(org.dromara.common.core.service.UserService.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动任务
|
* 启动任务
|
||||||
@ -182,7 +182,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
// 获取与当前任务关联的用户列表
|
// 获取与当前任务关联的用户列表
|
||||||
List<User> associatedUsers = userService.getByAssociateds(Collections.singletonList(flowTask.getId()));
|
List<User> associatedUsers = userService.getByAssociateds(Collections.singletonList(flowTask.getId()));
|
||||||
if (CollUtil.isNotEmpty(associatedUsers)) {
|
if (CollUtil.isNotEmpty(associatedUsers)) {
|
||||||
userList.addAll(WorkflowUtils.getUser(associatedUsers, flowTask.getId()));
|
userList.addAll(WorkflowUtils.buildUser(associatedUsers, flowTask.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 批量删除现有任务的办理人记录
|
// 批量删除现有任务的办理人记录
|
||||||
@ -247,7 +247,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
queryWrapper.eq("t.node_type", NodeType.BETWEEN.getKey());
|
queryWrapper.eq("t.node_type", NodeType.BETWEEN.getKey());
|
||||||
queryWrapper.in("t.processed_by", SpringUtils.getBean(WorkflowPermissionHandler.class).permissions());
|
queryWrapper.in("t.processed_by", SpringUtils.getBean(WorkflowPermissionHandler.class).permissions());
|
||||||
queryWrapper.in("t.flow_status", BusinessStatusEnum.WAITING.getStatus());
|
queryWrapper.in("t.flow_status", BusinessStatusEnum.WAITING.getStatus());
|
||||||
Page<FlowTaskVo> page = flwTaskMapper.getTaskWaitByPage(pageQuery.build(), queryWrapper);
|
Page<FlowTaskVo> page = getFlowTaskVoPage(pageQuery, queryWrapper);
|
||||||
return TableDataInfo.build(page);
|
return TableDataInfo.build(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,10 +277,27 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
public TableDataInfo<FlowTaskVo> pageByAllTaskWait(FlowTaskBo flowTaskBo, PageQuery pageQuery) {
|
public TableDataInfo<FlowTaskVo> pageByAllTaskWait(FlowTaskBo flowTaskBo, PageQuery pageQuery) {
|
||||||
QueryWrapper<FlowTaskBo> queryWrapper = buildQueryWrapper(flowTaskBo);
|
QueryWrapper<FlowTaskBo> queryWrapper = buildQueryWrapper(flowTaskBo);
|
||||||
queryWrapper.eq("t.node_type", NodeType.BETWEEN.getKey());
|
queryWrapper.eq("t.node_type", NodeType.BETWEEN.getKey());
|
||||||
Page<FlowTaskVo> page = flwTaskMapper.getTaskWaitByPage(pageQuery.build(), queryWrapper);
|
Page<FlowTaskVo> page = getFlowTaskVoPage(pageQuery, queryWrapper);
|
||||||
return TableDataInfo.build(page);
|
return TableDataInfo.build(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Page<FlowTaskVo> getFlowTaskVoPage(PageQuery pageQuery, QueryWrapper<FlowTaskBo> queryWrapper) {
|
||||||
|
Page<FlowTaskVo> page = flwTaskMapper.getTaskWaitByPage(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));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询已办任务
|
* 查询已办任务
|
||||||
*
|
*
|
||||||
@ -410,41 +427,6 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过taskId查询对应的任务办理人
|
|
||||||
*
|
|
||||||
* @param taskIds taskId串逗号分隔
|
|
||||||
* @return 任务办理人名称串逗号分隔
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String selectAssigneeNamesByIds(String taskIds) {
|
|
||||||
if (StringUtils.isBlank(taskIds)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
List<Long> taskIdList = StringUtils.splitTo(taskIds, Convert::toLong);
|
|
||||||
List<UserDTO> list = this.selectAssigneeByIds(taskIdList);
|
|
||||||
if (CollUtil.isEmpty(list)) {
|
|
||||||
return StringUtils.EMPTY;
|
|
||||||
}
|
|
||||||
return StreamUtils.join(list, UserDTO::getNickName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过taskId查询对应的任务办理人列表
|
|
||||||
*
|
|
||||||
* @param taskIdList 任务id
|
|
||||||
* @return 列表
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<UserDTO> selectAssigneeByIds(List<Long> taskIdList) {
|
|
||||||
if (CollUtil.isEmpty(taskIdList)) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
List<User> userList = userService.getByAssociateds(taskIdList
|
|
||||||
, UserType.APPROVAL.getKey(), UserType.TRANSFER.getKey(), UserType.DEPUTE.getKey());
|
|
||||||
return WorkflowUtils.getHandlerUser(userList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按照任务id查询任务
|
* 按照任务id查询任务
|
||||||
*
|
*
|
||||||
@ -637,6 +619,27 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
return true;
|
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 = 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> userDTOS = sysUserService.selectListByIds(StreamUtils.toList(value, e -> Long.valueOf(e.getProcessedBy())));
|
||||||
|
map.put(entry.getKey(), userDTOS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前任务的所有办理人
|
* 获取当前任务的所有办理人
|
||||||
*
|
*
|
||||||
@ -645,14 +648,10 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
@Override
|
@Override
|
||||||
public List<UserDTO> currentTaskAllUser(Long taskId) {
|
public List<UserDTO> currentTaskAllUser(Long taskId) {
|
||||||
// 获取与当前任务关联的用户列表
|
// 获取与当前任务关联的用户列表
|
||||||
List<User> associatedUsers = userService.getByAssociateds(Collections.singletonList(taskId));
|
List<User> userList = userService.getByAssociateds(Collections.singletonList(taskId));
|
||||||
if (CollUtil.isEmpty(associatedUsers)) {
|
if (CollUtil.isEmpty(userList)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
Set<User> users = WorkflowUtils.getUser(associatedUsers, taskId);
|
return sysUserService.selectListByIds(StreamUtils.toList(userList, e -> Long.valueOf(e.getProcessedBy())));
|
||||||
if (CollUtil.isEmpty(users)) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
return WorkflowUtils.getHandlerUser(new ArrayList<>(users));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
package org.dromara.workflow.service.impl;
|
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.dromara.common.translation.annotation.TranslationType;
|
|
||||||
import org.dromara.common.translation.core.TranslationInterface;
|
|
||||||
import org.dromara.workflow.common.constant.FlowConstant;
|
|
||||||
import org.dromara.workflow.service.IFlwTaskService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 任务办理人翻译实现
|
|
||||||
*
|
|
||||||
* @author AprilWind
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Service
|
|
||||||
@TranslationType(type = FlowConstant.TASK_ID_TO_ASSIGNEE)
|
|
||||||
public class TaskAssigneeTranslationImpl implements TranslationInterface<String> {
|
|
||||||
|
|
||||||
private final IFlwTaskService flwTaskService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String translation(Object key, String other) {
|
|
||||||
if (key instanceof Long id) {
|
|
||||||
return flwTaskService.selectAssigneeNamesByIds(id.toString());
|
|
||||||
} else if (key instanceof String id) {
|
|
||||||
return flwTaskService.selectAssigneeNamesByIds(id);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -20,7 +20,6 @@ import org.dromara.workflow.service.IFlwTaskService;
|
|||||||
import org.dromara.workflow.service.IWfTaskAssigneeService;
|
import org.dromara.workflow.service.IWfTaskAssigneeService;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,31 +33,13 @@ public class WorkflowUtils {
|
|||||||
public static final IFlwTaskService iFlwTaskService = SpringUtils.getBean(IFlwTaskService.class);
|
public static final IFlwTaskService iFlwTaskService = SpringUtils.getBean(IFlwTaskService.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取办理人
|
* 构建工作流用户
|
||||||
*
|
|
||||||
* @param userList 办理用户
|
|
||||||
* @return 用户
|
|
||||||
*/
|
|
||||||
public static List<UserDTO> getHandlerUser(List<User> userList) {
|
|
||||||
if (CollUtil.isEmpty(userList)) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
// 获取所有用户的 UserDTO 列表
|
|
||||||
return new ArrayList<>(userList.stream()
|
|
||||||
.map(User::getProcessedBy)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.flatMap(processedBy -> taskAssigneeService.fetchUsersByStorageId(processedBy).stream())
|
|
||||||
.collect(Collectors.toMap(UserDTO::getUserId, user -> user, (ex, rep) -> ex)).values());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取办理人
|
|
||||||
*
|
*
|
||||||
* @param userList 办理用户
|
* @param userList 办理用户
|
||||||
* @param taskId 任务ID
|
* @param taskId 任务ID
|
||||||
* @return 用户
|
* @return 用户
|
||||||
*/
|
*/
|
||||||
public static Set<User> getUser(List<User> userList, Long taskId) {
|
public static Set<User> buildUser(List<User> userList, Long taskId) {
|
||||||
if (CollUtil.isEmpty(userList)) {
|
if (CollUtil.isEmpty(userList)) {
|
||||||
return Set.of();
|
return Set.of();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user