From a0e4e344f67f3e5f00c35c8a6f6cee7763b39074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Tue, 5 Jan 2021 10:14:42 +0800 Subject: [PATCH] =?UTF-8?q?CHART-17758=20=E5=9F=8B=E7=82=B9=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=BF=9D=E5=AD=98=E6=97=B6=E6=8C=89=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/chart/info/ChartInfo.java | 19 ++++++++++++++++++- .../chart/info/ChartInfoCollector.java | 8 +++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java index 9025b98064..262ccc8778 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java @@ -19,6 +19,8 @@ import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; import com.fr.third.joda.time.DateTime; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.HashMap; import java.util.Map; @@ -27,7 +29,7 @@ import java.util.Map; * @version 10.0 * Created by Bjorn on 2020-02-17 */ -public class ChartInfo extends AbstractPointInfo { +public class ChartInfo extends AbstractPointInfo implements Comparable { public static final String XML_TAG = "ChartInfo"; private static final String CHART_CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("chartinfo.consuming") + "/single"; private static final String CHART_FUNCTION_URL = CloudCenter.getInstance().acquireUrlByKind("chart.info.function") + "/single"; @@ -338,4 +340,19 @@ public class ChartInfo extends AbstractPointInfo { chartInfo.chartConfigInfo = chartConfigInfo.clone(); return chartInfo; } + + @Override + public int compareTo(ChartInfo chartInfo) { + DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + return format.parse(this.getCompareDate()).compareTo(format.parse(chartInfo.getCompareDate())); + } catch (Exception ex) { + return 1; + } + } + + private String getCompareDate() { + return StringUtils.isNotEmpty(chartConsumingMap.get(ATTR_CHART_PROPERTY_END_TIME)) ? + chartConsumingMap.get(ATTR_CHART_PROPERTY_END_TIME) : chartConsumingMap.get(ATTR_CHART_TYPE_TIME); + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java index cd651fc6b3..1b34722e6f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java @@ -13,7 +13,10 @@ import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; import com.fr.third.joda.time.DateTime; +import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -269,7 +272,10 @@ public class ChartInfoCollector extends AbstractPointCollector { writer.end(); writer.startTAG(XML_CHART_INFO_LIST); - for (ChartInfo chartInfo : pointInfoMap.values()) { + + List list = new ArrayList<>(pointInfoMap.values()); + Collections.sort(list); + for (ChartInfo chartInfo : list) { chartInfo.writeXML(writer); } writer.end();