diff --git a/jeecg-boot-platform/jeecg-boot-module-bpm-flowable/src/main/java/org/jeecg/modules/bpm/controller/ActProcessController.java b/jeecg-boot-platform/jeecg-boot-module-bpm-flowable/src/main/java/org/jeecg/modules/bpm/controller/ActProcessController.java index 4cffbdf..09f64fa 100644 --- a/jeecg-boot-platform/jeecg-boot-module-bpm-flowable/src/main/java/org/jeecg/modules/bpm/controller/ActProcessController.java +++ b/jeecg-boot-platform/jeecg-boot-module-bpm-flowable/src/main/java/org/jeecg/modules/bpm/controller/ActProcessController.java @@ -11,6 +11,8 @@ import org.apache.commons.io.IOUtils; import org.flowable.common.engine.api.FlowableException; import org.flowable.engine.RepositoryService; import org.flowable.engine.RuntimeService; +import org.flowable.engine.TaskService; +import org.flowable.task.api.Task; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.api.ISysBaseAPI; import org.jeecg.common.util.RedisUtil; @@ -53,6 +55,8 @@ public class ActProcessController { @Autowired private RuntimeService runtimeService; @Autowired + private TaskService taskService; + @Autowired private ActProcessService actProcessService; @Autowired private IExtActProcessService extActProcessService; @@ -87,6 +91,21 @@ public class ActProcessController { if (oConvertUtils.isEmpty(dto.getVarField())) { return Result.error("流程变量名不能为空"); } + if (Boolean.TRUE.equals(dto.getLocal()) || oConvertUtils.isNotEmpty(dto.getExecutionId()) || oConvertUtils.isNotEmpty(dto.getTaskId())) { + String executionId = dto.getExecutionId(); + if (oConvertUtils.isEmpty(executionId) && oConvertUtils.isNotEmpty(dto.getTaskId())) { + Task task = taskService.createTaskQuery().taskId(dto.getTaskId()).singleResult(); + if (task == null) { + return Result.error("任务ID不存在"); + } + executionId = task.getExecutionId(); + } + if (oConvertUtils.isEmpty(executionId)) { + return Result.error("执行ID不能为空"); + } + runtimeService.setVariableLocal(executionId, dto.getVarField(), dto.getVarVal()); + return Result.OK("保存成功"); + } runtimeService.setVariable(dto.getProcessInstanceId(), dto.getVarField(), dto.getVarVal()); return Result.OK("保存成功"); } diff --git a/jeecg-boot-platform/jeecg-boot-module-bpm-flowable/src/main/java/org/jeecg/modules/bpm/dto/ProcessVariableDTO.java b/jeecg-boot-platform/jeecg-boot-module-bpm-flowable/src/main/java/org/jeecg/modules/bpm/dto/ProcessVariableDTO.java index d66a170..eff70be 100644 --- a/jeecg-boot-platform/jeecg-boot-module-bpm-flowable/src/main/java/org/jeecg/modules/bpm/dto/ProcessVariableDTO.java +++ b/jeecg-boot-platform/jeecg-boot-module-bpm-flowable/src/main/java/org/jeecg/modules/bpm/dto/ProcessVariableDTO.java @@ -13,9 +13,18 @@ public class ProcessVariableDTO implements Serializable { @Schema(description = "Process instance id") private String processInstanceId; + @Schema(description = "Task id") + private String taskId; + + @Schema(description = "Execution id") + private String executionId; + @Schema(description = "Process variable name") private String varField; @Schema(description = "Process variable value") private Object varVal; + + @Schema(description = "Whether to save as execution local variable") + private Boolean local; }