大声道撒旦
This commit is contained in:
parent
6cccc209c6
commit
963405defd
@ -30,32 +30,15 @@ public class GatewayExecutionListener implements ExecutionListener {
|
||||
String nodeName = flowElement.getName();
|
||||
String nodeType = flowElement.getClass().getSimpleName();
|
||||
log.debug("Node execution event: {}, processInstanceId: {}, nodeId: {}, nodeType: {}, nodeName:{}", eventName, processInstanceId, nodeId, nodeType, nodeName);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
WorkflowNodeInstanceStatusEnums status = null;
|
||||
LocalDateTime startTime = null;
|
||||
LocalDateTime endTime = null;
|
||||
switch (eventName) {
|
||||
case ExecutionListener.EVENTNAME_START:
|
||||
status = WorkflowNodeInstanceStatusEnums.RUNNING;
|
||||
startTime = now;
|
||||
break;
|
||||
case ExecutionListener.EVENTNAME_END:
|
||||
status = WorkflowNodeInstanceStatusEnums.COMPLETED;
|
||||
endTime = now;
|
||||
break;
|
||||
default:
|
||||
log.warn("Unexpected event type: {}", eventName);
|
||||
return;
|
||||
}
|
||||
eventPublisher.publishEvent(WorkflowNodeInstanceStatusChangeEvent.builder()
|
||||
.processInstanceId(processInstanceId)
|
||||
.executionId(executionId)
|
||||
.nodeId(nodeId)
|
||||
.nodeName(nodeName)
|
||||
.nodeType(nodeType)
|
||||
.status(status)
|
||||
.startTime(startTime)
|
||||
.endTime(endTime)
|
||||
.status(WorkflowNodeInstanceStatusEnums.COMPLETED)
|
||||
.startTime(LocalDateTime.now())
|
||||
.endTime(LocalDateTime.now())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
@ -65,7 +65,7 @@ public class BpmnConverter {
|
||||
return xml;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("转换工作流定义为XML失败", e);
|
||||
log.error("转换工作流<EFBFBD><EFBFBD>义为XML失败", e);
|
||||
throw new RuntimeException("转换工作流定义为XML失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
@ -167,38 +167,42 @@ public class BpmnConverter {
|
||||
* @param process 当前流程
|
||||
*/
|
||||
private void configureFlowElement(FlowElement element, WorkflowDefinitionGraphNode node, Process process) {
|
||||
// 步骤1:创建基本的扩展元素
|
||||
Map<String, List<ExtensionElement>> extensionElements = new HashMap<>();
|
||||
List<ExtensionElement> executionListeners = new ArrayList<>();
|
||||
|
||||
if (element instanceof Gateway) {
|
||||
// 网关节点只添加 start 监听器
|
||||
ExtensionElement startListener = createExecutionListener("start", "${globalNodeExecutionListener}");
|
||||
executionListeners.add(startListener);
|
||||
} else {
|
||||
// 其他节点添加 start 和 end 监听器
|
||||
ExtensionElement startListener = createExecutionListener("start", "${globalNodeExecutionListener}");
|
||||
ExtensionElement endListener = createExecutionListener("end", "${globalNodeExecutionListener}");
|
||||
executionListeners.add(startListener);
|
||||
executionListeners.add(endListener);
|
||||
}
|
||||
|
||||
extensionElements.put("executionListener", executionListeners);
|
||||
// 步骤1:配置执行监听器
|
||||
Map<String, List<ExtensionElement>> extensionElements = configureExecutionListeners(element);
|
||||
|
||||
// 步骤2:根据节点类型进行特定配置
|
||||
if (element instanceof ServiceTask) {
|
||||
configureServiceTask((ServiceTask) element, node, process, extensionElements);
|
||||
} else if (element instanceof Gateway) {
|
||||
// 为网关节点只添加监听器,不添加边界事件
|
||||
element.setExtensionElements(extensionElements);
|
||||
} else if (element instanceof StartEvent || element instanceof EndEvent) {
|
||||
// 为开始节点和结束节点设置监听器
|
||||
} else {
|
||||
element.setExtensionElements(extensionElements);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建基本的扩展元素(包含执行监听器)
|
||||
* 配置节点的执行监听器
|
||||
*
|
||||
* @param element 流程节点元素
|
||||
* @return 配置好的扩展元素Map
|
||||
*/
|
||||
private Map<String, List<ExtensionElement>> configureExecutionListeners(FlowElement element) {
|
||||
Map<String, List<ExtensionElement>> extensionElements = new HashMap<>();
|
||||
List<ExtensionElement> executionListeners = new ArrayList<>();
|
||||
|
||||
if (element instanceof Gateway) {
|
||||
// 网关节点只添加 start 监听器
|
||||
executionListeners.add(createExecutionListener("start", "${gatewayExecutionListener}"));
|
||||
} else {
|
||||
// 其他节点添加 start 和 end 监听器
|
||||
executionListeners.add(createExecutionListener("start", "${globalNodeExecutionListener}"));
|
||||
executionListeners.add(createExecutionListener("end", "${globalNodeExecutionListener}"));
|
||||
}
|
||||
|
||||
extensionElements.put("executionListener", executionListeners);
|
||||
return extensionElements;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创<EFBFBD><EFBFBD>基本的扩展元素(包含执行监听器)
|
||||
*
|
||||
* @return 包含基本扩展元素的Map
|
||||
*/
|
||||
@ -489,7 +493,8 @@ public class BpmnConverter {
|
||||
log.debug("转换连线: from {} to {}", edge.getFrom(), edge.getTo());
|
||||
|
||||
SequenceFlow flow = new SequenceFlow();
|
||||
flow.setId("FLOW_" + edge.getId().replaceAll("[^a-zA-Z0-9-_.]", "_"));
|
||||
String flowId = "FLOW_" + edge.getId().replaceAll("[^a-zA-Z0-9-_.]", "_");
|
||||
flow.setId(flowId);
|
||||
flow.setName(edge.getName());
|
||||
flow.setSourceRef(idMapping.get(edge.getFrom()));
|
||||
flow.setTargetRef(idMapping.get(edge.getTo()));
|
||||
@ -502,6 +507,13 @@ public class BpmnConverter {
|
||||
}
|
||||
}
|
||||
|
||||
// // 添加 take 事件监听器
|
||||
// Map<String, List<ExtensionElement>> extensionElements = new HashMap<>();
|
||||
// List<ExtensionElement> executionListeners = new ArrayList<>();
|
||||
// executionListeners.add(createExecutionListener("take", "${sequenceFlowTakeListener}"));
|
||||
// extensionElements.put("executionListener", executionListeners);
|
||||
// flow.setExtensionElements(extensionElements);
|
||||
|
||||
process.addFlowElement(flow);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user