add - 添加获取指定流程实例的运行图接口
This commit is contained in:
parent
edecba9f05
commit
13112303a6
@ -0,0 +1,14 @@
|
||||
package cn.axzo.workflow.core.repository.mapper;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2023/7/27 11:38
|
||||
*/
|
||||
public interface InfoMapper {
|
||||
|
||||
ArrayNode map(Object element);
|
||||
}
|
||||
@ -5,6 +5,7 @@ import cn.axzo.workflow.core.service.dto.request.process.*;
|
||||
import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
|
||||
import cn.axzo.workflow.core.service.dto.response.process.BpmProcessInstancePageItemVO;
|
||||
import cn.axzo.workflow.core.service.dto.response.process.BpmProcessInstanceVO;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.form.api.FormInfo;
|
||||
|
||||
@ -86,7 +87,7 @@ public interface BpmProcessInstanceService {
|
||||
|
||||
void deleteProcessInstance(String id, String reason, BpmProcessInstanceResultEnum resultEnum);
|
||||
|
||||
|
||||
ObjectNode getProcessInstanceGraphical(String processInstanceId, @Nullable String tenantId);
|
||||
|
||||
// /**
|
||||
// * 创还能 ProcessInstance 扩展记录
|
||||
|
||||
@ -4,6 +4,7 @@ import cn.axzo.workflow.core.common.enums.BpmProcessInstanceDeleteReasonEnum;
|
||||
import cn.axzo.workflow.core.common.enums.BpmProcessInstanceResultEnum;
|
||||
import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
|
||||
import cn.axzo.workflow.core.common.utils.BpmCollectionUtils;
|
||||
import cn.axzo.workflow.core.repository.mapper.InfoMapper;
|
||||
import cn.axzo.workflow.core.service.BpmProcessDefinitionService;
|
||||
import cn.axzo.workflow.core.service.BpmProcessInstanceService;
|
||||
import cn.axzo.workflow.core.service.converter.BpmHistoricProcessInstanceConverter;
|
||||
@ -15,16 +16,22 @@ import cn.axzo.workflow.core.service.dto.response.process.BpmProcessInstancePage
|
||||
import cn.axzo.workflow.core.service.dto.response.process.BpmProcessInstanceVO;
|
||||
import cn.azxo.framework.common.utils.StringUtils;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.bpmn.model.*;
|
||||
import org.flowable.common.engine.impl.db.SuspensionState;
|
||||
import org.flowable.common.engine.impl.identity.Authentication;
|
||||
import org.flowable.engine.HistoryService;
|
||||
import org.flowable.engine.RepositoryService;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.TaskService;
|
||||
import org.flowable.engine.history.HistoricActivityInstance;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.history.HistoricProcessInstanceQuery;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.flowable.engine.runtime.ProcessInstanceQuery;
|
||||
import org.flowable.form.api.FormInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
@ -59,9 +66,13 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||
@Autowired
|
||||
private HistoryService historyService;
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
@Resource
|
||||
private BpmProcessInstancePageItemConverter instancePageItemConverter;
|
||||
@Resource
|
||||
private BpmHistoricProcessInstanceConverter instanceConverter;
|
||||
protected List<String> eventElementTypes = new ArrayList<>();
|
||||
protected Map<String, InfoMapper> propertyMappers = new HashMap<>();
|
||||
|
||||
|
||||
@Override
|
||||
@ -439,4 +450,433 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||
public List<HistoricProcessInstance> getHistoricProcessInstances(Set<String> ids) {
|
||||
return historyService.createHistoricProcessInstanceQuery().processInstanceIds(ids).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectNode getProcessInstanceGraphical(String processInstanceId, @Nullable String tenantId) {
|
||||
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery()
|
||||
.processInstanceId(processInstanceId);
|
||||
if (StringUtils.isNotBlank(tenantId)) {
|
||||
query.processInstanceTenantId(tenantId);
|
||||
}
|
||||
ProcessInstance processInstance = query.singleResult();
|
||||
if (Objects.isNull(processInstance)) {
|
||||
throw new WorkflowEngineException("实例不存在");
|
||||
}
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
|
||||
|
||||
List<HistoricActivityInstance> activityInstances =
|
||||
historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list();
|
||||
|
||||
Set<String> completedActivityInstances = new HashSet<>();
|
||||
Set<String> currentElements = new HashSet<>();
|
||||
if (!CollectionUtils.isEmpty(activityInstances)) {
|
||||
for (HistoricActivityInstance activityInstance : activityInstances) {
|
||||
if (activityInstance.getEndTime() != null) {
|
||||
completedActivityInstances.add(activityInstance.getActivityId());
|
||||
} else {
|
||||
currentElements.add(activityInstance.getActivityId());
|
||||
}
|
||||
}
|
||||
}
|
||||
// Gather completed flows
|
||||
List<String> completedFlows = gatherCompletedFlows(completedActivityInstances, currentElements, bpmnModel);
|
||||
|
||||
Set<String> completedElements = new HashSet<>(completedActivityInstances);
|
||||
completedElements.addAll(completedFlows);
|
||||
|
||||
ObjectNode displayNode = processProcessElements(bpmnModel, completedElements, currentElements,
|
||||
new ArrayList<>(), processInstanceId);
|
||||
if (completedActivityInstances != null) {
|
||||
ArrayNode completedActivities = displayNode.putArray("completedActivities");
|
||||
for (String completed : completedActivityInstances) {
|
||||
completedActivities.add(completed);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentElements != null) {
|
||||
ArrayNode currentActivities = displayNode.putArray("currentActivities");
|
||||
for (String current : currentElements) {
|
||||
currentActivities.add(current);
|
||||
}
|
||||
}
|
||||
|
||||
if (completedFlows != null) {
|
||||
ArrayNode completedSequenceFlows = displayNode.putArray("completedSequenceFlows");
|
||||
for (String current : completedFlows) {
|
||||
completedSequenceFlows.add(current);
|
||||
}
|
||||
}
|
||||
return displayNode;
|
||||
}
|
||||
|
||||
protected List<String> gatherCompletedFlows(Set<String> completedActivityInstances,
|
||||
Set<String> currentActivityinstances, BpmnModel pojoModel) {
|
||||
|
||||
List<String> completedFlows = new ArrayList<>();
|
||||
List<String> activities = new ArrayList<>(completedActivityInstances);
|
||||
activities.addAll(currentActivityinstances);
|
||||
|
||||
// TODO: not a robust way of checking when parallel paths are active, should be revisited
|
||||
// Go over all activities and check if it's possible to match any outgoing paths against the activities
|
||||
for (FlowElement activity : pojoModel.getMainProcess().getFlowElements()) {
|
||||
if (activity instanceof FlowNode) {
|
||||
int index = activities.indexOf(activity.getId());
|
||||
if (index >= 0 && index + 1 < activities.size()) {
|
||||
List<SequenceFlow> outgoingFlows = ((FlowNode) activity).getOutgoingFlows();
|
||||
for (SequenceFlow flow : outgoingFlows) {
|
||||
String destinationFlowId = flow.getTargetRef();
|
||||
if (destinationFlowId.equals(activities.get(index + 1))) {
|
||||
completedFlows.add(flow.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return completedFlows;
|
||||
}
|
||||
|
||||
protected ObjectNode processProcessElements(BpmnModel pojoModel, Set<String> completedElements,
|
||||
Set<String> currentElements, Collection<String> breakpoints,
|
||||
String processInstanceId) {
|
||||
ObjectNode displayNode = objectMapper.createObjectNode();
|
||||
GraphicInfo diagramInfo = new GraphicInfo();
|
||||
|
||||
ArrayNode elementArray = objectMapper.createArrayNode();
|
||||
ArrayNode flowArray = objectMapper.createArrayNode();
|
||||
ArrayNode collapsedArray = objectMapper.createArrayNode();
|
||||
|
||||
if (!CollectionUtils.isEmpty(pojoModel.getPools())) {
|
||||
ArrayNode poolArray = objectMapper.createArrayNode();
|
||||
boolean firstElement = true;
|
||||
for (Pool pool : pojoModel.getPools()) {
|
||||
ObjectNode poolNode = objectMapper.createObjectNode();
|
||||
poolNode.put("id", pool.getId());
|
||||
poolNode.put("name", pool.getName());
|
||||
GraphicInfo poolInfo = pojoModel.getGraphicInfo(pool.getId());
|
||||
fillGraphicInfo(poolNode, poolInfo, true);
|
||||
org.flowable.bpmn.model.Process process = pojoModel.getProcess(pool.getId());
|
||||
if (process != null && !CollectionUtils.isEmpty(process.getLanes())) {
|
||||
ArrayNode laneArray = objectMapper.createArrayNode();
|
||||
for (Lane lane : process.getLanes()) {
|
||||
ObjectNode laneNode = objectMapper.createObjectNode();
|
||||
laneNode.put("id", lane.getId());
|
||||
laneNode.put("name", lane.getName());
|
||||
fillGraphicInfo(laneNode, pojoModel.getGraphicInfo(lane.getId()), true);
|
||||
laneArray.add(laneNode);
|
||||
}
|
||||
poolNode.set("lanes", laneArray);
|
||||
}
|
||||
poolArray.add(poolNode);
|
||||
|
||||
double rightX = poolInfo.getX() + poolInfo.getWidth();
|
||||
double bottomY = poolInfo.getY() + poolInfo.getHeight();
|
||||
double middleX = poolInfo.getX() + (poolInfo.getWidth() / 2);
|
||||
if (firstElement || middleX < diagramInfo.getX()) {
|
||||
diagramInfo.setX(middleX);
|
||||
}
|
||||
if (firstElement || poolInfo.getY() < diagramInfo.getY()) {
|
||||
diagramInfo.setY(poolInfo.getY());
|
||||
}
|
||||
if (rightX > diagramInfo.getWidth()) {
|
||||
diagramInfo.setWidth(rightX);
|
||||
}
|
||||
if (bottomY > diagramInfo.getHeight()) {
|
||||
diagramInfo.setHeight(bottomY);
|
||||
}
|
||||
firstElement = false;
|
||||
}
|
||||
displayNode.set("pools", poolArray);
|
||||
|
||||
} else {
|
||||
// in initialize with fake x and y to make sure the minimal
|
||||
// values are set
|
||||
diagramInfo.setX(9999);
|
||||
diagramInfo.setY(1000);
|
||||
}
|
||||
|
||||
for (org.flowable.bpmn.model.Process process : pojoModel.getProcesses()) {
|
||||
processElements(process.getFlowElements(), pojoModel, elementArray, flowArray, collapsedArray,
|
||||
diagramInfo, completedElements, currentElements, breakpoints, null, processInstanceId);
|
||||
processArtifacts(process.getArtifacts(), pojoModel, elementArray, flowArray, diagramInfo);
|
||||
}
|
||||
|
||||
displayNode.set("elements", elementArray);
|
||||
displayNode.set("flows", flowArray);
|
||||
displayNode.set("collapsed", collapsedArray);
|
||||
|
||||
displayNode.put("diagramBeginX", diagramInfo.getX());
|
||||
displayNode.put("diagramBeginY", diagramInfo.getY());
|
||||
displayNode.put("diagramWidth", diagramInfo.getWidth());
|
||||
displayNode.put("diagramHeight", diagramInfo.getHeight());
|
||||
return displayNode;
|
||||
}
|
||||
|
||||
protected void fillGraphicInfo(ObjectNode elementNode, GraphicInfo graphicInfo, boolean includeWidthAndHeight) {
|
||||
commonFillGraphicInfo(elementNode, graphicInfo.getX(), graphicInfo.getY(), graphicInfo.getWidth(),
|
||||
graphicInfo.getHeight(), includeWidthAndHeight);
|
||||
}
|
||||
|
||||
protected void commonFillGraphicInfo(ObjectNode elementNode, double x, double y, double width, double height,
|
||||
boolean includeWidthAndHeight) {
|
||||
|
||||
elementNode.put("x", x);
|
||||
elementNode.put("y", y);
|
||||
if (includeWidthAndHeight) {
|
||||
elementNode.put("width", width);
|
||||
elementNode.put("height", height);
|
||||
}
|
||||
}
|
||||
|
||||
protected void processElements(Collection<FlowElement> elementList, BpmnModel model, ArrayNode elementArray,
|
||||
ArrayNode flowArray,
|
||||
ArrayNode collapsedArray, GraphicInfo diagramInfo, Set<String> completedElements,
|
||||
Set<String> currentElements, Collection<String> breakpoints,
|
||||
ObjectNode collapsedNode, String processInstanceId) {
|
||||
|
||||
for (FlowElement element : elementList) {
|
||||
|
||||
ObjectNode elementNode = objectMapper.createObjectNode();
|
||||
if (completedElements != null) {
|
||||
elementNode.put("completed", completedElements.contains(element.getId()));
|
||||
}
|
||||
if (!breakpoints.isEmpty()) {
|
||||
elementNode.put("breakpoint", breakpoints.contains(element.getId()));
|
||||
}
|
||||
|
||||
if (currentElements != null) {
|
||||
elementNode.put("current", currentElements.contains(element.getId()));
|
||||
}
|
||||
|
||||
if (element instanceof SequenceFlow) {
|
||||
SequenceFlow flow = (SequenceFlow) element;
|
||||
elementNode.put("id", flow.getId());
|
||||
elementNode.put("type", "sequenceFlow");
|
||||
elementNode.put("sourceRef", flow.getSourceRef());
|
||||
elementNode.put("targetRef", flow.getTargetRef());
|
||||
elementNode.put("name", flow.getName());
|
||||
List<GraphicInfo> flowInfo = model.getFlowLocationGraphicInfo(flow.getId());
|
||||
if (!CollectionUtils.isEmpty(flowInfo)) {
|
||||
ArrayNode waypointArray = objectMapper.createArrayNode();
|
||||
for (GraphicInfo graphicInfo : flowInfo) {
|
||||
ObjectNode pointNode = objectMapper.createObjectNode();
|
||||
fillGraphicInfo(pointNode, graphicInfo, false);
|
||||
waypointArray.add(pointNode);
|
||||
fillDiagramInfo(graphicInfo, diagramInfo);
|
||||
}
|
||||
elementNode.set("waypoints", waypointArray);
|
||||
|
||||
String className = element.getClass().getSimpleName();
|
||||
if (propertyMappers.containsKey(className)) {
|
||||
elementNode.set("properties", propertyMappers.get(className).map(element));
|
||||
}
|
||||
|
||||
if (collapsedNode != null) {
|
||||
((ArrayNode) collapsedNode.get("flows")).add(elementNode);
|
||||
} else {
|
||||
flowArray.add(elementNode);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
elementNode.put("id", element.getId());
|
||||
elementNode.put("name", element.getName());
|
||||
|
||||
GraphicInfo graphicInfo = model.getGraphicInfo(element.getId());
|
||||
if (graphicInfo != null) {
|
||||
fillGraphicInfo(elementNode, graphicInfo, true);
|
||||
fillDiagramInfo(graphicInfo, diagramInfo);
|
||||
}
|
||||
|
||||
String className = element.getClass().getSimpleName();
|
||||
elementNode.put("type", className);
|
||||
fillEventTypes(className, element, elementNode);
|
||||
|
||||
if (element instanceof ServiceTask) {
|
||||
ServiceTask serviceTask = (ServiceTask) element;
|
||||
if (ServiceTask.MAIL_TASK.equals(serviceTask.getType())) {
|
||||
elementNode.put("taskType", "mail");
|
||||
|
||||
} else if ("camel".equals(serviceTask.getType())) {
|
||||
elementNode.put("taskType", "camel");
|
||||
|
||||
} else if ("mule".equals(serviceTask.getType())) {
|
||||
elementNode.put("taskType", "mule");
|
||||
|
||||
} else if (ServiceTask.HTTP_TASK.equals(serviceTask.getType())) {
|
||||
elementNode.put("taskType", "http");
|
||||
} else if (ServiceTask.SHELL_TASK.equals(serviceTask.getType())) {
|
||||
elementNode.put("taskType", "shell");
|
||||
}
|
||||
}
|
||||
|
||||
if (propertyMappers.containsKey(className)) {
|
||||
elementNode.set("properties", propertyMappers.get(className).map(element));
|
||||
}
|
||||
|
||||
if (collapsedNode != null) {
|
||||
((ArrayNode) collapsedNode.get("elements")).add(elementNode);
|
||||
} else {
|
||||
elementArray.add(elementNode);
|
||||
}
|
||||
|
||||
if (element instanceof SubProcess) {
|
||||
SubProcess subProcess = (SubProcess) element;
|
||||
ObjectNode newCollapsedNode = collapsedNode;
|
||||
// skip collapsed sub processes
|
||||
if (graphicInfo != null && graphicInfo.getExpanded() != null && !graphicInfo.getExpanded()) {
|
||||
elementNode.put("collapsed", "true");
|
||||
newCollapsedNode = objectMapper.createObjectNode();
|
||||
newCollapsedNode.put("id", subProcess.getId());
|
||||
newCollapsedNode.putArray("elements");
|
||||
newCollapsedNode.putArray("flows");
|
||||
collapsedArray.add(newCollapsedNode);
|
||||
}
|
||||
|
||||
processElements(subProcess.getFlowElements(), model, elementArray, flowArray, collapsedArray,
|
||||
diagramInfo, completedElements, currentElements, breakpoints, newCollapsedNode,
|
||||
processInstanceId);
|
||||
processArtifacts(subProcess.getArtifacts(), model, elementArray, flowArray, diagramInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void processArtifacts(Collection<Artifact> artifactList, BpmnModel model, ArrayNode elementArray,
|
||||
ArrayNode flowArray, GraphicInfo diagramInfo) {
|
||||
|
||||
for (Artifact artifact : artifactList) {
|
||||
|
||||
if (artifact instanceof Association) {
|
||||
ObjectNode elementNode = objectMapper.createObjectNode();
|
||||
Association flow = (Association) artifact;
|
||||
elementNode.put("id", flow.getId());
|
||||
elementNode.put("type", "association");
|
||||
elementNode.put("sourceRef", flow.getSourceRef());
|
||||
elementNode.put("targetRef", flow.getTargetRef());
|
||||
fillWaypoints(flow.getId(), model, elementNode, diagramInfo);
|
||||
flowArray.add(elementNode);
|
||||
|
||||
} else {
|
||||
|
||||
ObjectNode elementNode = objectMapper.createObjectNode();
|
||||
elementNode.put("id", artifact.getId());
|
||||
|
||||
if (artifact instanceof TextAnnotation) {
|
||||
TextAnnotation annotation = (TextAnnotation) artifact;
|
||||
elementNode.put("text", annotation.getText());
|
||||
}
|
||||
|
||||
GraphicInfo graphicInfo = model.getGraphicInfo(artifact.getId());
|
||||
if (graphicInfo != null) {
|
||||
fillGraphicInfo(elementNode, graphicInfo, true);
|
||||
fillDiagramInfo(graphicInfo, diagramInfo);
|
||||
}
|
||||
|
||||
String className = artifact.getClass().getSimpleName();
|
||||
elementNode.put("type", className);
|
||||
|
||||
elementArray.add(elementNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void fillDiagramInfo(GraphicInfo graphicInfo, GraphicInfo diagramInfo) {
|
||||
double rightX = graphicInfo.getX() + graphicInfo.getWidth();
|
||||
double bottomY = graphicInfo.getY() + graphicInfo.getHeight();
|
||||
double middleX = graphicInfo.getX() + (graphicInfo.getWidth() / 2);
|
||||
if (middleX < diagramInfo.getX()) {
|
||||
diagramInfo.setX(middleX);
|
||||
}
|
||||
if (graphicInfo.getY() < diagramInfo.getY()) {
|
||||
diagramInfo.setY(graphicInfo.getY());
|
||||
}
|
||||
if (rightX > diagramInfo.getWidth()) {
|
||||
diagramInfo.setWidth(rightX);
|
||||
}
|
||||
if (bottomY > diagramInfo.getHeight()) {
|
||||
diagramInfo.setHeight(bottomY);
|
||||
}
|
||||
}
|
||||
|
||||
protected void fillWaypoints(String id, BpmnModel model, ObjectNode elementNode, GraphicInfo diagramInfo) {
|
||||
List<GraphicInfo> flowInfo = model.getFlowLocationGraphicInfo(id);
|
||||
ArrayNode waypointArray = objectMapper.createArrayNode();
|
||||
for (GraphicInfo graphicInfo : flowInfo) {
|
||||
ObjectNode pointNode = objectMapper.createObjectNode();
|
||||
fillGraphicInfo(pointNode, graphicInfo, false);
|
||||
waypointArray.add(pointNode);
|
||||
fillDiagramInfo(graphicInfo, diagramInfo);
|
||||
}
|
||||
elementNode.set("waypoints", waypointArray);
|
||||
}
|
||||
|
||||
protected void fillEventTypes(String className, FlowElement element, ObjectNode elementNode) {
|
||||
if (eventElementTypes.contains(className)) {
|
||||
Event event = (Event) element;
|
||||
if (!CollectionUtils.isEmpty(event.getEventDefinitions())) {
|
||||
EventDefinition eventDef = event.getEventDefinitions().get(0);
|
||||
ObjectNode eventNode = objectMapper.createObjectNode();
|
||||
if (eventDef instanceof TimerEventDefinition) {
|
||||
TimerEventDefinition timerDef = (TimerEventDefinition) eventDef;
|
||||
eventNode.put("type", "timer");
|
||||
if (org.apache.commons.lang3.StringUtils.isNotEmpty(timerDef.getTimeCycle())) {
|
||||
eventNode.put("timeCycle", timerDef.getTimeCycle());
|
||||
}
|
||||
if (org.apache.commons.lang3.StringUtils.isNotEmpty(timerDef.getTimeDate())) {
|
||||
eventNode.put("timeDate", timerDef.getTimeDate());
|
||||
}
|
||||
if (org.apache.commons.lang3.StringUtils.isNotEmpty(timerDef.getTimeDuration())) {
|
||||
eventNode.put("timeDuration", timerDef.getTimeDuration());
|
||||
}
|
||||
|
||||
} else if (eventDef instanceof ConditionalEventDefinition) {
|
||||
ConditionalEventDefinition conditionalDef = (ConditionalEventDefinition) eventDef;
|
||||
eventNode.put("type", "conditional");
|
||||
if (org.apache.commons.lang3.StringUtils.isNotEmpty(conditionalDef.getConditionExpression())) {
|
||||
eventNode.put("condition", conditionalDef.getConditionExpression());
|
||||
}
|
||||
|
||||
} else if (eventDef instanceof ErrorEventDefinition) {
|
||||
ErrorEventDefinition errorDef = (ErrorEventDefinition) eventDef;
|
||||
eventNode.put("type", "error");
|
||||
if (org.apache.commons.lang3.StringUtils.isNotEmpty(errorDef.getErrorCode())) {
|
||||
eventNode.put("errorCode", errorDef.getErrorCode());
|
||||
}
|
||||
|
||||
} else if (eventDef instanceof EscalationEventDefinition) {
|
||||
EscalationEventDefinition escalationDef = (EscalationEventDefinition) eventDef;
|
||||
eventNode.put("type", "escalation");
|
||||
if (org.apache.commons.lang3.StringUtils.isNotEmpty(escalationDef.getEscalationCode())) {
|
||||
eventNode.put("escalationCode", escalationDef.getEscalationCode());
|
||||
}
|
||||
|
||||
} else if (eventDef instanceof SignalEventDefinition) {
|
||||
SignalEventDefinition signalDef = (SignalEventDefinition) eventDef;
|
||||
eventNode.put("type", "signal");
|
||||
if (org.apache.commons.lang3.StringUtils.isNotEmpty(signalDef.getSignalRef())) {
|
||||
eventNode.put("signalRef", signalDef.getSignalRef());
|
||||
}
|
||||
|
||||
} else if (eventDef instanceof MessageEventDefinition) {
|
||||
MessageEventDefinition messageDef = (MessageEventDefinition) eventDef;
|
||||
eventNode.put("type", "message");
|
||||
if (org.apache.commons.lang3.StringUtils.isNotEmpty(messageDef.getMessageRef())) {
|
||||
eventNode.put("messageRef", messageDef.getMessageRef());
|
||||
}
|
||||
|
||||
} else if (eventDef instanceof VariableListenerEventDefinition) {
|
||||
VariableListenerEventDefinition variableDef = (VariableListenerEventDefinition) eventDef;
|
||||
eventNode.put("type", "variable");
|
||||
if (org.apache.commons.lang3.StringUtils.isNotEmpty(variableDef.getVariableName())) {
|
||||
eventNode.put("variableName", variableDef.getVariableName());
|
||||
}
|
||||
if (org.apache.commons.lang3.StringUtils.isNotEmpty(variableDef.getVariableChangeType())) {
|
||||
eventNode.put("variableChangeType", variableDef.getVariableChangeType());
|
||||
}
|
||||
}
|
||||
elementNode.set("eventDefinition", eventNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import cn.axzo.workflow.core.service.dto.response.process.BpmProcessInstancePage
|
||||
import cn.axzo.workflow.core.service.dto.response.process.BpmProcessInstanceVO;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -62,21 +63,6 @@ public class BpmProcessInstanceController {
|
||||
* @param dto {@link BpmProcessInstanceQueryDTO} 可根据 Id,BusinessKey进行查询
|
||||
* @return 流程实例, 租户Id不必传
|
||||
*/
|
||||
// @GetMapping("/g
|
||||
// et")
|
||||
// public CommonResponse<ProcessInstance> getProcessInstance(@RequestBody BpmProcessInstanceQueryDTO dto) {
|
||||
// log.info("获得流程实例 getProcessInstance===>>>参数:{}}", JSON.toJSONString(dto));
|
||||
// ProcessInstance result = null;
|
||||
// // if (StringUtils.hasLength(dto.getProcessInstanceId())) {
|
||||
// // result = bpmProcessInstanceService.getProcessInstance(dto.getProcessInstanceId(), dto
|
||||
// // .getTenantId(),
|
||||
// // dto.getHasVariable());
|
||||
// // } else if (StringUtils.hasLength(dto.getBusinessKey())) {
|
||||
// // result = bpmProcessInstanceService.getProcessInstanceByBusinessKey(dto.getBusinessKey(),
|
||||
// // dto.getTenantId(), dto.getHasVariable());
|
||||
// // }
|
||||
// return CommonResponse.success(result);
|
||||
// }
|
||||
@GetMapping("/get")
|
||||
public CommonResponse<BpmProcessInstanceVO> getProcessInstanceVO(@RequestBody BpmProcessInstanceQueryDTO dto) {
|
||||
log.info("获得历史的流程实例 getProcessInstanceVO===>>>参数:{}", JSON.toJSONString(dto));
|
||||
@ -90,7 +76,7 @@ public class BpmProcessInstanceController {
|
||||
* @param processDefinitionId 流程定义的编号
|
||||
* @param status 1, "active"; 2, "suspended"
|
||||
*/
|
||||
@Operation(summary = "更新指定流程定义的版本的状态, 处于'suspended 状态的流程模型将不能再发起实例")
|
||||
@Operation(summary = "更新指定流程定义的版本的状态, 处于 suspended 状态的流程模型将不能再发起实例")
|
||||
@PutMapping("/status/update")
|
||||
public CommonResponse<Boolean> updateProcessStatus(@RequestParam String processDefinitionId,
|
||||
@RequestParam Integer status) {
|
||||
@ -99,4 +85,11 @@ public class BpmProcessInstanceController {
|
||||
return CommonResponse.success(result);
|
||||
}
|
||||
|
||||
@GetMapping("/graphical")
|
||||
public CommonResponse<ObjectNode> processInstanceGraphical(@RequestParam String processInstanceId,
|
||||
@RequestParam String tenantId) {
|
||||
return CommonResponse.success(bpmProcessInstanceService.getProcessInstanceGraphical(processInstanceId,
|
||||
tenantId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user