Parcourir la source

update 优化工作流模块的集合工具类,统一为CollUtil

wangql il y a 1 an
Parent
commit
6cc2da03e0

+ 2 - 3
ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessDefinitionServiceImpl.java

@@ -3,7 +3,6 @@ package org.dromara.workflow.service.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.codec.Base64;
 import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.IoUtil;
 import cn.hutool.core.util.ObjectUtil;
@@ -150,7 +149,7 @@ public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionSer
                 processDefinitionVoList.add(processDefinitionVo);
             }
         }
-        return CollectionUtil.reverse(processDefinitionVoList);
+        return CollUtil.reverse(processDefinitionVoList);
     }
 
     /**
@@ -195,7 +194,7 @@ public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionSer
     public boolean deleteDeployment(List<String> deploymentIds, List<String> processDefinitionIds) {
         try {
             List<HistoricProcessInstance> historicProcessInstances = QueryUtils.hisInstanceQuery().deploymentIdIn(deploymentIds).list();
-            if (CollectionUtil.isNotEmpty(historicProcessInstances)) {
+            if (CollUtil.isNotEmpty(historicProcessInstances)) {
                 Set<String> defIds = StreamUtils.toSet(historicProcessInstances, HistoricProcessInstance::getProcessDefinitionId);
                 List<ProcessDefinition> processDefinitions = QueryUtils.definitionQuery().processDefinitionIds(defIds).list();
                 if (CollUtil.isNotEmpty(processDefinitions)) {

+ 3 - 4
ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActTaskServiceImpl.java

@@ -2,7 +2,6 @@ package org.dromara.workflow.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -517,9 +516,9 @@ public class ActTaskServiceImpl implements IActTaskService {
             }
             taskService.addComment(task.getId(), task.getProcessInstanceId(), TaskStatusEnum.TERMINATION.getStatus(), terminationBo.getComment());
             List<Task> list = QueryUtils.taskQuery(task.getProcessInstanceId()).list();
-            if (CollectionUtil.isNotEmpty(list)) {
+            if (CollUtil.isNotEmpty(list)) {
                 List<Task> subTasks = StreamUtils.filter(list, e -> StringUtils.isNotBlank(e.getParentTaskId()));
-                if (CollectionUtil.isNotEmpty(subTasks)) {
+                if (CollUtil.isNotEmpty(subTasks)) {
                     subTasks.forEach(e -> taskService.deleteTask(e.getId()));
                 }
                 runtimeService.updateBusinessStatus(task.getProcessInstanceId(), BusinessStatusEnum.TERMINATION.getStatus());
@@ -768,7 +767,7 @@ public class ActTaskServiceImpl implements IActTaskService {
     public List<VariableVo> getInstanceVariable(String taskId) {
         List<VariableVo> variableVoList = new ArrayList<>();
         Map<String, VariableInstance> variableInstances = taskService.getVariableInstances(taskId);
-        if (CollectionUtil.isNotEmpty(variableInstances)) {
+        if (CollUtil.isNotEmpty(variableInstances)) {
             for (Map.Entry<String, VariableInstance> entry : variableInstances.entrySet()) {
                 VariableVo variableVo = new VariableVo();
                 variableVo.setKey(entry.getKey());

+ 4 - 4
ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/WfTaskBackNodeServiceImpl.java

@@ -1,6 +1,6 @@
 package org.dromara.workflow.service.impl;
 
-import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.RequiredArgsConstructor;
@@ -50,7 +50,7 @@ public class WfTaskBackNodeServiceImpl implements IWfTaskBackNodeService {
         } else {
             wfTaskBackNode.setTaskType(USER_TASK);
         }
-        if (CollectionUtil.isEmpty(list)) {
+        if (CollUtil.isEmpty(list)) {
             wfTaskBackNode.setOrderNo(0);
             wfTaskBackNodeMapper.insert(wfTaskBackNode);
         } else {
@@ -96,14 +96,14 @@ public class WfTaskBackNodeServiceImpl implements IWfTaskBackNodeService {
                 Integer orderNo = actTaskNode.getOrderNo();
                 List<WfTaskBackNode> taskNodeList = getListByInstanceId(processInstanceId);
                 List<Long> ids = new ArrayList<>();
-                if (CollectionUtil.isNotEmpty(taskNodeList)) {
+                if (CollUtil.isNotEmpty(taskNodeList)) {
                     for (WfTaskBackNode taskNode : taskNodeList) {
                         if (taskNode.getOrderNo() >= orderNo) {
                             ids.add(taskNode.getId());
                         }
                     }
                 }
-                if (CollectionUtil.isNotEmpty(ids)) {
+                if (CollUtil.isNotEmpty(ids)) {
                     wfTaskBackNodeMapper.deleteBatchIds(ids);
                 }
             }

+ 7 - 8
ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/WorkflowUserServiceImpl.java

@@ -1,7 +1,6 @@
 package org.dromara.workflow.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -70,11 +69,11 @@ public class WorkflowUserServiceImpl implements IWorkflowUserService {
         queryWrapper.eq(SysUser::getStatus, UserStatus.OK.getCode());
         if (multiInstance.getType() instanceof SequentialMultiInstanceBehavior) {
             List<Long> assigneeList = (List<Long>) runtimeService.getVariable(task.getExecutionId(), multiInstance.getAssigneeList());
-            queryWrapper.notIn(CollectionUtil.isNotEmpty(assigneeList), SysUser::getUserId, assigneeList);
+            queryWrapper.notIn(CollUtil.isNotEmpty(assigneeList), SysUser::getUserId, assigneeList);
         } else {
             List<Task> list = QueryUtils.taskQuery(task.getProcessInstanceId()).list();
             List<Long> userIds = StreamUtils.toList(list, e -> Long.valueOf(e.getAssignee()));
-            queryWrapper.notIn(CollectionUtil.isNotEmpty(userIds), SysUser::getUserId, userIds);
+            queryWrapper.notIn(CollUtil.isNotEmpty(userIds), SysUser::getUserId, userIds);
         }
         queryWrapper.like(StringUtils.isNotEmpty(bo.getUserName()), SysUser::getUserName, bo.getUserName());
         queryWrapper.like(StringUtils.isNotEmpty(bo.getNickName()), SysUser::getNickName, bo.getNickName());
@@ -109,7 +108,7 @@ public class WorkflowUserServiceImpl implements IWorkflowUserService {
         if (multiInstance.getType() instanceof SequentialMultiInstanceBehavior) {
             List<Long> userIds = StreamUtils.filter(assigneeList, e -> !String.valueOf(e).equals(task.getAssignee()));
             List<SysUserVo> sysUsers = null;
-            if (CollectionUtil.isNotEmpty(userIds)) {
+            if (CollUtil.isNotEmpty(userIds)) {
                 sysUsers = sysUserMapper.selectVoBatchIds(userIds);
             }
             for (Long userId : userIds) {
@@ -119,7 +118,7 @@ public class WorkflowUserServiceImpl implements IWorkflowUserService {
                 taskVo.setProcessInstanceId(task.getProcessInstanceId());
                 taskVo.setName(task.getName());
                 taskVo.setAssignee(userId);
-                if (CollectionUtil.isNotEmpty(sysUsers)) {
+                if (CollUtil.isNotEmpty(sysUsers)) {
                     sysUsers.stream().filter(u -> u.getUserId().toString().equals(userId.toString())).findFirst().ifPresent(u -> taskVo.setAssigneeName(u.getNickName()));
                 }
                 taskListVo.add(taskVo);
@@ -127,10 +126,10 @@ public class WorkflowUserServiceImpl implements IWorkflowUserService {
             return taskListVo;
         } else if (multiInstance.getType() instanceof ParallelMultiInstanceBehavior) {
             List<Task> tasks = StreamUtils.filter(taskList, e -> StringUtils.isBlank(e.getParentTaskId()) && !e.getExecutionId().equals(task.getExecutionId()) && e.getTaskDefinitionKey().equals(task.getTaskDefinitionKey()));
-            if (CollectionUtil.isNotEmpty(tasks)) {
+            if (CollUtil.isNotEmpty(tasks)) {
                 List<Long> userIds = StreamUtils.toList(tasks, e -> Long.valueOf(e.getAssignee()));
                 List<SysUserVo> sysUsers = null;
-                if (CollectionUtil.isNotEmpty(userIds)) {
+                if (CollUtil.isNotEmpty(userIds)) {
                     sysUsers = sysUserMapper.selectVoBatchIds(userIds);
                 }
                 for (Task t : tasks) {
@@ -140,7 +139,7 @@ public class WorkflowUserServiceImpl implements IWorkflowUserService {
                     taskVo.setProcessInstanceId(t.getProcessInstanceId());
                     taskVo.setName(t.getName());
                     taskVo.setAssignee(Long.valueOf(t.getAssignee()));
-                    if (CollectionUtil.isNotEmpty(sysUsers)) {
+                    if (CollUtil.isNotEmpty(sysUsers)) {
                         sysUsers.stream().filter(u -> u.getUserId().toString().equals(t.getAssignee())).findFirst().ifPresent(e -> taskVo.setAssigneeName(e.getNickName()));
                     }
                     taskListVo.add(taskVo);