From f7b6518038bdce0bde3a6fc53ddbc32393f162f7 Mon Sep 17 00:00:00 2001 From: ye1023 <12588209+ye1023@user.noreply.gitee.com> Date: Sun, 3 May 2026 11:37:24 +0800 Subject: [PATCH] =?UTF-8?q?yxk-20260506-=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E8=A1=A8=E8=BE=BE=E5=BC=8F=EF=BC=9A=20setPro?= =?UTF-8?q?cessVariable=E5=8F=AF=E4=BB=A5=E5=86=99=E5=85=A5=E4=B8=BB?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E5=8F=98=E9=87=8F/=E5=AD=90=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E5=B1=80=E9=83=A8=E5=8F=98=E9=87=8F=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=BA=86=20taskId=E3=80=81executionId=E3=80=81local?= =?UTF-8?q?=20=E5=AD=97=E6=AE=B5=20=E4=BC=A0=20local:=20true=20=E4=B8=94?= =?UTF-8?q?=E6=9C=89=20taskId=20=E6=97=B6=EF=BC=8C=E9=80=9A=E8=BF=87=20tas?= =?UTF-8?q?kId=20=E6=9F=A5=E5=BD=93=E5=89=8D=20executionId=20=E8=B0=83?= =?UTF-8?q?=E7=94=A8=20runtimeService.setVariableLocal(executionId,=20'sub?= =?UTF-8?q?ApproveUser',=20value)=20=E4=B8=8D=E4=BC=A0=20local/taskId/exec?= =?UTF-8?q?utionId=20=E6=97=B6=EF=BC=8C=E4=BF=9D=E6=8C=81=E5=8E=9F?= =?UTF-8?q?=E6=9D=A5=E7=9A=84=20setVariable(processInstanceId,=20...)=20?= =?UTF-8?q?=E8=A1=8C=E4=B8=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bpm/controller/ActProcessController.java | 19 +++++++++++++++++++ .../modules/bpm/dto/ProcessVariableDTO.java | 9 +++++++++ 2 files changed, 28 insertions(+) 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; }