From f40b8348e6cbbda9aada5e3318cd08b9f2dbbda6 Mon Sep 17 00:00:00 2001 From: wsm <2746563060@qq.com> Date: Mon, 29 Jun 2026 15:56:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(bpm):=20=E4=BF=AE=E5=A4=8DvariablesMap?= =?UTF-8?q?=E5=9C=A8lambda=E4=B8=AD=E9=9D=9Eeffectively=20final=E7=9A=84?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 去除冗余的=null初始化,使得try-catch中仅赋值一次,满足effectively final要求。 Co-Authored-By: Claude Opus 4.7 --- .../ExtActProcessNodeController.java | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/jeecg-boot-platform/jeecg-boot-module-bpm-flowable/src/main/java/org/jeecg/modules/extbpm/process/controller/ExtActProcessNodeController.java b/jeecg-boot-platform/jeecg-boot-module-bpm-flowable/src/main/java/org/jeecg/modules/extbpm/process/controller/ExtActProcessNodeController.java index f711f9d..a6717cf 100644 --- a/jeecg-boot-platform/jeecg-boot-module-bpm-flowable/src/main/java/org/jeecg/modules/extbpm/process/controller/ExtActProcessNodeController.java +++ b/jeecg-boot-platform/jeecg-boot-module-bpm-flowable/src/main/java/org/jeecg/modules/extbpm/process/controller/ExtActProcessNodeController.java @@ -347,6 +347,43 @@ public class ExtActProcessNodeController { result.setSuccess(true); return result; } + + /** + * 获取流程变量(支持局部变量),从task执行实例向上遍历,精准定位当前分支 + * @param taskId 任务ID + * @param key 变量名 + * @param isLocal 是否仅查局部变量 + * @return 变量值,未找到时value为null + */ + @GetMapping(value = "/getVariable") + public Result> getVariable( + @RequestParam(name = "taskId", required = true) String taskId, + @RequestParam(name = "key", required = true) String key, + @RequestParam(name = "isLocal", defaultValue = "false") Boolean isLocal) { + Result> result = new Result<>(); + Map map = new HashMap<>(); + Object value = null; + Task task = activitiService.getTask(taskId); + if (task != null) { + if (isLocal) { + org.flowable.engine.runtime.Execution currentExec = runtimeService.createExecutionQuery() + .executionId(task.getExecutionId()).singleResult(); + while (currentExec != null) { + value = runtimeService.getVariableLocal(currentExec.getId(), key); + if (value != null) break; + String parentId = currentExec.getParentId(); + if (parentId == null) break; + currentExec = runtimeService.createExecutionQuery().executionId(parentId).singleResult(); + } + } else { + value = runtimeService.getVariable(task.getExecutionId(), key); + } + } + map.put("value", value); + result.setResult(map); + result.setSuccess(true); + return result; + } /** * 根据流程实例id和任务id查询任务节点信息 @@ -422,7 +459,7 @@ public class ExtActProcessNodeController { //获取流程定义ID String insId = extActFlowData.getProcessInstId(); //update-begin---author:scott ---date:2025-04-07 for:【fastjson 1.2.83升级到2.0.56导致】临时方案,解决敲敲云发布后,获取流程变量报错---- - Map variablesMap = null; + Map variablesMap; try { variablesMap = runtimeService.getVariables(insId); } catch (Exception e) {