From 098d3347a0df808908aab8c554cd7c4febc5e6d9 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期一, 26 八月 2024 11:43:59 +0800 Subject: [PATCH] !577 发布 5.2.2 正式版 安全性提升 Merge pull request !577 from 疯狂的狮子Li/dev --- ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessInstanceServiceImpl.java | 53 +++++++++++++++++++++++++++++------------------------ 1 files changed, 29 insertions(+), 24 deletions(-) diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessInstanceServiceImpl.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessInstanceServiceImpl.java index 33227c2..8b9b113 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessInstanceServiceImpl.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessInstanceServiceImpl.java @@ -9,6 +9,7 @@ import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; +import org.dromara.common.core.enums.BusinessStatusEnum; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.service.UserService; import org.dromara.common.core.utils.StreamUtils; @@ -17,7 +18,6 @@ import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.satoken.utils.LoginHelper; import org.dromara.workflow.common.constant.FlowConstant; -import org.dromara.common.core.enums.BusinessStatusEnum; import org.dromara.workflow.common.enums.TaskStatusEnum; import org.dromara.workflow.domain.ActHiProcinst; import org.dromara.workflow.domain.bo.ProcessInstanceBo; @@ -34,7 +34,7 @@ import org.dromara.workflow.service.IWfTaskBackNodeService; import org.dromara.workflow.utils.QueryUtils; import org.dromara.workflow.utils.WorkflowUtils; -import org.flowable.bpmn.model.*; +import org.flowable.bpmn.model.BpmnModel; import org.flowable.engine.*; import org.flowable.engine.history.HistoricActivityInstance; import org.flowable.engine.history.HistoricProcessInstance; @@ -48,6 +48,7 @@ import org.flowable.task.api.Task; import org.flowable.task.api.history.HistoricTaskInstance; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -57,7 +58,6 @@ import java.nio.charset.StandardCharsets; import java.util.List; import java.util.*; -import java.util.stream.Collectors; /** * 娴佺▼瀹炰緥 鏈嶅姟灞傚疄鐜� @@ -69,12 +69,17 @@ @Service public class ActProcessInstanceServiceImpl implements IActProcessInstanceService { - private final RepositoryService repositoryService; - private final RuntimeService runtimeService; - private final HistoryService historyService; - private final TaskService taskService; + @Autowired(required = false) + private RepositoryService repositoryService; + @Autowired(required = false) + private RuntimeService runtimeService; + @Autowired(required = false) + private HistoryService historyService; + @Autowired(required = false) + private TaskService taskService; + @Autowired(required = false) + private ManagementService managementService; private final IActHiProcinstService actHiProcinstService; - private final ManagementService managementService; private final IWfTaskBackNodeService wfTaskBackNodeService; private final IWfNodeConfigService wfNodeConfigService; private final FlowProcessEventHandler flowProcessEventHandler; @@ -257,23 +262,23 @@ List<HistoricActivityInstance> highLightedFlowList = QueryUtils.hisActivityInstanceQuery(processInstanceId).orderByHistoricActivityInstanceStartTime().asc().list(); for (HistoricActivityInstance tempActivity : highLightedFlowList) { Map<String, Object> task = new HashMap<>(); - if (!FlowConstant.SEQUENCE_FLOW.equals(tempActivity.getActivityType()) && - !FlowConstant.PARALLEL_GATEWAY.equals(tempActivity.getActivityType()) && - !FlowConstant.EXCLUSIVE_GATEWAY.equals(tempActivity.getActivityType()) && - !FlowConstant.INCLUSIVE_GATEWAY.equals(tempActivity.getActivityType()) - ) { - task.put("key", tempActivity.getActivityId()); - task.put("completed", tempActivity.getEndTime() != null); - task.put("activityType", tempActivity.getActivityType()); - taskList.add(task); + switch (tempActivity.getActivityType()) { + case FlowConstant.SEQUENCE_FLOW, FlowConstant.PARALLEL_GATEWAY, + FlowConstant.EXCLUSIVE_GATEWAY, FlowConstant.INCLUSIVE_GATEWAY -> {} + default -> { + task.put("key", tempActivity.getActivityId()); + task.put("completed", tempActivity.getEndTime() != null); + task.put("activityType", tempActivity.getActivityType()); + taskList.add(task); + } } } ProcessInstance processInstance = QueryUtils.instanceQuery(processInstanceId).singleResult(); 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)) { Iterator<Map<String, Object>> iterator = taskList.iterator(); while (iterator.hasNext()) { @@ -389,7 +394,7 @@ } //闄勪欢 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)) { actHistoryInfoVo.setAttachmentList(attachments); } @@ -488,7 +493,7 @@ historicProcessInstance.getBusinessKey(), BusinessStatusEnum.INVALID.getStatus(), false); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -523,7 +528,7 @@ wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -547,7 +552,7 @@ wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -597,7 +602,7 @@ processInstance.getBusinessKey(), BusinessStatusEnum.CANCEL.getStatus(), false); return true; } catch (Exception e) { - e.printStackTrace(); + log.error("鎾ら攢澶辫触:" + e.getMessage(), e); throw new ServiceException("鎾ら攢澶辫触:" + e.getMessage()); } } -- Gitblit v1.9.3