From 11bfde3dc1f8fbb0bfd681e7ba35d491a4f52a06 Mon Sep 17 00:00:00 2001
From: AprilWind <2100166581@qq.com>
Date: 星期六, 25 五月 2024 22:39:50 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessInstanceServiceImpl.java |   65 +++++++-------------------------
 1 files changed, 15 insertions(+), 50 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 39fc8fc..b64c79e 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
@@ -76,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;
@@ -122,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);
@@ -169,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);
@@ -336,8 +336,7 @@
      * @param processInstanceId 娴佺▼瀹炰緥id
      */
     @Override
-    public Map<String, Object> getHistoryRecord(String processInstanceId) {
-        Map<String, Object> map = new HashMap<>();
+    public List<ActHistoryInfoVo> getHistoryRecord(String processInstanceId) {
         // 鏌ヨ浠诲姟鍔炵悊璁板綍
         List<HistoricTaskInstance> list = QueryUtils.hisTaskInstanceQuery(processInstanceId).orderByHistoricTaskInstanceEndTime().desc().list();
         list = StreamUtils.sorted(list, Comparator.comparing(HistoricTaskInstance::getEndTime, Comparator.nullsFirst(Date::compareTo)).reversed());
@@ -378,16 +377,7 @@
             }
             actHistoryInfoVoList.add(actHistoryInfoVo);
         }
-        List<ActHistoryInfoVo> collect = new ArrayList<>();
-        // 寰呭姙鐞�
-        List<ActHistoryInfoVo> waitingTask = StreamUtils.filter(actHistoryInfoVoList, e -> e.getEndTime() == null);
-        // 宸插姙鐞�
-        List<ActHistoryInfoVo> finishTask = StreamUtils.filter(actHistoryInfoVoList, e -> e.getEndTime() != null);
-        collect.addAll(waitingTask);
-        collect.addAll(finishTask);
         // 瀹℃壒璁板綍
-        map.put("historyRecordList", collect);
-        List<ActHistoryInfoVo> nodeInfoList = new ArrayList<>();
         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);
@@ -403,39 +393,14 @@
                     actHistoryInfoVo.setEndTime(null);
                     actHistoryInfoVo.setRunDuration(null);
                 });
-            nodeInfoList.add(actHistoryInfoVo);
         }
-        // 鑺傜偣淇℃伅
-        map.put("nodeListInfo", nodeInfoList);
-        BpmnModel bpmnModel = repositoryService.getBpmnModel(list.get(0).getProcessDefinitionId());
-        List<GraphicInfoVo> graphicInfoVos = new ArrayList<>();
-        Collection<FlowElement> flowElements = bpmnModel.getMainProcess().getFlowElements();
-        //鑺傜偣鍥惧舰淇℃伅
-        buildGraphicInfo(flowElements, graphicInfoVos, bpmnModel);
-        map.put("graphicInfoVos", graphicInfoVos);
-        return map;
-    }
+        List<ActHistoryInfoVo> recordList = new ArrayList<>();
+        // 寰呭姙鐞�
+        recordList.addAll(StreamUtils.filter(actHistoryInfoVoList, e -> e.getEndTime() == null));
+        // 宸插姙鐞�
+        recordList.addAll(StreamUtils.filter(actHistoryInfoVoList, e -> e.getEndTime() != null));
 
-    /**
-     * 鏋勫缓鑺傜偣鍥惧舰淇℃伅
-     *
-     * @param flowElements 鑺傜偣
-     */
-    private static void buildGraphicInfo(Collection<FlowElement> flowElements, List<GraphicInfoVo> graphicInfoVos, BpmnModel bpmnModel) {
-        for (FlowElement flowElement : flowElements) {
-            if (flowElement instanceof SubProcess) {
-                Collection<FlowElement> subFlowElements = ((SubProcess) flowElement).getFlowElements();
-                buildGraphicInfo(subFlowElements, graphicInfoVos, bpmnModel);
-            } else {
-                if (flowElement instanceof UserTask) {
-                    GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(flowElement.getId());
-                    GraphicInfoVo graphicInfoVo = BeanUtil.toBean(graphicInfo, GraphicInfoVo.class);
-                    graphicInfoVo.setNodeId(flowElement.getId());
-                    graphicInfoVo.setNodeName(flowElement.getName());
-                    graphicInfoVos.add(graphicInfoVo);
-                }
-            }
-        }
+        return recordList;
     }
 
     /**
@@ -523,7 +488,7 @@
             if (ObjectUtil.isNotEmpty(historicProcessInstanceList)) {
                 historyService.bulkDeleteHistoricProcessInstances(processInstanceIds);
             }
-            iWfTaskBackNodeService.deleteByInstanceIds(processInstanceIds);
+            wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds);
             return true;
         } catch (Exception e) {
             e.printStackTrace();
@@ -558,7 +523,7 @@
             if (ObjectUtil.isNotEmpty(historicProcessInstanceList)) {
                 historyService.bulkDeleteHistoricProcessInstances(processInstanceIds);
             }
-            iWfTaskBackNodeService.deleteByInstanceIds(processInstanceIds);
+            wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds);
             return true;
         } catch (Exception e) {
             e.printStackTrace();
@@ -576,7 +541,7 @@
     public boolean deleteFinishAndHisInstance(List<String> processInstanceIds) {
         try {
             historyService.bulkDeleteHistoricProcessInstances(processInstanceIds);
-            iWfTaskBackNodeService.deleteByInstanceIds(processInstanceIds);
+            wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds);
             return true;
         } catch (Exception e) {
             e.printStackTrace();
@@ -677,7 +642,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