Bladeren bron

add 增加设置流程变量接口

gssong 9 maanden geleden
bovenliggende
commit
44bef2d6d9

+ 35 - 0
ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/service/WorkflowService.java

@@ -1,6 +1,7 @@
 package org.dromara.common.core.service;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 通用 工作流服务
@@ -47,4 +48,38 @@ public interface WorkflowService {
      * @param fieldName 主键属性名称
      */
     void setBusinessInstanceListDTO(Object obj, List<String> idList, String fieldName);
+
+    /**
+     * 设置流程变量(全局变量)
+     *
+     * @param taskId       任务id
+     * @param variableName 变量名称
+     * @param value        变量值
+     */
+    void setVariable(String taskId, String variableName, Object value);
+
+    /**
+     * 设置流程变量(全局变量)
+     *
+     * @param taskId    任务id
+     * @param variables 流程变量
+     */
+    void setVariables(String taskId, Map<String, Object> variables);
+
+    /**
+     * 设置流程变量(本地变量,非全局变量)
+     *
+     * @param taskId       任务id
+     * @param variableName 变量名称
+     * @param value        变量值
+     */
+    void setVariableLocal(String taskId, String variableName, Object value);
+
+    /**
+     * 设置流程变量(本地变量,非全局变量)
+     *
+     * @param taskId    任务id
+     * @param variables 流程变量
+     */
+    void setVariablesLocal(String taskId, Map<String, Object> variables);
 }

+ 49 - 0
ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/WorkflowServiceImpl.java

@@ -4,9 +4,11 @@ import lombok.RequiredArgsConstructor;
 import org.dromara.common.core.service.WorkflowService;
 import org.dromara.workflow.service.IActProcessInstanceService;
 import org.dromara.workflow.utils.WorkflowUtils;
+import org.flowable.engine.RuntimeService;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 通用 工作流服务实现
@@ -18,6 +20,7 @@ import java.util.List;
 public class WorkflowServiceImpl implements WorkflowService {
 
     private final IActProcessInstanceService iActProcessInstanceService;
+    private final RuntimeService runtimeService;
 
     /**
      * 运行中的实例 删除程实例,删除历史记录,删除业务与流程关联信息
@@ -72,4 +75,50 @@ public class WorkflowServiceImpl implements WorkflowService {
     public void setBusinessInstanceListDTO(Object obj, List<String> idList, String fieldName) {
         WorkflowUtils.setBusinessInstanceListDTO(obj, idList, fieldName);
     }
+
+    /**
+     * 设置流程变量(全局变量)
+     *
+     * @param taskId       任务id
+     * @param variableName 变量名称
+     * @param value        变量值
+     */
+    @Override
+    public void setVariable(String taskId, String variableName, Object value) {
+        runtimeService.setVariable(taskId, variableName, value);
+    }
+
+    /**
+     * 设置流程变量(全局变量)
+     *
+     * @param taskId    任务id
+     * @param variables 流程变量
+     */
+    @Override
+    public void setVariables(String taskId, Map<String, Object> variables) {
+        runtimeService.setVariables(taskId, variables);
+    }
+
+    /**
+     * 设置流程变量(本地变量,非全局变量)
+     *
+     * @param taskId       任务id
+     * @param variableName 变量名称
+     * @param value        变量值
+     */
+    @Override
+    public void setVariableLocal(String taskId, String variableName, Object value) {
+        runtimeService.setVariableLocal(taskId, variableName, value);
+    }
+
+    /**
+     * 设置流程变量(本地变量,非全局变量)
+     *
+     * @param taskId    任务id
+     * @param variables 流程变量
+     */
+    @Override
+    public void setVariablesLocal(String taskId, Map<String, Object> variables) {
+        runtimeService.setVariablesLocal(taskId, variables);
+    }
 }