mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-19 17:58:17 +08:00
fix 按要求去掉filterSet、findFirstIfPresent
恢复OpenApiHandler、EncryptorManager
This commit is contained in:
parent
79940cb5e8
commit
db36b34114
@ -21,7 +21,7 @@ import java.util.stream.Collectors;
|
||||
public class StreamUtils {
|
||||
|
||||
/**
|
||||
* 将collection-list过滤
|
||||
* 将collection过滤
|
||||
*
|
||||
* @param collection 需要转化的集合
|
||||
* @param function 过滤方法
|
||||
@ -35,20 +35,6 @@ public class StreamUtils {
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
* 找到流中满足条件的第一个元素
|
||||
*
|
||||
@ -63,19 +49,6 @@ public class StreamUtils {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 找到流中任意一个满足条件的元素
|
||||
*
|
||||
|
||||
@ -154,7 +154,9 @@ public class OpenApiHandler extends OpenAPIService {
|
||||
buildTagsFromClass(handlerMethod.getBeanType(), tags, tagsStr, locale);
|
||||
|
||||
if (!CollectionUtils.isEmpty(tagsStr))
|
||||
tagsStr = StreamUtils.toSet(tagsStr, str -> propertyResolverUtils.resolve(str, locale));
|
||||
tagsStr = tagsStr.stream()
|
||||
.map(str -> propertyResolverUtils.resolve(str, locale))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (springdocTags.containsKey(handlerMethod)) {
|
||||
io.swagger.v3.oas.models.tags.Tag tag = springdocTags.get(handlerMethod);
|
||||
|
||||
@ -6,7 +6,6 @@ import cn.hutool.core.util.ReflectUtil;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.io.Resources;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.encrypt.annotation.EncryptField;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
@ -20,6 +19,7 @@ import org.springframework.util.ClassUtils;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 加密管理类
|
||||
@ -146,8 +146,9 @@ public class EncryptorManager {
|
||||
fieldSet.addAll(Arrays.asList(fields));
|
||||
clazz = clazz.getSuperclass();
|
||||
}
|
||||
fieldSet = StreamUtils.filterSet(fieldSet, field ->
|
||||
field.isAnnotationPresent(EncryptField.class) && field.getType() == String.class);
|
||||
fieldSet = fieldSet.stream().filter(field ->
|
||||
field.isAnnotationPresent(EncryptField.class) && field.getType() == String.class)
|
||||
.collect(Collectors.toSet());
|
||||
for (Field field : fieldSet) {
|
||||
field.setAccessible(true);
|
||||
}
|
||||
|
||||
@ -648,9 +648,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
||||
List<WfNodeConfigVo> wfNodeConfigVoList = wfNodeConfigService.selectByDefIds(processDefinitionIds);
|
||||
for (ProcessInstanceVo processInstanceVo : list) {
|
||||
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
||||
StreamUtils.findFirstIfPresent(wfNodeConfigVoList,
|
||||
e -> e.getDefinitionId().equals(processInstanceVo.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask()),
|
||||
processInstanceVo::setWfNodeConfigVo);
|
||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(processInstanceVo.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(processInstanceVo::setWfNodeConfigVo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,13 +281,8 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
task.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId(), userService));
|
||||
task.setMultiInstance(WorkflowUtils.isMultiInstance(task.getProcessDefinitionId(), task.getTaskDefinitionKey()) != null);
|
||||
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
||||
StreamUtils.findFirstIfPresent(wfNodeConfigVoList,
|
||||
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);
|
||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && e.getNodeId().equals(task.getTaskDefinitionKey()) && FlowConstant.FALSE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -338,28 +333,21 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
for (Task task : taskList) {
|
||||
TaskVo taskVo = BeanUtil.toBean(task, TaskVo.class);
|
||||
if (CollUtil.isNotEmpty(processInstanceList)) {
|
||||
StreamUtils.findFirstIfPresent(processInstanceList,
|
||||
e -> e.getId().equals(task.getProcessInstanceId()),
|
||||
e -> {
|
||||
taskVo.setBusinessStatus(e.getBusinessStatus());
|
||||
taskVo.setBusinessStatusName(BusinessStatusEnum.findByStatus(taskVo.getBusinessStatus()));
|
||||
taskVo.setProcessDefinitionKey(e.getProcessDefinitionKey());
|
||||
taskVo.setProcessDefinitionName(e.getProcessDefinitionName());
|
||||
taskVo.setProcessDefinitionVersion(e.getProcessDefinitionVersion());
|
||||
taskVo.setBusinessKey(e.getBusinessKey());
|
||||
});
|
||||
processInstanceList.stream().filter(e -> e.getId().equals(task.getProcessInstanceId())).findFirst().ifPresent(e -> {
|
||||
taskVo.setBusinessStatus(e.getBusinessStatus());
|
||||
taskVo.setBusinessStatusName(BusinessStatusEnum.findByStatus(taskVo.getBusinessStatus()));
|
||||
taskVo.setProcessDefinitionKey(e.getProcessDefinitionKey());
|
||||
taskVo.setProcessDefinitionName(e.getProcessDefinitionName());
|
||||
taskVo.setProcessDefinitionVersion(e.getProcessDefinitionVersion());
|
||||
taskVo.setBusinessKey(e.getBusinessKey());
|
||||
});
|
||||
}
|
||||
taskVo.setAssignee(StringUtils.isNotBlank(task.getAssignee()) ? Long.valueOf(task.getAssignee()) : null);
|
||||
taskVo.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId(), userService));
|
||||
taskVo.setMultiInstance(WorkflowUtils.isMultiInstance(task.getProcessDefinitionId(), task.getTaskDefinitionKey()) != null);
|
||||
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
||||
StreamUtils.findFirstIfPresent(wfNodeConfigVoList,
|
||||
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);
|
||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(taskVo::setWfNodeConfigVo);
|
||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && e.getNodeId().equals(task.getTaskDefinitionKey()) && FlowConstant.FALSE.equals(e.getApplyUserTask())).findFirst().ifPresent(taskVo::setWfNodeConfigVo);
|
||||
}
|
||||
list.add(taskVo);
|
||||
}
|
||||
@ -393,13 +381,8 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
for (TaskVo task : taskList) {
|
||||
task.setBusinessStatusName(BusinessStatusEnum.findByStatus(task.getBusinessStatus()));
|
||||
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
||||
StreamUtils.findFirstIfPresent(wfNodeConfigVoList,
|
||||
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);
|
||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && e.getNodeId().equals(task.getTaskDefinitionKey()) && FlowConstant.FALSE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -434,13 +417,8 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
for (TaskVo task : taskList) {
|
||||
task.setBusinessStatusName(BusinessStatusEnum.findByStatus(task.getBusinessStatus()));
|
||||
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
||||
StreamUtils.findFirstIfPresent(wfNodeConfigVoList,
|
||||
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);
|
||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && e.getNodeId().equals(task.getTaskDefinitionKey()) && FlowConstant.FALSE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -467,13 +445,8 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
for (TaskVo task : taskList) {
|
||||
task.setBusinessStatusName(BusinessStatusEnum.findByStatus(task.getBusinessStatus()));
|
||||
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
||||
StreamUtils.findFirstIfPresent(wfNodeConfigVoList,
|
||||
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);
|
||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && e.getNodeId().equals(task.getTaskDefinitionKey()) && FlowConstant.FALSE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -731,9 +704,9 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
List<HistoricTaskInstance> instanceList = QueryUtils.hisTaskInstanceQuery(processInstanceId).finished().orderByHistoricTaskInstanceEndTime().desc().list();
|
||||
List<Task> list = QueryUtils.taskQuery(processInstanceId).list();
|
||||
for (Task t : list) {
|
||||
StreamUtils.findFirstIfPresent(instanceList,
|
||||
e -> e.getTaskDefinitionKey().equals(t.getTaskDefinitionKey()),
|
||||
e -> taskService.setAssignee(t.getId(), e.getAssignee()));
|
||||
instanceList.stream().filter(e -> e.getTaskDefinitionKey().equals(t.getTaskDefinitionKey())).findFirst().ifPresent(e -> {
|
||||
taskService.setAssignee(t.getId(), e.getAssignee());
|
||||
});
|
||||
}
|
||||
//发送消息
|
||||
String message = "您的【" + processInstance.getName() + "】单据已经被驳回,请您注意查收。";
|
||||
@ -861,9 +834,7 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
taskVo.setName(task.getName());
|
||||
taskVo.setAssignee(userId);
|
||||
if (CollUtil.isNotEmpty(userList)) {
|
||||
StreamUtils.findFirstIfPresent(userList,
|
||||
u -> u.getUserId().toString().equals(userId.toString()),
|
||||
u -> taskVo.setAssigneeName(u.getNickName()));
|
||||
userList.stream().filter(u -> u.getUserId().toString().equals(userId.toString())).findFirst().ifPresent(u -> taskVo.setAssigneeName(u.getNickName()));
|
||||
}
|
||||
taskListVo.add(taskVo);
|
||||
}
|
||||
@ -881,9 +852,7 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
taskVo.setName(t.getName());
|
||||
taskVo.setAssignee(Long.valueOf(t.getAssignee()));
|
||||
if (CollUtil.isNotEmpty(userList)) {
|
||||
StreamUtils.findFirstIfPresent(userList,
|
||||
u -> u.getUserId().toString().equals(t.getAssignee()),
|
||||
e -> taskVo.setAssigneeName(e.getNickName()));
|
||||
userList.stream().filter(u -> u.getUserId().toString().equals(t.getAssignee())).findFirst().ifPresent(e -> taskVo.setAssigneeName(e.getNickName()));
|
||||
}
|
||||
taskListVo.add(taskVo);
|
||||
}
|
||||
|
||||
@ -67,9 +67,7 @@ public class WfNodeConfigServiceImpl implements IWfNodeConfigService {
|
||||
List<Long> formIds = StreamUtils.toList(wfNodeConfigVos, WfNodeConfigVo::getFormId);
|
||||
List<WfFormManageVo> wfFormManageVos = wfFormManageService.queryByIds(formIds);
|
||||
for (WfNodeConfigVo wfNodeConfigVo : wfNodeConfigVos) {
|
||||
StreamUtils.findFirstIfPresent(wfFormManageVos,
|
||||
e -> ObjectUtil.equals(e.getId(), wfNodeConfigVo.getFormId()),
|
||||
wfNodeConfigVo::setWfFormManageVo);
|
||||
wfFormManageVos.stream().filter(e -> ObjectUtil.equals(e.getId(), wfNodeConfigVo.getFormId())).findFirst().ifPresent(wfNodeConfigVo::setWfFormManageVo);
|
||||
}
|
||||
}
|
||||
return wfNodeConfigVos;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user