|
|
@@ -78,13 +78,13 @@ public class CompanyWorkflowEngineImpl implements CompanyWorkflowEngine {
|
|
|
log.info("工作流初始化成功: {} -> {}", workflowInstanceId, workflowDefinitionId);
|
|
|
|
|
|
return ExecutionResult.success()
|
|
|
- .withNextNodeKey(definition.getStartNodeKey())
|
|
|
- .withOutputData(Collections.singletonMap("workflowInstanceId", workflowInstanceId));
|
|
|
+ .nextNodeKey(definition.getStartNodeKey())
|
|
|
+ .workflowInstanceId(workflowInstanceId).build();
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
log.error("工作流初始化失败: {}", workflowDefinitionId, e);
|
|
|
return ExecutionResult.failure()
|
|
|
- .withErrorMessage("Initialization failed: " + e.getMessage());
|
|
|
+ .errorMessage("Initialization failed: " + e.getMessage()).build();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -102,7 +102,7 @@ public class CompanyWorkflowEngineImpl implements CompanyWorkflowEngine {
|
|
|
|
|
|
if (currentExec == null) {
|
|
|
return ExecutionResult.failure()
|
|
|
- .withErrorMessage("工作流实例不存在: " + workflowInstanceId);
|
|
|
+ .errorMessage("工作流实例不存在: " + workflowInstanceId).build();
|
|
|
}
|
|
|
|
|
|
// 反序列化执行上下文
|
|
|
@@ -116,7 +116,7 @@ public class CompanyWorkflowEngineImpl implements CompanyWorkflowEngine {
|
|
|
IWorkflowNode node = createNode(definition, nodeKey);
|
|
|
if (node == null) {
|
|
|
return ExecutionResult.failure()
|
|
|
- .withErrorMessage("节点不存在: " + nodeKey);
|
|
|
+ .errorMessage("节点不存在: " + nodeKey).build();
|
|
|
}
|
|
|
|
|
|
// 更新当前节点到执行上下文
|
|
|
@@ -140,8 +140,8 @@ public class CompanyWorkflowEngineImpl implements CompanyWorkflowEngine {
|
|
|
|
|
|
// 返回特殊结果表示流程被阻塞
|
|
|
return ExecutionResult.paused()
|
|
|
- .withNextNodeKey(result.getNextNodeKey())
|
|
|
- .withOutputData(result.getOutputData());
|
|
|
+ .nextNodeKey(result.getNextNodeKey())
|
|
|
+ .outputData(result.getOutputData()).build();
|
|
|
} else {
|
|
|
// 执行节点
|
|
|
ExecutionResult result = node.execute(context);
|
|
|
@@ -175,7 +175,7 @@ public class CompanyWorkflowEngineImpl implements CompanyWorkflowEngine {
|
|
|
log.error("节点执行失败: {} -> {}", workflowInstanceId, nodeKey, e);
|
|
|
updateWorkflowStatus(workflowInstanceId, ExecutionStatusEnum.FAILURE);
|
|
|
return ExecutionResult.failure()
|
|
|
- .withErrorMessage("Node execution failed: " + e.getMessage());
|
|
|
+ .errorMessage("Node execution failed: " + e.getMessage()).build();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -196,16 +196,16 @@ public class CompanyWorkflowEngineImpl implements CompanyWorkflowEngine {
|
|
|
|
|
|
if (rows > 0) {
|
|
|
log.info("工作流暂停成功: {}", workflowInstanceId);
|
|
|
- return ExecutionResult.success();
|
|
|
+ return ExecutionResult.success().build();
|
|
|
} else {
|
|
|
return ExecutionResult.failure()
|
|
|
- .withErrorMessage("工作流实例不存在: " + workflowInstanceId);
|
|
|
+ .errorMessage("工作流实例不存在: " + workflowInstanceId).build();
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
log.error("暂停工作流失败: {}", workflowInstanceId, e);
|
|
|
return ExecutionResult.failure()
|
|
|
- .withErrorMessage("Pause failed: " + e.getMessage());
|
|
|
+ .errorMessage("Pause failed: " + e.getMessage()).build();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -226,16 +226,16 @@ public class CompanyWorkflowEngineImpl implements CompanyWorkflowEngine {
|
|
|
|
|
|
if (rows > 0) {
|
|
|
log.info("工作流结束成功: {}", workflowInstanceId);
|
|
|
- return ExecutionResult.success();
|
|
|
+ return ExecutionResult.success().build();
|
|
|
} else {
|
|
|
return ExecutionResult.failure()
|
|
|
- .withErrorMessage("工作流实例不存在: " + workflowInstanceId);
|
|
|
+ .errorMessage("工作流实例不存在: " + workflowInstanceId).build();
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
log.error("结束工作流失败: {}", workflowInstanceId, e);
|
|
|
return ExecutionResult.failure()
|
|
|
- .withErrorMessage("Complete failed: " + e.getMessage());
|
|
|
+ .errorMessage("Complete failed: " + e.getMessage()).build();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -452,13 +452,13 @@ public class CompanyWorkflowEngineImpl implements CompanyWorkflowEngine {
|
|
|
|
|
|
if (currentExec == null) {
|
|
|
return ExecutionResult.failure()
|
|
|
- .withErrorMessage("工作流实例不存在: " + workflowInstanceId);
|
|
|
+ .errorMessage("工作流实例不存在: " + workflowInstanceId).build();
|
|
|
}
|
|
|
|
|
|
// 检查当前工作流是否处于暂停状态
|
|
|
if (!Integer.valueOf(ExecutionStatusEnum.WAITING.getValue()).equals(currentExec.getStatus())) {
|
|
|
return ExecutionResult.failure()
|
|
|
- .withErrorMessage("工作流未处于暂停状态,无法唤醒: " + workflowInstanceId);
|
|
|
+ .errorMessage("工作流未处于暂停状态,无法唤醒: " + workflowInstanceId).build();
|
|
|
}
|
|
|
|
|
|
// 反序列化执行上下文并合并新的输入数据
|
|
|
@@ -474,7 +474,7 @@ public class CompanyWorkflowEngineImpl implements CompanyWorkflowEngine {
|
|
|
IWorkflowNode node = createNode(definition, nodeKey);
|
|
|
if (node == null) {
|
|
|
return ExecutionResult.failure()
|
|
|
- .withErrorMessage("节点不存在: " + nodeKey);
|
|
|
+ .errorMessage("节点不存在: " + nodeKey).build();
|
|
|
}
|
|
|
|
|
|
// 继续执行节点逻辑
|
|
|
@@ -507,7 +507,7 @@ public class CompanyWorkflowEngineImpl implements CompanyWorkflowEngine {
|
|
|
log.error("唤醒阻塞节点失败: {} -> {}", workflowInstanceId, nodeKey, e);
|
|
|
updateWorkflowStatus(workflowInstanceId, ExecutionStatusEnum.FAILURE);
|
|
|
return ExecutionResult.failure()
|
|
|
- .withErrorMessage("Resume from blocking node failed: " + e.getMessage());
|
|
|
+ .errorMessage("Resume from blocking node failed: " + e.getMessage()).build();
|
|
|
}
|
|
|
}
|
|
|
}
|