mirror of
https://github.com/dataease/dataease.git
synced 2026-05-15 13:32:18 +08:00
fix(X-Pack): 阈值告警-动态时间小时粒度格式错误
This commit is contained in:
committed by
fit2cloud-chenyw
parent
3adf1c0bbb
commit
0a1dcf7194
@@ -171,7 +171,9 @@ public class ChartViewThresholdManage {
|
||||
int unit = Integer.parseInt(map.get("unit").toString());
|
||||
int suffix = Integer.parseInt(map.get("suffix").toString());
|
||||
String time = map.get("time").toString();
|
||||
|
||||
if (unit > 3) {
|
||||
time = getCustomTimeValue(format, unit, suffix, count, false);
|
||||
}
|
||||
List<String> unitLabels = null;
|
||||
if (StringUtils.equalsIgnoreCase("YYYY", format)) {
|
||||
unitLabels = List.of(Translator.get("i18n_time_year"));
|
||||
@@ -182,7 +184,7 @@ public class ChartViewThresholdManage {
|
||||
} else if (StringUtils.equalsIgnoreCase("HH:mm:ss", format)) {
|
||||
DEException.throwException("纯时间格式不支持动态格式");
|
||||
} else {
|
||||
unitLabels = List.of(Translator.get("i18n_time_year"), Translator.get("i18n_time_month"), Translator.get("i18n_time_date"));
|
||||
unitLabels = List.of(Translator.get("i18n_time_year"), Translator.get("i18n_time_month"), Translator.get("i18n_time_date"), Translator.get("i18n_time_hour"));
|
||||
}
|
||||
String unitText = unitLabels.get(unit - 1);
|
||||
String suffixText = Translator.get("i18n_time_ago");
|
||||
@@ -348,7 +350,7 @@ public class ChartViewThresholdManage {
|
||||
int suffix = Integer.parseInt(map.get("suffix").toString());
|
||||
String time = map.get("time").toString();
|
||||
String timeValue = getCustomTimeValue(format, unit, suffix, count, false);
|
||||
if (StringUtils.containsIgnoreCase(format, "yyyy-MM-dd HH") && StringUtils.isNotBlank(time)) {
|
||||
if (unit < 4 && StringUtils.containsIgnoreCase(format, "yyyy-MM-dd HH") && StringUtils.isNotBlank(time)) {
|
||||
return timeValue + " " + time;
|
||||
}
|
||||
return timeValue;
|
||||
@@ -393,7 +395,7 @@ public class ChartViewThresholdManage {
|
||||
if (hasTime) {
|
||||
now = now.withHour(0).withMinute(0).withSecond(0);
|
||||
} else {
|
||||
len = Math.min(len, 10);
|
||||
len = unit > 3 ? len : Math.min(len, 10);
|
||||
}
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(fullFormat.substring(0, len));
|
||||
if (count == 0) {
|
||||
@@ -409,11 +411,16 @@ public class ChartViewThresholdManage {
|
||||
return now.minusMonths(count).format(formatter);
|
||||
}
|
||||
return now.plusMonths(count).format(formatter);
|
||||
} else {
|
||||
} else if (unit == 3) {
|
||||
if (suffix == 1) {
|
||||
return now.minusDays(count).format(formatter);
|
||||
}
|
||||
return now.plusDays(count).format(formatter);
|
||||
} else {
|
||||
if (suffix == 1) {
|
||||
return now.minusHours(count).format(formatter);
|
||||
}
|
||||
return now.plusHours(count).format(formatter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user