瀏覽代碼

查询当前审批进度

xuefy 4 年之前
父節點
當前提交
0ff4c9d065
共有 1 個文件被更改,包括 37 次插入3 次删除
  1. 37 3
      flowable/src/main/java/com/huyi/flowable/controller/CloudSupplyChainController.java

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

@@ -3,16 +3,20 @@ package com.huyi.flowable.controller;
 import com.huyi.flowable.BaseResult;
 import com.huyi.flowable.annotation.Log;
 import com.huyi.flowable.mapper.CloudSupplyChainMapper;
+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.history.HistoricActivityInstance;
+import org.flowable.engine.runtime.ProcessInstance;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+
+import java.util.*;
 
 /**
  * 查询是否配置流程审批
@@ -24,6 +28,10 @@ public class CloudSupplyChainController {
     IdentityService identityService;
     @Autowired
     private CloudSupplyChainMapper cloudSupplyChainMapper;
+    @Autowired
+    protected HistoryService historyService;
+    @Autowired
+    protected RuntimeService runtimeService;
 
     /**
      * 查询是否配置审批流程
@@ -45,6 +53,32 @@ public class CloudSupplyChainController {
         baseResult.setData(list);
         return baseResult;
     }
+    /**
+     * 查询当前审批进程
+     * @param businessKey
+     * @return
+     */
+    @RequestMapping(value = "selectCurrentProcess")
+    @ResponseBody
+    public List<HistoricActivityInstance> selectCurrentProcess(@RequestParam("businessKey") String businessKey) {
+        // TODO,需在流程展示的类型均需在此配置
+        Set<String> typeSet = new HashSet<String>();
+        typeSet.add(BpmnXMLConstants.ELEMENT_TASK_USER);
+        typeSet.add(BpmnXMLConstants.ELEMENT_EVENT_START);
+        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()
+                    .processInstanceId(processInstanceList.get(0).getId())
+                    .activityTypes(typeSet)
+                    .orderByHistoricActivityInstanceStartTime()
+                    .asc().list();
+            return historicActivityInstanceList;
+        } else {
+            return null;
+        }
+
+    }