fix: 2.5.0:

1、仪表盘MiniBar查询近7天数据,不足补0
2、重试、定时任务折线图(按天,周,月,年补0)
3、优化仪表盘接口,重试,定时共用DateTypeEnum枚举类
This commit is contained in:
zhengweilin 2023-12-04 16:58:07 +08:00 committed by byteblogs168
parent 3c808f5c56
commit 171ef66695
27 changed files with 353 additions and 331 deletions

View File

@ -61,13 +61,13 @@ public class DashboardCardResponseDO {
@Data
public static class RetryTaskBar {
/**
* 时间x
* 时间x
*/
private String x;
/**
* 总数y
* 任务总数y
*/
private Long y;
private Long taskTotal;
}
}

View File

@ -0,0 +1,67 @@
package com.aizuda.easy.retry.template.datasource.persistence.dataobject;
import lombok.Data;
/**
* @author: wodeyangzipingpingwuqi
* @date : 2023-11-30
*/
@Data
public class DashboardLineResponseDO {
/**
* 时间x轴
*/
private String createDt;
/**
* 总量计算百分比
*/
private Long total;
/**
* 重试-成功数
*/
private Long successNum;
/**
* 重试-运行数
*/
private Long runningNum;
/**
* 重试-最大次数
*/
private Long maxCountNum;
/**
* 重试-暂停数
*/
private Long suspendNum;
/**
* 定时-失败任务
*/
private Long fail;
/**
* 定时-总任务数
*/
private Long totalNum;
/**
* 定时-无效任务数
*/
private Long failNum;
/**
* 定时-停止数
*/
private Long stopNum;
/**
* 定时-取消数
*/
private Long cancelNum;
}

View File

@ -24,7 +24,7 @@ public class DashboardRetryLineResponseDO {
/**
* 折线图列表
*/
private List<DispatchQuantityResponseDO> dispatchQuantityResponseVOList;
private List<DashboardLineResponseDO> dashboardLineResponseDOList;
@Data
public static class Task {

View File

@ -1,23 +0,0 @@
package com.aizuda.easy.retry.template.datasource.persistence.dataobject;
import lombok.Data;
/**
* @author: wodeyangzipingpingwuqi
* @date : 2023-11-30
*/
@Data
public class DashboardRetryLinkeResponseDO {
private String createDt;
private Long total;
private Long successNum;
private Long runningNum;
private Long maxCountNum;
private Long suspendNum;
}

View File

@ -1,27 +0,0 @@
package com.aizuda.easy.retry.template.datasource.persistence.dataobject;
import lombok.Data;
/**
* @author: www.byteblogs.com
* @date : 2022-04-22 20:27
*/
@Data
public class DispatchQuantityResponseDO {
private String createDt;
private Long total;
private Long successNum;
private Long fail;
private Long totalNum;
private Long failNum;
private Long stopNum;
private Long cancelNum;
}

View File

@ -1,8 +1,8 @@
package com.aizuda.easy.retry.template.datasource.persistence.mapper;
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO;
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.dataobject.DispatchQuantityResponseDO;
import com.aizuda.easy.retry.template.datasource.persistence.po.JobSummary;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -27,10 +27,10 @@ public interface JobSummaryMapper extends BaseMapper<JobSummary> {
IPage<DashboardRetryLineResponseDO.Task> jobTaskList(@Param("namespaceId") String namespaceId, Page<Object> page);
List<DispatchQuantityResponseDO> jobLineList(@Param("namespaceId") String namespaceId,
@Param("type") String type,
@Param("from") LocalDateTime from,
@Param("to") LocalDateTime to);
List<DashboardLineResponseDO> jobLineList(@Param("namespaceId") String namespaceId,
@Param("type") String type,
@Param("from") LocalDateTime from,
@Param("to") LocalDateTime to);
DashboardCardResponseDO.JobTask toJobTask(@Param("namespaceId") String namespaceId);

View File

@ -2,7 +2,7 @@ package com.aizuda.easy.retry.template.datasource.persistence.mapper;
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.DashboardRetryLinkeResponseDO;
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO;
import com.aizuda.easy.retry.template.datasource.persistence.po.RetrySummary;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -31,10 +31,10 @@ public interface RetrySummaryMapper extends BaseMapper<RetrySummary> {
IPage<DashboardRetryLineResponseDO.Task> retryTaskList(@Param("namespaceId") String namespaceId, Page<Object> page);
List<DashboardRetryLinkeResponseDO> retryLineList(@Param("namespaceId") String namespaceId,
@Param("type") String type,
@Param("from") LocalDateTime from,
@Param("to") LocalDateTime to);
List<DashboardLineResponseDO> retryLineList(@Param("namespaceId") String namespaceId,
@Param("type") String type,
@Param("from") LocalDateTime from,
@Param("to") LocalDateTime to);
List<DashboardRetryLineResponseDO.Rank> dashboardRank(@Param("namespaceId") String namespaceId,

View File

@ -2,8 +2,6 @@ package com.aizuda.easy.retry.template.datasource.persistence.mapper;
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryResponseDO;
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.DispatchQuantityResponseDO;
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.SceneQuantityRankResponseDO;
import com.aizuda.easy.retry.template.datasource.persistence.po.RetryTaskLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

View File

@ -73,14 +73,23 @@
</update>
<select id="jobLineList"
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DispatchQuantityResponseDO">
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO">
SELECT
<choose>
<when test="type == 'DAY'">
DATE_FORMAT(create_dt,'%H')
</when>
<when test="type == 'WEEK'">
DATE_FORMAT(create_dt,'%Y-%m-%d')
</when>
<when test="type =='MONTH'">
DATE_FORMAT(create_dt,'%Y-%m-%d')
</when>
<when test="type == 'YEAR'">
DATE_FORMAT(trigger_at,'%Y-%m')
DATE_FORMAT(create_dt,'%Y-%m')
</when>
<otherwise>
DATE_FORMAT(trigger_at,'%Y-%m-%d')
DATE_FORMAT(create_dt,'%Y-%m-%d')
</otherwise>
</choose>
AS createDt,

View File

@ -73,22 +73,48 @@
<select id="retryTaskBarList"
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTaskBar">
SELECT DATE_FORMAT(trigger_at, '%Y-%m-%d') AS x,
SUM(running_num + finish_num + max_count_num + suspend_num) AS y
FROM retry_summary
WHERE namespace_id = #{namespaceId}
GROUP BY trigger_at LIMIT 7
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
GROUP BY triggerAt
) b
ON tmp.date = b.triggerAt
</select>
<select id="retryLineList"
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLinkeResponseDO">
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO">
SELECT
<choose>
<when test="type == 'DAY'">
DATE_FORMAT(create_dt,'%H')
</when>
<when test="type == 'WEEK'">
DATE_FORMAT(create_dt,'%Y-%m-%d')
</when>
<when test="type =='MONTH'">
DATE_FORMAT(create_dt,'%Y-%m-%d')
</when>
<when test="type == 'YEAR'">
DATE_FORMAT(trigger_at,'%Y-%m')
DATE_FORMAT(create_dt,'%Y-%m')
</when>
<otherwise>
DATE_FORMAT(trigger_at,'%Y-%m-%d')
DATE_FORMAT(create_dt,'%Y-%m-%d')
</otherwise>
</choose>
AS createDt,

View File

@ -1,15 +1,18 @@
package com.aizuda.easy.retry.server.web.model.enums;
import com.aizuda.easy.retry.server.web.model.response.DispatchQuantityResponseVO;
import com.aizuda.easy.retry.server.web.model.response.DashboardLineResponseVO;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author: byteblogs
@ -17,9 +20,30 @@ import java.util.function.Function;
*/
public enum DateTypeEnum {
/**
*
* 按小时
*/
DAY(dispatchQuantityResponseVOList -> {
DAY(dashboardLineResponseVOList -> {
Map<String, DashboardLineResponseVO> dashboardLineResponseVOMap = dashboardLineResponseVOList.stream().collect(Collectors.toMap(DashboardLineResponseVO::getCreateDt, i -> i));
for (int i = 0; i <= LocalDateTime.now().with(TemporalAdjusters.lastDayOfMonth()).getHour(); i++) {
String format = LocalDateTime.of(LocalDate.now(), LocalTime.MIN).plusHours(i).format(DateTimeFormatter.ofPattern("HH"));
DashboardLineResponseVO dashboardLineResponseVO = dashboardLineResponseVOMap.get(format);
if (Objects.isNull(dashboardLineResponseVO)) {
dashboardLineResponseVO = new DashboardLineResponseVO()
.setTotal(0L)
.setTotalNum(0L)
.setFail(0L)
.setFailNum(0L)
.setMaxCountNum(0L)
.setRunningNum(0L)
.setSuccessNum(0L)
.setSuspendNum(0L)
.setStopNum(0L)
.setCancelNum(0L)
.setCreateDt(format);
dashboardLineResponseVOList.add(dashboardLineResponseVO);
}
}
}, (startTime) -> {
return Objects.isNull(startTime) ?
LocalDateTime.of(LocalDate.now(), LocalTime.MIN.withNano(0)) :
@ -32,7 +56,28 @@ public enum DateTypeEnum {
/**
*
*/
WEEK(dispatchQuantityResponseVOList -> {
WEEK(dashboardLineResponseVOList -> {
Map<String, DashboardLineResponseVO> dispatchQuantityResponseVOMap = dashboardLineResponseVOList.stream().collect(Collectors.toMap(DashboardLineResponseVO::getCreateDt, i -> i));
for (int i = 0; i < 7; i++) {
String format = LocalDateTime.of(LocalDate.now().minusDays(i), LocalTime.MIN).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
DashboardLineResponseVO dashboardLineResponseVO = dispatchQuantityResponseVOMap.get(format);
if (Objects.isNull(dashboardLineResponseVO)) {
dashboardLineResponseVO = new DashboardLineResponseVO()
.setTotal(0L)
.setTotalNum(0L)
.setFail(0L)
.setFailNum(0L)
.setMaxCountNum(0L)
.setRunningNum(0L)
.setSuccessNum(0L)
.setSuspendNum(0L)
.setStopNum(0L)
.setCancelNum(0L)
.setCreateDt(format);
dashboardLineResponseVOList.add(dashboardLineResponseVO);
}
}
}, (startTime) -> {
return Objects.isNull(startTime) ?
LocalDateTime.of(LocalDate.now().minusDays(7), LocalTime.MIN.withNano(0)) :
@ -46,7 +91,28 @@ public enum DateTypeEnum {
/**
*
*/
MONTH(dispatchQuantityResponseVOList -> {
MONTH(dashboardLineResponseVOList -> {
Map<String, DashboardLineResponseVO> dispatchQuantityResponseVOMap = dashboardLineResponseVOList.stream().collect(Collectors.toMap(DashboardLineResponseVO::getCreateDt, i -> i));
for (int i = 0; i < LocalDateTime.now().with(TemporalAdjusters.lastDayOfMonth()).getDayOfMonth(); i++) {
String format = LocalDateTime.of(LocalDate.now().minusDays(i), LocalTime.MIN).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
DashboardLineResponseVO dashboardLineResponseVO = dispatchQuantityResponseVOMap.get(format);
if (Objects.isNull(dashboardLineResponseVO)) {
dashboardLineResponseVO = new DashboardLineResponseVO()
.setTotal(0L)
.setTotalNum(0L)
.setFail(0L)
.setFailNum(0L)
.setMaxCountNum(0L)
.setRunningNum(0L)
.setSuccessNum(0L)
.setSuspendNum(0L)
.setStopNum(0L)
.setCancelNum(0L)
.setCreateDt(format);
dashboardLineResponseVOList.add(dashboardLineResponseVO);
}
}
}, (startTime) -> {
return Objects.isNull(startTime) ?
LocalDateTime.of(LocalDate.now().minusMonths(1), LocalTime.MIN.withNano(0)) :
@ -60,7 +126,7 @@ public enum DateTypeEnum {
/**
*
*/
YEAR(dispatchQuantityResponseVOList -> {
YEAR(dashboardLineResponseVOList -> {
}, (startTime) -> {
return LocalDateTime.of(LocalDate.now().with(TemporalAdjusters.firstDayOfYear()), LocalTime.MIN.withNano(0));
}, (endTime) -> {
@ -70,18 +136,18 @@ public enum DateTypeEnum {
/**
* 其他类型
*/
OTHERS(dispatchQuantityResponseVOList -> {
OTHERS(dashboardLineResponseVOList -> {
}, (startTime) -> {
return LocalDateTime.of(startTime.toLocalDate(), LocalTime.MIN.withNano(0));
}, (endTime) -> {
return LocalDateTime.of(endTime.toLocalDate(), LocalTime.MAX.withNano(0));
});
private Consumer<List<DispatchQuantityResponseVO>> consumer;
private Consumer<List<DashboardLineResponseVO>> consumer;
private Function<LocalDateTime, LocalDateTime> startTime;
private Function<LocalDateTime, LocalDateTime> endTime;
DateTypeEnum(Consumer<List<DispatchQuantityResponseVO>> listConsumer, Function<LocalDateTime, LocalDateTime> startTime, Function<LocalDateTime, LocalDateTime> endTime) {
DateTypeEnum(Consumer<List<DashboardLineResponseVO>> listConsumer, Function<LocalDateTime, LocalDateTime> startTime, Function<LocalDateTime, LocalDateTime> endTime) {
this.consumer = listConsumer;
this.startTime = startTime;
this.endTime = endTime;
@ -95,7 +161,7 @@ public enum DateTypeEnum {
return endTime;
}
public Consumer<List<DispatchQuantityResponseVO>> getConsumer() {
public Consumer<List<DashboardLineResponseVO>> getConsumer() {
return consumer;
}
}

View File

@ -1,101 +0,0 @@
package com.aizuda.easy.retry.server.web.model.enums;
import com.aizuda.easy.retry.server.web.model.response.DashboardRetryLinkeResponseVO;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.temporal.TemporalAdjusters;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Function;
/**
* @author: byteblogs
* @date: 2020/1/19 20:36
*/
public enum RetryDateTypeEnum {
/**
*
*/
DAY(dashboardRetryLinkeResponseVOList -> {
}, (startTime) -> {
return Objects.isNull(startTime) ?
LocalDateTime.of(LocalDate.now(), LocalTime.MIN.withNano(0)) :
LocalDateTime.of(startTime.toLocalDate(), LocalTime.MIN.withNano(0));
}, (endTime) -> {
return Objects.isNull(endTime) ?
LocalDateTime.of(LocalDate.now(), LocalTime.MAX.withNano(0)) :
LocalDateTime.of(endTime.toLocalDate(), LocalTime.MAX.withNano(0));
}),
/**
*
*/
WEEK(dashboardRetryLinkeResponseVOList -> {
}, (startTime) -> {
return Objects.isNull(startTime) ?
LocalDateTime.of(LocalDate.now().minusDays(7), LocalTime.MIN.withNano(0)) :
LocalDateTime.of(startTime.toLocalDate().minusDays(7), LocalTime.MIN.withNano(0));
}, (endTime) -> {
return Objects.isNull(endTime) ?
LocalDateTime.of(LocalDate.now(), LocalTime.MAX.withNano(0)) :
LocalDateTime.of(endTime.toLocalDate(), LocalTime.MAX.withNano(0));
}),
/**
*
*/
MONTH(dashboardRetryLinkeResponseVOList -> {
}, (startTime) -> {
return Objects.isNull(startTime) ?
LocalDateTime.of(LocalDate.now().minusMonths(1), LocalTime.MIN.withNano(0)) :
LocalDateTime.of(startTime.toLocalDate().minusMonths(1), LocalTime.MIN.withNano(0));
}, (endTime) -> {
return Objects.isNull(endTime) ?
LocalDateTime.of(LocalDate.now(), LocalTime.MAX.withNano(0)) :
LocalDateTime.of(endTime.toLocalDate(), LocalTime.MAX.withNano(0));
}),
/**
*
*/
YEAR(dashboardRetryLinkeResponseVOList -> {
}, (startTime) -> {
return LocalDateTime.of(LocalDate.now().with(TemporalAdjusters.firstDayOfYear()), LocalTime.MIN.withNano(0));
}, (endTime) -> {
return LocalDateTime.of(LocalDate.now().with(TemporalAdjusters.lastDayOfYear()), LocalTime.MAX.withNano(0));
}),
/**
* 其他类型
*/
OTHERS(dashboardRetryLinkeResponseVOList -> {
}, (startTime) -> {
return LocalDateTime.of(startTime.toLocalDate(), LocalTime.MIN.withNano(0));
}, (endTime) -> {
return LocalDateTime.of(endTime.toLocalDate(), LocalTime.MAX.withNano(0));
});
private Consumer<List<DashboardRetryLinkeResponseVO>> consumer;
private Function<LocalDateTime, LocalDateTime> startTime;
private Function<LocalDateTime, LocalDateTime> endTime;
RetryDateTypeEnum(Consumer<List<DashboardRetryLinkeResponseVO>> listConsumer, Function<LocalDateTime, LocalDateTime> startTime, Function<LocalDateTime, LocalDateTime> endTime) {
this.consumer = listConsumer;
this.startTime = startTime;
this.endTime = endTime;
}
public Function<LocalDateTime, LocalDateTime> getStartTime() {
return startTime;
}
public Function<LocalDateTime, LocalDateTime> getEndTime() {
return endTime;
}
public Consumer<List<DashboardRetryLinkeResponseVO>> getConsumer() {
return consumer;
}
}

View File

@ -75,13 +75,13 @@ public class DashboardCardResponseVO {
@Data
public static class RetryTaskBar {
/**
* 时间x
* 时间x
*/
private String x;
/**
* 总数y
* 任务总数y
*/
private Long y;
private Long taskTotal;
}
}

View File

@ -0,0 +1,69 @@
package com.aizuda.easy.retry.server.web.model.response;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* @author: wodeyangzipingpingwuqi
* @date : 2023-11-30
*/
@Data
@Accessors(chain = true)
public class DashboardLineResponseVO {
/**
* 时间x轴
*/
private String createDt;
/**
* 总量计算百分比
*/
private Long total;
/**
* 重试-成功数
*/
private Long successNum;
/**
* 重试-运行数
*/
private Long runningNum;
/**
* 重试-最大次数
*/
private Long maxCountNum;
/**
* 重试-暂停数
*/
private Long suspendNum;
/**
* 定时-失败任务
*/
private Long fail;
/**
* 定时-总任务数
*/
private Long totalNum;
/**
* 定时-无效任务数
*/
private Long failNum;
/**
* 定时-停止数
*/
private Long stopNum;
/**
* 定时-取消数
*/
private Long cancelNum;
}

View File

@ -25,23 +25,18 @@ public class DashboardRetryLineResponseVO {
/**
* 折线图列表
*/
private List<DispatchQuantityResponseVO> dispatchQuantityResponseVOList;
private List<DashboardRetryLinkeResponseVO> retryLinkeResponseVOList;
private List<DashboardLineResponseVO> dashboardLineResponseDOList;
@Data
public static class Task {
private String groupName;
private Integer run;
private Integer total;
}
@Data
public static class Rank {
private String name;
private String total;
}
}

View File

@ -1,23 +0,0 @@
package com.aizuda.easy.retry.server.web.model.response;
import lombok.Data;
/**
* @author: wodeyangzipingpingwuqi
* @date : 2023-11-30
*/
@Data
public class DashboardRetryLinkeResponseVO {
private String createDt;
private Long total;
private Long successNum;
private Long runningNum;
private Long maxCountNum;
private Long suspendNum;
}

View File

@ -1,28 +0,0 @@
package com.aizuda.easy.retry.server.web.model.response;
import lombok.Data;
/**
* @author: www.byteblogs.com
* @date : 2022-04-22 20:27
*/
@Data
public class DispatchQuantityResponseVO {
private String createDt;
private Long total;
private Long successNum;
private Long fail;
private Long totalNum;
private Long failNum;
private Long stopNum;
private Long cancelNum;
}

View File

@ -1,9 +1,7 @@
package com.aizuda.easy.retry.server.web.service.convert;
import com.aizuda.easy.retry.server.web.model.response.DashboardRetryLinkeResponseVO;
import com.aizuda.easy.retry.server.web.model.response.DispatchQuantityResponseVO;
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLinkeResponseDO;
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.DispatchQuantityResponseDO;
import com.aizuda.easy.retry.server.web.model.response.DashboardLineResponseVO;
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@ -19,7 +17,5 @@ public interface DispatchQuantityResponseVOConverter {
DispatchQuantityResponseVOConverter INSTANCE = Mappers.getMapper(DispatchQuantityResponseVOConverter.class);
List<DashboardRetryLinkeResponseVO> toDashboardRetryLinkeResponseVO(List<DashboardRetryLinkeResponseDO> dashboardRetryLinkeResponseDOList);
List<DispatchQuantityResponseVO> toDispatchQuantityResponseVO(List<DispatchQuantityResponseDO> dispatchQuantityResponseDOList);
List<DashboardLineResponseVO> toDashboardLineResponseVO(List<DashboardLineResponseDO> dashboardLineResponseDOList);
}

View File

@ -11,7 +11,6 @@ import com.aizuda.easy.retry.server.common.register.ServerRegister;
import com.aizuda.easy.retry.server.web.model.base.BaseQueryVO;
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.enums.RetryDateTypeEnum;
import com.aizuda.easy.retry.server.web.model.request.ServerNodeQueryVO;
import com.aizuda.easy.retry.server.web.model.response.*;
import com.aizuda.easy.retry.server.web.service.DashBoardService;
@ -19,8 +18,7 @@ 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.DashboardRetryLineResponseDO;
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLinkeResponseDO;
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.DispatchQuantityResponseDO;
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO;
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;
@ -40,6 +38,7 @@ import org.springframework.web.client.RestTemplate;
import java.text.MessageFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Comparator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@ -103,13 +102,14 @@ public class DashBoardServiceImpl implements DashBoardService {
dashboardRetryLineResponseVO.setTaskList(pageResult);
// 折线图
RetryDateTypeEnum dateTypeEnum = RetryDateTypeEnum.valueOf(type);
DateTypeEnum dateTypeEnum = DateTypeEnum.valueOf(type);
LocalDateTime startDateTime = dateTypeEnum.getStartTime().apply(StrUtil.isNotBlank(startTime) ? LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) : null);
LocalDateTime endDateTime = dateTypeEnum.getEndTime().apply(StrUtil.isNotBlank(endTime) ? LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) : null);
List<DashboardRetryLinkeResponseDO> dashboardRetryLinkeResponseDOList = retrySummaryMapper.retryLineList(namespaceId, type, startDateTime, endDateTime);
List<DashboardRetryLinkeResponseVO> retryLinkeResponseVOList = DispatchQuantityResponseVOConverter.INSTANCE.toDashboardRetryLinkeResponseVO(dashboardRetryLinkeResponseDOList);
dateTypeEnum.getConsumer().accept(retryLinkeResponseVOList);
dashboardRetryLineResponseVO.setRetryLinkeResponseVOList(retryLinkeResponseVOList);
List<DashboardLineResponseDO> dashboardRetryLinkeResponseDOList = retrySummaryMapper.retryLineList(namespaceId, type, startDateTime, endDateTime);
List<DashboardLineResponseVO> dashboardLineResponseVOList = DispatchQuantityResponseVOConverter.INSTANCE.toDashboardLineResponseVO(dashboardRetryLinkeResponseDOList);
dateTypeEnum.getConsumer().accept(dashboardLineResponseVOList);
dashboardLineResponseVOList.sort(Comparator.comparing(a -> a.getCreateDt()));
dashboardRetryLineResponseVO.setDashboardLineResponseDOList(dashboardLineResponseVOList);
// 排行榜
List<DashboardRetryLineResponseDO.Rank> rankList = retrySummaryMapper.dashboardRank(namespaceId, groupName, startDateTime, endDateTime);
@ -133,10 +133,11 @@ public class DashBoardServiceImpl implements DashBoardService {
DateTypeEnum dateTypeEnum = DateTypeEnum.valueOf(type);
LocalDateTime startDateTime = dateTypeEnum.getStartTime().apply(StrUtil.isNotBlank(startTime) ? LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) : null);
LocalDateTime endDateTime = dateTypeEnum.getEndTime().apply(StrUtil.isNotBlank(endTime) ? LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) : null);
List<DispatchQuantityResponseDO> dispatchQuantityResponseDOList = jobSummaryMapper.jobLineList(namespaceId, type, startDateTime, endDateTime);
List<DispatchQuantityResponseVO> dispatchQuantityResponseVOList = DispatchQuantityResponseVOConverter.INSTANCE.toDispatchQuantityResponseVO(dispatchQuantityResponseDOList);
dateTypeEnum.getConsumer().accept(dispatchQuantityResponseVOList);
dashboardRetryLineResponseVO.setDispatchQuantityResponseVOList(dispatchQuantityResponseVOList);
List<DashboardLineResponseDO> dashboardLineResponseDOList = jobSummaryMapper.jobLineList(namespaceId, type, startDateTime, endDateTime);
List<DashboardLineResponseVO> dashboardLineResponseVOList = DispatchQuantityResponseVOConverter.INSTANCE.toDashboardLineResponseVO(dashboardLineResponseDOList);
dateTypeEnum.getConsumer().accept(dashboardLineResponseVOList);
dashboardLineResponseVOList.sort(Comparator.comparing(a -> a.getCreateDt()));
dashboardRetryLineResponseVO.setDashboardLineResponseDOList(dashboardLineResponseVOList);
// 排行榜
List<DashboardRetryLineResponseDO.Rank> rankList = jobSummaryMapper.dashboardRank(namespaceId, groupName, startDateTime, endDateTime);

View File

@ -15,6 +15,7 @@ export default {
data () {
return {
viewRecords: [],
dashboardLineResponseDOList: [],
chart: null
}
},
@ -31,7 +32,7 @@ export default {
'endTime': endTime
}).then(res => {
this.$bus.$emit('job', res)
this.viewCharts(res.data.dispatchQuantityResponseVOList)
this.viewCharts(res.data.dashboardLineResponseDOList)
})
},
viewCharts (viewRecords, type = 'WEEK') {

View File

@ -32,7 +32,7 @@ export default {
'endTime': endTime
}).then(res => {
this.$bus.$emit('retry', res)
this.viewCharts(res.data.retryLinkeResponseVOList)
this.viewCharts(res.data.dashboardLineResponseDOList)
})
},
viewCharts (viewRecords, type = 'WEEK') {

View File

@ -11,7 +11,8 @@ const getters = {
userInfo: state => state.user.info,
addRouters: state => state.permission.addRouters,
multiTab: state => state.app.multiTab,
namespaces: state => state.user.namespaces
namespaces: state => state.user.namespaces,
mode: state => state.user.mode
}
export default getters

View File

@ -1,6 +1,6 @@
import storage from 'store'
import { login, getInfo } from '@/api/login'
import { ACCESS_TOKEN, APP_NAMESPACE } from '@/store/mutation-types'
import { ACCESS_TOKEN, APP_MODE, APP_NAMESPACE } from '@/store/mutation-types'
import { welcome, permissionsConfig } from '@/utils/util'
const user = {
@ -37,6 +37,9 @@ const user = {
} else {
storage.set(APP_NAMESPACE, namespaces[0].uniqueId)
}
},
SET_MODE: (state, mode) => {
storage.set(APP_MODE, mode)
}
},
@ -84,6 +87,7 @@ const user = {
return permission.permissionId
})
commit('SET_ROLES', result.role)
commit('SET_MODE', result.mode)
commit('SET_INFO', result)
} else {
reject(new Error('getInfo: roles must be a non-null array !'))

View File

@ -13,6 +13,7 @@ export const TOGGLE_WEAK = 'weak'
export const TOGGLE_MULTI_TAB = 'multi_tab'
export const APP_LANGUAGE = 'app_language'
export const APP_NAMESPACE = 'app_namespace'
export const APP_MODE = 'app_mode'
export const CONTENT_WIDTH_TYPE = {
Fluid: 'Fluid',

View File

@ -8,9 +8,9 @@
</a-tooltip>
<div class="antv-chart-mini">
<div class="chart-wrapper" :style="{ height: 46 }">
<v-chart :force-fit="true" :height="height" :data="retryTaskBarList" :padding="[36, 5, 18, 5]">
<v-chart :force-fit="true" :height="height" :data="retryTaskBarList" :padding="[30, 22, 18, 10]">
<v-tooltip />
<v-bar position="x*y" />
<v-bar position="x*taskTotal" />
</v-chart>
</div>
</div>
@ -72,15 +72,29 @@
<a-card :loading="loading" :bordered="true" :body-style="{padding: '0'}">
<div class="salesCard">
<a-tabs>
<a-tab-pane loading="true" :tab="$t('dashboard.analysis.sales')" v-if="$auth('RetryAnalysis.retry')" key="1">
<a-tabs @change="callback">
<div class="extra-wrapper" slot="tabBarExtraContent">
<div class="extra-item">
<a href="#" @click="dataHandler('DAY')"><a-checkable-tag :checked="type == 'DAY'">{{ $t('dashboard.analysis.all-day') }}</a-checkable-tag></a>
<a href="#" @click="dataHandler('WEEK')"><a-checkable-tag :checked="type == 'WEEK'">{{ $t('dashboard.analysis.all-week') }}</a-checkable-tag></a>
<a href="#" @click="dataHandler('MONTH')"><a-checkable-tag :checked="type == 'MONTH'">{{ $t('dashboard.analysis.all-month') }}</a-checkable-tag></a>
<a href="#" @click="dataHandler('YEAR')"><a-checkable-tag :checked="type == 'YEAR'">{{ $t('dashboard.analysis.all-year') }}</a-checkable-tag></a>
</div>
<div class="extra-item">
<a-range-picker @change="dateChange" :show-time="{format: 'HH:mm:ss',defaultValue: [moment('00:00:00', 'HH:mm:ss'),moment('23:59:59', 'HH:mm:ss')]}" format="YYYY-MM-DD HH:mm:ss" :placeholder="['Start Time', 'End Time']" />
</div>
<a-select placeholder="请输入组名称" @change="value => handleChange(value)" :style="{width: '256px'}">
<a-select-option v-for="item in groupNameList" :value="item" :key="item">{{ item }}</a-select-option>
</a-select>
</div>
<a-tab-pane loading="true" :tab="$t('dashboard.analysis.sales')" v-if="$auth('RetryAnalysis.retry')" key="RETRY">
<div>
<retry-analysis />
<retry-analysis ref="retryAnalysisRef"/>
</div>
</a-tab-pane>
<a-tab-pane :tab="$t('dashboard.analysis.visits')" v-if="$auth('JobAnalysis.job')" key="2">
<a-tab-pane :tab="$t('dashboard.analysis.visits')" v-if="$auth('JobAnalysis.job')" key="JOB">
<div>
<job-analysis />
<job-analysis ref="jobAnalysisRef"/>
</div>
</a-tab-pane>
</a-tabs>
@ -99,12 +113,13 @@ import {
NumberInfo,
MiniSmoothArea
} from '@/components'
import {
getDashboardTaskRetryJob
} from '@/api/manage'
import { getAllGroupNameList, getDashboardTaskRetryJob } from '@/api/manage'
import RetryAnalysis from '@/views/dashboard/RetryAnalysis.vue'
import JobAnalysis from '@/views/dashboard/JobAnalysis.vue'
import { APP_MODE } from '@/store/mutation-types'
import storage from 'store'
import moment from 'moment'
export default {
name: 'Analysis',
@ -124,6 +139,9 @@ export default {
loading: true,
height: 100,
retryTaskBarList: [],
groupNameList: [],
type: 'WEEK',
mode: '',
retryTask: {
totalNum: 0,
runningNum: 0,
@ -147,11 +165,26 @@ export default {
computed: {
},
methods: {
moment,
callback (key) {
this.mode = key
},
jumpPosList () {
this.$router.push({ path: '/dashboard/pods' })
},
dataHandler (type) {
this.type = type
this.mode === 'ALL' || this.mode === 'RETRY' ? this.$refs.retryAnalysisRef.dataHandler(this.type) : this.$refs.jobAnalysisRef.dataHandler(this.type)
},
dateChange (date, dateString) {
this.mode === 'ALL' || this.mode === 'RETRY' ? this.$refs.retryAnalysisRef.dateChange(date, dateString) : this.$refs.jobAnalysisRef.dateChange(date, dateString)
},
handleChange (value) {
this.mode === 'ALL' || this.mode === 'RETRY' ? this.$refs.retryAnalysisRef.handleChange(value) : this.$refs.jobAnalysisRef.handleChange(value)
}
},
created () {
this.mode = storage.get(APP_MODE)
getDashboardTaskRetryJob().then(res => {
this.retryTask = res.data.retryTask
this.jobTask = res.data.jobTask
@ -159,6 +192,10 @@ export default {
this.retryTaskBarList = res.data.retryTaskBarList
})
getAllGroupNameList().then(res => {
this.groupNameList = res.data
})
setTimeout(() => {
this.loading = !this.loading
}, 1000)
@ -179,7 +216,6 @@ export default {
}
.extra-wrapper {
line-height: 55px;
padding-right: 24px;
.extra-item {

View File

@ -1,19 +1,5 @@
<template>
<div class="antd-pro-pages-dashboard-analysis-twoColLayout" :class="!isMobile && 'desktop'">
<div class="extra-wrapper" slot="tabBarExtraContent">
<div class="extra-item">
<a href="#" @click="dataHandler('DAY')"><a-tag :class="dateType == 'DAY' ? 'in' : 'on'">{{ $t('dashboard.analysis.all-day') }}</a-tag></a>
<a href="#" @click="dataHandler('WEEK')"><a-tag :class="dateType == 'WEEK' ? 'in' : 'on'">{{ $t('dashboard.analysis.all-week') }}</a-tag></a>
<a href="#" @click="dataHandler('MONTH')"><a-tag :class="dateType == 'MONTH' ? 'in' : 'on'">{{ $t('dashboard.analysis.all-month') }}</a-tag></a>
<a href="#" @click="dataHandler('YEAR')"><a-tag :class="dateType == 'YEAR' ? 'in' : 'on'">{{ $t('dashboard.analysis.all-year') }}</a-tag></a>
</div>
<div class="extra-item">
<a-range-picker @change="dateChange" :show-time="{format: 'HH:mm:ss',defaultValue: [moment('00:00:00', 'HH:mm:ss'),moment('23:59:59', 'HH:mm:ss')]}" format="YYYY-MM-DD HH:mm:ss" :placeholder="['Start Time', 'End Time']" />
</div>
<a-select placeholder="请输入组名称" @change="value => handleChange(value)" :style="{width: '256px'}">
<a-select-option v-for="item in groupNameList" :value="item" :key="item">{{ item }}</a-select-option>
</a-select>
</div>
<a-row>
<a-col :xl="16" :lg="12" :md="12" :sm="24" :xs="24">
<g2-job-line ref="jobViewChart" name="G2JobLine" />
@ -38,13 +24,6 @@
</a-col>
<a-col :xl="12" :lg="24" :md="24" :sm="24" :xs="24">
<a-card class="antd-pro-pages-dashboard-analysis-salesCard" :loading="loading" :bordered="false" :title="$t('dashboard.analysis.the-proportion-of-sales')" :style="{ height: '100%' }">
<div slot="extra" style="height: inherit;">
<div class="analysis-salesTypeRadio">
<a-radio-group defaultValue="a">
<a-radio-button value="timing">{{ $t('dashboard.analysis.channel.stores') }}</a-radio-button>
</a-radio-group>
</div>
</div>
<h4>{{ $t('dashboard.analysis.job.sales') }}</h4>
<div>
<div>
@ -86,8 +65,7 @@ export default {
loading: true,
rankList: [],
taskList: [],
dispatchQuantityResponseVOList: [],
dateType: 'WEEK',
dashboardLineResponseDOList: [],
type: 'WEEK',
groupName: '',
startTime: '',
@ -139,7 +117,7 @@ export default {
this.cancelNum = 0
this.rankList = res.data.rankList
this.taskList = res.data.taskList
res.data.dispatchQuantityResponseVOList.forEach(res => {
res.data.dashboardLineResponseDOList.forEach(res => {
this.successNum += res.successNum
this.failNum += res.failNum
this.stopNum += res.stopNum
@ -157,7 +135,6 @@ export default {
methods: {
moment,
dataHandler (type) {
this.dateType = type
this.type = type
this.$refs.jobViewChart.getDashboardJobLine(this.groupName, this.type, this.startTime, this.endTime)
},

View File

@ -1,19 +1,5 @@
<template>
<div class="antd-pro-pages-dashboard-analysis-twoColLayout" :class="!isMobile && 'desktop'">
<div class="extra-wrapper" slot="tabBarExtraContent">
<div class="extra-item">
<a href="#" @click="dataHandler('DAY')"><a-tag :class="dateType == 'DAY' ? 'in' : 'on'">{{ $t('dashboard.analysis.all-day') }}</a-tag></a>
<a href="#" @click="dataHandler('WEEK')"><a-tag :class="dateType == 'WEEK' ? 'in' : 'on'">{{ $t('dashboard.analysis.all-week') }}</a-tag></a>
<a href="#" @click="dataHandler('MONTH')"><a-tag :class="dateType == 'MONTH' ? 'in' : 'on'">{{ $t('dashboard.analysis.all-month') }}</a-tag></a>
<a href="#" @click="dataHandler('YEAR')"><a-tag :class="dateType == 'YEAR' ? 'in' : 'on'">{{ $t('dashboard.analysis.all-year') }}</a-tag></a>
</div>
<div class="extra-item">
<a-range-picker @change="dateChange" :show-time="{format: 'HH:mm:ss',defaultValue: [moment('00:00:00', 'HH:mm:ss'),moment('23:59:59', 'HH:mm:ss')]}" format="YYYY-MM-DD HH:mm:ss" :placeholder="['Start Time', 'End Time']" />
</div>
<a-select placeholder="请输入组名称" @change="value => handleChange(value)" :style="{width: '256px'}">
<a-select-option v-for="item in groupNameList" :value="item" :key="item">{{ item }}</a-select-option>
</a-select>
</div>
<a-row>
<a-col :xl="16" :lg="12" :md="12" :sm="24" :xs="24">
<g2-retry-line ref="viewChart" name="RetryLine" />
@ -38,13 +24,6 @@
</a-col>
<a-col :xl="12" :lg="24" :md="24" :sm="24" :xs="24">
<a-card class="antd-pro-pages-dashboard-analysis-salesCard" :loading="loading" :bordered="false" :title="$t('dashboard.analysis.the-proportion-of-sales')" :style="{ height: '100%' }">
<div slot="extra" style="height: inherit;">
<div class="analysis-salesTypeRadio">
<a-radio-group defaultValue="a">
<a-radio-button value="retry">{{ $t('dashboard.analysis.channel.online') }}</a-radio-button>
</a-radio-group>
</div>
</div>
<h4>{{ $t('dashboard.analysis.sales') }}</h4>
<div>
<div>
@ -86,7 +65,6 @@ export default {
loading: true,
rankList: [],
taskList: [],
dateType: 'WEEK',
type: 'WEEK',
groupName: '',
startTime: [],
@ -133,7 +111,7 @@ export default {
this.suspendNum = 0
this.rankList = res.data.rankList
this.taskList = res.data.taskList
res.data.retryLinkeResponseVOList.forEach(res => {
res.data.dashboardLineResponseDOList.forEach(res => {
this.successNum += res.successNum
this.runningNum += res.runningNum
this.maxCountNum += res.maxCountNum
@ -151,7 +129,6 @@ export default {
methods: {
moment,
dataHandler (type) {
this.dateType = type
this.type = type
this.$refs.viewChart.getDashboardRetryLine(this.groupName, this.type, this.startTime, this.endTime)
},