update - 调整业务节点设置审批人事件的逻辑
This commit is contained in:
parent
7d8e8dd8dc
commit
86ed43bc67
@ -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
|
||||
|
||||
@ -10,17 +10,13 @@ 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.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;
|
||||
@ -54,7 +50,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;
|
||||
|
||||
|
||||
/**
|
||||
@ -114,15 +109,15 @@ 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());
|
||||
// // 触发事件
|
||||
// ProcessEngineConfigurationImpl processEngineConfiguration =
|
||||
// CommandContextUtil.getProcessEngineConfiguration();
|
||||
// FlowableEventDispatcher eventDispatcher =
|
||||
// processEngineConfiguration.getEventDispatcher();
|
||||
// eventDispatcher.dispatchEvent(new
|
||||
// BizSpecifyAssigneeEventImpl(ADD_ASSIGNEE, execution),
|
||||
// processEngineConfiguration.getEngineCfgKey());
|
||||
break;
|
||||
default:
|
||||
// 这里只会是 human 这一种情况, 因为 nobody 在转 BPMN 协议时,Activity 直接变成了 ReceiveTask 节点了。
|
||||
|
||||
@ -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;
|
||||
@ -30,6 +31,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 节点被设置审批人时,推送待办消息
|
||||
@ -63,6 +65,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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user