diff --git a/ruoyi-api/ruoyi-api-workflow/src/main/java/org/dromara/workflow/api/domain/event/ProcessTaskEvent.java b/ruoyi-api/ruoyi-api-workflow/src/main/java/org/dromara/workflow/api/domain/event/ProcessTaskEvent.java index 8ba2caef..75a4cf39 100644 --- a/ruoyi-api/ruoyi-api-workflow/src/main/java/org/dromara/workflow/api/domain/event/ProcessTaskEvent.java +++ b/ruoyi-api/ruoyi-api-workflow/src/main/java/org/dromara/workflow/api/domain/event/ProcessTaskEvent.java @@ -18,9 +18,14 @@ public class ProcessTaskEvent implements Serializable { private static final long serialVersionUID = 1L; /** - * 流程定义key与流程节点标识(拼接方式:流程定义key_流程节点) + * 流程定义key */ - private String keyNode; + private String key; + + /** + * 审批节点key + */ + private String taskDefinitionKey; /** * 任务id diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/handler/FlowProcessEventHandler.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/handler/FlowProcessEventHandler.java index 8b376c96..94924a84 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/handler/FlowProcessEventHandler.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/handler/FlowProcessEventHandler.java @@ -34,13 +34,15 @@ public class FlowProcessEventHandler { /** * 执行办理任务监听 * - * @param keyNode 流程定义key与流程节点标识(拼接方式:流程定义key_流程节点) - * @param taskId 任务id - * @param businessKey 业务id + * @param key 流程key + * @param taskDefinitionKey 审批节点key + * @param taskId 任务id + * @param businessKey 业务id */ - public void processTaskHandler(String keyNode, String taskId, String businessKey) { + public void processTaskHandler(String key, String taskDefinitionKey, String taskId, String businessKey) { ProcessTaskEvent processTaskEvent = new ProcessTaskEvent(); - processTaskEvent.setKeyNode(keyNode); + processTaskEvent.setKey(key); + processTaskEvent.setTaskDefinitionKey(taskDefinitionKey); processTaskEvent.setTaskId(taskId); processTaskEvent.setBusinessKey(businessKey); SpringUtils.context().publishEvent(processTaskEvent); diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActTaskServiceImpl.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActTaskServiceImpl.java index 95a1c169..dad0c96d 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActTaskServiceImpl.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActTaskServiceImpl.java @@ -186,8 +186,8 @@ public class ActTaskServiceImpl implements IActTaskService { } runtimeService.updateBusinessStatus(task.getProcessInstanceId(), BusinessStatusEnum.WAITING.getStatus()); //办理监听 - String keyNode = processInstance.getProcessDefinitionKey() + "_" + task.getTaskDefinitionKey(); - flowProcessEventHandler.processTaskHandler(keyNode, task.getId(), processInstance.getBusinessKey()); + flowProcessEventHandler.processTaskHandler(processInstance.getProcessDefinitionKey(), task.getTaskDefinitionKey(), + task.getId(), processInstance.getBusinessKey()); //办理意见 taskService.addComment(completeTaskBo.getTaskId(), task.getProcessInstanceId(), TaskStatusEnum.PASS.getStatus(), StringUtils.isBlank(completeTaskBo.getMessage()) ? "同意" : completeTaskBo.getMessage()); //办理任务 diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java index 0bbcca66..f035fb41 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java @@ -136,10 +136,15 @@ public class TestLeaveServiceImpl implements ITestLeaveService { /** * 执行办理任务监听 + * 示例:也可通过 @EventListener(condition = "#processTaskEvent.key=='leave1'")进行判断 + * 在方法中判断流程节点key + * if ("xxx".equals(processTaskEvent.getTaskDefinitionKey())) { + * //执行业务逻辑 + * } * * @param processTaskEvent 参数 */ - @EventListener(condition = "#processTaskEvent.keyNode=='leave1_Activity_14633hx'") + @EventListener(condition = "#processTaskEvent.key=='leave1' && #processTaskEvent.taskDefinitionKey=='Activity_14633hx'") public void processTaskHandler(ProcessTaskEvent processTaskEvent) { log.info("当前任务执行了{}", processTaskEvent.toString()); TestLeave testLeave = baseMapper.selectById(Long.valueOf(processTaskEvent.getBusinessKey()));