Browse Source

[Fix-11583][UI] Fix the API usage of gantt graph (#11642)

3.2.0-release
Chris 2 years ago committed by GitHub
parent
commit
3c86e52075
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 43
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
  2. 2
      dolphinscheduler-ui/src/views/projects/workflow/instance/gantt/components/gantt-chart.tsx
  3. 5
      dolphinscheduler-ui/src/views/projects/workflow/instance/gantt/use-gantt.ts

43
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java

@ -17,15 +17,20 @@
package org.apache.dolphinscheduler.api.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.*;
import static org.apache.dolphinscheduler.common.Constants.*;
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_DEPENDENT;
import org.apache.dolphinscheduler.api.dto.gantt.GanttDto;
import org.apache.dolphinscheduler.api.dto.gantt.Task;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
import org.apache.dolphinscheduler.api.service.*;
import org.apache.dolphinscheduler.api.service.ExecutorService;
import org.apache.dolphinscheduler.api.service.LoggerService;
import org.apache.dolphinscheduler.api.service.ProcessDefinitionService;
import org.apache.dolphinscheduler.api.service.ProcessInstanceService;
import org.apache.dolphinscheduler.api.service.ProjectService;
import org.apache.dolphinscheduler.api.service.UsersService;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
@ -47,22 +52,31 @@ import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode;
import org.apache.dolphinscheduler.service.expand.CuringParamsService;
import org.apache.dolphinscheduler.service.process.ProcessService;
import org.apache.dolphinscheduler.service.task.TaskPluginManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.*;
import static org.apache.dolphinscheduler.common.Constants.*;
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_DEPENDENT;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* process instance service impl
@ -787,8 +801,7 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce
if (!nodeList.isEmpty()) {
List<Long> taskCodes = nodeList.stream().map(Long::parseLong).collect(Collectors.toList());
List<TaskInstance> taskInstances = taskInstanceMapper.queryByProcessInstanceIdsAndTaskCodes(
Collections.singletonList(processInstanceId), taskCodes
);
Collections.singletonList(processInstanceId), taskCodes);
for (String node : nodeList) {
TaskInstance taskInstance = null;
for (TaskInstance instance : taskInstances) {
@ -809,7 +822,7 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce
task.getEndDate().add(endTime.getTime());
task.setIsoStart(startTime);
task.setIsoEnd(endTime);
task.setStatus(taskInstance.getState().toString());
task.setStatus(taskInstance.getState().getDesc().toUpperCase());
task.setExecutionDate(taskInstance.getStartTime());
task.setDuration(DateUtils.format2Readable(endTime.getTime() - startTime.getTime()));
taskList.add(task);

2
dolphinscheduler-ui/src/views/projects/workflow/instance/gantt/components/gantt-chart.tsx

@ -80,7 +80,7 @@ const GanttChart = defineComponent({
minTime = minTime < start ? minTime : start
maxTime = maxTime > end ? maxTime : end
data[task.status].push({
name: task.name,
name: task.taskName,
value: [index, start, end, end - start],
itemStyle: {
color: state[task.status as ITaskState].color

5
dolphinscheduler-ui/src/views/projects/workflow/instance/gantt/use-gantt.ts

@ -32,10 +32,7 @@ export function useGantt() {
variables.seriesData = obj.tasks.map((item) => {
variables.taskList.push(item.taskName)
return {
name: item.taskName,
...item
}
return item
}) as any
}

Loading…
Cancel
Save