mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-19 17:58:17 +08:00
refactor : 使用封装好的StreamUtils工具类代替项目中的部分stream操作
This commit is contained in:
parent
0cb3105cea
commit
79940cb5e8
@ -16,6 +16,7 @@ import org.dromara.common.core.domain.model.SocialLoginBody;
|
|||||||
import org.dromara.common.core.enums.UserStatus;
|
import org.dromara.common.core.enums.UserStatus;
|
||||||
import org.dromara.common.core.exception.ServiceException;
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
import org.dromara.common.core.exception.user.UserException;
|
import org.dromara.common.core.exception.user.UserException;
|
||||||
|
import org.dromara.common.core.utils.StreamUtils;
|
||||||
import org.dromara.common.core.utils.ValidatorUtils;
|
import org.dromara.common.core.utils.ValidatorUtils;
|
||||||
import org.dromara.common.json.utils.JsonUtils;
|
import org.dromara.common.json.utils.JsonUtils;
|
||||||
import org.dromara.common.satoken.utils.LoginHelper;
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
@ -83,7 +84,7 @@ public class SocialAuthStrategy implements IAuthStrategy {
|
|||||||
}
|
}
|
||||||
SysSocialVo social;
|
SysSocialVo social;
|
||||||
if (TenantHelper.isEnable()) {
|
if (TenantHelper.isEnable()) {
|
||||||
Optional<SysSocialVo> opt = list.stream().filter(x -> x.getTenantId().equals(loginBody.getTenantId())).findAny();
|
Optional<SysSocialVo> opt = StreamUtils.findAny(list, x -> x.getTenantId().equals(loginBody.getTenantId()));
|
||||||
if (opt.isEmpty()) {
|
if (opt.isEmpty()) {
|
||||||
throw new ServiceException("对不起,你没有权限登录当前租户!");
|
throw new ServiceException("对不起,你没有权限登录当前租户!");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import lombok.NoArgsConstructor;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -20,7 +21,7 @@ import java.util.stream.Collectors;
|
|||||||
public class StreamUtils {
|
public class StreamUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将collection过滤
|
* 将collection-list过滤
|
||||||
*
|
*
|
||||||
* @param collection 需要转化的集合
|
* @param collection 需要转化的集合
|
||||||
* @param function 过滤方法
|
* @param function 过滤方法
|
||||||
@ -34,6 +35,61 @@ public class StreamUtils {
|
|||||||
return collection.stream().filter(function).collect(Collectors.toList());
|
return collection.stream().filter(function).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将collection-set过滤
|
||||||
|
*
|
||||||
|
* @param collection 需要转化的集合
|
||||||
|
* @param function 过滤方法
|
||||||
|
* @return 过滤后的Set
|
||||||
|
*/
|
||||||
|
public static <E> Set<E> filterSet(Collection<E> collection, Predicate<E> function) {
|
||||||
|
if (CollUtil.isEmpty(collection)) {
|
||||||
|
return CollUtil.newHashSet() ;
|
||||||
|
}
|
||||||
|
return collection.stream().filter(function).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 找到流中满足条件的第一个元素
|
||||||
|
*
|
||||||
|
* @param collection 需要查询的集合
|
||||||
|
* @param function 过滤方法
|
||||||
|
* @return 找到符合条件的第一个元素,没有则返回null
|
||||||
|
*/
|
||||||
|
public static <E> E findFirst(Collection<E> collection, Predicate<E> function) {
|
||||||
|
if (CollUtil.isEmpty(collection)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return collection.stream().filter(function).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 找到流中第一个满足条件的元素之后执行操作
|
||||||
|
* @param collection 需要查询的集合
|
||||||
|
* @param function 过滤方法
|
||||||
|
* @param action 执行的动作
|
||||||
|
*/
|
||||||
|
public static <E> void findFirstIfPresent(Collection<E> collection, Predicate<E> function, Consumer<E> action) {
|
||||||
|
if (CollUtil.isEmpty(collection)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
collection.stream().filter(function).findFirst().ifPresent(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 找到流中任意一个满足条件的元素
|
||||||
|
*
|
||||||
|
* @param collection 需要查询的集合
|
||||||
|
* @param function 过滤方法
|
||||||
|
* @return 找到符合条件的任意一个元素,没有则返回null
|
||||||
|
*/
|
||||||
|
public static <E> Optional<E> findAny(Collection<E> collection, Predicate<E> function) {
|
||||||
|
if (CollUtil.isEmpty(collection)) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
return collection.stream().filter(function).findAny();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将collection拼接
|
* 将collection拼接
|
||||||
*
|
*
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import io.swagger.v3.oas.models.Paths;
|
|||||||
import io.swagger.v3.oas.models.tags.Tag;
|
import io.swagger.v3.oas.models.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.dromara.common.core.utils.StreamUtils;
|
||||||
import org.springdoc.core.customizers.OpenApiBuilderCustomizer;
|
import org.springdoc.core.customizers.OpenApiBuilderCustomizer;
|
||||||
import org.springdoc.core.customizers.ServerBaseUrlCustomizer;
|
import org.springdoc.core.customizers.ServerBaseUrlCustomizer;
|
||||||
import org.springdoc.core.properties.SpringDocConfigProperties;
|
import org.springdoc.core.properties.SpringDocConfigProperties;
|
||||||
@ -153,9 +154,7 @@ public class OpenApiHandler extends OpenAPIService {
|
|||||||
buildTagsFromClass(handlerMethod.getBeanType(), tags, tagsStr, locale);
|
buildTagsFromClass(handlerMethod.getBeanType(), tags, tagsStr, locale);
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(tagsStr))
|
if (!CollectionUtils.isEmpty(tagsStr))
|
||||||
tagsStr = tagsStr.stream()
|
tagsStr = StreamUtils.toSet(tagsStr, str -> propertyResolverUtils.resolve(str, locale));
|
||||||
.map(str -> propertyResolverUtils.resolve(str, locale))
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
|
|
||||||
if (springdocTags.containsKey(handlerMethod)) {
|
if (springdocTags.containsKey(handlerMethod)) {
|
||||||
io.swagger.v3.oas.models.tags.Tag tag = springdocTags.get(handlerMethod);
|
io.swagger.v3.oas.models.tags.Tag tag = springdocTags.get(handlerMethod);
|
||||||
@ -230,7 +229,7 @@ public class OpenApiHandler extends OpenAPIService {
|
|||||||
.flatMap(x -> Stream.of(x.value())).collect(Collectors.toSet());
|
.flatMap(x -> Stream.of(x.value())).collect(Collectors.toSet());
|
||||||
methodTags.addAll(AnnotatedElementUtils.findAllMergedAnnotations(method, io.swagger.v3.oas.annotations.tags.Tag.class));
|
methodTags.addAll(AnnotatedElementUtils.findAllMergedAnnotations(method, io.swagger.v3.oas.annotations.tags.Tag.class));
|
||||||
if (!CollectionUtils.isEmpty(methodTags)) {
|
if (!CollectionUtils.isEmpty(methodTags)) {
|
||||||
tagsStr.addAll(methodTags.stream().map(tag -> propertyResolverUtils.resolve(tag.name(), locale)).collect(Collectors.toSet()));
|
tagsStr.addAll(StreamUtils.toSet(methodTags, tag -> propertyResolverUtils.resolve(tag.name(), locale)));
|
||||||
List<io.swagger.v3.oas.annotations.tags.Tag> allTags = new ArrayList<>(methodTags);
|
List<io.swagger.v3.oas.annotations.tags.Tag> allTags = new ArrayList<>(methodTags);
|
||||||
addTags(allTags, tags, locale);
|
addTags(allTags, tags, locale);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import cn.hutool.core.util.ReflectUtil;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.ibatis.io.Resources;
|
import org.apache.ibatis.io.Resources;
|
||||||
|
import org.dromara.common.core.utils.StreamUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.encrypt.annotation.EncryptField;
|
import org.dromara.common.encrypt.annotation.EncryptField;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
@ -19,7 +20,6 @@ import org.springframework.util.ClassUtils;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加密管理类
|
* 加密管理类
|
||||||
@ -146,9 +146,8 @@ public class EncryptorManager {
|
|||||||
fieldSet.addAll(Arrays.asList(fields));
|
fieldSet.addAll(Arrays.asList(fields));
|
||||||
clazz = clazz.getSuperclass();
|
clazz = clazz.getSuperclass();
|
||||||
}
|
}
|
||||||
fieldSet = fieldSet.stream().filter(field ->
|
fieldSet = StreamUtils.filterSet(fieldSet, field ->
|
||||||
field.isAnnotationPresent(EncryptField.class) && field.getType() == String.class)
|
field.isAnnotationPresent(EncryptField.class) && field.getType() == String.class);
|
||||||
.collect(Collectors.toSet());
|
|
||||||
for (Field field : fieldSet) {
|
for (Field field : fieldSet) {
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.toolkit.Db;
|
|||||||
import org.apache.ibatis.logging.Log;
|
import org.apache.ibatis.logging.Log;
|
||||||
import org.apache.ibatis.logging.LogFactory;
|
import org.apache.ibatis.logging.LogFactory;
|
||||||
import org.dromara.common.core.utils.MapstructUtils;
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
|
import org.dromara.common.core.utils.StreamUtils;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -341,7 +342,7 @@ public interface BaseMapperPlus<T, V> extends BaseMapper<T> {
|
|||||||
* @return 查询到的符合条件的对象列表,经过转换为指定类型的对象后返回
|
* @return 查询到的符合条件的对象列表,经过转换为指定类型的对象后返回
|
||||||
*/
|
*/
|
||||||
default <C> List<C> selectObjs(Wrapper<T> wrapper, Function<? super Object, C> mapper) {
|
default <C> List<C> selectObjs(Wrapper<T> wrapper, Function<? super Object, C> mapper) {
|
||||||
return this.selectObjs(wrapper).stream().filter(Objects::nonNull).map(mapper).collect(Collectors.toList());
|
return StreamUtils.toList(this.selectObjs(wrapper), mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,6 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色 业务层处理
|
* 角色 业务层处理
|
||||||
@ -106,7 +105,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||||||
List<SysRoleVo> userRoles = baseMapper.selectRolesByUserId(userId);
|
List<SysRoleVo> userRoles = baseMapper.selectRolesByUserId(userId);
|
||||||
List<SysRoleVo> roles = selectRoleAll();
|
List<SysRoleVo> roles = selectRoleAll();
|
||||||
// 使用HashSet提高查找效率
|
// 使用HashSet提高查找效率
|
||||||
Set<Long> userRoleIds = userRoles.stream().map(SysRoleVo::getRoleId).collect(Collectors.toSet());
|
Set<Long> userRoleIds = StreamUtils.toSet(userRoles, SysRoleVo::getRoleId);
|
||||||
for (SysRoleVo role : roles) {
|
for (SysRoleVo role : roles) {
|
||||||
if (userRoleIds.contains(role.getRoleId())) {
|
if (userRoleIds.contains(role.getRoleId())) {
|
||||||
role.setFlag(true);
|
role.setFlag(true);
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package org.dromara.workflow.flowable.cmd;
|
|||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.dromara.common.core.utils.StreamUtils;
|
||||||
import org.flowable.common.engine.impl.interceptor.Command;
|
import org.flowable.common.engine.impl.interceptor.Command;
|
||||||
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||||
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
|
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
|
||||||
@ -59,7 +60,7 @@ public class DeleteSequenceMultiInstanceCmd implements Command<Void> {
|
|||||||
}
|
}
|
||||||
List<Long> userIdList = new ArrayList<>();
|
List<Long> userIdList = new ArrayList<>();
|
||||||
userIds.forEach(e -> {
|
userIds.forEach(e -> {
|
||||||
Long userId = assignees.stream().filter(id -> ObjectUtil.equals(id, e)).findFirst().orElse(null);
|
Long userId = StreamUtils.findFirst(assignees, id -> ObjectUtil.equals(id, e));
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
userIdList.add(e);
|
userIdList.add(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -270,10 +270,10 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|||||||
}
|
}
|
||||||
ProcessInstance processInstance = QueryUtils.instanceQuery(processInstanceId).singleResult();
|
ProcessInstance processInstance = QueryUtils.instanceQuery(processInstanceId).singleResult();
|
||||||
if (processInstance != null) {
|
if (processInstance != null) {
|
||||||
taskList = taskList.stream().filter(e -> !e.get("activityType").equals(FlowConstant.END_EVENT)).collect(Collectors.toList());
|
taskList = StreamUtils.filter(taskList, e -> !e.get("activityType").equals(FlowConstant.END_EVENT));
|
||||||
}
|
}
|
||||||
//查询出运行中节点
|
//查询出运行中节点
|
||||||
List<Map<String, Object>> runtimeNodeList = taskList.stream().filter(e -> !(Boolean) e.get("completed")).collect(Collectors.toList());
|
List<Map<String, Object>> runtimeNodeList = StreamUtils.filter(taskList, e -> !(Boolean) e.get("completed"));
|
||||||
if (CollUtil.isNotEmpty(runtimeNodeList)) {
|
if (CollUtil.isNotEmpty(runtimeNodeList)) {
|
||||||
Iterator<Map<String, Object>> iterator = taskList.iterator();
|
Iterator<Map<String, Object>> iterator = taskList.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
@ -389,7 +389,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|||||||
}
|
}
|
||||||
//附件
|
//附件
|
||||||
if (CollUtil.isNotEmpty(attachmentList)) {
|
if (CollUtil.isNotEmpty(attachmentList)) {
|
||||||
List<Attachment> attachments = attachmentList.stream().filter(e -> e.getTaskId().equals(historicTaskInstance.getId())).collect(Collectors.toList());
|
List<Attachment> attachments = StreamUtils.filter(attachmentList, e -> e.getTaskId().equals(historicTaskInstance.getId()));
|
||||||
if (CollUtil.isNotEmpty(attachments)) {
|
if (CollUtil.isNotEmpty(attachments)) {
|
||||||
actHistoryInfoVo.setAttachmentList(attachments);
|
actHistoryInfoVo.setAttachmentList(attachments);
|
||||||
}
|
}
|
||||||
@ -648,7 +648,9 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|||||||
List<WfNodeConfigVo> wfNodeConfigVoList = wfNodeConfigService.selectByDefIds(processDefinitionIds);
|
List<WfNodeConfigVo> wfNodeConfigVoList = wfNodeConfigService.selectByDefIds(processDefinitionIds);
|
||||||
for (ProcessInstanceVo processInstanceVo : list) {
|
for (ProcessInstanceVo processInstanceVo : list) {
|
||||||
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
||||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(processInstanceVo.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(processInstanceVo::setWfNodeConfigVo);
|
StreamUtils.findFirstIfPresent(wfNodeConfigVoList,
|
||||||
|
e -> e.getDefinitionId().equals(processInstanceVo.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask()),
|
||||||
|
processInstanceVo::setWfNodeConfigVo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -281,8 +281,13 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|||||||
task.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId(), userService));
|
task.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId(), userService));
|
||||||
task.setMultiInstance(WorkflowUtils.isMultiInstance(task.getProcessDefinitionId(), task.getTaskDefinitionKey()) != null);
|
task.setMultiInstance(WorkflowUtils.isMultiInstance(task.getProcessDefinitionId(), task.getTaskDefinitionKey()) != null);
|
||||||
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
||||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
StreamUtils.findFirstIfPresent(wfNodeConfigVoList,
|
||||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && e.getNodeId().equals(task.getTaskDefinitionKey()) && FlowConstant.FALSE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask()),
|
||||||
|
task::setWfNodeConfigVo);
|
||||||
|
|
||||||
|
StreamUtils.findFirstIfPresent(wfNodeConfigVoList,
|
||||||
|
e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && e.getNodeId().equals(task.getTaskDefinitionKey()) && FlowConstant.FALSE.equals(e.getApplyUserTask()),
|
||||||
|
task::setWfNodeConfigVo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,7 +338,9 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|||||||
for (Task task : taskList) {
|
for (Task task : taskList) {
|
||||||
TaskVo taskVo = BeanUtil.toBean(task, TaskVo.class);
|
TaskVo taskVo = BeanUtil.toBean(task, TaskVo.class);
|
||||||
if (CollUtil.isNotEmpty(processInstanceList)) {
|
if (CollUtil.isNotEmpty(processInstanceList)) {
|
||||||
processInstanceList.stream().filter(e -> e.getId().equals(task.getProcessInstanceId())).findFirst().ifPresent(e -> {
|
StreamUtils.findFirstIfPresent(processInstanceList,
|
||||||
|
e -> e.getId().equals(task.getProcessInstanceId()),
|
||||||
|
e -> {
|
||||||
taskVo.setBusinessStatus(e.getBusinessStatus());
|
taskVo.setBusinessStatus(e.getBusinessStatus());
|
||||||
taskVo.setBusinessStatusName(BusinessStatusEnum.findByStatus(taskVo.getBusinessStatus()));
|
taskVo.setBusinessStatusName(BusinessStatusEnum.findByStatus(taskVo.getBusinessStatus()));
|
||||||
taskVo.setProcessDefinitionKey(e.getProcessDefinitionKey());
|
taskVo.setProcessDefinitionKey(e.getProcessDefinitionKey());
|
||||||
@ -346,8 +353,13 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|||||||
taskVo.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId(), userService));
|
taskVo.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId(), userService));
|
||||||
taskVo.setMultiInstance(WorkflowUtils.isMultiInstance(task.getProcessDefinitionId(), task.getTaskDefinitionKey()) != null);
|
taskVo.setMultiInstance(WorkflowUtils.isMultiInstance(task.getProcessDefinitionId(), task.getTaskDefinitionKey()) != null);
|
||||||
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
||||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(taskVo::setWfNodeConfigVo);
|
StreamUtils.findFirstIfPresent(wfNodeConfigVoList,
|
||||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && e.getNodeId().equals(task.getTaskDefinitionKey()) && FlowConstant.FALSE.equals(e.getApplyUserTask())).findFirst().ifPresent(taskVo::setWfNodeConfigVo);
|
e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask()),
|
||||||
|
taskVo::setWfNodeConfigVo);
|
||||||
|
|
||||||
|
StreamUtils.findFirstIfPresent(wfNodeConfigVoList,
|
||||||
|
e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && e.getNodeId().equals(task.getTaskDefinitionKey()) && FlowConstant.FALSE.equals(e.getApplyUserTask()),
|
||||||
|
taskVo::setWfNodeConfigVo);
|
||||||
}
|
}
|
||||||
list.add(taskVo);
|
list.add(taskVo);
|
||||||
}
|
}
|
||||||
@ -381,8 +393,13 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|||||||
for (TaskVo task : taskList) {
|
for (TaskVo task : taskList) {
|
||||||
task.setBusinessStatusName(BusinessStatusEnum.findByStatus(task.getBusinessStatus()));
|
task.setBusinessStatusName(BusinessStatusEnum.findByStatus(task.getBusinessStatus()));
|
||||||
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
||||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
StreamUtils.findFirstIfPresent(wfNodeConfigVoList,
|
||||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && e.getNodeId().equals(task.getTaskDefinitionKey()) && FlowConstant.FALSE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask()),
|
||||||
|
task::setWfNodeConfigVo);
|
||||||
|
|
||||||
|
StreamUtils.findFirstIfPresent(wfNodeConfigVoList,
|
||||||
|
e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && e.getNodeId().equals(task.getTaskDefinitionKey()) && FlowConstant.FALSE.equals(e.getApplyUserTask()),
|
||||||
|
task::setWfNodeConfigVo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -417,8 +434,13 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|||||||
for (TaskVo task : taskList) {
|
for (TaskVo task : taskList) {
|
||||||
task.setBusinessStatusName(BusinessStatusEnum.findByStatus(task.getBusinessStatus()));
|
task.setBusinessStatusName(BusinessStatusEnum.findByStatus(task.getBusinessStatus()));
|
||||||
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
||||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
StreamUtils.findFirstIfPresent(wfNodeConfigVoList,
|
||||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && e.getNodeId().equals(task.getTaskDefinitionKey()) && FlowConstant.FALSE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask()),
|
||||||
|
task::setWfNodeConfigVo);
|
||||||
|
|
||||||
|
StreamUtils.findFirstIfPresent(wfNodeConfigVoList,
|
||||||
|
e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && e.getNodeId().equals(task.getTaskDefinitionKey()) && FlowConstant.FALSE.equals(e.getApplyUserTask()),
|
||||||
|
task::setWfNodeConfigVo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -445,8 +467,13 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|||||||
for (TaskVo task : taskList) {
|
for (TaskVo task : taskList) {
|
||||||
task.setBusinessStatusName(BusinessStatusEnum.findByStatus(task.getBusinessStatus()));
|
task.setBusinessStatusName(BusinessStatusEnum.findByStatus(task.getBusinessStatus()));
|
||||||
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
||||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
StreamUtils.findFirstIfPresent(wfNodeConfigVoList,
|
||||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && e.getNodeId().equals(task.getTaskDefinitionKey()) && FlowConstant.FALSE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask()),
|
||||||
|
task::setWfNodeConfigVo);
|
||||||
|
|
||||||
|
StreamUtils.findFirstIfPresent(wfNodeConfigVoList,
|
||||||
|
e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && e.getNodeId().equals(task.getTaskDefinitionKey()) && FlowConstant.FALSE.equals(e.getApplyUserTask()),
|
||||||
|
task::setWfNodeConfigVo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -704,9 +731,9 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|||||||
List<HistoricTaskInstance> instanceList = QueryUtils.hisTaskInstanceQuery(processInstanceId).finished().orderByHistoricTaskInstanceEndTime().desc().list();
|
List<HistoricTaskInstance> instanceList = QueryUtils.hisTaskInstanceQuery(processInstanceId).finished().orderByHistoricTaskInstanceEndTime().desc().list();
|
||||||
List<Task> list = QueryUtils.taskQuery(processInstanceId).list();
|
List<Task> list = QueryUtils.taskQuery(processInstanceId).list();
|
||||||
for (Task t : list) {
|
for (Task t : list) {
|
||||||
instanceList.stream().filter(e -> e.getTaskDefinitionKey().equals(t.getTaskDefinitionKey())).findFirst().ifPresent(e -> {
|
StreamUtils.findFirstIfPresent(instanceList,
|
||||||
taskService.setAssignee(t.getId(), e.getAssignee());
|
e -> e.getTaskDefinitionKey().equals(t.getTaskDefinitionKey()),
|
||||||
});
|
e -> taskService.setAssignee(t.getId(), e.getAssignee()));
|
||||||
}
|
}
|
||||||
//发送消息
|
//发送消息
|
||||||
String message = "您的【" + processInstance.getName() + "】单据已经被驳回,请您注意查收。";
|
String message = "您的【" + processInstance.getName() + "】单据已经被驳回,请您注意查收。";
|
||||||
@ -834,7 +861,9 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|||||||
taskVo.setName(task.getName());
|
taskVo.setName(task.getName());
|
||||||
taskVo.setAssignee(userId);
|
taskVo.setAssignee(userId);
|
||||||
if (CollUtil.isNotEmpty(userList)) {
|
if (CollUtil.isNotEmpty(userList)) {
|
||||||
userList.stream().filter(u -> u.getUserId().toString().equals(userId.toString())).findFirst().ifPresent(u -> taskVo.setAssigneeName(u.getNickName()));
|
StreamUtils.findFirstIfPresent(userList,
|
||||||
|
u -> u.getUserId().toString().equals(userId.toString()),
|
||||||
|
u -> taskVo.setAssigneeName(u.getNickName()));
|
||||||
}
|
}
|
||||||
taskListVo.add(taskVo);
|
taskListVo.add(taskVo);
|
||||||
}
|
}
|
||||||
@ -852,7 +881,9 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|||||||
taskVo.setName(t.getName());
|
taskVo.setName(t.getName());
|
||||||
taskVo.setAssignee(Long.valueOf(t.getAssignee()));
|
taskVo.setAssignee(Long.valueOf(t.getAssignee()));
|
||||||
if (CollUtil.isNotEmpty(userList)) {
|
if (CollUtil.isNotEmpty(userList)) {
|
||||||
userList.stream().filter(u -> u.getUserId().toString().equals(t.getAssignee())).findFirst().ifPresent(e -> taskVo.setAssigneeName(e.getNickName()));
|
StreamUtils.findFirstIfPresent(userList,
|
||||||
|
u -> u.getUserId().toString().equals(t.getAssignee()),
|
||||||
|
e -> taskVo.setAssigneeName(e.getNickName()));
|
||||||
}
|
}
|
||||||
taskListVo.add(taskVo);
|
taskListVo.add(taskVo);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,7 +67,9 @@ public class WfNodeConfigServiceImpl implements IWfNodeConfigService {
|
|||||||
List<Long> formIds = StreamUtils.toList(wfNodeConfigVos, WfNodeConfigVo::getFormId);
|
List<Long> formIds = StreamUtils.toList(wfNodeConfigVos, WfNodeConfigVo::getFormId);
|
||||||
List<WfFormManageVo> wfFormManageVos = wfFormManageService.queryByIds(formIds);
|
List<WfFormManageVo> wfFormManageVos = wfFormManageService.queryByIds(formIds);
|
||||||
for (WfNodeConfigVo wfNodeConfigVo : wfNodeConfigVos) {
|
for (WfNodeConfigVo wfNodeConfigVo : wfNodeConfigVos) {
|
||||||
wfFormManageVos.stream().filter(e -> ObjectUtil.equals(e.getId(), wfNodeConfigVo.getFormId())).findFirst().ifPresent(wfNodeConfigVo::setWfFormManageVo);
|
StreamUtils.findFirstIfPresent(wfFormManageVos,
|
||||||
|
e -> ObjectUtil.equals(e.getId(), wfNodeConfigVo.getFormId()),
|
||||||
|
wfNodeConfigVo::setWfFormManageVo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return wfNodeConfigVos;
|
return wfNodeConfigVos;
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.common.core.exception.ServiceException;
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
|
import org.dromara.common.core.utils.StreamUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.satoken.utils.LoginHelper;
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
import org.dromara.workflow.domain.WfTaskBackNode;
|
import org.dromara.workflow.domain.WfTaskBackNode;
|
||||||
@ -56,7 +57,7 @@ public class WfTaskBackNodeServiceImpl implements IWfTaskBackNodeService {
|
|||||||
wfTaskBackNode.setOrderNo(0);
|
wfTaskBackNode.setOrderNo(0);
|
||||||
wfTaskBackNodeMapper.insert(wfTaskBackNode);
|
wfTaskBackNodeMapper.insert(wfTaskBackNode);
|
||||||
} else {
|
} else {
|
||||||
WfTaskBackNode taskNode = list.stream().filter(e -> e.getNodeId().equals(wfTaskBackNode.getNodeId()) && e.getOrderNo() == 0).findFirst().orElse(null);
|
WfTaskBackNode taskNode = StreamUtils.findFirst(list, e -> e.getNodeId().equals(wfTaskBackNode.getNodeId()) && e.getOrderNo() == 0);
|
||||||
if (ObjectUtil.isEmpty(taskNode)) {
|
if (ObjectUtil.isEmpty(taskNode)) {
|
||||||
wfTaskBackNode.setOrderNo(list.get(0).getOrderNo() + 1);
|
wfTaskBackNode.setOrderNo(list.get(0).getOrderNo() + 1);
|
||||||
WfTaskBackNode node = getListByInstanceIdAndNodeId(wfTaskBackNode.getInstanceId(), wfTaskBackNode.getNodeId());
|
WfTaskBackNode node = getListByInstanceIdAndNodeId(wfTaskBackNode.getInstanceId(), wfTaskBackNode.getNodeId());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user