diff --git a/core/core-backend/src/main/java/io/dataease/chart/manage/ChartViewThresholdManage.java b/core/core-backend/src/main/java/io/dataease/chart/manage/ChartViewThresholdManage.java index 174e085412..24b8470111 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/manage/ChartViewThresholdManage.java +++ b/core/core-backend/src/main/java/io/dataease/chart/manage/ChartViewThresholdManage.java @@ -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 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); } }