Parcourir la source

流程-列表页面驳回后处理获取流程信息功能开发

user5 il y a 2 ans
Parent
commit
7f520d9f72

+ 77 - 4
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/controller/FlowableTaskController.java

@@ -4,6 +4,7 @@
 package com.jeeplus.flowable.controller;
 
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.extra.spring.SpringUtil;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
@@ -29,8 +30,10 @@ import com.jeeplus.sys.service.dto.UserDTO;
 import com.jeeplus.sys.utils.UserUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.ibatis.annotations.Param;
+import org.flowable.bpmn.model.Process;
 import org.flowable.common.engine.impl.identity.Authentication;
 import org.flowable.engine.HistoryService;
+import org.flowable.engine.RepositoryService;
 import org.flowable.engine.RuntimeService;
 import org.flowable.engine.TaskService;
 import org.flowable.engine.runtime.ProcessInstance;
@@ -127,7 +130,7 @@ public class FlowableTaskController {
      */
     @GetMapping("getTaskDef")
     public ResponseEntity getTaskDef(Flow flow) {
-        if(StringUtils.isNotBlank(flow.getTaskId()) && StringUtils.isBlank(flow.getTaskName()) && StringUtils.isBlank(flow.getTaskDefKey())){
+        /*if(StringUtils.isNotBlank(flow.getTaskId()) && StringUtils.isBlank(flow.getTaskName()) && StringUtils.isBlank(flow.getTaskDefKey())){
             ActRuTaskInfo taskInfoByTaskId = flowTaskService.getTaskInfoByTaskId(flow.getTaskId());
             if(null != taskInfoByTaskId){
                 flow.setTaskId(taskInfoByTaskId.getId());
@@ -135,7 +138,7 @@ public class FlowableTaskController {
                 flow.setTaskName(taskInfoByTaskId.getName());
                 flow.setTaskDefKey(taskInfoByTaskId.getTaskDefKey());
             }
-        }
+        }*/
         // 获取流程XML上的表单KEY
         String formKey = flowTaskService.getFormKey(flow.getProcDefId(), flow.getTaskDefKey());
 
@@ -171,6 +174,76 @@ public class FlowableTaskController {
 
 
 
+
+    /**
+     * 获取流程表单
+     */
+    @GetMapping("getTaskDefInfo")
+    public ResponseEntity getTaskDefInfo(Flow flow) {
+        if(StringUtils.isNotBlank(flow.getTaskId()) && StringUtils.isBlank(flow.getTaskName()) && StringUtils.isBlank(flow.getTaskDefKey())){
+            ActRuTaskInfo taskInfoByTaskId = flowTaskService.getTaskInfoByTaskId(flow.getTaskId());
+            if(null != taskInfoByTaskId){
+                flow.setTaskId(taskInfoByTaskId.getId());
+                flow.setProcInsId(taskInfoByTaskId.getProcInstId());
+                flow.setTaskName(taskInfoByTaskId.getName());
+                flow.setTaskDefKey(taskInfoByTaskId.getTaskDefKey());
+            }
+            //当前任务信息
+            Task task =taskService.createTaskQuery().processInstanceId(flow.getProcInsId()).active().singleResult();
+            if(null != task){
+                if(StringUtils.isNotBlank(task.getProcessDefinitionId())){
+                    flow.setProcDefId(task.getProcessDefinitionId());
+                }
+                if(null != task.getProcessVariables ()){
+                    String title = (String) task.getProcessVariables().get("title");
+                    if(StringUtils.isNotBlank(title)){
+                        flow.setTitle(title);
+                    }else{
+                        flow.setTitle("");
+                    }
+                }
+            }
+
+            Process process = SpringUtil.getBean (RepositoryService.class).getBpmnModel (taskInfoByTaskId.getProcDefId ()).getMainProcess ();
+            if(null != process && StringUtils.isNotBlank(process.getId())){
+                flow.setProcDefKey(process.getId());
+            }
+        }
+        // 获取流程XML上的表单KEY
+        String formKey = flowTaskService.getFormKey(flow.getProcDefId(), flow.getTaskDefKey());
+
+        NodeSetting typeNode = nodeSettingService.queryByKey (flow.getProcDefKey(), flow.getTaskDefKey(), "formType");
+        NodeSetting ReadOnlyNode = nodeSettingService.queryByKey (flow.getProcDefKey(), flow.getTaskDefKey(), "formReadOnly");
+        String formType = "1";
+        boolean formReadOnly = false;
+        if(typeNode != null){
+            formType = typeNode.getValue ();
+            formReadOnly = "true".equals(ReadOnlyNode.getValue ());
+        }else{
+            if(StringUtils.isBlank(formKey)){
+                formType = "1";
+            }else if(formKey.indexOf("/")>=0){
+                formType = "2";
+            }
+        }
+
+        // 获取流程实例对象
+        if (flow.getProcInsId() != null) {
+            if (flowTaskService.getProcIns(flow.getProcInsId()) != null) {
+                flow.setProcIns(flowTaskService.getProcIns(flow.getProcInsId()));
+            } else {
+                flow.setFinishedProcIns(flowTaskService.getFinishedProcIns(flow.getProcInsId()));
+            }
+        }
+
+        flow.setFormUrl(formKey);
+        flow.setFormReadOnly(formReadOnly);
+        flow.setFormType(formType);
+        return ResponseEntity.ok (flow);
+    }
+
+
+
     /**
      * 启动流程
      */
@@ -258,7 +331,7 @@ public class FlowableTaskController {
     @PostMapping("audit")
     public ResponseEntity auditTask(HttpServletRequest request, Flow flow) {
 
-        if(StringUtils.isNotBlank(flow.getTaskId()) && StringUtils.isBlank(flow.getTaskName()) && StringUtils.isBlank(flow.getTaskDefKey())){
+        /*if(StringUtils.isNotBlank(flow.getTaskId()) && StringUtils.isBlank(flow.getTaskName()) && StringUtils.isBlank(flow.getTaskDefKey())){
             ActRuTaskInfo taskInfoByTaskId = flowTaskService.getTaskInfoByTaskId(flow.getTaskId());
             if(null != taskInfoByTaskId){
                 flow.setTaskId(taskInfoByTaskId.getId());
@@ -266,7 +339,7 @@ public class FlowableTaskController {
                 flow.setTaskName(taskInfoByTaskId.getName());
                 flow.setTaskDefKey(taskInfoByTaskId.getTaskDefKey());
             }
-        }
+        }*/
         Map<String, Object> vars = Maps.newHashMap();
         Map<String, String[]> map = request.getParameterMap();
         for (Map.Entry<String, String[]> entry : map.entrySet()) {