From 6d2cc6e87d609589a23ea8e95331bb64a1a9a88c Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期五, 21 六月 2024 14:59:50 +0800 Subject: [PATCH] update 优化 替换过期方法 --- ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessInstanceServiceImpl.java | 56 +++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 39 insertions(+), 17 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 5a46978..b833bcc 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; @@ -280,7 +282,7 @@ } } map.put("taskList", taskList); - List<ActHistoryInfoVo> historyTaskList = getHistoryTaskList(processInstanceId, processInstance.getProcessDefinitionVersion()); + List<ActHistoryInfoVo> historyTaskList = getHistoryTaskList(processInstanceId, processDefinition.getVersion()); map.put("historyList", historyTaskList); InputStream inputStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), processDefinition.getResourceName()); xml.append(IoUtil.read(inputStream, StandardCharsets.UTF_8)); @@ -313,21 +315,41 @@ Map<String, List<ActHistoryInfoVo>> groupByKey = StreamUtils.groupByKey(actHistoryInfoVoList, ActHistoryInfoVo::getTaskDefinitionKey); for (Map.Entry<String, List<ActHistoryInfoVo>> entry : groupByKey.entrySet()) { ActHistoryInfoVo historyInfoVo = new ActHistoryInfoVo(); - BeanUtils.copyProperties(entry.getValue().get(0), historyInfoVo); - actHistoryInfoVoList.stream().filter(e -> e.getTaskDefinitionKey().equals(entry.getKey()) && e.getEndTime() == null).findFirst() - .ifPresent(e -> { - historyInfoVo.setStatus("寰呭鐞�"); - historyInfoVo.setStartTime(e.getStartTime()); - historyInfoVo.setEndTime(null); - historyInfoVo.setRunDuration(null); - if (ObjectUtil.isEmpty(e.getAssignee())) { - ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(e.getId()); + if (entry.getValue().size() > 1) { + List<ActHistoryInfoVo> historyInfoVos = StreamUtils.filter(entry.getValue(), e -> StringUtils.isNotBlank(e.getAssignee())); + if (CollUtil.isNotEmpty(historyInfoVos)) { + ActHistoryInfoVo infoVo = historyInfoVos.get(0); + BeanUtils.copyProperties(infoVo, historyInfoVo); + historyInfoVo.setStatus(infoVo.getEndTime() == null ? "寰呭鐞�" : "宸插鐞�"); + historyInfoVo.setStartTime(infoVo.getStartTime()); + 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(), userService); if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) { historyInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr)); } } - }); + } + } else { + actHistoryInfoVoList.stream().filter(e -> e.getTaskDefinitionKey().equals(entry.getKey())).findFirst() + .ifPresent(e -> { + BeanUtils.copyProperties(e, historyInfoVo); + historyInfoVo.setStatus(e.getEndTime() == null ? "寰呭鐞�" : "宸插鐞�"); + historyInfoVo.setStartTime(e.getStartTime()); + 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(), userService); + if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) { + historyInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr)); + } + } + }); + + } historyInfoVoList.add(historyInfoVo); + } return historyInfoVoList; } @@ -374,7 +396,7 @@ } //璁剧疆浜哄憳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)); } @@ -466,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()); } } @@ -501,7 +523,7 @@ wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -525,7 +547,7 @@ wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -575,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()); } } @@ -655,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