Merge branch '1.3.0-SNAPSHOT' into feature/REQ-2090

# Conflicts:
#	workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/listener/EngineExecutionStartListener.java
This commit is contained in:
wangli 2024-03-18 11:12:38 +08:00
commit e636738238
3 changed files with 22 additions and 24 deletions

View File

@ -1,8 +1,7 @@
package cn.axzo.workflow.core.engine.event;
import org.flowable.common.engine.api.delegate.event.FlowableEventType;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl;
import org.flowable.task.service.delegate.DelegateTask;
import java.util.Map;
@ -19,21 +18,21 @@ public class BizSpecifyAssigneeEventImpl implements BizSpecifyAssigneeEvent {
private final String activityName;
private final String processInstanceId;
private final String processDefinitionId;
private final String businessKey;
private final String executionId;
private final Map<String, Object> variables;
public BizSpecifyAssigneeEventImpl(BizSpecifyAssigneeEventType bizSpecifyAssigneeEventType,
DelegateExecution execution) {
DelegateTask delegateTask, String businessKey,
Map<String, Object> processVariables) {
this.type = bizSpecifyAssigneeEventType;
this.activityId = execution.getCurrentActivityId();
this.activityName = ((ExecutionEntityImpl) execution).getCurrentActivityName();
this.processInstanceId = execution.getProcessInstanceId();
this.processDefinitionId = execution.getProcessDefinitionId();
this.businessKey = ((ExecutionEntityImpl) execution).getBusinessKey();
this.executionId = execution.getId();
this.variables = execution.getVariables();
this.activityId = delegateTask.getTaskDefinitionKey();
this.activityName = delegateTask.getName();
this.processInstanceId = delegateTask.getProcessInstanceId();
this.processDefinitionId = delegateTask.getProcessDefinitionId();
this.businessKey = businessKey;
this.executionId = delegateTask.getExecutionId();
this.variables = processVariables;
}
@Override

View File

@ -10,18 +10,14 @@ import cn.axzo.workflow.core.deletage.BpmnTaskAssigneeSelector;
import cn.axzo.workflow.core.deletage.BpmnTaskCalculateDTO;
import cn.axzo.workflow.core.deletage.BpmnTaskDelegate;
import cn.axzo.workflow.core.deletage.MockTaskAssigneeSelector;
import cn.axzo.workflow.core.engine.event.BizSpecifyAssigneeEventImpl;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.flowable.bpmn.model.Process;
import org.flowable.bpmn.model.UserTask;
import org.flowable.common.engine.api.delegate.event.FlowableEventDispatcher;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Value;
@ -56,7 +52,6 @@ import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getApprove
import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getNodeType;
import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getProcessServerVersion;
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.removeDuplicateByPersonId;
import static cn.axzo.workflow.core.engine.event.BizSpecifyAssigneeEventType.ADD_ASSIGNEE;
/**
@ -136,15 +131,7 @@ public class EngineExecutionStartListener implements ExecutionListener {
DUMMY_ASSIGNEE_TYPE, "dummyApprover");
assigneeIdList.add(dummyApprover.buildAssigneeId());
execution.setVariable(INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT + currentActivityId, Lists.newArrayList(dummyApprover));
// 触发事件
ProcessEngineConfigurationImpl processEngineConfiguration =
CommandContextUtil.getProcessEngineConfiguration();
FlowableEventDispatcher eventDispatcher = processEngineConfiguration.getEventDispatcher();
eventDispatcher.dispatchEvent(new BizSpecifyAssigneeEventImpl(ADD_ASSIGNEE, execution),
processEngineConfiguration.getEngineCfgKey());
break;
default:
// 这里只会是 human 这一种情况 因为 nobody 在转 BPMN 协议时Activity 直接变成了 ReceiveTask 节点了

View File

@ -3,6 +3,7 @@ package cn.axzo.workflow.server.controller.listener.task;
import cn.axzo.workflow.common.model.request.bpmn.BpmnNoticeConf;
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
import cn.axzo.workflow.core.engine.event.BizSpecifyAssigneeEventImpl;
import cn.axzo.workflow.core.engine.event.MessagePushEventBuilder;
import cn.axzo.workflow.core.engine.event.MessagePushEventImpl;
import cn.axzo.workflow.core.engine.event.MessagePushEventType;
@ -32,6 +33,7 @@ import java.util.Optional;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT;
import static cn.axzo.workflow.common.constant.BpmnConstants.NO_ASSIGNEE;
import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_ASSIGNEE_SKIP_FLAT;
import static cn.axzo.workflow.core.engine.event.BizSpecifyAssigneeEventType.ADD_ASSIGNEE;
/**
* UserTask 节点被设置审批人时,推送待办消息
@ -66,6 +68,16 @@ public class MessagePushTaskEventListener implements BpmnTaskEventListener, Orde
}
if (Objects.equals(NO_ASSIGNEE, delegateTask.getAssignee())) {
// 业务指定审批人, 不用发待办
// 但需要触发 PROCESS_ACTIVITY_WAIT_ASSIGNEE 事件
ProcessInstance processInstance =
runtimeService.createProcessInstanceQuery().includeProcessVariables().processInstanceId(delegateTask.getProcessInstanceId())
.singleResult();
ProcessEngineConfigurationImpl processEngineConfiguration =
CommandContextUtil.getProcessEngineConfiguration();
FlowableEventDispatcher eventDispatcher = processEngineConfiguration.getEventDispatcher();
eventDispatcher.dispatchEvent(new BizSpecifyAssigneeEventImpl(ADD_ASSIGNEE, delegateTask,
processInstance.getBusinessKey(), processInstance.getProcessVariables()),
processEngineConfiguration.getEngineCfgKey());
return;
}
pendingPush(delegateTask);