add - 业务节点"不设置"审批人的审批日志处理
This commit is contained in:
parent
230270f2b9
commit
0d42431e9e
@ -1,6 +1,10 @@
|
|||||||
package cn.axzo.workflow.core.engine.behavior;
|
package cn.axzo.workflow.core.engine.behavior;
|
||||||
|
|
||||||
|
import cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum;
|
||||||
|
import cn.axzo.workflow.core.engine.event.ReceiveTaskExtInstCreateEventImpl;
|
||||||
|
import cn.axzo.workflow.core.service.ExtAxHiTaskInstService;
|
||||||
import org.flowable.bpmn.model.ReceiveTask;
|
import org.flowable.bpmn.model.ReceiveTask;
|
||||||
|
import org.flowable.common.engine.api.delegate.event.FlowableEventDispatcher;
|
||||||
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||||
import org.flowable.engine.delegate.DelegateExecution;
|
import org.flowable.engine.delegate.DelegateExecution;
|
||||||
import org.flowable.engine.impl.bpmn.behavior.ReceiveTaskActivityBehavior;
|
import org.flowable.engine.impl.bpmn.behavior.ReceiveTaskActivityBehavior;
|
||||||
@ -18,7 +22,7 @@ import org.flowable.task.service.impl.persistence.entity.TaskEntity;
|
|||||||
* @since 2023/11/23 14:41
|
* @since 2023/11/23 14:41
|
||||||
*/
|
*/
|
||||||
public class CustomReceiveTaskActivityBehavior extends ReceiveTaskActivityBehavior {
|
public class CustomReceiveTaskActivityBehavior extends ReceiveTaskActivityBehavior {
|
||||||
|
private ExtAxHiTaskInstService hiTaskInstService;
|
||||||
protected ReceiveTask receiveTask;
|
protected ReceiveTask receiveTask;
|
||||||
|
|
||||||
public CustomReceiveTaskActivityBehavior(ReceiveTask receiveTask) {
|
public CustomReceiveTaskActivityBehavior(ReceiveTask receiveTask) {
|
||||||
@ -39,6 +43,12 @@ public class CustomReceiveTaskActivityBehavior extends ReceiveTaskActivityBehavi
|
|||||||
task.setPropagatedStageInstanceId(execution.getPropagatedStageInstanceId());
|
task.setPropagatedStageInstanceId(execution.getPropagatedStageInstanceId());
|
||||||
task.setName(receiveTask.getName());
|
task.setName(receiveTask.getName());
|
||||||
TaskHelper.insertTask(task, (ExecutionEntity) execution, false, false);
|
TaskHelper.insertTask(task, (ExecutionEntity) execution, false, false);
|
||||||
|
|
||||||
|
FlowableEventDispatcher eventDispatcher = processEngineConfiguration.getEventDispatcher();
|
||||||
|
|
||||||
|
eventDispatcher.dispatchEvent(new ReceiveTaskExtInstCreateEventImpl(execution.getProcessInstanceId(),
|
||||||
|
receiveTask.getId(), task.getId(), BpmnProcessInstanceResultEnum.APPROVED),
|
||||||
|
processEngineConfiguration.getEngineCfgKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -0,0 +1,42 @@
|
|||||||
|
package cn.axzo.workflow.core.engine.event;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.flowable.common.engine.api.FlowableIllegalArgumentException;
|
||||||
|
import org.flowable.common.engine.api.delegate.event.FlowableEventType;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接收任务的扩展表任务创建时间类型
|
||||||
|
*
|
||||||
|
* @author wangli
|
||||||
|
* @since 2024/2/5 18:46
|
||||||
|
*/
|
||||||
|
public enum ReceiveTaskCreateEventType implements FlowableEventType {
|
||||||
|
|
||||||
|
COMPLETE;
|
||||||
|
public static final ReceiveTaskCreateEventType[] EMPTY_ARRAY = new ReceiveTaskCreateEventType[]{};
|
||||||
|
|
||||||
|
public static ReceiveTaskCreateEventType[] getTypesFromString(String string) {
|
||||||
|
List<ReceiveTaskCreateEventType> result = new ArrayList<>();
|
||||||
|
if (string != null && !string.isEmpty()) {
|
||||||
|
String[] split = StringUtils.split(string, ",");
|
||||||
|
for (String typeName : split) {
|
||||||
|
boolean found = false;
|
||||||
|
for (ReceiveTaskCreateEventType type : values()) {
|
||||||
|
if (typeName.toUpperCase().equals(type.name())) {
|
||||||
|
result.add(type);
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
throw new FlowableIllegalArgumentException("Invalid event-type: " + typeName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.toArray(EMPTY_ARRAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package cn.axzo.workflow.core.engine.event;
|
||||||
|
|
||||||
|
import cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum;
|
||||||
|
import org.flowable.common.engine.api.delegate.event.FlowableEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接收任务的扩展任务记录表创建的事件
|
||||||
|
*
|
||||||
|
* @author wangli
|
||||||
|
* @since 2024/2/5 18:26
|
||||||
|
*/
|
||||||
|
public interface ReceiveTaskExtInstCreateEvent extends FlowableEvent {
|
||||||
|
|
||||||
|
String getProcessInstanceId();
|
||||||
|
|
||||||
|
String getActivityId();
|
||||||
|
|
||||||
|
String getTaskId();
|
||||||
|
|
||||||
|
BpmnProcessInstanceResultEnum getResultEnum();
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
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.ReceiveTaskCreateEventType.COMPLETE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接收任务的扩展任务记录表创建的事件实现
|
||||||
|
*
|
||||||
|
* @author wangli
|
||||||
|
* @since 2024/2/5 18:27
|
||||||
|
*/
|
||||||
|
public class ReceiveTaskExtInstCreateEventImpl implements ReceiveTaskExtInstCreateEvent {
|
||||||
|
|
||||||
|
private final String processInstanceId;
|
||||||
|
private final String activityId;
|
||||||
|
private final String taskId;
|
||||||
|
private final BpmnProcessInstanceResultEnum resultEnum;
|
||||||
|
|
||||||
|
public ReceiveTaskExtInstCreateEventImpl(String processInstanceId, String activityId, String taskId,
|
||||||
|
BpmnProcessInstanceResultEnum resultEnum) {
|
||||||
|
this.processInstanceId = processInstanceId;
|
||||||
|
this.activityId = activityId;
|
||||||
|
this.taskId = taskId;
|
||||||
|
this.resultEnum = resultEnum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProcessInstanceId() {
|
||||||
|
return processInstanceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActivityId() {
|
||||||
|
return activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTaskId() {
|
||||||
|
return taskId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BpmnProcessInstanceResultEnum getResultEnum() {
|
||||||
|
return resultEnum;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FlowableEventType getType() {
|
||||||
|
return COMPLETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
package cn.axzo.workflow.core.listener.impl;
|
||||||
|
|
||||||
|
import cn.axzo.workflow.core.engine.event.ReceiveTaskCreateEventType;
|
||||||
|
import cn.axzo.workflow.core.engine.event.ReceiveTaskExtInstCreateEvent;
|
||||||
|
import cn.axzo.workflow.core.repository.entity.ExtAxHiTaskInst;
|
||||||
|
import cn.axzo.workflow.core.service.ExtAxHiTaskInstService;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.flowable.common.engine.api.delegate.event.AbstractFlowableEventListener;
|
||||||
|
import org.flowable.common.engine.api.delegate.event.FlowableEvent;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static cn.axzo.workflow.core.engine.event.ReceiveTaskCreateEventType.COMPLETE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* @author wangli
|
||||||
|
* @since 2024/2/5 18:39
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class ReceiveTaskExtInstCreateEventListener extends AbstractFlowableEventListener {
|
||||||
|
private final ExtAxHiTaskInstService extAxHiTaskInstService;
|
||||||
|
public static final Set<ReceiveTaskCreateEventType> SUPPORT_EVENTS =
|
||||||
|
ImmutableSet.<ReceiveTaskCreateEventType>builder()
|
||||||
|
.add(COMPLETE)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEvent(FlowableEvent flowableEvent) {
|
||||||
|
if (flowableEvent instanceof ReceiveTaskExtInstCreateEvent) {
|
||||||
|
ReceiveTaskExtInstCreateEvent event = (ReceiveTaskExtInstCreateEvent) flowableEvent;
|
||||||
|
ReceiveTaskCreateEventType type = (ReceiveTaskCreateEventType) event.getType();
|
||||||
|
if (SUPPORT_EVENTS.contains(type)) {
|
||||||
|
saveExtTaskInst(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFailOnException() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveExtTaskInst(ReceiveTaskExtInstCreateEvent event) {
|
||||||
|
ExtAxHiTaskInst entity = new ExtAxHiTaskInst();
|
||||||
|
entity.setProcInstId(event.getProcessInstanceId());
|
||||||
|
entity.setTaskDefinitionKey(event.getActivityId());
|
||||||
|
entity.setTaskId(event.getTaskId());
|
||||||
|
entity.setStatus(event.getResultEnum().getStatus());
|
||||||
|
extAxHiTaskInstService.save(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user