Browse Source

Pull request #3244: CHART-17758 埋点数据保存时按时间排序

Merge in DESIGN/design from ~BJORN/design:release/10.0 to release/10.0

* commit '0c0261f6333c08dfefdfc7222799469579c66d02':
  CHART-17758 埋点数据保存时按时间排序
feature/big-screen
Bjorn 4 years ago
parent
commit
7080fed291
  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.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<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_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);
}
}

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.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<ChartInfo> {
writer.end();
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);
}
writer.end();

Loading…
Cancel
Save