|
@@ -102,8 +102,6 @@ public class CompanyWorkflowEngineImpl implements CompanyWorkflowEngine {
|
|
|
currentExecutionMapper.selectByWorkflowInstanceId(workflowInstanceId);
|
|
currentExecutionMapper.selectByWorkflowInstanceId(workflowInstanceId);
|
|
|
|
|
|
|
|
if (currentExec == null) {
|
|
if (currentExec == null) {
|
|
|
-// return ExecutionResult.failure()
|
|
|
|
|
-// .errorMessage("工作流实例不存在: " + workflowInstanceId).build();
|
|
|
|
|
throw new CustomException("工作流实例不存在: " + workflowInstanceId);
|
|
throw new CustomException("工作流实例不存在: " + workflowInstanceId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -124,40 +122,27 @@ public class CompanyWorkflowEngineImpl implements CompanyWorkflowEngine {
|
|
|
context.setCurrentNodeKey(nodeKey);
|
|
context.setCurrentNodeKey(nodeKey);
|
|
|
ExecutionResult result = node.execute(context);
|
|
ExecutionResult result = node.execute(context);
|
|
|
|
|
|
|
|
-// if (node.isAsync()) {
|
|
|
|
|
-// // 阻塞节点:执行节点后暂停流程,等待外部事件唤醒
|
|
|
|
|
-//
|
|
|
|
|
-// // 返回特殊结果表示流程被阻塞
|
|
|
|
|
-// return ExecutionResult.paused()
|
|
|
|
|
-// .nextNodeKey(result.getNextNodeKey())
|
|
|
|
|
-// .outputData(result.getOutputData()).build();
|
|
|
|
|
-// } else {
|
|
|
|
|
-// // 执行节点
|
|
|
|
|
-// ExecutionResult result = node.execute(context);
|
|
|
|
|
-//
|
|
|
|
|
-// // 如果执行成功,返回下一个节点ID
|
|
|
|
|
-// if (result.isSuccess()) {
|
|
|
|
|
-// // 检查是否是结束节点
|
|
|
|
|
-// if (StringUtils.isBlank(result.getNextNodeKey())) {
|
|
|
|
|
-// // 结束工作流
|
|
|
|
|
-// completeWorkflow(workflowInstanceId);
|
|
|
|
|
-// } else {
|
|
|
|
|
-// // 更新当前节点为下一个节点
|
|
|
|
|
-// updateCurrentNode(workflowInstanceId, result.getNextNodeKey());
|
|
|
|
|
-// }
|
|
|
|
|
-// } else {
|
|
|
|
|
-// // 执行失败时更新状态
|
|
|
|
|
-// updateWorkflowStatus(workflowInstanceId, ExecutionStatusEnum.FAILURE);
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
-// return result;
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ // 处理执行结果
|
|
|
|
|
+ if (result.isSuccess()) {
|
|
|
|
|
+ // 检查是否是结束节点或无下一节点
|
|
|
|
|
+ if (StringUtils.isBlank(result.getNextNodeKey())) {
|
|
|
|
|
+ // 结束工作流
|
|
|
|
|
+ completeWorkflow(workflowInstanceId);
|
|
|
|
|
+ log.info("工作流执行完成 - workflowInstanceId: {}", workflowInstanceId);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 继续执行下一个节点
|
|
|
|
|
+ executeNode(workflowInstanceId, result.getNextNodeKey());
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 执行失败时更新状态
|
|
|
|
|
+ updateWorkflowStatus(workflowInstanceId, ExecutionStatusEnum.FAILURE);
|
|
|
|
|
+ log.error("节点执行失败 - workflowInstanceId: {}, nodeKey: {}, error: {}",
|
|
|
|
|
+ workflowInstanceId, nodeKey, result.getErrorMessage());
|
|
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- log.error("节点执行失败: {} -> {}", workflowInstanceId, nodeKey, e);
|
|
|
|
|
|
|
+ log.error("节点执行异常: {} -> {}", workflowInstanceId, nodeKey, e);
|
|
|
updateWorkflowStatus(workflowInstanceId, ExecutionStatusEnum.FAILURE);
|
|
updateWorkflowStatus(workflowInstanceId, ExecutionStatusEnum.FAILURE);
|
|
|
- throw new CustomException("节点执行失败");
|
|
|
|
|
-// return ExecutionResult.failure()
|
|
|
|
|
-// .errorMessage("Node execution failed: " + e.getMessage()).build();
|
|
|
|
|
|
|
+ throw new CustomException("节点执行失败: " + e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|