From 6cc24dc763c4da6d4105a79b9cf534f23f4af19b Mon Sep 17 00:00:00 2001 From: DoubleH <1402818247@qq.com> Date: 星期六, 06 七月 2024 13:58:26 +0800 Subject: [PATCH] !561 使用封装好的StreamUtils工具类代替项目中的部分stream操作 * refactor : 使用封装好的StreamUtils工具类代替项目中的部分stream操作 --- ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessInstanceServiceImpl.java | 24 +++++++++++++----------- 1 files changed, 13 insertions(+), 11 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 dafd059..3b18b61 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 @@ -10,6 +10,7 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.exception.ServiceException; +import org.dromara.common.core.service.UserService; import org.dromara.common.core.utils.StreamUtils; import org.dromara.common.core.utils.StringUtils; import org.dromara.common.mybatis.core.page.PageQuery; @@ -77,6 +78,7 @@ private final IWfTaskBackNodeService wfTaskBackNodeService; private final IWfNodeConfigService wfNodeConfigService; private final FlowProcessEventHandler flowProcessEventHandler; + private final UserService userService; @Value("${flowable.activity-font-name}") private String activityFontName; @@ -268,10 +270,10 @@ } 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()) { @@ -323,7 +325,7 @@ historyInfoVo.setEndTime(infoVo.getEndTime() == null ? null : infoVo.getEndTime()); historyInfoVo.setRunDuration(infoVo.getEndTime() == null ? null : infoVo.getRunDuration()); if (ObjectUtil.isEmpty(infoVo.getAssignee())) { - ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(infoVo.getId()); + ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(infoVo.getId(), userService); if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) { historyInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr)); } @@ -338,7 +340,7 @@ historyInfoVo.setEndTime(e.getEndTime() == null ? null : e.getEndTime()); historyInfoVo.setRunDuration(e.getEndTime() == null ? null : e.getRunDuration()); if (ObjectUtil.isEmpty(e.getAssignee())) { - ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(e.getId()); + ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(e.getId(), userService); if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) { historyInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr)); } @@ -387,14 +389,14 @@ } //闄勪欢 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); } } //璁剧疆浜哄憳id if (ObjectUtil.isEmpty(historicTaskInstance.getAssignee())) { - ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(historicTaskInstance.getId()); + ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(historicTaskInstance.getId(), userService); if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) { actHistoryInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr)); } @@ -486,7 +488,7 @@ historicProcessInstance.getBusinessKey(), BusinessStatusEnum.INVALID.getStatus(), false); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -521,7 +523,7 @@ wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -545,7 +547,7 @@ wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -595,7 +597,7 @@ processInstance.getBusinessKey(), BusinessStatusEnum.CANCEL.getStatus(), false); return true; } catch (Exception e) { - e.printStackTrace(); + log.error("鎾ら攢澶辫触:" + e.getMessage(), e); throw new ServiceException("鎾ら攢澶辫触:" + e.getMessage()); } } @@ -675,7 +677,7 @@ message = "鎮ㄧ殑銆�" + processInstance.getName() + "銆戝崟鎹繕鏈鎵癸紝璇锋偍鍙婃椂澶勭悊銆�"; } List<Task> list = QueryUtils.taskQuery(taskUrgingBo.getProcessInstanceId()).list(); - WorkflowUtils.sendMessage(list, processInstance.getName(), taskUrgingBo.getMessageType(), message); + WorkflowUtils.sendMessage(list, processInstance.getName(), taskUrgingBo.getMessageType(), message, userService); } catch (ServiceException e) { throw new ServiceException(e.getMessage()); } -- Gitblit v1.9.3