From 405a98c8f3fb970806f93e70a8dc97da395c54d3 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期四, 09 五月 2024 17:08:21 +0800 Subject: [PATCH] update 优化 规范命名规则 --- ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessInstanceServiceImpl.java | 40 ++++++++++++++++++++++------------------ 1 files changed, 22 insertions(+), 18 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 a0da21d..6339302 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 @@ -3,6 +3,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.codec.Base64; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.ObjectUtil; import lombok.RequiredArgsConstructor; @@ -75,8 +76,8 @@ private final IActHiProcinstService actHiProcinstService; private final ManagementService managementService; private final FlowEventStrategy flowEventStrategy; - private final IWfTaskBackNodeService iWfTaskBackNodeService; - private final IWfNodeConfigService iWfNodeConfigService; + private final IWfTaskBackNodeService wfTaskBackNodeService; + private final IWfNodeConfigService wfNodeConfigService; @Value("${flowable.activity-font-name}") private String activityFontName; @@ -121,7 +122,7 @@ } if (CollUtil.isNotEmpty(list)) { List<String> processDefinitionIds = StreamUtils.toList(list, ProcessInstanceVo::getProcessDefinitionId); - List<WfNodeConfigVo> wfNodeConfigVoList = iWfNodeConfigService.selectByDefIds(processDefinitionIds); + List<WfNodeConfigVo> wfNodeConfigVoList = wfNodeConfigService.selectByDefIds(processDefinitionIds); for (ProcessInstanceVo processInstanceVo : list) { if (CollUtil.isNotEmpty(wfNodeConfigVoList)) { wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(processInstanceVo.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(processInstanceVo::setWfNodeConfigVo); @@ -168,7 +169,7 @@ } if (CollUtil.isNotEmpty(list)) { List<String> processDefinitionIds = StreamUtils.toList(list, ProcessInstanceVo::getProcessDefinitionId); - List<WfNodeConfigVo> wfNodeConfigVoList = iWfNodeConfigService.selectByDefIds(processDefinitionIds); + List<WfNodeConfigVo> wfNodeConfigVoList = wfNodeConfigService.selectByDefIds(processDefinitionIds); for (ProcessInstanceVo processInstanceVo : list) { if (CollUtil.isNotEmpty(wfNodeConfigVoList)) { wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(processInstanceVo.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(processInstanceVo::setWfNodeConfigVo); @@ -300,7 +301,6 @@ for (HistoricTaskInstance historicTaskInstance : list) { ActHistoryInfoVo actHistoryInfoVo = new ActHistoryInfoVo(); BeanUtils.copyProperties(historicTaskInstance, actHistoryInfoVo); - actHistoryInfoVo.setAssignee(StringUtils.isNotBlank(historicTaskInstance.getAssignee()) ? Long.valueOf(historicTaskInstance.getAssignee()) : null); actHistoryInfoVo.setStatus(actHistoryInfoVo.getEndTime() == null ? "寰呭鐞�" : "宸插鐞�"); if (ObjectUtil.isNotEmpty(historicTaskInstance.getDurationInMillis())) { actHistoryInfoVo.setRunDuration(getDuration(historicTaskInstance.getDurationInMillis())); @@ -318,6 +318,12 @@ historyInfoVo.setStartTime(e.getStartTime()); historyInfoVo.setEndTime(null); historyInfoVo.setRunDuration(null); + if (ObjectUtil.isEmpty(e.getAssignee())) { + ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(e.getId()); + if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) { + historyInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr)); + } + } }); historyInfoVoList.add(historyInfoVo); } @@ -356,16 +362,18 @@ if (ObjectUtil.isNotEmpty(historicTaskInstance.getDurationInMillis())) { actHistoryInfoVo.setRunDuration(getDuration(historicTaskInstance.getDurationInMillis())); } - try { - actHistoryInfoVo.setAssignee(StringUtils.isNotBlank(historicTaskInstance.getAssignee()) ? Long.valueOf(historicTaskInstance.getAssignee()) : null); - } catch (NumberFormatException ignored) { - log.warn("褰撳墠浠诲姟銆恵}銆�,鍔炵悊浜鸿浆鎹汉鍛業D銆恵}銆戝紓甯革紒", historicTaskInstance.getName(), historicTaskInstance.getAssignee()); - } //闄勪欢 if (CollUtil.isNotEmpty(attachmentList)) { List<Attachment> attachments = attachmentList.stream().filter(e -> e.getTaskId().equals(historicTaskInstance.getId())).collect(Collectors.toList()); if (CollUtil.isNotEmpty(attachments)) { actHistoryInfoVo.setAttachmentList(attachments); + } + } + //璁剧疆浜哄憳id + if (ObjectUtil.isEmpty(historicTaskInstance.getAssignee())) { + ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(historicTaskInstance.getId()); + if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) { + actHistoryInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr)); } } actHistoryInfoVoList.add(actHistoryInfoVo); @@ -383,10 +391,6 @@ Map<String, List<ActHistoryInfoVo>> groupByKey = StreamUtils.groupByKey(actHistoryInfoVoList, ActHistoryInfoVo::getTaskDefinitionKey); for (Map.Entry<String, List<ActHistoryInfoVo>> entry : groupByKey.entrySet()) { ActHistoryInfoVo actHistoryInfoVo = BeanUtil.toBean(entry.getValue().get(0), ActHistoryInfoVo.class); - String nickName = entry.getValue().stream().filter(e -> StringUtils.isNotBlank(e.getNickName()) && e.getEndTime() == null).map(ActHistoryInfoVo::getNickName).toList().stream().distinct().collect(Collectors.joining(StringUtils.SEPARATOR)); - if (StringUtils.isNotBlank(nickName)) { - actHistoryInfoVo.setNickName(nickName); - } actHistoryInfoVoList.stream().filter(e -> e.getTaskDefinitionKey().equals(entry.getKey()) && e.getEndTime() != null).findFirst() .ifPresent(e -> { actHistoryInfoVo.setStatus("宸插鐞�"); @@ -519,7 +523,7 @@ if (ObjectUtil.isNotEmpty(historicProcessInstanceList)) { historyService.bulkDeleteHistoricProcessInstances(processInstanceIds); } - iWfTaskBackNodeService.deleteByInstanceIds(processInstanceIds); + wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds); return true; } catch (Exception e) { e.printStackTrace(); @@ -554,7 +558,7 @@ if (ObjectUtil.isNotEmpty(historicProcessInstanceList)) { historyService.bulkDeleteHistoricProcessInstances(processInstanceIds); } - iWfTaskBackNodeService.deleteByInstanceIds(processInstanceIds); + wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds); return true; } catch (Exception e) { e.printStackTrace(); @@ -572,7 +576,7 @@ public boolean deleteFinishAndHisInstance(List<String> processInstanceIds) { try { historyService.bulkDeleteHistoricProcessInstances(processInstanceIds); - iWfTaskBackNodeService.deleteByInstanceIds(processInstanceIds); + wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds); return true; } catch (Exception e) { e.printStackTrace(); @@ -673,7 +677,7 @@ } if (CollUtil.isNotEmpty(list)) { List<String> processDefinitionIds = StreamUtils.toList(list, ProcessInstanceVo::getProcessDefinitionId); - List<WfNodeConfigVo> wfNodeConfigVoList = iWfNodeConfigService.selectByDefIds(processDefinitionIds); + List<WfNodeConfigVo> wfNodeConfigVoList = wfNodeConfigService.selectByDefIds(processDefinitionIds); for (ProcessInstanceVo processInstanceVo : list) { if (CollUtil.isNotEmpty(wfNodeConfigVoList)) { wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(processInstanceVo.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(processInstanceVo::setWfNodeConfigVo); -- Gitblit v1.9.3