diff --git a/workflow-engine-common/src/main/java/cn/axzo/workflow/common/model/response/mq/MessagePushDTO.java b/workflow-engine-common/src/main/java/cn/axzo/workflow/common/model/response/mq/MessagePushDTO.java index 95f97ab77..04a5e0d79 100644 --- a/workflow-engine-common/src/main/java/cn/axzo/workflow/common/model/response/mq/MessagePushDTO.java +++ b/workflow-engine-common/src/main/java/cn/axzo/workflow/common/model/response/mq/MessagePushDTO.java @@ -31,6 +31,11 @@ public class MessagePushDTO implements Serializable { */ private String processInstanceId; + /** + * 业务 ID + */ + private String processDefinitionKey; + /** * 流程任务 ID */ diff --git a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/event/MessagePushEvent.java b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/event/MessagePushEvent.java index 1af8582a1..6f57f3383 100644 --- a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/event/MessagePushEvent.java +++ b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/event/MessagePushEvent.java @@ -25,6 +25,8 @@ public interface MessagePushEvent extends FlowableEvent { String getProcessDefinitionId(); + String getProcessDefinitionKey(); + String getCurrentTaskDefinitionKey(); String getTenantId(); diff --git a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/event/MessagePushEventBuilder.java b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/event/MessagePushEventBuilder.java index f3c11e84a..0fbea9e20 100644 --- a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/event/MessagePushEventBuilder.java +++ b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/event/MessagePushEventBuilder.java @@ -26,21 +26,21 @@ import static cn.axzo.workflow.core.engine.event.MessagePushEventType.SMS; public class MessagePushEventBuilder { public static MessagePushEventImpl createEvent(MessagePushEventType type, List assigners, - BpmnNoticeConf noticeConf, String processInstanceId, + BpmnNoticeConf noticeConf, String processInstanceId, String processDefinitionKey, String tenantId, String taskId) { switch (type) { case NOTICE: - return createNoticeEvent(assigners, noticeConf, processInstanceId, tenantId, taskId); + return createNoticeEvent(assigners, noticeConf, processInstanceId, processDefinitionKey, tenantId, taskId); case PENDING_PUSH: throw new WorkflowEngineException(MESSAGE_PUSH_EVENT_BUILD_ERROR); case PENDING_COMPLETE: - return createPendingCompleteEvent(assigners, noticeConf, processInstanceId, tenantId, taskId); + return createPendingCompleteEvent(assigners, noticeConf, processInstanceId, processDefinitionKey, tenantId, taskId); case CARBON_COPY: - return createCarbonCopyEvent(assigners, noticeConf, processInstanceId, tenantId); + return createCarbonCopyEvent(assigners, noticeConf, processInstanceId, processDefinitionKey, tenantId); case CARBON_COPY_COMPLETE: - return createCarbonCopyCompleteEvent(assigners, noticeConf, processInstanceId, tenantId); + return createCarbonCopyCompleteEvent(assigners, noticeConf, processInstanceId, processDefinitionKey, tenantId); case SMS: - return createSmsEvent(assigners, noticeConf, processInstanceId, tenantId, taskId); + return createSmsEvent(assigners, noticeConf, processInstanceId, processDefinitionKey, tenantId, taskId); default: throw new WorkflowEngineException(MES_PUSH_OBJECT_BUILD_ERROR); } @@ -48,9 +48,9 @@ public class MessagePushEventBuilder { public static MessagePushEventImpl createNoticeEvent(List assigners, BpmnNoticeConf noticeConf - , String processInstanceId, String tenantId, String taskId) { + , String processInstanceId, String processDefinitionKey, String tenantId, String taskId) { MessagePushEventImpl newEvent = new MessagePushEventImpl(NOTICE, assigners, noticeConf, processInstanceId, - tenantId, taskId); + processDefinitionKey, tenantId, taskId); return newEvent; } @@ -58,47 +58,55 @@ public class MessagePushEventBuilder { BpmnNoticeConf noticeConf, BpmnApproveConf processApproveConf, String processInstanceId, - String processDefinitionId, String currentTaskDefinitionKey, + String processDefinitionId, + String processDefinitionKey, + String currentTaskDefinitionKey, String tenantId, String taskId) { - MessagePushEventImpl newEvent = new MessagePushEventImpl(PENDING_PUSH, assigners, noticeConf, processApproveConf, processInstanceId, - processDefinitionId, currentTaskDefinitionKey, tenantId, taskId); + MessagePushEventImpl newEvent = new MessagePushEventImpl(PENDING_PUSH, assigners, noticeConf, processApproveConf, + processInstanceId, processDefinitionId, processDefinitionKey, currentTaskDefinitionKey, tenantId, taskId); return newEvent; } public static MessagePushEventImpl createPendingCompleteEvent(List assigners, BpmnNoticeConf noticeConf, String processInstanceId, + String processDefinitionKey, String tenantId, String taskId) { MessagePushEventImpl newEvent = new MessagePushEventImpl(PENDING_COMPLETE, assigners, noticeConf, - processInstanceId, + processInstanceId, processDefinitionKey, tenantId, taskId); return newEvent; } - public static MessagePushEvent createPendingRollbackEvent(String processInstanceId, String tenantId, String taskId, BpmnNoticeConf noticeConf) { - return new MessagePushEventImpl(PENDING_ROLLBACK, null, noticeConf, processInstanceId, tenantId, taskId); + public static MessagePushEvent createPendingRollbackEvent(String processInstanceId, String processDefinitionKey, + String tenantId, String taskId, BpmnNoticeConf noticeConf) { + return new MessagePushEventImpl(PENDING_ROLLBACK, null, noticeConf, processInstanceId, processDefinitionKey, tenantId, taskId); } public static MessagePushEventImpl createCarbonCopyEvent(List assigners, BpmnNoticeConf noticeConf, String processInstanceId, + String processDefinitionKey, String tenantId) { MessagePushEventImpl newEvent = new MessagePushEventImpl(CARBON_COPY, assigners, noticeConf, - processInstanceId, tenantId, null); + processInstanceId, processDefinitionKey, tenantId, null); return newEvent; } public static MessagePushEventImpl createCarbonCopyCompleteEvent(List assigners, BpmnNoticeConf noticeConf, String processInstanceId, + String processDefinitionKey, String tenantId) { MessagePushEventImpl newEvent = new MessagePushEventImpl(CARBON_COPY_COMPLETE, assigners, noticeConf, - processInstanceId, tenantId, null); + processInstanceId, processDefinitionKey, tenantId, null); return newEvent; } public static MessagePushEventImpl createSmsEvent(List assigners, BpmnNoticeConf noticeConf, - String processInstanceId, String tenantId, String taskId) { + String processInstanceId, + String processDefinitionKey, + String tenantId, String taskId) { MessagePushEventImpl newEvent = new MessagePushEventImpl(SMS, assigners, noticeConf, processInstanceId, - tenantId, taskId); + processDefinitionKey, tenantId, taskId); return newEvent; } } diff --git a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/event/MessagePushEventImpl.java b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/event/MessagePushEventImpl.java index 98bf4dc09..d6eabf517 100644 --- a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/event/MessagePushEventImpl.java +++ b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/event/MessagePushEventImpl.java @@ -25,6 +25,7 @@ public class MessagePushEventImpl implements MessagePushEvent { private BpmnApproveConf processApproveConfig; private String processInstanceId; private String processDefinitionId; + private String processDefinitionKey; private String currentTaskDefinitionKey; private String tenantId; private String taskId; @@ -48,11 +49,13 @@ public class MessagePushEventImpl implements MessagePushEvent { * @param tenantId * @param taskId */ - public MessagePushEventImpl(FlowableEventType type, List assigners, BpmnNoticeConf noticeConfig, String processInstanceId, String tenantId, String taskId) { + public MessagePushEventImpl(FlowableEventType type, List assigners, BpmnNoticeConf noticeConfig, + String processInstanceId, String processDefinitionKey, String tenantId, String taskId) { this.type = type; this.assigners = assigners; this.noticeConfig = noticeConfig; this.processInstanceId = processInstanceId; + this.processDefinitionKey = processDefinitionKey; this.tenantId = tenantId; this.taskId = taskId; } @@ -75,7 +78,7 @@ public class MessagePushEventImpl implements MessagePushEvent { public MessagePushEventImpl(FlowableEventType type, List assigners, BpmnNoticeConf noticeConfig, BpmnApproveConf processApproveConfig, - String processInstanceId, String processDefinitionId, + String processInstanceId, String processDefinitionId, String processDefinitionKey, String currentTaskDefinitionKey, String tenantId, String taskId) { this.type = type; this.assigners = assigners; @@ -141,6 +144,15 @@ public class MessagePushEventImpl implements MessagePushEvent { this.processDefinitionId = processDefinitionId; } + @Override + public String getProcessDefinitionKey() { + return processDefinitionKey; + } + + public void setProcessDefinitionKey(String processDefinitionKey) { + this.processDefinitionKey = processDefinitionKey; + } + @Override public String getCurrentTaskDefinitionKey() { return currentTaskDefinitionKey; diff --git a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/listener/EngineCarbonCopyEventListener.java b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/listener/EngineCarbonCopyEventListener.java index c9f26d948..47d9a3cae 100644 --- a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/listener/EngineCarbonCopyEventListener.java +++ b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/listener/EngineCarbonCopyEventListener.java @@ -38,6 +38,7 @@ import java.util.concurrent.atomic.AtomicReference; import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT; import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getCarbonCopyConfigs; +import static cn.axzo.workflow.core.listener.AbstractBpmnEventListener.parseProcessDefinitionKey; /** * 抄送功能的具体实现 @@ -110,6 +111,7 @@ public class EngineCarbonCopyEventListener implements JavaDelegate { MessagePushEventImpl event = MessagePushEventBuilder.createEvent(MessagePushEventType.CARBON_COPY, carbonUsers, bpmnNoticeConf, execution.getProcessInstanceId(), + parseProcessDefinitionKey(execution.getProcessDefinitionId()), execution.getTenantId(), getCarbonTaskId(execution)); eventDispatcher.dispatchEvent(event, processEngineConfiguration.getEngineCfgKey()); } diff --git a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/listener/EngineProcessInstanceEventListener.java b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/listener/EngineProcessInstanceEventListener.java index 8a0073440..c27afe2e0 100644 --- a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/listener/EngineProcessInstanceEventListener.java +++ b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/listener/EngineProcessInstanceEventListener.java @@ -158,7 +158,8 @@ public class EngineProcessInstanceEventListener extends AbstractFlowableEngineEv .execute(new CustomNoticeDestinationUserSelectorCmd(engineExecutionStartListener, historicTaskInstanceConverter, serviceVersion, workspaceType, config.getNotice(), event.getProcessInstanceId(), assigner)); MessagePushEventImpl messagePushEvent = MessagePushEventBuilder.createEvent(MessagePushEventType.NOTICE, - assigners, config, processInstance.getProcessInstanceId(), processInstance.getTenantId(), null); + assigners, config, processInstance.getProcessInstanceId(), processInstance.getProcessDefinitionKey(), + processInstance.getTenantId(), null); log.info("发送通知消息: {}", JSONUtil.toJsonStr(messagePushEvent)); eventDispatcher.dispatchEvent(messagePushEvent, processEngineConfiguration.getEngineCfgKey()); } diff --git a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/listener/AbstractBpmnEventListener.java b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/listener/AbstractBpmnEventListener.java index 63399b2ec..5fa245c7d 100644 --- a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/listener/AbstractBpmnEventListener.java +++ b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/listener/AbstractBpmnEventListener.java @@ -3,6 +3,7 @@ package cn.axzo.workflow.core.listener; import cn.axzo.workflow.core.common.context.OperationContext; import cn.hutool.json.JSONUtil; import org.slf4j.MDC; +import org.springframework.util.StringUtils; import static cn.azxo.framework.common.constatns.Constants.CTX_LOG_ID_MDC; @@ -33,4 +34,11 @@ public abstract class AbstractBpmnEventListener impl protected String buildCacheKey(String apiUrl, Object request) { return apiUrl + JSONUtil.toJsonStr(request); } + + public static String parseProcessDefinitionKey(String processDefinitionId) { + if (StringUtils.hasText(processDefinitionId)) { + return ""; + } + return processDefinitionId.split(":")[0]; + } } diff --git a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/service/impl/BpmnProcessTaskServiceImpl.java b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/service/impl/BpmnProcessTaskServiceImpl.java index 5eb112cf3..86f7d06f8 100644 --- a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/service/impl/BpmnProcessTaskServiceImpl.java +++ b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/service/impl/BpmnProcessTaskServiceImpl.java @@ -628,6 +628,7 @@ public class BpmnProcessTaskServiceImpl implements BpmnProcessTaskService { MessagePushEventImpl event = MessagePushEventBuilder.createEvent(MessagePushEventType.valueOf(type), Lists.newArrayList(assigner), noticeConfig.orElse(null), processInstance.getProcessInstanceId(), + processInstance.getProcessDefinitionKey(), processInstance.getTenantId(), task.getId()); event.setProcessInstanceId(processInstance.getProcessInstanceId()); event.setTenantId(processInstance.getTenantId()); diff --git a/workflow-engine-server/src/main/java/cn/axzo/workflow/server/controller/listener/error/ApproveErrorReporterEventListener.java b/workflow-engine-server/src/main/java/cn/axzo/workflow/server/controller/listener/error/ApproveErrorReporterEventListener.java index 501ae8c5e..0f684ac04 100644 --- a/workflow-engine-server/src/main/java/cn/axzo/workflow/server/controller/listener/error/ApproveErrorReporterEventListener.java +++ b/workflow-engine-server/src/main/java/cn/axzo/workflow/server/controller/listener/error/ApproveErrorReporterEventListener.java @@ -31,6 +31,7 @@ import java.util.Optional; import static cn.axzo.workflow.core.common.code.BpmnTaskRespCode.TASK_COMPLETE_FAIL_ASSIGN_NOT_SELF; import static cn.axzo.workflow.core.common.code.BpmnTaskRespCode.TASK_COMPLETE_FAIL_NOT_EXISTS; import static cn.axzo.workflow.core.common.code.BpmnTaskRespCode.TASK_HAS_BEEN_COMPLETE; +import static cn.axzo.workflow.core.listener.AbstractBpmnEventListener.parseProcessDefinitionKey; import static org.flowable.common.engine.api.delegate.event.FlowableEngineEventType.JOB_MOVED_TO_DEADLETTER; /** @@ -80,7 +81,9 @@ public class ApproveErrorReporterEventListener implements BpmnAsyncJobEventListe Optional noticeConfig = BpmnMetaParserHelper.getNoticeConfig(process); ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(); FlowableEventDispatcher eventDispatcher = processEngineConfiguration.getEventDispatcher(); - MessagePushEvent event = MessagePushEventBuilder.createPendingRollbackEvent(jobEvent.getProcessInstanceId(), jobInfo.getTenantId(), dto.getTaskId(), noticeConfig.orElse(new BpmnNoticeConf())); + MessagePushEvent event = MessagePushEventBuilder.createPendingRollbackEvent(jobEvent.getProcessInstanceId(), + parseProcessDefinitionKey(jobEvent.getProcessDefinitionId()), + jobInfo.getTenantId(), dto.getTaskId(), noticeConfig.orElse(new BpmnNoticeConf())); log.info("发送恢复待办的流程事件消息: taskDto:{},event:{}", JSONUtil.toJsonStr(dto), JSONUtil.toJsonStr(event)); eventDispatcher.dispatchEvent(event, processEngineConfiguration.getEngineCfgKey()); } diff --git a/workflow-engine-server/src/main/java/cn/axzo/workflow/server/controller/listener/notice/RocketMqMessagePushEventListener.java b/workflow-engine-server/src/main/java/cn/axzo/workflow/server/controller/listener/notice/RocketMqMessagePushEventListener.java index d58f4c073..3bed16c49 100644 --- a/workflow-engine-server/src/main/java/cn/axzo/workflow/server/controller/listener/notice/RocketMqMessagePushEventListener.java +++ b/workflow-engine-server/src/main/java/cn/axzo/workflow/server/controller/listener/notice/RocketMqMessagePushEventListener.java @@ -376,6 +376,7 @@ public class RocketMqMessagePushEventListener extends AbstractBpmnEventListener< Object> variables) { return new MessagePushDTO() .setProcessInstanceId(event.getProcessInstanceId()) + .setProcessDefinitionKey(event.getProcessDefinitionKey()) .setType(type) .setTemplateId(templateId) .setTaskId(event.getTaskId()) diff --git a/workflow-engine-server/src/main/java/cn/axzo/workflow/server/controller/listener/process/MessagePushProcessEventListener.java b/workflow-engine-server/src/main/java/cn/axzo/workflow/server/controller/listener/process/MessagePushProcessEventListener.java index 81cc92bb9..75660f280 100644 --- a/workflow-engine-server/src/main/java/cn/axzo/workflow/server/controller/listener/process/MessagePushProcessEventListener.java +++ b/workflow-engine-server/src/main/java/cn/axzo/workflow/server/controller/listener/process/MessagePushProcessEventListener.java @@ -76,7 +76,7 @@ public class MessagePushProcessEventListener extends AbstractBpmnEventListener

{ MessagePushEventImpl messagePushEvent = MessagePushEventBuilder.createEvent(MessagePushEventType.PENDING_COMPLETE, null, noticeConfig, - event.getProcessInstanceId(), null, null); + event.getProcessInstanceId(), parseProcessDefinitionKey(event.getProcessDefinitionId()), null, null); log.info("发送完成实例下所有待办的消息: {}", JSONUtil.toJsonStr(messagePushEvent)); @@ -87,7 +87,7 @@ public class MessagePushProcessEventListener extends AbstractBpmnEventListener