浏览代码

修改流程进度查询

xuefy 3 年之前
父节点
当前提交
2c5a2f83bb
共有 1 个文件被更改,包括 39 次插入3 次删除
  1. 39 3
      flowable/src/main/java/com/huyi/flowable/controller/CloudSupplyChainController.java

+ 39 - 3
flowable/src/main/java/com/huyi/flowable/controller/CloudSupplyChainController.java

@@ -3,12 +3,16 @@ package com.huyi.flowable.controller;
 import com.huyi.flowable.BaseResult;
 import com.huyi.flowable.annotation.Log;
 import com.huyi.flowable.mapper.CloudSupplyChainMapper;
+import com.huyi.flowable.util.ListUtil;
 import org.flowable.bpmn.constants.BpmnXMLConstants;
 import org.flowable.engine.HistoryService;
 import org.flowable.engine.IdentityService;
 import org.flowable.engine.RuntimeService;
+import org.flowable.engine.TaskService;
 import org.flowable.engine.history.HistoricActivityInstance;
 import org.flowable.engine.runtime.ProcessInstance;
+import org.flowable.engine.task.Comment;
+import org.flowable.idm.api.User;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.transaction.annotation.Transactional;
@@ -16,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import java.lang.reflect.InvocationTargetException;
 import java.util.*;
 
 /**
@@ -32,6 +37,8 @@ public class CloudSupplyChainController {
     protected HistoryService historyService;
     @Autowired
     protected RuntimeService runtimeService;
+    @Autowired
+    protected TaskService taskService;
 
     /**
      * 查询是否配置审批流程
@@ -61,7 +68,7 @@ public class CloudSupplyChainController {
     @Log
     @RequestMapping(value = "selectCurrentProcess")
     @ResponseBody
-    public BaseResult selectCurrentProcess(@RequestParam("businessKey") String businessKey) {
+    public BaseResult selectCurrentProcess(@RequestParam("businessKey") String businessKey) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
         // TODO,需在流程展示的类型均需在此配置
         Set<String> typeSet = new HashSet<String>();
         typeSet.add(BpmnXMLConstants.ELEMENT_TASK_USER);
@@ -69,12 +76,41 @@ public class CloudSupplyChainController {
         typeSet.add(BpmnXMLConstants.ELEMENT_EVENT_END);
         List<ProcessInstance> processInstanceList = runtimeService.createProcessInstanceQuery().processInstanceBusinessKey(businessKey).orderByStartTime().desc().list();
         if (processInstanceList.size() != 0) {
-            List<HistoricActivityInstance> historicActivityInstanceList = historyService.createHistoricActivityInstanceQuery()
+            List<HistoricActivityInstance> hisTaskList = historyService.createHistoricActivityInstanceQuery()
                     .processInstanceId(processInstanceList.get(0).getId())
                     .activityTypes(typeSet)
                     .orderByHistoricActivityInstanceStartTime()
                     .asc().list();
-            return new BaseResult(historicActivityInstanceList);
+            List<String> assigneeList = ListUtil.getIdFromList(hisTaskList, "assignee");
+
+            List<User> userList = identityService.createUserQuery().userIds(assigneeList).list();
+
+            String[] str1 = {"assignee"};
+            String[] str2 = {"id"};
+            String[] str3 = {"displayName"};
+            String[] str4 = {"displayName"};
+
+            List<Map<String, Object>> resList = ListUtil.mergeList(hisTaskList, userList, str1, str2, str3, str4);
+
+            // 查询意见
+            List<Comment> commentEntityList = taskService.getProcessInstanceComments(processInstanceList.get(0).getId());
+
+            for (Map<String, Object> data : resList) {
+                for (Comment comment : commentEntityList) {
+                    System.out.println(comment.getTaskId() + "   " + data.get("id"));
+                    if (comment.getTaskId().equals(data.get("taskId"))) {
+                        if (data.get("commontList") != null) {
+                            ((List<Comment>)data.get("commontList")).add(comment);
+                        } else {
+                            List<Comment> commentList = new ArrayList<>();
+                            commentList.add(comment);
+                            data.put("commentList", commentList);
+                        }
+                    }
+                }
+            }
+
+            return new BaseResult(resList);
         } else {
             return new BaseResult("500", "未查询到流程", null);
         }