feat: 增加任务耗时展示
This commit is contained in:
7
.idea/codeStyles/Project.xml
generated
7
.idea/codeStyles/Project.xml
generated
@@ -1,5 +1,11 @@
|
|||||||
<component name="ProjectCodeStyleConfiguration">
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
<code_scheme name="Project" version="173">
|
<code_scheme name="Project" version="173">
|
||||||
|
<JSCodeStyleSettings version="0">
|
||||||
|
<option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
|
||||||
|
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
||||||
|
<option name="USE_DOUBLE_QUOTES" value="false" />
|
||||||
|
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
||||||
|
</JSCodeStyleSettings>
|
||||||
<JavaCodeStyleSettings>
|
<JavaCodeStyleSettings>
|
||||||
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="100" />
|
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="100" />
|
||||||
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="100" />
|
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="100" />
|
||||||
@@ -25,7 +31,6 @@
|
|||||||
<option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
|
<option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
|
||||||
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
||||||
<option name="USE_DOUBLE_QUOTES" value="false" />
|
<option name="USE_DOUBLE_QUOTES" value="false" />
|
||||||
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
||||||
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
||||||
</TypeScriptCodeStyleSettings>
|
</TypeScriptCodeStyleSettings>
|
||||||
<codeStyleSettings language="CSS">
|
<codeStyleSettings language="CSS">
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package com.lanyuanxiaoyao.leopard.server.controller;
|
package com.lanyuanxiaoyao.leopard.server.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.BetweenFormatter;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.lanyuanxiaoyao.leopard.server.entity.Task;
|
import com.lanyuanxiaoyao.leopard.server.entity.Task;
|
||||||
import com.lanyuanxiaoyao.leopard.server.service.TaskService;
|
import com.lanyuanxiaoyao.leopard.server.service.TaskService;
|
||||||
import com.lanyuanxiaoyao.service.template.controller.GlobalResponse;
|
import com.lanyuanxiaoyao.service.template.controller.GlobalResponse;
|
||||||
import com.lanyuanxiaoyao.service.template.controller.SimpleControllerSupport;
|
import com.lanyuanxiaoyao.service.template.controller.SimpleControllerSupport;
|
||||||
|
import java.time.Duration;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@@ -46,30 +50,51 @@ public class TaskController extends SimpleControllerSupport<Task, Void, TaskCont
|
|||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private TaskCost calculateCost(LocalDateTime start, LocalDateTime finish) {
|
||||||
protected Function<Task, ListItem> listItemMapper() {
|
if (ObjectUtil.isNull(start) || ObjectUtil.isNull(finish)) {
|
||||||
return task -> new ListItem(
|
return new TaskCost(null, null);
|
||||||
task.getId(),
|
}
|
||||||
task.getName(),
|
var duration = Duration.between(start, finish).toMillis();
|
||||||
task.getDescription(),
|
return new TaskCost(
|
||||||
task.getStatus(),
|
duration,
|
||||||
task.getLaunchedTime(),
|
DateUtil.formatBetween(duration, BetweenFormatter.Level.SECOND)
|
||||||
task.getFinishedTime()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Function<Task, ListItem> listItemMapper() {
|
||||||
|
return task -> {
|
||||||
|
var cost = calculateCost(task.getLaunchedTime(), task.getFinishedTime());
|
||||||
|
return new ListItem(
|
||||||
|
task.getId(),
|
||||||
|
task.getName(),
|
||||||
|
task.getDescription(),
|
||||||
|
task.getStatus(),
|
||||||
|
task.getLaunchedTime(),
|
||||||
|
task.getFinishedTime(),
|
||||||
|
cost.cost(),
|
||||||
|
cost.costText()
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<Task, DetailItem> detailItemMapper() {
|
protected Function<Task, DetailItem> detailItemMapper() {
|
||||||
return task -> new DetailItem(
|
return task -> {
|
||||||
task.getId(),
|
var cost = calculateCost(task.getLaunchedTime(), task.getFinishedTime());
|
||||||
task.getName(),
|
return new DetailItem(
|
||||||
task.getDescription(),
|
task.getId(),
|
||||||
task.getStatus(),
|
task.getName(),
|
||||||
task.getError(),
|
task.getDescription(),
|
||||||
task.getResult(),
|
task.getStatus(),
|
||||||
task.getLaunchedTime(),
|
task.getError(),
|
||||||
task.getFinishedTime()
|
task.getResult(),
|
||||||
);
|
task.getLaunchedTime(),
|
||||||
|
task.getFinishedTime(),
|
||||||
|
cost.cost(),
|
||||||
|
cost.costText()
|
||||||
|
);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public record ListItem(
|
public record ListItem(
|
||||||
@@ -78,7 +103,9 @@ public class TaskController extends SimpleControllerSupport<Task, Void, TaskCont
|
|||||||
String description,
|
String description,
|
||||||
Task.Status status,
|
Task.Status status,
|
||||||
LocalDateTime launchedTime,
|
LocalDateTime launchedTime,
|
||||||
LocalDateTime finishedTime
|
LocalDateTime finishedTime,
|
||||||
|
Long cost,
|
||||||
|
String costText
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,10 +117,15 @@ public class TaskController extends SimpleControllerSupport<Task, Void, TaskCont
|
|||||||
String error,
|
String error,
|
||||||
String result,
|
String result,
|
||||||
LocalDateTime launchedTime,
|
LocalDateTime launchedTime,
|
||||||
LocalDateTime finishedTime
|
LocalDateTime finishedTime,
|
||||||
|
Long cost,
|
||||||
|
String costText
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public record ExecuteRequest(Long templateId, Map<String, Object> params) {
|
public record ExecuteRequest(Long templateId, Map<String, Object> params) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public record TaskCost(Long cost, String costText) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,13 @@ function TaskList() {
|
|||||||
width: 100,
|
width: 100,
|
||||||
...remoteMappings('task_status', 'status'),
|
...remoteMappings('task_status', 'status'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: '耗时',
|
||||||
|
type: 'tpl',
|
||||||
|
align: 'center',
|
||||||
|
width: 150,
|
||||||
|
tpl: "${IF(costText, costText, '/')}",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'launchedTime',
|
name: 'launchedTime',
|
||||||
label: '启动时间',
|
label: '启动时间',
|
||||||
|
|||||||
Reference in New Issue
Block a user