yxk-20260506-自定义流程表达式:
setProcessVariable可以写入主流程变量/子流程局部变量 增加了 taskId、executionId、local 字段 传 local: true 且有 taskId 时,通过 taskId 查当前 executionId 调用 runtimeService.setVariableLocal(executionId, 'subApproveUser', value) 不传 local/taskId/executionId 时,保持原来的 setVariable(processInstanceId, ...) 行为
This commit is contained in:
+19
@@ -11,6 +11,8 @@ import org.apache.commons.io.IOUtils;
|
|||||||
import org.flowable.common.engine.api.FlowableException;
|
import org.flowable.common.engine.api.FlowableException;
|
||||||
import org.flowable.engine.RepositoryService;
|
import org.flowable.engine.RepositoryService;
|
||||||
import org.flowable.engine.RuntimeService;
|
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.api.vo.Result;
|
||||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||||
import org.jeecg.common.util.RedisUtil;
|
import org.jeecg.common.util.RedisUtil;
|
||||||
@@ -53,6 +55,8 @@ public class ActProcessController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RuntimeService runtimeService;
|
private RuntimeService runtimeService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private TaskService taskService;
|
||||||
|
@Autowired
|
||||||
private ActProcessService actProcessService;
|
private ActProcessService actProcessService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IExtActProcessService extActProcessService;
|
private IExtActProcessService extActProcessService;
|
||||||
@@ -87,6 +91,21 @@ public class ActProcessController {
|
|||||||
if (oConvertUtils.isEmpty(dto.getVarField())) {
|
if (oConvertUtils.isEmpty(dto.getVarField())) {
|
||||||
return Result.error("流程变量名不能为空");
|
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());
|
runtimeService.setVariable(dto.getProcessInstanceId(), dto.getVarField(), dto.getVarVal());
|
||||||
return Result.OK("保存成功");
|
return Result.OK("保存成功");
|
||||||
}
|
}
|
||||||
|
|||||||
+9
@@ -13,9 +13,18 @@ public class ProcessVariableDTO implements Serializable {
|
|||||||
@Schema(description = "Process instance id")
|
@Schema(description = "Process instance id")
|
||||||
private String processInstanceId;
|
private String processInstanceId;
|
||||||
|
|
||||||
|
@Schema(description = "Task id")
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
@Schema(description = "Execution id")
|
||||||
|
private String executionId;
|
||||||
|
|
||||||
@Schema(description = "Process variable name")
|
@Schema(description = "Process variable name")
|
||||||
private String varField;
|
private String varField;
|
||||||
|
|
||||||
@Schema(description = "Process variable value")
|
@Schema(description = "Process variable value")
|
||||||
private Object varVal;
|
private Object varVal;
|
||||||
|
|
||||||
|
@Schema(description = "Whether to save as execution local variable")
|
||||||
|
private Boolean local;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user