fix: 2.5.0:
1、Dashboard 折线图fail统计错误 2、Dashbaord 重试任务Bar SQL优化删除函数,兼容多数据源
This commit is contained in:
parent
cf3136d22d
commit
1d30f62edb
@ -3,7 +3,7 @@ package com.aizuda.easy.retry.template.datasource.persistence.dataobject;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author: wodeyangzipingpingwuqi
|
||||
@ -22,11 +22,6 @@ public class DashboardCardResponseDO {
|
||||
*/
|
||||
private RetryTask retryTask;
|
||||
|
||||
/**
|
||||
* 重试任务折线图
|
||||
*/
|
||||
private List<RetryTaskBar> retryTaskBarList;
|
||||
|
||||
@Data
|
||||
public static class RetryTask {
|
||||
|
||||
@ -44,6 +39,9 @@ public class DashboardCardResponseDO {
|
||||
|
||||
// 暂停重试
|
||||
private Long suspendNum;
|
||||
|
||||
// 触发时间
|
||||
private LocalDateTime triggerAt;
|
||||
}
|
||||
|
||||
@Data
|
||||
@ -61,17 +59,4 @@ public class DashboardCardResponseDO {
|
||||
// 成功率
|
||||
private BigDecimal successRate;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class RetryTaskBar {
|
||||
/**
|
||||
* 时间x轴
|
||||
*/
|
||||
private String x;
|
||||
|
||||
/**
|
||||
* 任务总数y轴
|
||||
*/
|
||||
private Long taskTotal;
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public interface RetrySummaryMapper extends BaseMapper<RetrySummary> {
|
||||
|
||||
DashboardCardResponseDO.RetryTask retryTask(@Param("namespaceId") String namespaceId, @Param("groupNames") List<String> groupNames);
|
||||
|
||||
List<DashboardCardResponseDO.RetryTaskBar> retryTaskBarList(@Param("namespaceId") String namespaceId, @Param("groupNames") List<String> groupNames);
|
||||
List<DashboardCardResponseDO.RetryTask> retryTaskBarList(@Param("namespaceId") String namespaceId, @Param("groupNames") List<String> groupNames);
|
||||
|
||||
IPage<DashboardRetryLineResponseDO.Task> retryTaskList(@Param("namespaceId") String namespaceId, @Param("groupNames") List<String> groupNames, Page<Object> page);
|
||||
|
||||
|
@ -57,33 +57,18 @@
|
||||
</select>
|
||||
|
||||
<select id="retryTaskBarList"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTaskBar">
|
||||
SELECT tmp.date AS x, ifnull(b.taskTotal, 0) AS taskTotal
|
||||
FROM (SELECT curdate() AS date
|
||||
UNION ALL
|
||||
SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY) AS date
|
||||
UNION ALL
|
||||
SELECT DATE_SUB(CURDATE(), interval 2 day) AS date
|
||||
UNION ALL
|
||||
SELECT DATE_SUB(CURDATE(), interval 3 day) AS date
|
||||
UNION ALL
|
||||
SELECT DATE_SUB(CURDATE(), interval 4 day) AS date
|
||||
UNION ALL
|
||||
SELECT DATE_SUB(CURDATE(), interval 5 day) AS date
|
||||
UNION ALL
|
||||
SELECT DATE_SUB(CURDATE(), interval 6 day) AS date) tmp
|
||||
LEFT JOIN (SELECT DATE (trigger_at) AS triggerAt,
|
||||
SUM(running_num + finish_num + max_count_num + suspend_num) AS taskTotal FROM retry_summary
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTask">
|
||||
SELECT
|
||||
trigger_at, running_num, finish_num, max_count_num, suspend_num
|
||||
FROM retry_summary
|
||||
WHERE namespace_id = #{namespaceId}
|
||||
<if test="groupNames != null and groupNames.size > 0">
|
||||
AND group_name IN
|
||||
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
||||
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
||||
#{groupName}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY triggerAt
|
||||
) b
|
||||
ON tmp.date = b.triggerAt
|
||||
ORDER BY id DESC LIMIT 7
|
||||
</select>
|
||||
|
||||
<select id="retryLineList"
|
||||
|
@ -70,10 +70,9 @@
|
||||
</choose>
|
||||
AS createDt,
|
||||
ifnull(SUM(success_num), 0) AS success,
|
||||
ifnull(SUM(fail_num), 0) AS failNum,
|
||||
ifnull(SUM(stop_num), 0) AS stop,
|
||||
ifnull(SUM(cancel_num), 0) AS cancel,
|
||||
ifnull(SUM(fail_num + stop_num + cancel_num), 0) AS fail,
|
||||
ifnull(SUM(fail_num), 0) AS fail,
|
||||
ifnull(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total
|
||||
FROM job_summary
|
||||
<where>
|
||||
|
@ -41,49 +41,35 @@
|
||||
|
||||
<select id="retryTask"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTask">
|
||||
SELECT ifnull(sum(running_num), 0) AS runningNum,
|
||||
ifnull(sum(finish_num), 0) AS finishNum,
|
||||
ifnull(sum(max_count_num), 0) AS maxCountNum,
|
||||
ifnull(sum(suspend_num), 0) AS suspendNum,
|
||||
ifnull(sum(running_num + finish_num + max_count_num + suspend_num), 0) AS totalNum
|
||||
SELECT
|
||||
IFNULL(SUM(running_num), 0) AS runningNum,
|
||||
IFNULL(SUM(finish_num), 0) AS finishNum,
|
||||
IFNULL(SUM(max_count_num), 0) AS maxCountNum,
|
||||
IFNULL(SUM(suspend_num), 0) AS suspendNum,
|
||||
IFNULL(SUM(running_num + finish_num + max_count_num + suspend_num), 0) AS totalNum
|
||||
FROM retry_summary
|
||||
WHERE namespace_id = #{namespaceId}
|
||||
<if test="groupNames != null and groupNames.size > 0">
|
||||
AND group_name IN
|
||||
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
||||
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
||||
#{groupName}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="retryTaskBarList"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTaskBar">
|
||||
SELECT tmp.date AS x, ifnull(b.taskTotal, 0) AS taskTotal
|
||||
FROM (SELECT curdate() AS date
|
||||
UNION ALL
|
||||
SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY) AS date
|
||||
UNION ALL
|
||||
SELECT DATE_SUB(CURDATE(), interval 2 day) AS date
|
||||
UNION ALL
|
||||
SELECT DATE_SUB(CURDATE(), interval 3 day) AS date
|
||||
UNION ALL
|
||||
SELECT DATE_SUB(CURDATE(), interval 4 day) AS date
|
||||
UNION ALL
|
||||
SELECT DATE_SUB(CURDATE(), interval 5 day) AS date
|
||||
UNION ALL
|
||||
SELECT DATE_SUB(CURDATE(), interval 6 day) AS date) tmp
|
||||
LEFT JOIN (SELECT DATE (trigger_at) AS triggerAt,
|
||||
SUM(running_num + finish_num + max_count_num + suspend_num) AS taskTotal FROM retry_summary
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTask">
|
||||
SELECT
|
||||
trigger_at, running_num, finish_num, max_count_num, suspend_num
|
||||
FROM retry_summary
|
||||
WHERE namespace_id = #{namespaceId}
|
||||
<if test="groupNames != null and groupNames.size > 0">
|
||||
AND group_name IN
|
||||
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
||||
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
||||
#{groupName}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY triggerAt
|
||||
) b
|
||||
ON tmp.date = b.triggerAt
|
||||
ORDER BY id DESC LIMIT 7
|
||||
</select>
|
||||
|
||||
<select id="retryLineList"
|
||||
@ -107,16 +93,16 @@
|
||||
</otherwise>
|
||||
</choose>
|
||||
AS createDt,
|
||||
ifnull(SUM(finish_num), 0) AS successNum,
|
||||
ifnull(SUM(running_num), 0) AS runningNum,
|
||||
ifnull(SUM(max_count_num), 0) AS maxCountNum,
|
||||
ifnull(SUM(suspend_num), 0) AS suspendNum,
|
||||
ifnull(SUM(finish_num + running_num + max_count_num + suspend_num), 0) AS total
|
||||
IFNULL(SUM(finish_num), 0) AS successNum,
|
||||
IFNULL(SUM(running_num), 0) AS runningNum,
|
||||
IFNULL(SUM(max_count_num), 0) AS maxCountNum,
|
||||
IFNULL(SUM(suspend_num), 0) AS suspendNum,
|
||||
IFNULL(SUM(finish_num + running_num + max_count_num + suspend_num), 0) AS total
|
||||
FROM retry_summary
|
||||
<where>
|
||||
<if test="groupNames != null and groupNames.size > 0">
|
||||
AND group_name IN
|
||||
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
||||
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
||||
#{groupName}
|
||||
</foreach>
|
||||
</if>
|
||||
@ -136,7 +122,7 @@
|
||||
<where>
|
||||
<if test="groupNames != null and groupNames.size > 0">
|
||||
AND group_name IN
|
||||
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
||||
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
||||
#{groupName}
|
||||
</foreach>
|
||||
</if>
|
||||
@ -153,14 +139,14 @@
|
||||
|
||||
<select id="retryTaskList"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Task">
|
||||
SELECT group_name AS groupName,
|
||||
sum(CASE WHEN (scene_status = 1) THEN 1 ELSE 0 END) AS run,
|
||||
count(*) AS total
|
||||
SELECT group_name AS groupName,
|
||||
SUM(CASE WHEN (scene_status = 1) THEN 1 ELSE 0 END) AS run,
|
||||
COUNT(*) AS total
|
||||
FROM scene_config
|
||||
WHERE namespace_id = #{namespaceId}
|
||||
<if test="groupNames != null and groupNames.size > 0">
|
||||
AND group_name IN
|
||||
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
||||
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
||||
#{groupName}
|
||||
</foreach>
|
||||
</if>
|
||||
|
@ -57,33 +57,18 @@
|
||||
</select>
|
||||
|
||||
<select id="retryTaskBarList"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTaskBar">
|
||||
SELECT tmp.date AS x, COALESCE(b.taskTotal, 0) AS taskTotal
|
||||
FROM (SELECT CURRENT_DATE AS date
|
||||
UNION ALL
|
||||
SELECT CURRENT_DATE - INTERVAL '1 day' AS date
|
||||
UNION ALL
|
||||
SELECT CURRENT_DATE - INTERVAL '2 days' AS date
|
||||
UNION ALL
|
||||
SELECT CURRENT_DATE - INTERVAL '3 days' AS date
|
||||
UNION ALL
|
||||
SELECT CURRENT_DATE - INTERVAL '4 days' AS date
|
||||
UNION ALL
|
||||
SELECT CURRENT_DATE - INTERVAL '5 days' AS date
|
||||
UNION ALL
|
||||
SELECT CURRENT_DATE - INTERVAL '6 days' AS date) tmp
|
||||
LEFT JOIN (SELECT DATE (trigger_at) AS triggerAt,
|
||||
SUM(running_num + finish_num + max_count_num + suspend_num) AS taskTotal FROM retry_summary
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTask">
|
||||
SELECT
|
||||
trigger_at, running_num, finish_num, max_count_num, suspend_num
|
||||
FROM retry_summary
|
||||
WHERE namespace_id = #{namespaceId}
|
||||
<if test="groupNames != null and groupNames.size > 0">
|
||||
AND group_name IN
|
||||
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
||||
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
||||
#{groupName}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY triggerAt
|
||||
) b
|
||||
ON tmp.date = b.triggerAt
|
||||
ORDER BY id DESC LIMIT 7
|
||||
</select>
|
||||
|
||||
<select id="retryLineList"
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.aizuda.easy.retry.server.web.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
@ -77,6 +78,7 @@ public class DashboardCardResponseVO {
|
||||
}
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class RetryTaskBar {
|
||||
/**
|
||||
* 时间x轴
|
||||
|
@ -5,8 +5,6 @@ import com.aizuda.easy.retry.template.datasource.persistence.dataobject.Dashboar
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhengweilin
|
||||
* @version 1.0.0
|
||||
@ -18,6 +16,4 @@ public interface RetrySummaryResponseVOConverter {
|
||||
RetrySummaryResponseVOConverter INSTANCE = Mappers.getMapper(RetrySummaryResponseVOConverter.class);
|
||||
|
||||
DashboardCardResponseVO.RetryTask toRetryTask(DashboardCardResponseDO.RetryTask retryTask);
|
||||
|
||||
List<DashboardCardResponseVO.RetryTaskBar> toRetryTaskBar(List<DashboardCardResponseDO.RetryTaskBar> retryTaskBarList);
|
||||
}
|
||||
|
@ -13,14 +13,17 @@ import com.aizuda.easy.retry.server.web.model.base.PageResult;
|
||||
import com.aizuda.easy.retry.server.web.model.enums.DateTypeEnum;
|
||||
import com.aizuda.easy.retry.server.web.model.request.ServerNodeQueryVO;
|
||||
import com.aizuda.easy.retry.server.web.model.request.UserSessionVO;
|
||||
import com.aizuda.easy.retry.server.web.model.response.*;
|
||||
import com.aizuda.easy.retry.server.web.model.response.DashboardCardResponseVO;
|
||||
import com.aizuda.easy.retry.server.web.model.response.DashboardLineResponseVO;
|
||||
import com.aizuda.easy.retry.server.web.model.response.DashboardRetryLineResponseVO;
|
||||
import com.aizuda.easy.retry.server.web.model.response.ServerNodeResponseVO;
|
||||
import com.aizuda.easy.retry.server.web.service.DashBoardService;
|
||||
import com.aizuda.easy.retry.server.web.service.convert.*;
|
||||
import com.aizuda.easy.retry.server.web.util.UserSessionUtils;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.ActivePodQuantityResponseDO;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.mapper.JobSummaryMapper;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.mapper.RetrySummaryMapper;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.mapper.ServerNodeMapper;
|
||||
@ -38,7 +41,9 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@ -79,7 +84,22 @@ public class DashBoardServiceImpl implements DashBoardService {
|
||||
// 定时任务
|
||||
dashboardCardResponseVO.setJobTask(JobSummaryResponseVOConverter.INSTANCE.toTaskJob(jobSummaryMapper.toJobTask(namespaceId, groupNames)));
|
||||
// 重试任务柱状图
|
||||
dashboardCardResponseVO.setRetryTaskBarList(RetrySummaryResponseVOConverter.INSTANCE.toRetryTaskBar(retrySummaryMapper.retryTaskBarList(namespaceId, groupNames)));
|
||||
HashMap<LocalDateTime, DashboardCardResponseVO.RetryTaskBar> retryTaskBarMap = new HashMap<>();
|
||||
for (int i = 0; i < 7; i++) {
|
||||
DashboardCardResponseVO.RetryTaskBar retryTaskBar = new DashboardCardResponseVO.RetryTaskBar().setX(LocalDateTime.of(LocalDate.now(), LocalTime.MIN).plusDays(-i).toLocalDate().toString()).setTaskTotal(0L);
|
||||
retryTaskBarMap.put(LocalDateTime.of(LocalDate.now(), LocalTime.MIN).plusDays(-i), retryTaskBar);
|
||||
}
|
||||
|
||||
List<DashboardCardResponseDO.RetryTask> retryTaskList = retrySummaryMapper.retryTaskBarList(namespaceId, groupNames);
|
||||
Map<LocalDateTime, LongSummaryStatistics> summaryStatisticsMap = retryTaskList.stream().collect(Collectors.groupingBy(DashboardCardResponseDO.RetryTask::getTriggerAt,
|
||||
Collectors.summarizingLong(i -> i.getMaxCountNum() + i.getRunningNum() + i.getSuspendNum() + i.getFinishNum())));
|
||||
for (Map.Entry<LocalDateTime, LongSummaryStatistics> map : summaryStatisticsMap.entrySet()) {
|
||||
if (retryTaskBarMap.containsKey(LocalDateTime.of(map.getKey().toLocalDate(), LocalTime.MIN))) {
|
||||
DashboardCardResponseVO.RetryTaskBar retryTaskBar = retryTaskBarMap.get(LocalDateTime.of(map.getKey().toLocalDate(), LocalTime.MIN));
|
||||
retryTaskBar.setX(map.getKey().toLocalDate().toString()).setTaskTotal(map.getValue().getSum());
|
||||
}
|
||||
}
|
||||
dashboardCardResponseVO.setRetryTaskBarList(new ArrayList<>(retryTaskBarMap.values()));
|
||||
// 在线Pods
|
||||
List<ActivePodQuantityResponseDO> activePodQuantityDO = serverNodeMapper.countActivePod(Lists.newArrayList(userSessionVO.getNamespaceId(), ServerRegister.NAMESPACE_ID));
|
||||
Map<Integer, Long> map = activePodQuantityDO.stream().collect(Collectors.toMap(ActivePodQuantityResponseDO::getNodeType, ActivePodQuantityResponseDO::getTotal));
|
||||
|
Loading…
Reference in New Issue
Block a user