From 042c18baa2ba223f46eda58ae1139823b6e3ad7f Mon Sep 17 00:00:00 2001 From: ye1023 <12588209+ye1023@user.noreply.gitee.com> Date: Thu, 30 Apr 2026 11:15:52 +0800 Subject: [PATCH] =?UTF-8?q?yxk-20260430-=E5=A2=9E=E5=8A=A0setProcessVariab?= =?UTF-8?q?le=E6=8E=A5=E5=8F=A3=EF=BC=8C=E8=AE=BE=E7=BD=AE=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bpm/controller/ActProcessController.java | 17 +++++++++++++++ .../modules/bpm/dto/ProcessVariableDTO.java | 21 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 jeecg-boot-platform/jeecg-boot-module-bpm-flowable/src/main/java/org/jeecg/modules/bpm/dto/ProcessVariableDTO.java 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 023b876..4cffbdf 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 @@ -10,11 +10,13 @@ import org.apache.commons.io.FilenameUtils; 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.jeecg.common.api.vo.Result; import org.jeecg.common.system.api.ISysBaseAPI; import org.jeecg.common.util.RedisUtil; import org.jeecg.common.util.TokenUtils; import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.bpm.dto.ProcessVariableDTO; import org.jeecg.modules.bpm.service.impl.ActProcessService; import org.jeecg.modules.extbpm.process.service.IExtActProcessService; import org.jeecg.modules.extbpm.util.CommonRandomUtil; @@ -49,6 +51,8 @@ public class ActProcessController { @Autowired private RepositoryService repositoryService; @Autowired + private RuntimeService runtimeService; + @Autowired private ActProcessService actProcessService; @Autowired private IExtActProcessService extActProcessService; @@ -74,6 +78,19 @@ public class ActProcessController { return result; } + @PostMapping(value = "/setProcessVariable") + @Operation(summary = "设置流程变量") + public Result setProcessVariable(@RequestBody ProcessVariableDTO dto) { + if (dto == null || oConvertUtils.isEmpty(dto.getProcessInstanceId())) { + return Result.error("流程实例ID不能为空"); + } + if (oConvertUtils.isEmpty(dto.getVarField())) { + return Result.error("流程变量名不能为空"); + } + runtimeService.setVariable(dto.getProcessInstanceId(), dto.getVarField(), dto.getVarVal()); + return Result.OK("保存成功"); + } + @PostMapping("deploy") @Operation(summary = "部署流程文件") public Result deploy(@RequestParam("processFile") MultipartFile file) throws IOException { 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 new file mode 100644 index 0000000..d66a170 --- /dev/null +++ b/jeecg-boot-platform/jeecg-boot-module-bpm-flowable/src/main/java/org/jeecg/modules/bpm/dto/ProcessVariableDTO.java @@ -0,0 +1,21 @@ +package org.jeecg.modules.bpm.dto; + +import java.io.Serializable; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "Process variable DTO") +public class ProcessVariableDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "Process instance id") + private String processInstanceId; + + @Schema(description = "Process variable name") + private String varField; + + @Schema(description = "Process variable value") + private Object varVal; +}