update - 调整引擎事件的处理逻辑, 让各事件处理逻辑更通用标准
This commit is contained in:
parent
d1bb97de18
commit
20820d1bce
@ -1,7 +1,7 @@
|
||||
package cn.axzo.workflow.core.engine.behavior;
|
||||
|
||||
import cn.axzo.workflow.core.engine.event.ReceiveTaskExtInstCompleteEvent;
|
||||
import cn.axzo.workflow.core.engine.event.ReceiveTaskExtInstCreateEvent;
|
||||
import cn.axzo.workflow.core.engine.event.ExtTaskInstCreateEvent;
|
||||
import cn.axzo.workflow.core.engine.event.ExtTaskInstUpdateEvent;
|
||||
import cn.axzo.workflow.core.service.ExtAxHiTaskInstService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.bpmn.model.ReceiveTask;
|
||||
@ -55,7 +55,7 @@ public class CustomReceiveTaskActivityBehavior extends ReceiveTaskActivityBehavi
|
||||
|
||||
// 添加 taskInst 扩展表数据
|
||||
FlowableEventDispatcher eventDispatcher = processEngineConfiguration.getEventDispatcher();
|
||||
eventDispatcher.dispatchEvent(new ReceiveTaskExtInstCreateEvent(execution.getProcessInstanceId(),
|
||||
eventDispatcher.dispatchEvent(new ExtTaskInstCreateEvent(execution.getProcessInstanceId(),
|
||||
execution.getCurrentActivityId(), task.getId(), PROCESSING),
|
||||
processEngineConfiguration.getEngineCfgKey());
|
||||
}
|
||||
@ -71,7 +71,7 @@ public class CustomReceiveTaskActivityBehavior extends ReceiveTaskActivityBehavi
|
||||
Task task = taskService.createTaskQuery().executionId(execution.getId())
|
||||
.taskDefinitionKey(execution.getCurrentActivityId()).singleResult();
|
||||
if (Objects.nonNull(task)) {
|
||||
eventDispatcher.dispatchEvent(new ReceiveTaskExtInstCompleteEvent(execution.getProcessInstanceId(),
|
||||
eventDispatcher.dispatchEvent(new ExtTaskInstUpdateEvent(execution.getProcessInstanceId(),
|
||||
receiveTask.getId(), task.getId(), APPROVED),
|
||||
processEngineConfiguration.getEngineCfgKey());
|
||||
} else {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package cn.axzo.workflow.core.engine.behavior;
|
||||
|
||||
import cn.axzo.workflow.core.engine.event.ReceiveTaskExtInstCompleteEvent;
|
||||
import cn.axzo.workflow.core.engine.event.ReceiveTaskExtInstCreateEvent;
|
||||
import cn.axzo.workflow.core.engine.event.ExtTaskInstCreateEvent;
|
||||
import cn.axzo.workflow.core.engine.event.ExtTaskInstUpdateEvent;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.bpmn.model.MapExceptionEntry;
|
||||
import org.flowable.bpmn.model.ServiceTask;
|
||||
@ -61,7 +61,7 @@ public class CustomServiceTaskDelegateExpressionActivityBehavior extends Service
|
||||
|
||||
// 添加 taskInst 扩展表数据
|
||||
FlowableEventDispatcher eventDispatcher = processEngineConfiguration.getEventDispatcher();
|
||||
eventDispatcher.dispatchEvent(new ReceiveTaskExtInstCreateEvent(execution.getProcessInstanceId(),
|
||||
eventDispatcher.dispatchEvent(new ExtTaskInstCreateEvent(execution.getProcessInstanceId(),
|
||||
execution.getCurrentActivityId(), task.getId(), PROCESSING),
|
||||
processEngineConfiguration.getEngineCfgKey());
|
||||
super.execute(execution);
|
||||
@ -74,7 +74,7 @@ public class CustomServiceTaskDelegateExpressionActivityBehavior extends Service
|
||||
CommandContextUtil.getProcessEngineConfiguration(commandContext);
|
||||
|
||||
FlowableEventDispatcher eventDispatcher = processEngineConfiguration.getEventDispatcher();
|
||||
eventDispatcher.dispatchEvent(new ReceiveTaskExtInstCompleteEvent(execution.getProcessInstanceId(),
|
||||
eventDispatcher.dispatchEvent(new ExtTaskInstUpdateEvent(execution.getProcessInstanceId(),
|
||||
execution.getCurrentActivityId(), task.getId(), APPROVED),
|
||||
processEngineConfiguration.getEngineCfgKey());
|
||||
super.leave(execution);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package cn.axzo.workflow.core.engine.behavior;
|
||||
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
|
||||
import cn.axzo.workflow.core.common.enums.BpmnProcessTaskResultEnum;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -30,6 +31,10 @@ import org.flowable.task.service.event.impl.FlowableTaskEventBuilder;
|
||||
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_INITIATOR;
|
||||
import static cn.axzo.workflow.common.enums.BpmnFlowNodeType.NODE_STARTER;
|
||||
|
||||
/**
|
||||
* 自定义的用户审批任务节点行为处理器
|
||||
@ -181,6 +186,11 @@ public class CustomUserTaskActivityBehavior extends UserTaskActivityBehavior {
|
||||
List<String> candidateUsers, List<String> candidateGroups, TaskEntity task,
|
||||
ExpressionManager expressionManager, DelegateExecution execution,
|
||||
ProcessEngineConfigurationImpl processEngineConfiguration) {
|
||||
if (Objects.equals(NODE_STARTER.getType(), execution.getCurrentActivityId())) {
|
||||
BpmnTaskDelegateAssigner assigner = execution.getVariable(INTERNAL_INITIATOR,
|
||||
BpmnTaskDelegateAssigner.class);
|
||||
assignee = assigner.buildAssigneeId();
|
||||
}
|
||||
super.handleAssignments(taskService, assignee, owner, candidateUsers, candidateGroups, task,
|
||||
expressionManager, execution, processEngineConfiguration);
|
||||
|
||||
|
||||
@ -6,20 +6,30 @@ import org.flowable.common.engine.api.delegate.event.FlowableEventType;
|
||||
import static cn.axzo.workflow.core.engine.event.ReceiveTaskEventType.CREATE;
|
||||
|
||||
/**
|
||||
* 接收任务的扩展任务记录表创建的事件实现
|
||||
* 扩展任务记录表创建的事件实现
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2024/2/5 18:27
|
||||
*/
|
||||
public class ReceiveTaskExtInstCreateEvent implements ReceiveTaskExtInstEvent {
|
||||
public class ExtTaskInstCreateEvent implements ExtTaskInstEvent {
|
||||
|
||||
private final String processInstanceId;
|
||||
private final String activityId;
|
||||
private final String taskId;
|
||||
private String assignee;
|
||||
private final BpmnProcessInstanceResultEnum resultEnum;
|
||||
|
||||
public ReceiveTaskExtInstCreateEvent(String processInstanceId, String activityId, String taskId,
|
||||
BpmnProcessInstanceResultEnum resultEnum) {
|
||||
public ExtTaskInstCreateEvent(String processInstanceId, String activityId, String taskId,
|
||||
String assignee, BpmnProcessInstanceResultEnum resultEnum) {
|
||||
this.processInstanceId = processInstanceId;
|
||||
this.activityId = activityId;
|
||||
this.taskId = taskId;
|
||||
this.assignee = assignee;
|
||||
this.resultEnum = resultEnum;
|
||||
}
|
||||
|
||||
public ExtTaskInstCreateEvent(String processInstanceId, String activityId, String taskId,
|
||||
BpmnProcessInstanceResultEnum resultEnum) {
|
||||
this.processInstanceId = processInstanceId;
|
||||
this.activityId = activityId;
|
||||
this.taskId = taskId;
|
||||
@ -38,6 +48,11 @@ public class ReceiveTaskExtInstCreateEvent implements ReceiveTaskExtInstEvent {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssignee() {
|
||||
return assignee;
|
||||
}
|
||||
|
||||
public BpmnProcessInstanceResultEnum getResultEnum() {
|
||||
return resultEnum;
|
||||
}
|
||||
@ -9,7 +9,7 @@ import org.flowable.common.engine.api.delegate.event.FlowableEvent;
|
||||
* @author wangli
|
||||
* @since 2024/2/5 18:26
|
||||
*/
|
||||
public interface ReceiveTaskExtInstEvent extends FlowableEvent {
|
||||
public interface ExtTaskInstEvent extends FlowableEvent {
|
||||
|
||||
String getProcessInstanceId();
|
||||
|
||||
@ -17,6 +17,8 @@ public interface ReceiveTaskExtInstEvent extends FlowableEvent {
|
||||
|
||||
String getTaskId();
|
||||
|
||||
String getAssignee();
|
||||
|
||||
BpmnProcessInstanceResultEnum getResultEnum();
|
||||
|
||||
}
|
||||
@ -3,48 +3,65 @@ package cn.axzo.workflow.core.engine.event;
|
||||
import cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum;
|
||||
import org.flowable.common.engine.api.delegate.event.FlowableEventType;
|
||||
|
||||
import static cn.axzo.workflow.core.engine.event.ReceiveTaskEventType.COMPLETE;
|
||||
import static cn.axzo.workflow.core.engine.event.ReceiveTaskEventType.UPDATE;
|
||||
|
||||
/**
|
||||
* 接收任务的扩展任务记录表创建的事件实现
|
||||
* 扩展任务记录表创建的事件实现
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2024/2/5 18:27
|
||||
* @since 27/03/2024 15:02
|
||||
*/
|
||||
public class ReceiveTaskExtInstCompleteEvent implements ReceiveTaskExtInstEvent {
|
||||
|
||||
public class ExtTaskInstUpdateEvent implements ExtTaskInstEvent {
|
||||
private final String processInstanceId;
|
||||
private final String activityId;
|
||||
private final String taskId;
|
||||
private String assignee;
|
||||
private final BpmnProcessInstanceResultEnum resultEnum;
|
||||
|
||||
public ReceiveTaskExtInstCompleteEvent(String processInstanceId, String activityId, String taskId,
|
||||
BpmnProcessInstanceResultEnum resultEnum) {
|
||||
public ExtTaskInstUpdateEvent(String processInstanceId, String activityId, String taskId,
|
||||
String assignee, BpmnProcessInstanceResultEnum resultEnum) {
|
||||
this.processInstanceId = processInstanceId;
|
||||
this.activityId = activityId;
|
||||
this.taskId = taskId;
|
||||
this.assignee = assignee;
|
||||
this.resultEnum = resultEnum;
|
||||
}
|
||||
|
||||
public ExtTaskInstUpdateEvent(String processInstanceId, String activityId, String taskId,
|
||||
BpmnProcessInstanceResultEnum resultEnum) {
|
||||
this.processInstanceId = processInstanceId;
|
||||
this.activityId = activityId;
|
||||
this.taskId = taskId;
|
||||
this.resultEnum = resultEnum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProcessInstanceId() {
|
||||
return processInstanceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActivityId() {
|
||||
return activityId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssignee() {
|
||||
return assignee;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmnProcessInstanceResultEnum getResultEnum() {
|
||||
return resultEnum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlowableEventType getType() {
|
||||
return COMPLETE;
|
||||
return UPDATE;
|
||||
}
|
||||
|
||||
}
|
||||
@ -15,7 +15,8 @@ import java.util.List;
|
||||
*/
|
||||
public enum ReceiveTaskEventType implements FlowableEventType {
|
||||
CREATE,
|
||||
COMPLETE;
|
||||
UPDATE,
|
||||
;
|
||||
public static final ReceiveTaskEventType[] EMPTY_ARRAY = new ReceiveTaskEventType[]{};
|
||||
|
||||
public static ReceiveTaskEventType[] getTypesFromString(String string) {
|
||||
|
||||
@ -2,15 +2,11 @@ package cn.axzo.workflow.core.engine.listener;
|
||||
|
||||
import cn.axzo.workflow.common.model.request.bpmn.BpmnNoticeConf;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.ExtHiTaskSearchDTO;
|
||||
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
|
||||
import cn.axzo.workflow.core.engine.cmd.CustomCarbonCopyUserSelectorCmd;
|
||||
import cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper;
|
||||
import cn.axzo.workflow.core.engine.event.MessagePushEventBuilder;
|
||||
import cn.axzo.workflow.core.engine.event.MessagePushEventImpl;
|
||||
import cn.axzo.workflow.core.engine.event.MessagePushEventType;
|
||||
import cn.axzo.workflow.core.repository.entity.ExtAxHiTaskInst;
|
||||
import cn.axzo.workflow.core.service.ExtAxHiTaskInstService;
|
||||
import cn.axzo.workflow.core.service.converter.BpmnHistoricTaskInstanceConverter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.bpmn.model.Process;
|
||||
@ -32,11 +28,9 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.COMMENT_TYPE_OPERATION_DESC;
|
||||
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;
|
||||
|
||||
@ -61,8 +55,6 @@ public class EngineCarbonCopyEventListener implements JavaDelegate {
|
||||
@Resource
|
||||
private BpmnHistoricTaskInstanceConverter historicTaskInstanceConverter;
|
||||
@Resource
|
||||
private ExtAxHiTaskInstService extAxHiTaskInstService;
|
||||
@Resource
|
||||
private String serviceVersion;
|
||||
|
||||
@Override
|
||||
@ -88,20 +80,8 @@ public class EngineCarbonCopyEventListener implements JavaDelegate {
|
||||
runtimeService.setVariable(processInstanceId,
|
||||
INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT + currentActivityId, carbonUsers);
|
||||
|
||||
ExtHiTaskSearchDTO searchDTO = new ExtHiTaskSearchDTO();
|
||||
searchDTO.setProcessInstanceId(processInstanceId);
|
||||
searchDTO.setTaskDefinitionKey(currentActivityId);
|
||||
extAxHiTaskInstService.queryList(searchDTO)
|
||||
.stream()
|
||||
.max(Comparator.comparing(ExtAxHiTaskInst::getCreateAt))
|
||||
.ifPresent(i ->
|
||||
CustomTaskHelper.addComment(CommandContextUtil.getCommandContext(), i.getTaskId(),
|
||||
processInstanceId, COMMENT_TYPE_OPERATION_DESC, "抄送" + carbonUsers.size() + "人"));
|
||||
|
||||
// 发送抄送事件
|
||||
invokeCarbonCopy(carbonUsers, BpmnMetaParserHelper.getNoticeConfig(mainProcess), execution);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void invokeCarbonCopy(List<BpmnTaskDelegateAssigner> carbonUsers,
|
||||
|
||||
@ -87,20 +87,14 @@ public class EngineExecutionStartListener implements ExecutionListener {
|
||||
if (execution.hasVariable(assigneeListVariableName)) {
|
||||
return;
|
||||
}
|
||||
if (Objects.equals(NODE_STARTER.getType(), currentActivityId)) {
|
||||
// UserTask 多实例, 该变量用于引擎
|
||||
BpmnTaskDelegateAssigner initiator = execution.getVariable(INTERNAL_INITIATOR,
|
||||
BpmnTaskDelegateAssigner.class);
|
||||
execution.setVariable(assigneeListVariableName, initiator.buildAssigneeId());
|
||||
|
||||
execution.setVariable(INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT + currentActivityId,
|
||||
Lists.newArrayList(initiator));
|
||||
return;
|
||||
}
|
||||
|
||||
Process mainProcess = ProcessDefinitionUtil.getBpmnModel(execution.getProcessDefinitionId()).getMainProcess();
|
||||
UserTask userTask = (UserTask) mainProcess.getFlowElement(currentActivityId);
|
||||
|
||||
Optional<BpmnFlowNodeType> nodeType = getNodeType(userTask);
|
||||
if (nodeType.isPresent() && Objects.equals(nodeType.get(), NODE_STARTER)) {
|
||||
|
||||
}
|
||||
|
||||
// 从 version=1.2.1-SNAPSHOT 开始,才给 process 节点增加了 serverVersion 属性
|
||||
Optional<String> processServerVersion = getProcessServerVersion(mainProcess);
|
||||
if (processServerVersion.isPresent()) {
|
||||
@ -117,7 +111,18 @@ public class EngineExecutionStartListener implements ExecutionListener {
|
||||
DefaultArtifactVersion supportVersion = new DefaultArtifactVersion(FLOW_SERVER_VERSION_121);
|
||||
DefaultArtifactVersion currentVersion = new DefaultArtifactVersion(processServerVersion);
|
||||
if (currentVersion.compareTo(supportVersion) >= 0 && nodeType.isPresent()
|
||||
&& (Objects.equals(NODE_TASK, nodeType.get()) || Objects.equals(NODE_BUSINESS, nodeType.get()))) {
|
||||
&& (Objects.equals(NODE_TASK, nodeType.get()) || Objects.equals(NODE_BUSINESS, nodeType.get()) || Objects.equals(NODE_STARTER, nodeType.get()))) {
|
||||
if (Objects.equals(NODE_STARTER, nodeType.get())) {
|
||||
// UserTask 多实例, 该变量用于引擎
|
||||
BpmnTaskDelegateAssigner initiator = execution.getVariable(INTERNAL_INITIATOR,
|
||||
BpmnTaskDelegateAssigner.class);
|
||||
|
||||
// 仅用于节点人员快照
|
||||
execution.setVariable(INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT + currentActivityId,
|
||||
Lists.newArrayList(initiator));
|
||||
return;
|
||||
}
|
||||
|
||||
getApprovalMethod(userTask).ifPresent(method -> {
|
||||
List<String> assigneeIdList = new ArrayList<>();
|
||||
switch (method) {
|
||||
|
||||
@ -2,12 +2,16 @@ package cn.axzo.workflow.core.listener.impl;
|
||||
|
||||
import cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
|
||||
import cn.axzo.workflow.core.engine.event.ExtTaskInstCreateEvent;
|
||||
import cn.axzo.workflow.core.engine.event.ExtTaskInstUpdateEvent;
|
||||
import cn.axzo.workflow.core.listener.BpmnTaskEventListener;
|
||||
import cn.axzo.workflow.core.repository.entity.ExtAxHiTaskInst;
|
||||
import cn.axzo.workflow.core.service.ExtAxHiTaskInstService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.common.engine.api.delegate.event.FlowableEventDispatcher;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||
import org.flowable.task.service.delegate.DelegateTask;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -18,6 +22,7 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.OLD_INTERNAL_INITIA
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_COMPLETE_OPERATION_TYPE;
|
||||
import static cn.axzo.workflow.common.enums.BpmnFlowNodeType.NODE_STARTER;
|
||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.DELETED;
|
||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.PROCESSING;
|
||||
|
||||
/**
|
||||
* Core 包内置的,可共用与 Jar 包集成和微服务集成
|
||||
@ -37,13 +42,19 @@ public class InternalExtAxTaskInstEvent_min_Listener implements BpmnTaskEventLis
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreated(DelegateTask delegateTask) {
|
||||
ProcessEngineConfigurationImpl processEngineConfiguration =
|
||||
CommandContextUtil.getProcessEngineConfiguration();
|
||||
FlowableEventDispatcher eventDispatcher = processEngineConfiguration.getEventDispatcher();
|
||||
eventDispatcher.dispatchEvent(new ExtTaskInstCreateEvent(delegateTask.getProcessInstanceId(),
|
||||
delegateTask.getTaskDefinitionKey(), delegateTask.getId(), PROCESSING),
|
||||
processEngineConfiguration.getEngineCfgKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAssigned(DelegateTask delegateTask) {
|
||||
ExtAxHiTaskInst entity = new ExtAxHiTaskInst();
|
||||
entity.setProcInstId(delegateTask.getProcessInstanceId());
|
||||
entity.setTaskDefinitionKey(delegateTask.getTaskDefinitionKey());
|
||||
entity.setTaskId(delegateTask.getId());
|
||||
entity.setStatus(BpmnProcessInstanceResultEnum.PROCESSING.getStatus());
|
||||
String assignee;
|
||||
// 记录发起人
|
||||
if (Objects.equals(delegateTask.getTaskDefinitionKey(), NODE_STARTER.getType())) {
|
||||
BpmnTaskDelegateAssigner assigner =
|
||||
@ -54,11 +65,19 @@ public class InternalExtAxTaskInstEvent_min_Listener implements BpmnTaskEventLis
|
||||
assigner = (BpmnTaskDelegateAssigner) runtimeService.getVariable(delegateTask.getProcessInstanceId(),
|
||||
OLD_INTERNAL_INITIATOR);
|
||||
}
|
||||
entity.setAssignee(assigner.buildAssigneeId());
|
||||
assignee = assigner.buildAssigneeId();
|
||||
} else {
|
||||
entity.setAssignee(delegateTask.getAssignee());
|
||||
assignee = delegateTask.getAssignee();
|
||||
}
|
||||
hiTaskInstService.save(entity);
|
||||
|
||||
|
||||
ProcessEngineConfigurationImpl processEngineConfiguration =
|
||||
CommandContextUtil.getProcessEngineConfiguration();
|
||||
FlowableEventDispatcher eventDispatcher = processEngineConfiguration.getEventDispatcher();
|
||||
eventDispatcher.dispatchEvent(new ExtTaskInstUpdateEvent(delegateTask.getProcessInstanceId(),
|
||||
delegateTask.getTaskDefinitionKey(), delegateTask.getId(), assignee, PROCESSING),
|
||||
processEngineConfiguration.getEngineCfgKey());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -68,17 +87,18 @@ public class InternalExtAxTaskInstEvent_min_Listener implements BpmnTaskEventLis
|
||||
log.debug("taskId:{}, operationType:{}", delegateTask.getId(), operationType);
|
||||
}
|
||||
|
||||
ExtAxHiTaskInst taskInst = hiTaskInstService.getByTaskId(delegateTask.getId(),
|
||||
delegateTask.getProcessInstanceId());
|
||||
if (Objects.isNull(taskInst)) {
|
||||
return;
|
||||
}
|
||||
// 多实例或签同意时,无法正确区分状态, 所以默认认为这种是无需展示在日志中的
|
||||
BpmnProcessInstanceResultEnum resultEnum = DELETED;
|
||||
|
||||
if (Objects.nonNull(operationType)) {
|
||||
taskInst.setStatus(String.valueOf(operationType));
|
||||
} else {
|
||||
// 多实例或签同意时,无法正确区分状态, 所以默认认为这种是无需展示在日志中的
|
||||
taskInst.setStatus(DELETED.getStatus());
|
||||
resultEnum = BpmnProcessInstanceResultEnum.valueOfStatus(String.valueOf(operationType));
|
||||
}
|
||||
hiTaskInstService.update(taskInst);
|
||||
|
||||
ProcessEngineConfigurationImpl processEngineConfiguration =
|
||||
CommandContextUtil.getProcessEngineConfiguration();
|
||||
FlowableEventDispatcher eventDispatcher = processEngineConfiguration.getEventDispatcher();
|
||||
eventDispatcher.dispatchEvent(new ExtTaskInstUpdateEvent(delegateTask.getProcessInstanceId(),
|
||||
delegateTask.getTaskDefinitionKey(), delegateTask.getId(), resultEnum),
|
||||
processEngineConfiguration.getEngineCfgKey());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
package cn.axzo.workflow.core.listener.impl;
|
||||
|
||||
import cn.axzo.workflow.core.engine.event.ExtTaskInstCreateEvent;
|
||||
import cn.axzo.workflow.core.engine.event.ExtTaskInstEvent;
|
||||
import cn.axzo.workflow.core.engine.event.ExtTaskInstUpdateEvent;
|
||||
import cn.axzo.workflow.core.engine.event.ReceiveTaskEventType;
|
||||
import cn.axzo.workflow.core.engine.event.ReceiveTaskExtInstCompleteEvent;
|
||||
import cn.axzo.workflow.core.engine.event.ReceiveTaskExtInstCreateEvent;
|
||||
import cn.axzo.workflow.core.engine.event.ReceiveTaskExtInstEvent;
|
||||
import cn.axzo.workflow.core.repository.entity.ExtAxHiTaskInst;
|
||||
import cn.axzo.workflow.core.service.ExtAxHiTaskInstService;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@ -16,8 +16,8 @@ import org.springframework.stereotype.Component;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.axzo.workflow.core.engine.event.ReceiveTaskEventType.COMPLETE;
|
||||
import static cn.axzo.workflow.core.engine.event.ReceiveTaskEventType.CREATE;
|
||||
import static cn.axzo.workflow.core.engine.event.ReceiveTaskEventType.UPDATE;
|
||||
|
||||
/**
|
||||
* 操作 ext_ax_taskinst 表的事件
|
||||
@ -33,21 +33,21 @@ public class ReceiveTaskExtInstEventListener extends AbstractFlowableEventListen
|
||||
public static final Set<ReceiveTaskEventType> SUPPORT_EVENTS =
|
||||
ImmutableSet.<ReceiveTaskEventType>builder()
|
||||
.add(CREATE)
|
||||
.add(COMPLETE)
|
||||
.add(UPDATE)
|
||||
.build();
|
||||
|
||||
@Override
|
||||
public void onEvent(FlowableEvent flowableEvent) {
|
||||
if (flowableEvent instanceof ReceiveTaskExtInstEvent) {
|
||||
ReceiveTaskExtInstEvent event = (ReceiveTaskExtInstEvent) flowableEvent;
|
||||
if (flowableEvent instanceof ExtTaskInstEvent) {
|
||||
ExtTaskInstEvent event = (ExtTaskInstEvent) flowableEvent;
|
||||
ReceiveTaskEventType eventType = (ReceiveTaskEventType) flowableEvent.getType();
|
||||
if (SUPPORT_EVENTS.contains(eventType)) {
|
||||
switch (eventType) {
|
||||
case CREATE:
|
||||
saveExtTaskInst((ReceiveTaskExtInstCreateEvent) event);
|
||||
saveExtTaskInst((ExtTaskInstCreateEvent) event);
|
||||
break;
|
||||
case COMPLETE:
|
||||
updateExtTaskInst((ReceiveTaskExtInstCompleteEvent) event);
|
||||
case UPDATE:
|
||||
updateExtTaskInst((ExtTaskInstUpdateEvent) event);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
@ -60,19 +60,21 @@ public class ReceiveTaskExtInstEventListener extends AbstractFlowableEventListen
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateExtTaskInst(ReceiveTaskExtInstCompleteEvent event) {
|
||||
private void updateExtTaskInst(ExtTaskInstUpdateEvent event) {
|
||||
ExtAxHiTaskInst entity = extAxHiTaskInstService.getByTaskId(event.getTaskId(), event.getProcessInstanceId());
|
||||
if (Objects.nonNull(entity)) {
|
||||
entity.setAssignee(event.getAssignee());
|
||||
entity.setStatus(event.getResultEnum().getStatus());
|
||||
extAxHiTaskInstService.update(entity);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveExtTaskInst(ReceiveTaskExtInstCreateEvent event) {
|
||||
private void saveExtTaskInst(ExtTaskInstCreateEvent event) {
|
||||
ExtAxHiTaskInst entity = new ExtAxHiTaskInst();
|
||||
entity.setProcInstId(event.getProcessInstanceId());
|
||||
entity.setTaskDefinitionKey(event.getActivityId());
|
||||
entity.setTaskId(event.getTaskId());
|
||||
entity.setAssignee(event.getAssignee());
|
||||
entity.setStatus(event.getResultEnum().getStatus());
|
||||
extAxHiTaskInstService.save(entity);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user