|
|
@ -54,6 +54,7 @@ import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelationLog; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelationLog; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Project; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Project; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskDefinition; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Tenant; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Tenant; |
|
|
@ -63,6 +64,7 @@ import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TenantMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TenantMapper; |
|
|
|
import org.apache.dolphinscheduler.service.process.ProcessService; |
|
|
|
import org.apache.dolphinscheduler.service.process.ProcessService; |
|
|
@ -140,6 +142,9 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private TenantMapper tenantMapper; |
|
|
|
private TenantMapper tenantMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
TaskDefinitionMapper taskDefinitionMapper; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* return top n SUCCESS process instance order by running time which started between startTime and endTime |
|
|
|
* return top n SUCCESS process instance order by running time which started between startTime and endTime |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -175,7 +180,7 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<ProcessInstance> processInstances = processInstanceMapper.queryTopNProcessInstance(size, start, end, ExecutionStatus.SUCCESS); |
|
|
|
List<ProcessInstance> processInstances = processInstanceMapper.queryTopNProcessInstance(size, start, end, ExecutionStatus.SUCCESS, projectCode); |
|
|
|
result.put(DATA_LIST, processInstances); |
|
|
|
result.put(DATA_LIST, processInstances); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -202,7 +207,7 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce |
|
|
|
ProcessDefinition processDefinition = processService.findProcessDefinition(processInstance.getProcessDefinitionCode(), |
|
|
|
ProcessDefinition processDefinition = processService.findProcessDefinition(processInstance.getProcessDefinitionCode(), |
|
|
|
processInstance.getProcessDefinitionVersion()); |
|
|
|
processInstance.getProcessDefinitionVersion()); |
|
|
|
|
|
|
|
|
|
|
|
if (processDefinition == null) { |
|
|
|
if (processDefinition == null || projectCode != processDefinition.getProjectCode()) { |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processId); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processId); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
processInstance.setWarningGroupId(processDefinition.getWarningGroupId()); |
|
|
|
processInstance.setWarningGroupId(processDefinition.getWarningGroupId()); |
|
|
@ -310,6 +315,11 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
ProcessInstance processInstance = processService.findProcessInstanceDetailById(processId); |
|
|
|
ProcessInstance processInstance = processService.findProcessInstanceDetailById(processId); |
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processDefineMapper.queryByCode(processInstance.getProcessDefinitionCode()); |
|
|
|
|
|
|
|
if (processDefinition != null && projectCode != processDefinition.getProjectCode()) { |
|
|
|
|
|
|
|
putMsg(result, Status.PROCESS_INSTANCE_NOT_EXIST, processId); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
List<TaskInstance> taskInstanceList = processService.findValidTaskListByProcessId(processId); |
|
|
|
List<TaskInstance> taskInstanceList = processService.findValidTaskListByProcessId(processId); |
|
|
|
addDependResultForTaskList(taskInstanceList); |
|
|
|
addDependResultForTaskList(taskInstanceList); |
|
|
|
Map<String, Object> resultMap = new HashMap<>(); |
|
|
|
Map<String, Object> resultMap = new HashMap<>(); |
|
|
@ -389,6 +399,13 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce |
|
|
|
putMsg(result, Status.TASK_INSTANCE_NOT_EXISTS, taskId); |
|
|
|
putMsg(result, Status.TASK_INSTANCE_NOT_EXISTS, taskId); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskInstance.getTaskCode()); |
|
|
|
|
|
|
|
if (taskDefinition != null && projectCode != taskDefinition.getProjectCode()) { |
|
|
|
|
|
|
|
putMsg(result, Status.TASK_INSTANCE_NOT_EXISTS, taskId); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!taskInstance.isSubProcess()) { |
|
|
|
if (!taskInstance.isSubProcess()) { |
|
|
|
putMsg(result, Status.TASK_INSTANCE_NOT_SUB_WORKFLOW_INSTANCE, taskInstance.getName()); |
|
|
|
putMsg(result, Status.TASK_INSTANCE_NOT_SUB_WORKFLOW_INSTANCE, taskInstance.getName()); |
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -440,6 +457,12 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce |
|
|
|
putMsg(result, Status.PROCESS_INSTANCE_NOT_EXIST, processInstanceId); |
|
|
|
putMsg(result, Status.PROCESS_INSTANCE_NOT_EXIST, processInstanceId); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//check process instance exists in project
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition0 = processDefineMapper.queryByCode(processInstance.getProcessDefinitionCode()); |
|
|
|
|
|
|
|
if (processDefinition0 != null && projectCode != processDefinition0.getProjectCode()) { |
|
|
|
|
|
|
|
putMsg(result, Status.PROCESS_INSTANCE_NOT_EXIST, processInstanceId); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
//check process instance status
|
|
|
|
//check process instance status
|
|
|
|
if (!processInstance.getState().typeIsFinished()) { |
|
|
|
if (!processInstance.getState().typeIsFinished()) { |
|
|
|
putMsg(result, Status.PROCESS_INSTANCE_STATE_OPERATION_ERROR, |
|
|
|
putMsg(result, Status.PROCESS_INSTANCE_STATE_OPERATION_ERROR, |
|
|
@ -593,6 +616,12 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processDefineMapper.queryByCode(processInstance.getProcessDefinitionCode()); |
|
|
|
|
|
|
|
if (processDefinition != null && projectCode != processDefinition.getProjectCode()) { |
|
|
|
|
|
|
|
putMsg(result, Status.PROCESS_INSTANCE_NOT_EXIST, processInstanceId); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
processService.removeTaskLogFile(processInstanceId); |
|
|
|
processService.removeTaskLogFile(processInstanceId); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
@ -617,11 +646,12 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce |
|
|
|
/** |
|
|
|
/** |
|
|
|
* view process instance variables |
|
|
|
* view process instance variables |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @param projectCode project code |
|
|
|
* @param processInstanceId process instance id |
|
|
|
* @param processInstanceId process instance id |
|
|
|
* @return variables data |
|
|
|
* @return variables data |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Map<String, Object> viewVariables(Integer processInstanceId) { |
|
|
|
public Map<String, Object> viewVariables(long projectCode, Integer processInstanceId) { |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
ProcessInstance processInstance = processInstanceMapper.queryDetailById(processInstanceId); |
|
|
|
ProcessInstance processInstance = processInstanceMapper.queryDetailById(processInstanceId); |
|
|
@ -630,6 +660,12 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce |
|
|
|
throw new RuntimeException("workflow instance is null"); |
|
|
|
throw new RuntimeException("workflow instance is null"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processDefineMapper.queryByCode(processInstance.getProcessDefinitionCode()); |
|
|
|
|
|
|
|
if (processDefinition != null && projectCode != processDefinition.getProjectCode()) { |
|
|
|
|
|
|
|
putMsg(result, Status.PROCESS_INSTANCE_NOT_EXIST, processInstanceId); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> timeParams = BusinessTimeUtils |
|
|
|
Map<String, String> timeParams = BusinessTimeUtils |
|
|
|
.getBusinessTime(processInstance.getCmdTypeIfComplement(), |
|
|
|
.getBusinessTime(processInstance.getCmdTypeIfComplement(), |
|
|
|
processInstance.getScheduleTime()); |
|
|
|
processInstance.getScheduleTime()); |
|
|
@ -689,12 +725,13 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce |
|
|
|
/** |
|
|
|
/** |
|
|
|
* encapsulation gantt structure |
|
|
|
* encapsulation gantt structure |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @param projectCode project code |
|
|
|
* @param processInstanceId process instance id |
|
|
|
* @param processInstanceId process instance id |
|
|
|
* @return gantt tree data |
|
|
|
* @return gantt tree data |
|
|
|
* @throws Exception exception when json parse |
|
|
|
* @throws Exception exception when json parse |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Map<String, Object> viewGantt(Integer processInstanceId) throws Exception { |
|
|
|
public Map<String, Object> viewGantt(long projectCode, Integer processInstanceId) throws Exception { |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
ProcessInstance processInstance = processInstanceMapper.queryDetailById(processInstanceId); |
|
|
|
ProcessInstance processInstance = processInstanceMapper.queryDetailById(processInstanceId); |
|
|
@ -707,6 +744,10 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce |
|
|
|
processInstance.getProcessDefinitionCode(), |
|
|
|
processInstance.getProcessDefinitionCode(), |
|
|
|
processInstance.getProcessDefinitionVersion() |
|
|
|
processInstance.getProcessDefinitionVersion() |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
if (processDefinition != null && projectCode != processDefinition.getProjectCode()) { |
|
|
|
|
|
|
|
putMsg(result, Status.PROCESS_INSTANCE_NOT_EXIST, processInstanceId); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
GanttDto ganttDto = new GanttDto(); |
|
|
|
GanttDto ganttDto = new GanttDto(); |
|
|
|
DAG<String, TaskNode, TaskNodeRelation> dag = processService.genDagGraph(processDefinition); |
|
|
|
DAG<String, TaskNode, TaskNodeRelation> dag = processService.genDagGraph(processDefinition); |
|
|
|
//topological sort
|
|
|
|
//topological sort
|
|
|
|