Pre Merge pull request !65 from dhb52/dev_3.2.0
This commit is contained in:
commit
b48041b5f7
@ -83,7 +83,7 @@
|
||||
COALESCE(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total
|
||||
FROM (
|
||||
SELECT
|
||||
DATE_FORMAT(trigger_at, #{dateFormat}) AS createDt,
|
||||
TO_CHAR(trigger_at, #{dateFormat}) AS createDt,
|
||||
success_num,
|
||||
fail_num,
|
||||
stop_num,
|
||||
@ -91,7 +91,7 @@
|
||||
FROM job_summary
|
||||
${ew.customSqlSegment}
|
||||
)
|
||||
GROUP BY DATE_FORMAT(trigger_at, #{dateFormat})
|
||||
GROUP BY createDt
|
||||
</select>
|
||||
|
||||
<select id="toJobTask"
|
||||
|
@ -53,16 +53,16 @@
|
||||
<select id="jobLineList"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO">
|
||||
SELECT
|
||||
DATE_FORMAT(trigger_at, #{dateFormat}) AS createDt,
|
||||
COALESCE(SUM(success_num), 0) AS success,
|
||||
COALESCE(SUM(fail_num), 0) AS failNum,
|
||||
COALESCE(SUM(stop_num), 0) AS stop,
|
||||
COALESCE(SUM(cancel_num), 0) AS cancel,
|
||||
COALESCE(SUM(fail_num + stop_num + cancel_num), 0) AS fail,
|
||||
COALESCE(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total
|
||||
TO_CHAR(trigger_at, #{dateFormat}) AS createDt,
|
||||
COALESCE(SUM(success_num), 0) AS success,
|
||||
COALESCE(SUM(fail_num), 0) AS failNum,
|
||||
COALESCE(SUM(stop_num), 0) AS stop,
|
||||
COALESCE(SUM(cancel_num), 0) AS cancel,
|
||||
COALESCE(SUM(fail_num + stop_num + cancel_num), 0) AS fail,
|
||||
COALESCE(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total
|
||||
FROM job_summary
|
||||
${ew.customSqlSegment}
|
||||
GROUP BY DATE_FORMAT(trigger_at, #{dateFormat})
|
||||
GROUP BY createDt
|
||||
</select>
|
||||
|
||||
<select id="toJobTask"
|
||||
@ -79,13 +79,14 @@
|
||||
<select id="dashboardRank"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Rank">
|
||||
SELECT
|
||||
<if test="systemTaskType == 3">
|
||||
CONCAT(group_name, '/', (SELECT job_name FROM job WHERE id = business_id)) name,
|
||||
</if>
|
||||
<if test="systemTaskType == 4">
|
||||
CONCAT(group_name, '/', (SELECT workflow_name FROM workflow WHERE id = business_id)) name,
|
||||
</if>
|
||||
SUM(fail_num) AS total FROM job_summary
|
||||
<if test="systemTaskType == 3">
|
||||
CONCAT(group_name, '/', (SELECT job_name FROM job WHERE id = business_id)) name,
|
||||
</if>
|
||||
<if test="systemTaskType == 4">
|
||||
CONCAT(group_name, '/', (SELECT workflow_name FROM workflow WHERE id = business_id)) name,
|
||||
</if>
|
||||
SUM(fail_num) AS total
|
||||
FROM job_summary
|
||||
${ew.customSqlSegment}
|
||||
HAVING SUM(fail_num) > 0
|
||||
ORDER BY total DESC LIMIT 10
|
||||
|
@ -71,7 +71,7 @@
|
||||
ISNULL(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total
|
||||
FROM (
|
||||
SELECT
|
||||
DATE_FORMAT(trigger_at, #{dateFormat}) AS createDt,
|
||||
FORMAT(trigger_at, #{dateFormat}) AS createDt,
|
||||
success_num,
|
||||
stop_num,
|
||||
cancel_num,
|
||||
@ -79,7 +79,7 @@
|
||||
FROM job_summary
|
||||
${ew.customSqlSegment}
|
||||
) AS subquery
|
||||
GROUP BY DATE_FORMAT(trigger_at, #{dateFormat})
|
||||
GROUP BY createDt
|
||||
</select>
|
||||
|
||||
<select id="toJobTask"
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.aizuda.easy.retry.server.common.enums;
|
||||
|
||||
import com.aizuda.easy.retry.template.datasource.enums.DbTypeEnum;
|
||||
import com.aizuda.easy.retry.template.datasource.utils.DbUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@ -13,15 +15,13 @@ import lombok.Getter;
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum DashboardLineEnum {
|
||||
|
||||
DAY("DAY", "%H"),
|
||||
WEEK("WEEK", "%Y-%m-%d"),
|
||||
MONTH("MONTH", "%Y-%m-%d"),
|
||||
YEAR("YEAR", "%Y-%m"),
|
||||
DAY("DAY"),
|
||||
WEEK("WEEK"),
|
||||
MONTH("MONTH"),
|
||||
YEAR("YEAR"),
|
||||
;
|
||||
|
||||
private final String unit;
|
||||
private final String dateFormat;
|
||||
|
||||
public static DashboardLineEnum modeOf(String mode) {
|
||||
for (DashboardLineEnum value : DashboardLineEnum.values()) {
|
||||
@ -32,4 +32,35 @@ public enum DashboardLineEnum {
|
||||
|
||||
return DashboardLineEnum.WEEK;
|
||||
}
|
||||
|
||||
public static String dateFormat(String unit) {
|
||||
DashboardLineEnum mode = modeOf(unit);
|
||||
|
||||
if (DbUtils.getDbType().equals(DbTypeEnum.MYSQL)) {
|
||||
switch (mode) {
|
||||
case YEAR: return "%Y-%m";
|
||||
case DAY: return "%H";
|
||||
default: return "%Y-%m-%d";
|
||||
}
|
||||
} else if (DbUtils.getDbType().equals(DbTypeEnum.MARIADB)) {
|
||||
switch (mode) {
|
||||
case YEAR: return "%Y-%m";
|
||||
case DAY: return "%H";
|
||||
default: return "%Y-%m-%d";
|
||||
}
|
||||
} else if (DbUtils.getDbType().equals(DbTypeEnum.SQLSERVER)) {
|
||||
switch (mode) {
|
||||
case YEAR: return "yyyy-MM";
|
||||
case DAY: return "HH";
|
||||
default: return "yyyy-MM-dd";
|
||||
}
|
||||
} else { // Oracle, Postgres
|
||||
switch (mode) {
|
||||
case YEAR: return "yyyy-MM";
|
||||
case DAY: return "HH24";
|
||||
default: return "yyyy-MM-dd";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ public class DashBoardServiceImpl implements DashBoardService {
|
||||
.eq(JobSummary::getSystemTaskType, systemTaskType)
|
||||
.eq(JobSummary::getNamespaceId, namespaceId)
|
||||
.between(JobSummary::getTriggerAt, startDateTime, endDateTime);
|
||||
List<DashboardLineResponseDO> dashboardLineResponseDOList = jobSummaryMapper.jobLineList(DashboardLineEnum.modeOf(type).getDateFormat(), queryWrapper);
|
||||
List<DashboardLineResponseDO> dashboardLineResponseDOList = jobSummaryMapper.jobLineList(DashboardLineEnum.dateFormat(type), queryWrapper);
|
||||
List<DashboardLineResponseVO> dashboardLineResponseVOList = DispatchQuantityResponseVOConverter.INSTANCE.toDashboardLineResponseVO(dashboardLineResponseDOList);
|
||||
dateTypeEnum.getConsumer().accept(dashboardLineResponseVOList);
|
||||
dashboardLineResponseVOList.sort(Comparator.comparing(a -> a.getCreateDt()));
|
||||
@ -289,4 +289,5 @@ public class DashBoardServiceImpl implements DashBoardService {
|
||||
}
|
||||
return new PageResult<>(serverNodePageDTO, serverNodeResponseVOS);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user