Эх сурвалжийг харах

流程表单属性接口修改

wangliang 1 жил өмнө
parent
commit
20e145342d

+ 0 - 30
sop-business/src/main/java/com/qmth/sop/business/activiti/DefaultInstanceConvertToMultiInstance.java

@@ -1,30 +0,0 @@
-package com.qmth.sop.business.activiti;
-
-import com.qmth.sop.common.contant.SystemConstant;
-import com.qmth.sop.common.enums.FlowApproveOperationEnum;
-
-/**
- * @Description: 创建并行/串行业务
- * @Param:
- * @return:
- * @Author: wangliang
- * @Date: 2022/2/8
- */
-public interface DefaultInstanceConvertToMultiInstance extends MultiWorkFlow {
-
-    public static final String EXP_PREFIX = "${";
-    public static final String EXP_SUFFIX = "}";
-    public static final String EXP_EQUAL = "==";
-    public static final String ASSIGNEE_USER = "assignee";
-    public static final String DEFAULT_ASSIGNEE_LIST = "assigneeList";
-    public static final String DEFAULT_ASSIGNEE_LIST_EXP = EXP_PREFIX + DEFAULT_ASSIGNEE_LIST;
-    public static final String ASSIGNEE_USER_EXP = EXP_PREFIX + ASSIGNEE_USER;
-    public static final String APPROVE_ID_EXP = EXP_PREFIX + "approveId" + EXP_SUFFIX;
-    public static final String DEFAULT_USER_TASK = "_default";
-    public static final String DEFAULT_USER_TASK_NAME = "提交申请";
-    public static final String USER_TASK_APPROVE_NAME = "审核人";
-    public static final String NR_OF_COMPLETED_INSTANCES = "nrOfCompletedInstances";
-    public static final String NR_OF_INSTANCES = "nrOfInstances";
-    public static final String REJECT_EXP = EXP_PREFIX + NR_OF_COMPLETED_INSTANCES + SystemConstant.ORG_SPLIT + NR_OF_INSTANCES + EXP_EQUAL + 1 + " || " + FlowApproveOperationEnum.REJECT.getId();
-    public static final String REJECT_EXP_SUFFIX = EXP_EQUAL + 1 + EXP_SUFFIX;
-}

+ 0 - 21
sop-business/src/main/java/com/qmth/sop/business/activiti/MultiWorkFlow.java

@@ -1,21 +0,0 @@
-package com.qmth.sop.business.activiti;
-
-import org.activiti.bpmn.model.UserTask;
-
-/**
- * @Description: 并行/串行业务
- * @Param:
- * @return:
- * @Author: wangliang
- * @Date: 2022/2/8
- */
-public interface MultiWorkFlow {
-
-    /**
-     * 创建并行/串行会签节点
-     *
-     * @param userTask
-     * @param sequential
-     */
-    UserTask createMultiInstanceLoopCharacteristics(UserTask userTask, boolean sequential);
-}

+ 115 - 0
sop-business/src/main/java/com/qmth/sop/business/activiti/ProcessEventRejectCmd.java

@@ -0,0 +1,115 @@
+package com.qmth.sop.business.activiti;
+
+import com.qmth.sop.common.contant.SpringContextHolder;
+import com.qmth.sop.common.contant.SystemConstant;
+import org.activiti.bpmn.model.BpmnModel;
+import org.activiti.bpmn.model.FlowNode;
+import org.activiti.engine.HistoryService;
+import org.activiti.engine.ManagementService;
+import org.activiti.engine.RepositoryService;
+import org.activiti.engine.history.HistoricTaskInstance;
+import org.activiti.engine.impl.history.HistoryManager;
+import org.activiti.engine.impl.interceptor.Command;
+import org.activiti.engine.impl.interceptor.CommandContext;
+import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
+import org.activiti.engine.impl.persistence.entity.TaskEntity;
+import org.activiti.engine.impl.persistence.entity.TaskEntityManager;
+import org.springframework.util.CollectionUtils;
+
+import java.util.*;
+
+/**
+ * @Description: 驳回任意节点
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2023/7/22
+ */
+public class ProcessEventRejectCmd implements Command {
+
+    /**
+     * 任务ID
+     */
+    private String taskId;
+
+    /**
+     * 目标任务节点key
+     */
+    private String destTaskKey;
+
+
+    private Map<String, Object> map = new HashMap<>();
+
+    /**
+     * @param taskId      任务ID
+     * @param destTaskKey 目标任务节点key
+     */
+    public ProcessEventRejectCmd(String taskId, String destTaskKey, Map<String, Object> map) {
+        this.taskId = taskId;
+        this.destTaskKey = destTaskKey;
+        this.map = map;
+    }
+
+    @Override
+    public Object execute(CommandContext commandContext) {
+        RepositoryService repositoryService = SpringContextHolder.getBean(RepositoryService.class);
+        HistoryService historyService = SpringContextHolder.getBean(HistoryService.class);
+        //获取任务实例管理类
+        TaskEntityManager taskEntityManager = commandContext.getTaskEntityManager();
+        //获取当前任务实例
+        TaskEntity currentTask = taskEntityManager.findById(taskId);
+
+        List<HistoricTaskInstance> historicTaskInstanceList = historyService.createHistoricTaskInstanceQuery()
+                .processInstanceId(currentTask.getProcessInstanceId()).orderByHistoricTaskInstanceEndTime().desc().list();
+
+        //获取当前节点的执行实例
+        List<String> rejectApproveIdList = new ArrayList<>();
+        if (!CollectionUtils.isEmpty(historicTaskInstanceList)) {
+            Integer index = null;
+            for (HistoricTaskInstance historicTaskInstance : historicTaskInstanceList) {
+                if (Objects.equals(historicTaskInstance.getTaskDefinitionKey(), destTaskKey)) {
+                    String formKey = historicTaskInstance.getFormKey();
+                    if (Objects.nonNull(formKey)) {
+                        index = Integer.valueOf(formKey.substring(formKey.indexOf(".") - 1, formKey.indexOf(".")));
+                    }
+                    rejectApproveIdList.add(historicTaskInstance.getAssignee());
+                }
+            }
+            map.put(SystemConstant.ASSIGNEE + index, rejectApproveIdList);
+            map.put(SystemConstant.DEFAULT_ASSIGNEE_LIST + index, rejectApproveIdList);
+        }
+        //获取当前节点的执行实例
+        ExecutionEntity execution = currentTask.getExecution();
+        execution.setVariables(map);
+
+        //获取流程定义id
+        String processDefinitionId = execution.getProcessDefinitionId();
+        //获取目标节点
+        BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
+        FlowNode flowElement = (FlowNode) bpmnModel.getMainProcess().getFlowElement(destTaskKey);
+
+        //获取历史管理
+        HistoryManager historyManager = commandContext.getHistoryManager();
+
+        //通知当前活动结束(更新act_hi_actinst)
+        historyManager.recordActivityEnd(execution, "jump to " + taskId);
+        //通知任务节点结束(更新act_hi_taskinst)
+        historyManager.recordTaskEnd(taskId, "jump to" + destTaskKey);
+        //删除正在执行的当前任务
+        taskEntityManager.delete(taskId);
+        //此时设置执行实例的当前活动节点为目标节点
+        execution.setCurrentFlowElement(flowElement);
+        //向operations中压入继续流程的操作类
+        commandContext.getAgenda().planContinueProcessOperation(execution);
+        return null;
+    }
+
+    /**
+     * 跳转任意节点
+     *
+     * @param managementService
+     */
+    public void jump(ManagementService managementService) {
+        managementService.executeCommand(this);
+    }
+}

+ 22 - 17
sop-business/src/main/java/com/qmth/sop/business/bean/FormPropertyBean.java

@@ -1,6 +1,8 @@
 package com.qmth.sop.business.bean;
 package com.qmth.sop.business.bean;
 
 
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.sop.business.bean.result.FlowTaskResult;
 import com.qmth.sop.business.bean.result.FlowTaskResult;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 
 
@@ -10,16 +12,19 @@ import java.io.Serializable;
 public class FormPropertyBean implements Serializable {
 public class FormPropertyBean implements Serializable {
 
 
     @ApiModelProperty(value = "流程id")
     @ApiModelProperty(value = "流程id")
-    String flowId;
+    @JsonSerialize(using = ToStringSerializer.class)
+    Long flowId;
 
 
     @ApiModelProperty(value = "sopid")
     @ApiModelProperty(value = "sopid")
     String sopId;
     String sopId;
 
 
     @ApiModelProperty(value = "流程任务id")
     @ApiModelProperty(value = "流程任务id")
-    String taskId;
+    @JsonSerialize(using = ToStringSerializer.class)
+    Long taskId;
 
 
     @ApiModelProperty(value = "用户id")
     @ApiModelProperty(value = "用户id")
-    String userId;
+    @JsonSerialize(using = ToStringSerializer.class)
+    Long userId;
 
 
     @ApiModelProperty(value = "动态表单")
     @ApiModelProperty(value = "动态表单")
     FlowTaskResult setupMap;
     FlowTaskResult setupMap;
@@ -28,13 +33,13 @@ public class FormPropertyBean implements Serializable {
 
 
     }
     }
 
 
-    public FormPropertyBean(String flowId, String taskId, FlowTaskResult setupMap) {
+    public FormPropertyBean(Long flowId, Long taskId, FlowTaskResult setupMap) {
         this.flowId = flowId;
         this.flowId = flowId;
         this.taskId = taskId;
         this.taskId = taskId;
         this.setupMap = setupMap;
         this.setupMap = setupMap;
     }
     }
 
 
-    public FormPropertyBean(String flowId, String taskId, String userId, FlowTaskResult setupMap) {
+    public FormPropertyBean(Long flowId, Long taskId, Long userId, FlowTaskResult setupMap) {
         this.flowId = flowId;
         this.flowId = flowId;
         this.taskId = taskId;
         this.taskId = taskId;
         this.userId = userId;
         this.userId = userId;
@@ -49,30 +54,30 @@ public class FormPropertyBean implements Serializable {
         this.sopId = sopId;
         this.sopId = sopId;
     }
     }
 
 
-    public String getUserId() {
-        return userId;
-    }
-
-    public void setUserId(String userId) {
-        this.userId = userId;
-    }
-
-    public String getFlowId() {
+    public Long getFlowId() {
         return flowId;
         return flowId;
     }
     }
 
 
-    public void setFlowId(String flowId) {
+    public void setFlowId(Long flowId) {
         this.flowId = flowId;
         this.flowId = flowId;
     }
     }
 
 
-    public String getTaskId() {
+    public Long getTaskId() {
         return taskId;
         return taskId;
     }
     }
 
 
-    public void setTaskId(String taskId) {
+    public void setTaskId(Long taskId) {
         this.taskId = taskId;
         this.taskId = taskId;
     }
     }
 
 
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
     public FlowTaskResult getSetupMap() {
     public FlowTaskResult getSetupMap() {
         return setupMap;
         return setupMap;
     }
     }

+ 2 - 5
sop-business/src/main/java/com/qmth/sop/business/entity/TFFlowLog.java

@@ -80,15 +80,12 @@ public class TFFlowLog extends BaseEntity implements Serializable {
 
 
     }
     }
 
 
-    public TFFlowLog(Long orgId, Long approveId, Long userId, FlowApproveOperationEnum approveOperation,
-                     Integer approveSetup, String approveRemark, Long flowId, Long taskId, Long objectId
-            , String pendApproveId) {
+    public TFFlowLog(Long orgId, Long approveId, Long userId,
+                     Integer approveSetup, Long flowId, Long taskId, Long objectId, String pendApproveId) {
         this.orgId = orgId;
         this.orgId = orgId;
         this.approveId = approveId;
         this.approveId = approveId;
         insertInfo(userId);
         insertInfo(userId);
-        this.approveOperation = approveOperation;
         this.approveSetup = approveSetup;
         this.approveSetup = approveSetup;
-        this.approveRemark = approveRemark;
         this.flowId = flowId;
         this.flowId = flowId;
         this.taskId = taskId;
         this.taskId = taskId;
         this.objectId = objectId;
         this.objectId = objectId;

+ 12 - 8
sop-common/src/main/java/com/qmth/sop/common/contant/SystemConstant.java

@@ -107,7 +107,6 @@ public class SystemConstant {
      */
      */
     public static LinkedMultiValueMap<String, String> FLOW_MAP = new LinkedMultiValueMap<>();
     public static LinkedMultiValueMap<String, String> FLOW_MAP = new LinkedMultiValueMap<>();
     public static final String BPMN_PREFIX = ".bpmn";
     public static final String BPMN_PREFIX = ".bpmn";
-    public static final String START_EVENT = "startEvent";
     public static final String END_EVENT = "endEvent";
     public static final String END_EVENT = "endEvent";
     public static final String USER_TASK = "userTask";
     public static final String USER_TASK = "userTask";
     public static final String NAME = "name";
     public static final String NAME = "name";
@@ -115,15 +114,20 @@ public class SystemConstant {
     public static final String FORM_KEY = "formKey";
     public static final String FORM_KEY = "formKey";
     public static final String FLOW_FORM_ID_SPACE = "|";
     public static final String FLOW_FORM_ID_SPACE = "|";
     public static final Integer END_TEMP_ID = 100000000;
     public static final Integer END_TEMP_ID = 100000000;
-    public static final String FLOW_ID = "flowId";
-    public static final String TASK_ID = "taskId";
     public static final String FORM_PROPERTIES = "formProperties";
     public static final String FORM_PROPERTIES = "formProperties";
-    public static final String SETUP = "setup";
     public static final String FLOW_DEPLOYMENT_ID = "flowDeploymentId";
     public static final String FLOW_DEPLOYMENT_ID = "flowDeploymentId";
-    public static final String APPROVE_ID = "approveId";
-    public static final String APPROVE = "approve";//流程审核变量
-    public static final String SETUP_MAP = "setupMap";//流程步骤变量
-    public static final String APPROVE_USER_IDS = "approveUserIds";//流程审批人列表
+//    public static final String APPROVE = "approve";//流程审核变量
+    public static final String DEFAULT_ASSIGNEE_LIST = "assigneeList";
+    public static final String ASSIGNEE = "assignee";
+    public static final String NR_OF_COMPLETED_INSTANCES = "nrOfCompletedInstances";
+    public static final String NR_OF_INSTANCES = "nrOfInstances";
+
+    /**
+     * 锁
+     */
+    public static final String LOCK_FLOW_TASK_PREFIX = "lock:flow:task:";//流程节点锁
+
+    public static final Long LOCK_FLOW_TASK_TIME_OUT = 60L * 2 * 1000;
 
 
     /**
     /**
      * 获取数据库uuid
      * 获取数据库uuid

+ 3 - 3
sop-common/src/main/java/com/qmth/sop/common/lock/MemoryLock.java

@@ -25,16 +25,16 @@ public class MemoryLock {
      * @param timeout
      * @param timeout
      * @return
      * @return
      */
      */
-    public boolean lock(String key, Object value, int timeout) {
+    public boolean lock(String key, Object value, Long timeout) {
         if (Objects.isNull(stringCache.get(key))) {
         if (Objects.isNull(stringCache.get(key))) {
             stringCache.put(key, value);
             stringCache.put(key, value);
-            timeCache.put(key, System.currentTimeMillis() + Long.valueOf(timeout + ""));
+            timeCache.put(key, System.currentTimeMillis() + timeout);
             return true;
             return true;
         } else {
         } else {
             if (timeCache.get(key).longValue() < System.currentTimeMillis()) {
             if (timeCache.get(key).longValue() < System.currentTimeMillis()) {
                 //锁已经过期
                 //锁已经过期
                 stringCache.put(key, value);
                 stringCache.put(key, value);
-                timeCache.put(key, System.currentTimeMillis() + Long.valueOf(timeout + ""));
+                timeCache.put(key, System.currentTimeMillis() + timeout);
                 return true;
                 return true;
             } else {
             } else {
                 return false;
                 return false;

+ 294 - 212
sop-server/src/main/java/com/qmth/sop/server/api/ActivitiFromHtmlController.java

@@ -1,11 +1,10 @@
 package com.qmth.sop.server.api;
 package com.qmth.sop.server.api;
 
 
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.qmth.sop.business.activiti.DefaultInstanceConvertToMultiInstance;
+import com.qmth.boot.api.exception.ApiException;
+import com.qmth.sop.business.activiti.ProcessEventRejectCmd;
 import com.qmth.sop.business.bean.FormPropertyBean;
 import com.qmth.sop.business.bean.FormPropertyBean;
-import com.qmth.sop.business.bean.result.FlowFormWidgetResult;
 import com.qmth.sop.business.bean.result.FlowResult;
 import com.qmth.sop.business.bean.result.FlowResult;
 import com.qmth.sop.business.bean.result.FlowTaskResult;
 import com.qmth.sop.business.bean.result.FlowTaskResult;
 import com.qmth.sop.business.entity.TFCustomFlow;
 import com.qmth.sop.business.entity.TFCustomFlow;
@@ -15,8 +14,11 @@ import com.qmth.sop.business.entity.TFFlowLog;
 import com.qmth.sop.business.service.*;
 import com.qmth.sop.business.service.*;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.*;
 import com.qmth.sop.common.enums.*;
+import com.qmth.sop.common.lock.MemoryLock;
 import com.qmth.sop.common.util.GsonUtil;
 import com.qmth.sop.common.util.GsonUtil;
 import com.qmth.sop.common.util.JacksonUtil;
 import com.qmth.sop.common.util.JacksonUtil;
+import com.qmth.sop.common.util.Result;
+import com.qmth.sop.common.util.ResultUtil;
 import io.swagger.annotations.*;
 import io.swagger.annotations.*;
 import org.activiti.bpmn.model.BpmnModel;
 import org.activiti.bpmn.model.BpmnModel;
 import org.activiti.bpmn.model.FlowNode;
 import org.activiti.bpmn.model.FlowNode;
@@ -25,6 +27,7 @@ import org.activiti.engine.FormService;
 import org.activiti.engine.RepositoryService;
 import org.activiti.engine.RepositoryService;
 import org.activiti.engine.RuntimeService;
 import org.activiti.engine.RuntimeService;
 import org.activiti.engine.TaskService;
 import org.activiti.engine.TaskService;
+import org.activiti.engine.impl.TaskServiceImpl;
 import org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior;
 import org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior;
 import org.activiti.engine.repository.DeploymentBuilder;
 import org.activiti.engine.repository.DeploymentBuilder;
 import org.activiti.engine.runtime.ProcessInstance;
 import org.activiti.engine.runtime.ProcessInstance;
@@ -38,7 +41,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
@@ -49,7 +51,7 @@ import java.util.zip.ZipInputStream;
 
 
 @Api(tags = "测试流程表单htmlController")
 @Api(tags = "测试流程表单htmlController")
 @RestController
 @RestController
-@RequestMapping("/activiti/form/html")
+@RequestMapping("/flow")
 public class ActivitiFromHtmlController {
 public class ActivitiFromHtmlController {
     private final static Logger log = LoggerFactory.getLogger(ActivitiFromHtmlController.class);
     private final static Logger log = LoggerFactory.getLogger(ActivitiFromHtmlController.class);
 
 
@@ -80,114 +82,83 @@ public class ActivitiFromHtmlController {
     @Resource
     @Resource
     TFFlowLogService tfFlowLogService;
     TFFlowLogService tfFlowLogService;
 
 
-    /**
-     * 注册流程
-     *
-     * @return
-     */
+    @Resource
+    MemoryLock memoryLock;
+
     @ApiOperation(value = "创建流程接口")
     @ApiOperation(value = "创建流程接口")
     @RequestMapping(value = "/createDeployment", method = RequestMethod.POST)
     @RequestMapping(value = "/createDeployment", method = RequestMethod.POST)
     @Transactional
     @Transactional
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
-    public Map<String, Object> createDeployment() throws IOException {
+    public Result createDeployment() throws IOException {
         DeploymentBuilder builder = repositoryService.createDeployment();
         DeploymentBuilder builder = repositoryService.createDeployment();
         ClassPathResource resource = new ClassPathResource("testform1.zip");
         ClassPathResource resource = new ClassPathResource("testform1.zip");
         ZipInputStream zip = new ZipInputStream(resource.getInputStream());
         ZipInputStream zip = new ZipInputStream(resource.getInputStream());
         builder.addZipInputStream(zip);
         builder.addZipInputStream(zip);
-        return flowStart(builder.deploy().getId(), null, null);
+        return formPropertiesGet(builder.deploy().getId(), null);
     }
     }
 
 
     @ApiOperation(value = "获取流程部署信息")
     @ApiOperation(value = "获取流程部署信息")
-    @RequestMapping(value = "/flow/deployment/data", method = RequestMethod.POST)
+    @RequestMapping(value = "/deployment/data", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
-    public Map<String, Object> getFlowData() {
-        return Collections.singletonMap("data", tfCustomFlowService.findFlowDeploymentList());
+    public Result getDeploymentData() {
+        return ResultUtil.ok(tfCustomFlowService.findFlowDeploymentList());
     }
     }
 
 
     @ApiOperation(value = "获取流程表单属性接口")
     @ApiOperation(value = "获取流程表单属性接口")
-    @RequestMapping(value = "/flow/formPropertie/get", method = RequestMethod.POST)
+    @RequestMapping(value = "/form_properties/get", method = RequestMethod.POST)
     @Transactional
     @Transactional
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
-    public Map<String, Object> flowStart(@ApiParam(value = "流程部署id") @RequestParam(required = false) String flowDeploymentId,
-                                         @ApiParam(value = "流程id") @RequestParam(required = false) Long flowId,
-                                         @ApiParam(value = "流程任务id") @RequestParam(required = false) Long taskId) {
+    public Result formPropertiesGet(@ApiParam(value = "流程部署id") @RequestParam(required = false) String flowDeploymentId,
+                                    @ApiParam(value = "流程任务id") @RequestParam(required = false) Long taskId) {
         Map<String, Object> map = new HashMap<>();
         Map<String, Object> map = new HashMap<>();
         FlowResult flowResult = null;
         FlowResult flowResult = null;
         TFCustomFlow tfCustomFlow = null;
         TFCustomFlow tfCustomFlow = null;
         if (Objects.nonNull(flowDeploymentId)) {
         if (Objects.nonNull(flowDeploymentId)) {
-            String processDefinitionId = null;
             tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getFlowDeploymentId, flowDeploymentId));
             tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getFlowDeploymentId, flowDeploymentId));
-            Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
+            Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
             if (Objects.isNull(tfCustomFlow.getFlowDefinitionId())) {
             if (Objects.isNull(tfCustomFlow.getFlowDefinitionId())) {
-                processDefinitionId = activitiConsumerService.findProcessDefinitionIdByDeploymentId(flowDeploymentId);
+                String processDefinitionId = activitiConsumerService.findProcessDefinitionIdByDeploymentId(flowDeploymentId);
                 tfCustomFlow.setFlowDefinitionId(processDefinitionId);
                 tfCustomFlow.setFlowDefinitionId(processDefinitionId);
                 tfCustomFlowService.updateById(tfCustomFlow);
                 tfCustomFlowService.updateById(tfCustomFlow);
-            } else {
-                processDefinitionId = tfCustomFlow.getFlowDefinitionId();
             }
             }
             flowResult = JSONObject.parseObject(tfCustomFlow.getFlowProcessVar(), FlowResult.class);
             flowResult = JSONObject.parseObject(tfCustomFlow.getFlowProcessVar(), FlowResult.class);
             map = this.getFlowFormPropertie(flowResult, map, 1);
             map = this.getFlowFormPropertie(flowResult, map, 1);
         } else {
         } else {
-            List<Task> taskList = null;
-            if (Objects.nonNull(flowId) && !Objects.equals(flowId, "")) {
-                taskList = taskService.createTaskQuery().processInstanceId(String.valueOf(flowId)).list();
-            } else if (Objects.nonNull(taskId) && !Objects.equals(taskId, "")) {
-                taskList = taskService.createTaskQuery().taskId(String.valueOf(taskId)).list();
+            List<Task> taskList = taskService.createTaskQuery().taskId(String.valueOf(taskId)).list();
+            if (CollectionUtils.isEmpty(taskList)) {
+                throw ExceptionResultEnum.ERROR.exception("流程任务数据为空!");
             }
             }
-            if (!CollectionUtils.isEmpty(taskList)) {
-                if (Objects.isNull(flowId)) {
-                    flowId = Long.parseLong(taskList.get(0).getProcessInstanceId());
-                }
-                TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, flowId));
-                Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有实例数据!"));
-                tfCustomFlow = tfCustomFlowService.getById(tfCustomFlowEntity.gettFCustomFlowId());
-                Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
+            Long flowId = Long.parseLong(taskList.get(0).getProcessInstanceId());
+            TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, flowId));
+            Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有实例数据!"));
+            tfCustomFlow = tfCustomFlowService.getById(tfCustomFlowEntity.gettFCustomFlowId());
+            Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
 
 
-                flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
-                LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
-                for (Task task : taskList) {
-                    FlowTaskResult currFlowTaskResult = GsonUtil.fromJson(GsonUtil.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
-                    map = this.getFlowFormPropertie(flowResult, map, currFlowTaskResult.getSetup());
-                    break;
-                }
+            flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
+            LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
+            for (Task task : taskList) {
+                FlowTaskResult currFlowTaskResult = GsonUtil.fromJson(GsonUtil.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
+                map = this.getFlowFormPropertie(flowResult, map, currFlowTaskResult.getSetup());
+                break;
             }
             }
         }
         }
         map.put(SystemConstant.FLOW_DEPLOYMENT_ID, tfCustomFlow.getFlowDeploymentId());
         map.put(SystemConstant.FLOW_DEPLOYMENT_ID, tfCustomFlow.getFlowDeploymentId());
         map.put(SystemConstant.ID, tfCustomFlow.getId());
         map.put(SystemConstant.ID, tfCustomFlow.getId());
-        return map;
+        return ResultUtil.ok(map);
     }
     }
 
 
-    /**
-     * 获取表单属性
-     *
-     * @param flowResult
-     * @param map
-     * @param setup
-     * @return
-     */
-    public Map<String, Object> getFlowFormPropertie(FlowResult flowResult, Map<String, Object> map, int setup) {
-        Map<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
-        for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
-            FlowTaskResult flowTaskResultTemp = GsonUtil.fromJson(GsonUtil.toJson(entry.getValue()), FlowTaskResult.class);
-            if (flowTaskResultTemp.getSetup().intValue() == setup) {
-                map.put(SystemConstant.FORM_PROPERTIES, flowTaskResultTemp);
-                break;
-            }
-        }
-        return map;
-    }
-
-    @ApiOperation(value = "启动流程接口")
-    @RequestMapping(value = "/start/flow", method = RequestMethod.POST)
+    @ApiOperation(value = "流程审批接口")
+    @RequestMapping(value = "/approve", method = RequestMethod.POST)
     @Transactional
     @Transactional
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
-    public Map<String, Object> startFlow(@ApiParam(value = "流程部署id", required = true) @RequestParam String flowDeploymentId,
-                                         @ApiParam(value = "流程操作", required = true) @RequestParam FlowApprovePassEnum approve,
-                                         @ApiParam(value = "流程id") @RequestParam(required = false) Long flowId,
-                                         @ApiParam(value = "流程表单数据") @RequestParam(required = false) String formProperties,
-                                         @ApiParam(value = "流程审批人") @RequestParam(required = false) List<Long> approveUserIds,
-                                         @ApiParam(value = "上传文件") @RequestParam(required = false) MultipartFile file,
-                                         HttpServletRequest request) {
+    public Result approve(@ApiParam(value = "流程部署id") @RequestParam(required = false) String flowDeploymentId,
+                          @ApiParam(value = "流程操作", required = true) @RequestParam FlowApprovePassEnum approve,
+                          @ApiParam(value = "流程任务id") @RequestParam(required = false) Long taskId,
+                          @ApiParam(value = "流程表单数据") @RequestParam(required = false) String formProperties,
+                          @ApiParam(value = "流程审批人") @RequestParam(required = false) List<Long> approveUserIds,
+                          @ApiParam(value = "流程审批意见") @RequestParam(required = false) String approveRemark,
+//                                         @ApiParam(value = "上传文件") @RequestParam(required = false) MultipartFile file,
+                          HttpServletRequest request) {
         Map<String, Object> map = new HashMap<>();
         Map<String, Object> map = new HashMap<>();
         Map<String, String> formDataMap = new HashMap<>();
         Map<String, String> formDataMap = new HashMap<>();
         Map<String, String[]> parameterMap = request.getParameterMap();
         Map<String, String[]> parameterMap = request.getParameterMap();
@@ -199,102 +170,246 @@ public class ActivitiFromHtmlController {
         }
         }
         map.putAll(formDataMap);
         map.putAll(formDataMap);
 
 
-        List<String> approveIdList = approveUserIds.stream().map(s -> String.valueOf(s)).collect(Collectors.toList());
-        TFCustomFlow tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getFlowDeploymentId, flowDeploymentId));
-        Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
+        List<String> approveIdList = null;
+        if (!CollectionUtils.isEmpty(approveUserIds)) {
+            approveIdList = approveUserIds.stream().map(s -> String.valueOf(s)).collect(Collectors.toList());
+        } else {
+            approveIdList.add("123");//否则是当前登录用户
+        }
         String processFlowId = null;
         String processFlowId = null;
         TFCustomFlowEntity tfCustomFlowEntity = null;
         TFCustomFlowEntity tfCustomFlowEntity = null;
         TFFlowApprove tfFlowApprove = null;
         TFFlowApprove tfFlowApprove = null;
-        if (Objects.isNull(flowId)) {
-            map.put(DefaultInstanceConvertToMultiInstance.DEFAULT_ASSIGNEE_LIST + 1, approveIdList);
+        Task taskTemp = null;
+        FlowResult flowResult = null;
+        if (Objects.nonNull(flowDeploymentId) && Objects.isNull(taskId)) {
+            TFCustomFlow tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getFlowDeploymentId, flowDeploymentId));
+            Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
+
+            map.put(SystemConstant.DEFAULT_ASSIGNEE_LIST + 1, approveIdList);
             ProcessInstance processInstance = runtimeService.startProcessInstanceById(tfCustomFlow.getFlowDefinitionId(), map);
             ProcessInstance processInstance = runtimeService.startProcessInstanceById(tfCustomFlow.getFlowDefinitionId(), map);
             processFlowId = processInstance.getId();
             processFlowId = processInstance.getId();
             tfCustomFlowEntity = new TFCustomFlowEntity(tfCustomFlow.getId(), null);
             tfCustomFlowEntity = new TFCustomFlowEntity(tfCustomFlow.getId(), null);
             tfFlowApprove = new TFFlowApprove(null, Long.parseLong(approveIdList.get(approveIdList.size() - 1)), FlowStatusEnum.valueOf(approve.name()), null);
             tfFlowApprove = new TFFlowApprove(null, Long.parseLong(approveIdList.get(approveIdList.size() - 1)), FlowStatusEnum.valueOf(approve.name()), null);
-        } else {
-            processFlowId = String.valueOf(flowId);
-            tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, flowId));
-            tfFlowApprove = tfFlowApproveService.getOne(new QueryWrapper<TFFlowApprove>().lambda().eq(TFFlowApprove::getFlowId, flowId));
+            flowResult = JSONObject.parseObject(tfCustomFlow.getFlowProcessVar(), FlowResult.class);
+        } else if (Objects.nonNull(taskId)) {
+            taskTemp = taskService.createTaskQuery().taskId(String.valueOf(taskId)).singleResult();
+            Optional.ofNullable(taskTemp).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程任务数据为空!"));
+            processFlowId = taskTemp.getProcessInstanceId();
         }
         }
-        Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有实例数据!"));
-        Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有审批数据!"));
 
 
-        List<TFFlowLog> tfFlowLogList = new ArrayList<>();
-        FlowResult flowResult = null;
-        if (Objects.nonNull(tfCustomFlowEntity.getFlowProcessVar())) {
-            flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
-        } else {
-            flowResult = JSONObject.parseObject(tfCustomFlow.getFlowProcessVar(), FlowResult.class);
+        boolean lock = memoryLock.lock(SystemConstant.LOCK_FLOW_TASK_PREFIX + processFlowId, processFlowId, SystemConstant.LOCK_FLOW_TASK_TIME_OUT);
+        if (!lock) {
+            throw ExceptionResultEnum.ERROR.exception("正在审批中,请稍候再试!");
         }
         }
-        LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
+        try {
+            List<Task> taskList = new ArrayList<>();
+            if (Objects.isNull(taskTemp)) {
+                taskList = taskService.createTaskQuery().processInstanceId(processFlowId).list();
+            } else {
+                tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, Long.parseLong(processFlowId)));
+                Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有实例数据!"));
+                flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
 
 
-        tfCustomFlowEntity.setFlowId(Long.parseLong(processFlowId));
-        tfFlowApprove.setFlowId(Long.parseLong(processFlowId));
-        tfFlowApprove.setApproveMaxSetup(setupMap.size());
-        List<Task> taskList = taskService.createTaskQuery().processInstanceId(processFlowId).list();
-        if (!CollectionUtils.isEmpty(taskList)) {
+                tfFlowApprove = tfFlowApproveService.getOne(new QueryWrapper<TFFlowApprove>().lambda().eq(TFFlowApprove::getFlowId, Long.parseLong(processFlowId)));
+                Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有审批数据!"));
+                taskList.add(taskTemp);
+            }
+            List<TFFlowLog> tfFlowLogList = new ArrayList<>();
+            LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
+
+            tfCustomFlowEntity.setFlowId(Long.parseLong(processFlowId));
+            tfFlowApprove.setFlowId(Long.parseLong(processFlowId));
+            tfFlowApprove.setApproveMaxSetup(setupMap.size());
             for (Task task : taskList) {
             for (Task task : taskList) {
-                String currActivityId = task.getTaskDefinitionKey();
                 BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
                 BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
-                FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(currActivityId);
-                FlowTaskResult currFlowTaskResult = null, nextFlowTaskResult = null;
+                FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(task.getTaskDefinitionKey());
+                FlowTaskResult currFlowTaskResult = null, nextFlowTaskResult = null, formDataFlowTaskResult = null;
                 Integer nrOfCompletedInstances = null, nrOfInstances = null;
                 Integer nrOfCompletedInstances = null, nrOfInstances = null;
                 boolean multiInstance = false;
                 boolean multiInstance = false;
                 if (currFlow instanceof UserTask) {
                 if (currFlow instanceof UserTask) {
                     if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {
                     if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {
-                        nrOfCompletedInstances = (Integer) taskService.getVariable(task.getId(), DefaultInstanceConvertToMultiInstance.NR_OF_COMPLETED_INSTANCES);
+                        nrOfCompletedInstances = (Integer) taskService.getVariable(task.getId(), SystemConstant.NR_OF_COMPLETED_INSTANCES);
                         nrOfCompletedInstances++;
                         nrOfCompletedInstances++;
-                        nrOfInstances = (Integer) taskService.getVariable(task.getId(), DefaultInstanceConvertToMultiInstance.NR_OF_INSTANCES);
+                        nrOfInstances = (Integer) taskService.getVariable(task.getId(), SystemConstant.NR_OF_INSTANCES);
                         multiInstance = true;
                         multiInstance = true;
                     }
                     }
-                    if (Objects.isNull(formProperties)) {
-                        currFlowTaskResult = GsonUtil.fromJson(GsonUtil.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
-                    } else {
-                        currFlowTaskResult = JSONObject.parseObject(formProperties, FlowTaskResult.class);
+                    currFlowTaskResult = GsonUtil.fromJson(GsonUtil.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
+                    if (Objects.nonNull(formProperties)) {
+                        formDataFlowTaskResult = JSONObject.parseObject(formProperties, FlowTaskResult.class);
                     }
                     }
                     int currSetup = currFlowTaskResult.getSetup().intValue();
                     int currSetup = currFlowTaskResult.getSetup().intValue();
-                    currSetup = currSetup == setupMap.size() - 1 ? 0 : currSetup + 1;
-
+                    if (currSetup != 1 && approve == FlowApprovePassEnum.START) {
+                        throw ExceptionResultEnum.ERROR.exception("只有流程第一步才需要提交!");
+                    }
                     //流程流水日志
                     //流程流水日志
                     TFFlowLog tfFlowLog = new TFFlowLog(null, Long.parseLong(task.getAssignee()), null,
                     TFFlowLog tfFlowLog = new TFFlowLog(null, Long.parseLong(task.getAssignee()), null,
-                            FlowApproveOperationEnum.valueOf(approve.name()), currFlowTaskResult.getSetup(),
-                            FlowApproveSetupEnum.START.getTitle(), Long.parseLong(processFlowId),
+                            currFlowTaskResult.getSetup(), Long.parseLong(processFlowId),
                             Long.parseLong(task.getId()), tfCustomFlowEntity.getId(), approveIdList.toString().replaceAll("\\[", "").replaceAll("\\]", ""));
                             Long.parseLong(task.getId()), tfCustomFlowEntity.getId(), approveIdList.toString().replaceAll("\\[", "").replaceAll("\\]", ""));
+                    if (approve == FlowApprovePassEnum.PASS || approve == FlowApprovePassEnum.DRAFT || approve == FlowApprovePassEnum.START) {
+                        currSetup = currSetup == setupMap.size() - 1 ? 0 : currSetup + 1;
+                        nextFlowTaskResult = this.getNextFlowTaskResult(nrOfCompletedInstances,
+                                nrOfInstances,
+                                currFlowTaskResult,
+                                nextFlowTaskResult,
+                                currSetup,
+                                setupMap,
+                                approve);
 
 
-                    nextFlowTaskResult = this.getNextFlowTaskResult(nrOfCompletedInstances,
-                            nrOfInstances,
-                            currFlowTaskResult,
-                            nextFlowTaskResult,
-                            currSetup,
-                            setupMap,
-                            approve);
-
-                    this.approvePass(currFlowTaskResult,
-                            setupMap,
-                            multiInstance,
-                            nrOfCompletedInstances,
-                            nrOfInstances,
-                            tfFlowApprove,
-                            tfFlowLog,
-                            nextFlowTaskResult,
-                            map,
-                            approve);
-
-                    map.put(DefaultInstanceConvertToMultiInstance.DEFAULT_ASSIGNEE_LIST + nextFlowTaskResult.getSetup(), approveIdList);
-                    setupMap.put(task.getTaskDefinitionKey(), currFlowTaskResult);
+                        this.approvePass(currFlowTaskResult,
+                                setupMap,
+                                multiInstance,
+                                nrOfCompletedInstances,
+                                nrOfInstances,
+                                tfFlowApprove,
+                                tfFlowLog,
+                                nextFlowTaskResult,
+                                map,
+                                approve,
+                                approveRemark);
+                        map.put(SystemConstant.DEFAULT_ASSIGNEE_LIST + nextFlowTaskResult.getSetup(), approveIdList);
+                    } else if (approve == FlowApprovePassEnum.REJECT || approve == FlowApprovePassEnum.CANCEL) {
+                        currSetup = currSetup - 1;
+                        nextFlowTaskResult = this.getNextFlowTaskResult(nrOfCompletedInstances,
+                                nrOfInstances,
+                                currFlowTaskResult,
+                                nextFlowTaskResult,
+                                currSetup,
+                                setupMap,
+                                approve);
+
+                        this.approveReject(multiInstance,
+                                map,
+                                currFlowTaskResult,
+                                nextFlowTaskResult,
+                                tfFlowApprove,
+                                tfFlowLog,
+                                approve,
+                                approveRemark);
+                    }
+                    if (Objects.nonNull(formDataFlowTaskResult) && Objects.equals(task.getTaskDefinitionKey(), formDataFlowTaskResult.getTaskKey())) {
+                        setupMap.put(task.getTaskDefinitionKey(), formDataFlowTaskResult);
+                    }
                     flowResult.setSetupMap(setupMap);
                     flowResult.setSetupMap(setupMap);
                     tfCustomFlowEntity.setFlowProcessVar(JacksonUtil.parseJson(flowResult));
                     tfCustomFlowEntity.setFlowProcessVar(JacksonUtil.parseJson(flowResult));
-                    if (approve == FlowApprovePassEnum.START) {
+                    if (approve != FlowApprovePassEnum.DRAFT && approve != FlowApprovePassEnum.REJECT) {
                         taskService.complete(task.getId(), map);
                         taskService.complete(task.getId(), map);
+                    } else if (approve == FlowApprovePassEnum.REJECT) {
+                        ((TaskServiceImpl) taskService).getCommandExecutor().execute(new ProcessEventRejectCmd(task.getId(), nextFlowTaskResult.getTaskKey(), map));
+                        if (Objects.nonNull(map.get(SystemConstant.DEFAULT_ASSIGNEE_LIST + nextFlowTaskResult.getSetup()))) {
+                            List<String> rejectApproveIdList = (List<String>) map.get(SystemConstant.DEFAULT_ASSIGNEE_LIST + nextFlowTaskResult.getSetup());
+                            tfFlowLog.setPendApproveId(rejectApproveIdList.toString().replaceAll("\\[", "").replaceAll("\\]", ""));
+                        }
                     }
                     }
                     tfFlowLogList.add(tfFlowLog);
                     tfFlowLogList.add(tfFlowLog);
                 }
                 }
             }
             }
+            tfCustomFlowEntityService.saveOrUpdate(tfCustomFlowEntity);
+            tfFlowApproveService.saveOrUpdate(tfFlowApprove);
+            tfFlowLogService.saveBatch(tfFlowLogList);
+        } catch (Exception e) {
+            log.error(SystemConstant.LOG_ERROR, e);
+            if (e instanceof ApiException) {
+                ResultUtil.error((ApiException) e, e.getMessage());
+            } else {
+                ResultUtil.error(e.getMessage());
+            }
+        } finally {
+            memoryLock.unlock(SystemConstant.LOCK_FLOW_TASK_PREFIX + processFlowId);
         }
         }
-        tfCustomFlowEntityService.saveOrUpdate(tfCustomFlowEntity);
-        tfFlowApproveService.saveOrUpdate(tfFlowApprove);
-        tfFlowLogService.saveBatch(tfFlowLogList);
-        return Collections.singletonMap("success", true);
+        return ResultUtil.ok(true);
+    }
+
+    @ApiOperation(value = "获取待办接口")
+    @RequestMapping(value = "/getTaskList", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result getTaskList(@ApiParam(value = "用户id", required = true) @RequestParam Long userId) {
+        Map<String, Object> map = new HashMap<>();
+        List<FormPropertyBean> formPropertyList = new LinkedList<>();
+        List<Task> taskList = taskService.createTaskQuery().taskAssignee(String.valueOf(userId)).list();
+        if (!CollectionUtils.isEmpty(taskList)) {
+            for (Task t : taskList) {
+                TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, Long.parseLong(t.getProcessInstanceId())));
+                Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有实例数据!"));
+                TFCustomFlow tfCustomFlow = tfCustomFlowService.getById(tfCustomFlowEntity.gettFCustomFlowId());
+                Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
+
+                FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
+                LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
+                for (Task task : taskList) {
+                    FlowTaskResult currFlowTaskResult = GsonUtil.fromJson(GsonUtil.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
+                    map = this.getFlowFormPropertie(flowResult, map, currFlowTaskResult.getSetup());
+                    break;
+                }
+                formPropertyList.add(new FormPropertyBean(Long.parseLong(t.getProcessInstanceId()), Long.parseLong(t.getId()), userId, (FlowTaskResult) map.get(SystemConstant.FORM_PROPERTIES)));
+            }
+        }
+        return ResultUtil.ok(formPropertyList);
+    }
+
+//    @ApiOperation(value = "流程提交接口")
+//    @RequestMapping(value = "/complete", method = RequestMethod.POST)
+//    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+//    public Map<String, Object> complete(@ApiParam(value = "流程taskId", required = true) @RequestParam String taskId,
+//                                        @ApiParam(value = "上传文件") @RequestParam(required = false) MultipartFile[] files, HttpServletRequest
+//                                                request) {
+//        Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
+//        Map<String, Object> varMap = new HashMap<>();
+//        Map<String, String> formDataMap = new HashMap<>();
+//        Map<String, String[]> parameterMap = request.getParameterMap();
+//        Set<Map.Entry<String, String[]>> entrySet = parameterMap.entrySet();
+//        for (Map.Entry<String, String[]> entry : entrySet) {
+//            String key = entry.getKey();
+//            String[] value = entry.getValue();
+//            formDataMap.put(key, value[0]);
+//        }
+//        varMap.putAll(formDataMap);
+//        String flowTaskId = task.getId();
+//        String processInstanceId = task.getProcessInstanceId();
+//        String processDefinitionId = task.getProcessDefinitionId();
+//        formService.submitTaskFormData(flowTaskId, formDataMap);
+//        List<Task> taskList = taskService.createTaskQuery().processInstanceId(processInstanceId).list();
+//        if (!CollectionUtils.isEmpty(taskList)) {
+//            List<FormPropertyBean> formPropertyList = new LinkedList<>();
+//            for (Task t : taskList) {
+//                String nextFlowTaskId = t.getId();
+//                Object o = formService.getRenderedTaskForm(nextFlowTaskId);
+//                log.info("userId:{},taskId:{},flowId:{},processDefinitionId:{}", t.getAssignee(), nextFlowTaskId, processInstanceId, processDefinitionId);
+//                if (Objects.nonNull(o)) {
+//                    log.info("task formProperties:{}", JacksonUtil.parseJson(o));
+//                    List<FlowFormWidgetResult> list = JSONArray.parseArray(o.toString(), FlowFormWidgetResult.class);
+//                    formPropertyList.add(new FormPropertyBean(processInstanceId, flowTaskId, t.getAssignee(), null));
+//                }
+//                varMap.put("formProperties", formPropertyList);
+//            }
+//        }
+//        return varMap;
+//    }
+
+    @ApiOperation(value = "结束流程接口")
+    @RequestMapping(value = "/delete", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result delete(String runId) {
+        return ResultUtil.ok(activitiConsumerService.deleteProcessInstance(runId));
+    }
+
+    /**
+     * 获取表单属性
+     *
+     * @param flowResult
+     * @param map
+     * @param setup
+     * @return
+     */
+    public Map<String, Object> getFlowFormPropertie(FlowResult flowResult, Map<String, Object> map, int setup) {
+        Map<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
+        for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
+            FlowTaskResult flowTaskResultTemp = GsonUtil.fromJson(GsonUtil.toJson(entry.getValue()), FlowTaskResult.class);
+            if (flowTaskResultTemp.getSetup().intValue() == setup) {
+                map.put(SystemConstant.FORM_PROPERTIES, flowTaskResultTemp);
+                break;
+            }
+        }
+        return map;
     }
     }
 
 
     /**
     /**
@@ -310,6 +425,7 @@ public class ActivitiFromHtmlController {
      * @param nextFlowTaskResult
      * @param nextFlowTaskResult
      * @param map
      * @param map
      * @param approvePass
      * @param approvePass
+     * @param approveRemark
      */
      */
     public void approvePass(FlowTaskResult currFlowTaskResult,
     public void approvePass(FlowTaskResult currFlowTaskResult,
                             Map<String, FlowTaskResult> setupMap,
                             Map<String, FlowTaskResult> setupMap,
@@ -320,7 +436,8 @@ public class ActivitiFromHtmlController {
                             TFFlowLog tfFlowLog,
                             TFFlowLog tfFlowLog,
                             FlowTaskResult nextFlowTaskResult,
                             FlowTaskResult nextFlowTaskResult,
                             Map<String, Object> map,
                             Map<String, Object> map,
-                            FlowApprovePassEnum approvePass) {
+                            FlowApprovePassEnum approvePass,
+                            String approveRemark) {
         if (multiInstance) {
         if (multiInstance) {
             map.computeIfAbsent(FlowApproveOperationEnum.REJECT.getId() + currFlowTaskResult.getSetup(), v -> 0);
             map.computeIfAbsent(FlowApproveOperationEnum.REJECT.getId() + currFlowTaskResult.getSetup(), v -> 0);
         }
         }
@@ -352,7 +469,46 @@ public class ActivitiFromHtmlController {
         } else {
         } else {
             tfFlowLog.setApproveOperation(FlowApproveOperationEnum.APPROVE);
             tfFlowLog.setApproveOperation(FlowApproveOperationEnum.APPROVE);
         }
         }
-        map.put(SystemConstant.APPROVE, nextFlowTaskResult.getTaskKey());
+        if (Objects.nonNull(approveRemark)) {
+            tfFlowLog.setApproveRemark(approveRemark);
+        } else {
+            tfFlowLog.setApproveRemark(tfFlowLog.getApproveOperation().getTitle());
+        }
+//        map.put(SystemConstant.APPROVE, nextFlowTaskResult.getTaskKey());
+    }
+
+    /**
+     * 审批驳回
+     *
+     * @param multiInstance
+     * @param map
+     * @param currFlowTaskResult
+     * @param nextFlowTaskResult
+     * @param tfFlowApprove
+     * @param tfFlowLog
+     * @param approvePass
+     * @param approveRemark
+     */
+    protected void approveReject(boolean multiInstance,
+                                 Map<String, Object> map,
+                                 FlowTaskResult currFlowTaskResult,
+                                 FlowTaskResult nextFlowTaskResult,
+                                 TFFlowApprove tfFlowApprove,
+                                 TFFlowLog tfFlowLog,
+                                 FlowApprovePassEnum approvePass,
+                                 String approveRemark) {
+        if (multiInstance) {
+            map.computeIfAbsent(FlowApproveOperationEnum.REJECT.getId() + currFlowTaskResult.getSetup(), v -> 1);
+        }
+//        map.put(SystemConstant.APPROVE, nextFlowTaskResult.getTaskKey());
+        tfFlowApprove.setSetup(nextFlowTaskResult.getSetup());
+        tfFlowApprove.setStatus(FlowStatusEnum.convertToEnum(approvePass.name()));
+        tfFlowLog.setApproveOperation(FlowApproveOperationEnum.convertToEnum(approvePass.name()));
+        if (Objects.nonNull(approveRemark)) {
+            tfFlowLog.setApproveRemark(approveRemark);
+        } else {
+            tfFlowLog.setApproveRemark(tfFlowLog.getApproveOperation().getTitle());
+        }
     }
     }
 
 
     /**
     /**
@@ -409,78 +565,4 @@ public class ActivitiFromHtmlController {
         }
         }
         return nextFlowTaskResult;
         return nextFlowTaskResult;
     }
     }
-
-    @ApiOperation(value = "获取待办接口")
-    @RequestMapping(value = "/getTaskList", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
-    public Map<String, Object> getTaskList(@ApiParam(value = "用户id", required = true) @RequestParam String
-                                                   userId, HttpServletRequest request) {
-        Map<String, Object> varMap = new HashMap<>();
-        List<Task> taskList = taskService.createTaskQuery().taskAssignee(userId).list();
-        if (!CollectionUtils.isEmpty(taskList)) {
-            List<FormPropertyBean> formPropertyList = new LinkedList<>();
-            for (Task t : taskList) {
-                String flowTaskId = t.getId();
-                String processInstanceId = t.getProcessInstanceId();
-                String processDefinitionId = t.getProcessDefinitionId();
-                log.info("用户id:{},taskId:{},flowId:{},processDefinitionId:{},formKey:{}", userId, flowTaskId, processInstanceId, processDefinitionId, t.getFormKey());
-                if (Objects.nonNull(t.getFormKey())) {
-                    Object o = formService.getRenderedTaskForm(flowTaskId);
-                    if (Objects.nonNull(o)) {
-                        log.info("task formProperties:{}", JacksonUtil.parseJson(o));
-                        List<FlowFormWidgetResult> list = JSONArray.parseArray(o.toString(), FlowFormWidgetResult.class);
-                        formPropertyList.add(new FormPropertyBean(processInstanceId, flowTaskId, userId, null));
-                    }
-                }
-                varMap.put("formProperties", formPropertyList);
-            }
-        }
-        return varMap;
-    }
-
-    @ApiOperation(value = "流程提交接口")
-    @RequestMapping(value = "/complete", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
-    public Map<String, Object> complete(@ApiParam(value = "流程taskId", required = true) @RequestParam String taskId,
-                                        @ApiParam(value = "上传文件") @RequestParam(required = false) MultipartFile[] files, HttpServletRequest
-                                                request) {
-        Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
-        Map<String, Object> varMap = new HashMap<>();
-        Map<String, String> formDataMap = new HashMap<>();
-        Map<String, String[]> parameterMap = request.getParameterMap();
-        Set<Map.Entry<String, String[]>> entrySet = parameterMap.entrySet();
-        for (Map.Entry<String, String[]> entry : entrySet) {
-            String key = entry.getKey();
-            String[] value = entry.getValue();
-            formDataMap.put(key, value[0]);
-        }
-        varMap.putAll(formDataMap);
-        String flowTaskId = task.getId();
-        String processInstanceId = task.getProcessInstanceId();
-        String processDefinitionId = task.getProcessDefinitionId();
-        formService.submitTaskFormData(flowTaskId, formDataMap);
-        List<Task> taskList = taskService.createTaskQuery().processInstanceId(processInstanceId).list();
-        if (!CollectionUtils.isEmpty(taskList)) {
-            List<FormPropertyBean> formPropertyList = new LinkedList<>();
-            for (Task t : taskList) {
-                String nextFlowTaskId = t.getId();
-                Object o = formService.getRenderedTaskForm(nextFlowTaskId);
-                log.info("userId:{},taskId:{},flowId:{},processDefinitionId:{}", t.getAssignee(), nextFlowTaskId, processInstanceId, processDefinitionId);
-                if (Objects.nonNull(o)) {
-                    log.info("task formProperties:{}", JacksonUtil.parseJson(o));
-                    List<FlowFormWidgetResult> list = JSONArray.parseArray(o.toString(), FlowFormWidgetResult.class);
-                    formPropertyList.add(new FormPropertyBean(processInstanceId, flowTaskId, t.getAssignee(), null));
-                }
-                varMap.put("formProperties", formPropertyList);
-            }
-        }
-        return varMap;
-    }
-
-    @ApiOperation(value = "结束流程接口")
-    @RequestMapping(value = "/deleteProcessInstance", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
-    public boolean deleteProcessInstance(String runId) {
-        return activitiConsumerService.deleteProcessInstance(runId);
-    }
 }
 }