大声道撒旦

This commit is contained in:
dengqichen 2025-01-06 15:28:26 +08:00
parent 7618bb3ef6
commit d64504284e
3 changed files with 15 additions and 22 deletions

View File

@ -12,17 +12,17 @@ public interface WorkFlowConstants {
String ASYNC_CONTINUATION = "async-continuation";
String WORKFLOW_PREVIOUS_NODE_EXECUTION_STATUS_VARIABLE_NAME = "PREVIOUS_NODE_EXECUTION_STATUS";
String WORKFLOW_PREVIOUS_NODE_EXECUTION_STATE_VARIABLE_NAME = "PREVIOUS_NODE_EXECUTION_STATE";
/**
* 执行状态成功
*/
String WORKFLOW_NODE_EXECUTION_STATUS_SUCCESS = "SUCCESS";
String WORKFLOW_NODE_EXECUTION_STATE_SUCCESS = "SUCCESS";
/**
* 执行状态失败
*/
String WORKFLOW_NODE_EXECUTION_STATUS_FAILURE = "FAILURE";
String WORKFLOW_NODE_EXECUTION_STATE_FAILURE = "FAILURE";
/**
* 执行状态中止

View File

@ -2,20 +2,16 @@ package com.qqchen.deploy.backend.workflow.delegate;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.qqchen.deploy.backend.workflow.constants.WorkFlowConstants;
import lombok.extern.slf4j.Slf4j;
import org.flowable.bpmn.model.ServiceTask;
import org.flowable.engine.delegate.BpmnError;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.JavaDelegate;
import org.flowable.common.engine.api.delegate.Expression;
import org.springframework.beans.factory.annotation.Autowired;
import static com.qqchen.deploy.backend.workflow.constants.WorkFlowConstants.WORKFLOW_NODE_EXECUTION_STATUS_FAILURE;
import static com.qqchen.deploy.backend.workflow.constants.WorkFlowConstants.WORKFLOW_NODE_EXECUTION_STATUS_SUCCESS;
import static com.qqchen.deploy.backend.workflow.constants.WorkFlowConstants.WORKFLOW_PREVIOUS_NODE_EXECUTION_STATUS_VARIABLE_NAME;
import static com.qqchen.deploy.backend.workflow.constants.WorkFlowConstants.WORKFLOW_NODE_EXECUTION_STATE_FAILURE;
import static com.qqchen.deploy.backend.workflow.constants.WorkFlowConstants.WORKFLOW_NODE_EXECUTION_STATE_SUCCESS;
import static com.qqchen.deploy.backend.workflow.constants.WorkFlowConstants.WORKFLOW_PREVIOUS_NODE_EXECUTION_STATE_VARIABLE_NAME;
import java.util.Map;
import java.util.Optional;
/**
@ -60,12 +56,12 @@ public abstract class BaseNodeDelegate<P, L> implements JavaDelegate {
// 如果节点没有设置状态默认设置成功状态
String status = getExecutionStatus(execution);
if (status == null) {
setExecutionStatus(execution, WORKFLOW_NODE_EXECUTION_STATUS_SUCCESS);
setExecutionStatus(execution, WORKFLOW_NODE_EXECUTION_STATE_SUCCESS);
}
} catch (Exception e) {
// 设置失败状态
setExecutionStatus(execution, WORKFLOW_NODE_EXECUTION_STATUS_FAILURE);
setExecutionStatus(execution, WORKFLOW_NODE_EXECUTION_STATE_FAILURE);
log.error("Task execution failed", e);
}
}
@ -77,7 +73,7 @@ public abstract class BaseNodeDelegate<P, L> implements JavaDelegate {
* @param status 状态值
*/
protected void setExecutionStatus(DelegateExecution execution, String status) {
execution.setVariable(WORKFLOW_PREVIOUS_NODE_EXECUTION_STATUS_VARIABLE_NAME, status);
execution.setVariable(WORKFLOW_PREVIOUS_NODE_EXECUTION_STATE_VARIABLE_NAME, status);
log.debug("Set execution status: {}", status);
}
@ -109,7 +105,7 @@ public abstract class BaseNodeDelegate<P, L> implements JavaDelegate {
*/
private void clearPreviousNodeStatus(DelegateExecution execution) {
// 只有在当前节点是ServiceTask时才清除状态
execution.removeVariable(WORKFLOW_PREVIOUS_NODE_EXECUTION_STATUS_VARIABLE_NAME);
execution.removeVariable(WORKFLOW_PREVIOUS_NODE_EXECUTION_STATE_VARIABLE_NAME);
log.debug("Cleared previous node status for node: {}", execution.getCurrentActivityId());
}
@ -121,7 +117,7 @@ public abstract class BaseNodeDelegate<P, L> implements JavaDelegate {
*/
protected String getExecutionStatus(DelegateExecution execution) {
return Optional.ofNullable(execution.getVariables())
.map(vars -> vars.get(WORKFLOW_PREVIOUS_NODE_EXECUTION_STATUS_VARIABLE_NAME))
.map(vars -> vars.get(WORKFLOW_PREVIOUS_NODE_EXECUTION_STATE_VARIABLE_NAME))
.map(Object::toString)
.orElse(null);
}

View File

@ -17,11 +17,11 @@ import jakarta.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Optional;
import static com.qqchen.deploy.backend.workflow.constants.WorkFlowConstants.WORKFLOW_PREVIOUS_NODE_EXECUTION_STATUS_VARIABLE_NAME;
import static com.qqchen.deploy.backend.workflow.constants.WorkFlowConstants.WORKFLOW_PREVIOUS_NODE_EXECUTION_STATE_VARIABLE_NAME;
@Slf4j
@Component("globalNodeExecutionListener")
public class GlobalExecutionListener implements ExecutionListener {
public class GlobalNodeExecutionListener implements ExecutionListener {
@Resource
@Lazy
@ -43,7 +43,7 @@ public class GlobalExecutionListener implements ExecutionListener {
LocalDateTime startTime = null;
LocalDateTime endTime = null;
String nodeExecutionStatus = Optional.ofNullable(execution.getVariables())
.map(vars -> vars.get(WORKFLOW_PREVIOUS_NODE_EXECUTION_STATUS_VARIABLE_NAME))
.map(vars -> vars.get(WORKFLOW_PREVIOUS_NODE_EXECUTION_STATE_VARIABLE_NAME))
.map(Object::toString)
.orElse(null);
switch (eventName) {
@ -55,7 +55,7 @@ public class GlobalExecutionListener implements ExecutionListener {
if (StringUtils.isEmpty(nodeExecutionStatus)) {
status = WorkflowNodeInstanceStatusEnums.COMPLETED;
} else {
if (WorkFlowConstants.WORKFLOW_NODE_EXECUTION_STATUS_SUCCESS.equals(nodeExecutionStatus)) {
if (WorkFlowConstants.WORKFLOW_NODE_EXECUTION_STATE_SUCCESS.equals(nodeExecutionStatus)) {
status = WorkflowNodeInstanceStatusEnums.COMPLETED;
} else {
status = WorkflowNodeInstanceStatusEnums.FAILED;
@ -77,8 +77,5 @@ public class GlobalExecutionListener implements ExecutionListener {
.startTime(startTime)
.endTime(endTime)
.build());
if (StringUtils.isNotEmpty(nodeExecutionStatus)) {
execution.removeVariable(WORKFLOW_PREVIOUS_NODE_EXECUTION_STATUS_VARIABLE_NAME);
}
}
}