Browse Source

CHART-17758 埋点数据保存时按时间排序

feature/big-screen
白岳 4 years ago
parent
commit
a0e4e344f6
  1. 19
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java
  2. 8
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java

19
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.stable.xml.XMLableReader;
import com.fr.third.joda.time.DateTime; import com.fr.third.joda.time.DateTime;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -27,7 +29,7 @@ import java.util.Map;
* @version 10.0 * @version 10.0
* Created by Bjorn on 2020-02-17 * Created by Bjorn on 2020-02-17
*/ */
public class ChartInfo extends AbstractPointInfo { public class ChartInfo extends AbstractPointInfo implements Comparable<ChartInfo> {
public static final String XML_TAG = "ChartInfo"; 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_CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("chartinfo.consuming") + "/single";
private static final String CHART_FUNCTION_URL = CloudCenter.getInstance().acquireUrlByKind("chart.info.function") + "/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(); chartInfo.chartConfigInfo = chartConfigInfo.clone();
return chartInfo; 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);
}
} }

8
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.stable.xml.XMLableReader;
import com.fr.third.joda.time.DateTime; import com.fr.third.joda.time.DateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -269,7 +272,10 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
writer.end(); writer.end();
writer.startTAG(XML_CHART_INFO_LIST); writer.startTAG(XML_CHART_INFO_LIST);
for (ChartInfo chartInfo : pointInfoMap.values()) {
List<ChartInfo> list = new ArrayList<>(pointInfoMap.values());
Collections.sort(list);
for (ChartInfo chartInfo : list) {
chartInfo.writeXML(writer); chartInfo.writeXML(writer);
} }
writer.end(); writer.end();

Loading…
Cancel
Save