|
|
@@ -3,6 +3,7 @@ package com.fs.company.service.impl.call.node;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
+import com.fs.common.exception.CustomException;
|
|
|
import com.fs.common.utils.spring.SpringUtils;
|
|
|
import com.fs.company.domain.*;
|
|
|
import com.fs.company.mapper.*;
|
|
|
@@ -74,7 +75,7 @@ public abstract class AbstractWorkflowNode implements IWorkflowNode {
|
|
|
try {
|
|
|
CompanyAiWorkflowExec companyAiWorkflowExec = companyAiWorkflowExecMapper.selectByWorkflowInstanceId(context.getWorkflowInstanceId());
|
|
|
if (!Integer.valueOf(ExecutionStatusEnum.WAITING.getValue()).equals(companyAiWorkflowExec.getStatus())) {
|
|
|
- return handleExecutionError(new Exception("状态不符合"), context);
|
|
|
+ return handleExecutionError(new CustomException("状态不符合"), context);
|
|
|
}
|
|
|
return doContinue(context);
|
|
|
} catch (Exception e) {
|
|
|
@@ -85,7 +86,15 @@ public abstract class AbstractWorkflowNode implements IWorkflowNode {
|
|
|
companyAiWorkflowExecLog.setWorkflowInstanceId(context.getWorkflowInstanceId());
|
|
|
companyAiWorkflowExecLog.setNodeKey(context.getCurrentNodeKey());
|
|
|
companyAiWorkflowExecLog.setStatus(ExecutionStatusEnum.PAUSED.getValue());
|
|
|
- companyAiWorkflowExecLogMapper.selectCompanyAiWorkflowExecLogList(companyAiWorkflowExecLog);
|
|
|
+ List<CompanyAiWorkflowExecLog> companyAiWorkflowExecLogs = companyAiWorkflowExecLogMapper.selectCompanyAiWorkflowExecLogList(companyAiWorkflowExecLog);
|
|
|
+ if(null != companyAiWorkflowExecLogs){
|
|
|
+ CompanyAiWorkflowExecLog fExecLog = companyAiWorkflowExecLogs.get(0);
|
|
|
+ fExecLog.setStatus(ExecutionStatusEnum.SUCCESS.getValue());
|
|
|
+ fExecLog.setEndTime(new Date());
|
|
|
+ long durationInMillis = fExecLog.getEndTime().getTime() - fExecLog.getStartTime().getTime();
|
|
|
+ fExecLog.setDuration(durationInMillis);
|
|
|
+ companyAiWorkflowExecLogMapper.updateById(fExecLog);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -112,6 +121,7 @@ public abstract class AbstractWorkflowNode implements IWorkflowNode {
|
|
|
Integer logStatus = 0;
|
|
|
if (result.isSuccess()) {
|
|
|
logStatus = ExecutionStatusEnum.SUCCESS.getValue();
|
|
|
+ updateWorkflowStatus(context.getWorkflowInstanceId(), ExecutionStatusEnum.SUCCESS);
|
|
|
} else {
|
|
|
logStatus = ExecutionStatusEnum.FAILURE.getValue();
|
|
|
updateWorkflowStatus(context.getWorkflowInstanceId(), ExecutionStatusEnum.FAILURE);
|
|
|
@@ -226,10 +236,13 @@ public abstract class AbstractWorkflowNode implements IWorkflowNode {
|
|
|
CompanyAiWorkflowExecLog logEntry = new CompanyAiWorkflowExecLog();
|
|
|
logEntry.setWorkflowInstanceId(workflowInstanceId);
|
|
|
logEntry.setNodeKey(nodeKey);
|
|
|
+ logEntry.setNodeName(nodeName);
|
|
|
logEntry.setNodeType(nodeType.getValue());
|
|
|
logEntry.setStatus(result.getStatus().getValue());
|
|
|
+ logEntry.setInputData(objectMapper.writeValueAsString(context.getVariables()));
|
|
|
logEntry.setOutputData(objectMapper.writeValueAsString(result.getOutputData()));
|
|
|
logEntry.setErrorMessage(result.getErrorMessage());
|
|
|
+ logEntry.setCreatedTime(new Date());
|
|
|
Long startTime = context.getVariable("node_start_time_" + nodeKey, Long.class);
|
|
|
if (null != startTime) {
|
|
|
logEntry.setStartTime(new Date(startTime));
|