Browse Source

CHART-13272 埋点功能优化,增加字段&&测试图表判断

feature/big-screen
白岳 5 years ago
parent
commit
74ebe8ddc4
  1. 45
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java
  2. 39
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java
  3. 4
      designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java
  4. 2
      designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java
  5. 17
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java

45
designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java

@ -30,6 +30,7 @@ public class ChartInfo extends AbstractPointInfo {
private static final String XML_CHART_CONSUMING_MAP = "chartConsumingMap";
private static final String ATTR_TEST_TEMPLATE = "testTemplate";
private static final String ATTR_TEST_CHART = "testChart";
private static final String ATTR_DAY_COUNT = "day_count";
private static final String ATTR_USERNAME = "username";
private static final String ATTR_UUID = "uuid";
@ -44,6 +45,11 @@ public class ChartInfo extends AbstractPointInfo {
private static final String ATTR_CHART_PROPERTY_END_TIME = "chartPropertyEndTime";
private static final String ATTR_JAR_TIME = "jarTime";
private static final String ATTR_VERSION = "version";
private static final String ATTR_USER_ID = "userId";
private static final String ATTR_FIRST_CHART_TYPE = "firstChartType";
private static final String ATTR_OVER_CHART_TYPE_COUNT = "overChartTypeCount";
private static final String ATTR_IS_NEW = "isNew";
private static final String ATTR_IS_REUSE = "isReuse";
private static final int COMPLETE_DAY_COUNT = 3; // 判断图表是否可以上传的天数
@ -57,6 +63,8 @@ public class ChartInfo extends AbstractPointInfo {
private boolean testTemplate;
private boolean testChart;
private ChartInfo() {
}
@ -64,6 +72,7 @@ public class ChartInfo extends AbstractPointInfo {
this.chartId = chartId;
this.templateId = templateId;
this.book = book;
this.testChart = true;
}
public String getChartId() {
@ -91,13 +100,17 @@ public class ChartInfo extends AbstractPointInfo {
@Override
public boolean isTestTemplate() {
return testTemplate;
return testTemplate || testChart;
}
public void setTestTemplate(boolean testTemplate) {
this.testTemplate = testTemplate;
}
public void setTestChart(boolean testChart) {
this.testChart = testChart;
}
static ChartInfo newInstanceByRead(XMLableReader reader) {
ChartInfo chartInfo = new ChartInfo();
reader.readXMLObject(chartInfo);
@ -105,13 +118,14 @@ public class ChartInfo extends AbstractPointInfo {
}
public static ChartInfo newInstance(String chartId, String chartType) {
return newInstance(chartId, chartType, null);
return newInstance(chartId, chartType, null, false, false);
}
public static ChartInfo newInstance(String chartId, String chartType, String createTime) {
public static ChartInfo newInstance(String chartId, String chartType, String createTime, boolean isNew, boolean isReuse) {
HashMap<String, String> chartConsumingMap = new HashMap<>();
String username = MarketConfig.getInstance().getBbsUsername();
String userId = String.valueOf(MarketConfig.getInstance().getBbsUid());
String uuid = DesignerEnvManager.getEnvManager().getUUID();
String activityKey = DesignerEnvManager.getEnvManager().getActivationKey();
@ -138,6 +152,11 @@ public class ChartInfo extends AbstractPointInfo {
chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, "");
chartConsumingMap.put(ATTR_JAR_TIME, jarTime);
chartConsumingMap.put(ATTR_VERSION, version);
chartConsumingMap.put(ATTR_USER_ID, userId);
chartConsumingMap.put(ATTR_FIRST_CHART_TYPE, chartType);
chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, "0");
chartConsumingMap.put(ATTR_IS_NEW, String.valueOf(isNew));
chartConsumingMap.put(ATTR_IS_REUSE, String.valueOf(isReuse));
ChartInfo chartInfo = new ChartInfo(chartId, templateId, book);
chartInfo.chartConsumingMap = chartConsumingMap;
@ -158,6 +177,7 @@ public class ChartInfo extends AbstractPointInfo {
writer.attr(ATTR_DAY_COUNT, this.idleDayCount);
}
writer.attr(ATTR_TEST_TEMPLATE, this.testTemplate);
writer.attr(ATTR_TEST_CHART, this.testChart);
writer.startTAG(XML_CHART_CONSUMING_MAP);
writer.attr(ATTR_USERNAME, chartConsumingMap.get(ATTR_USERNAME));
writer.attr(ATTR_UUID, chartConsumingMap.get(ATTR_UUID));
@ -170,6 +190,11 @@ public class ChartInfo extends AbstractPointInfo {
writer.attr(ATTR_CHART_PROPERTY_END_TIME, chartConsumingMap.get(ATTR_CHART_PROPERTY_END_TIME));
writer.attr(ATTR_JAR_TIME, chartConsumingMap.get(ATTR_JAR_TIME));
writer.attr(ATTR_VERSION, chartConsumingMap.get(ATTR_VERSION));
writer.attr(ATTR_USER_ID, chartConsumingMap.get(ATTR_USER_ID));
writer.attr(ATTR_FIRST_CHART_TYPE, chartConsumingMap.get(ATTR_FIRST_CHART_TYPE));
writer.attr(ATTR_OVER_CHART_TYPE_COUNT, chartConsumingMap.get(ATTR_OVER_CHART_TYPE_COUNT));
writer.attr(ATTR_IS_NEW, chartConsumingMap.get(ATTR_IS_NEW));
writer.attr(ATTR_IS_REUSE, chartConsumingMap.get(ATTR_IS_REUSE));
writer.end();
writer.end();
}
@ -182,6 +207,7 @@ public class ChartInfo extends AbstractPointInfo {
chartId = reader.getAttrAsString(ATTR_CHART_ID, StringUtils.EMPTY);
templateId = reader.getAttrAsString(ATTR_TEMPLATE_ID, StringUtils.EMPTY);
testTemplate = reader.getAttrAsBoolean(ATTR_TEST_TEMPLATE, true);
testChart = reader.getAttrAsBoolean(ATTR_TEST_CHART, false);
} else {
String name = reader.getTagName();
if (XML_CHART_CONSUMING_MAP.equals(name)) {
@ -198,6 +224,11 @@ public class ChartInfo extends AbstractPointInfo {
chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, reader.getAttrAsString(ATTR_CHART_PROPERTY_END_TIME, StringUtils.EMPTY));
chartConsumingMap.put(ATTR_JAR_TIME, reader.getAttrAsString(ATTR_JAR_TIME, StringUtils.EMPTY));
chartConsumingMap.put(ATTR_VERSION, reader.getAttrAsString(ATTR_VERSION, "8.0"));
chartConsumingMap.put(ATTR_USER_ID, reader.getAttrAsString(ATTR_USER_ID, StringUtils.EMPTY));
chartConsumingMap.put(ATTR_FIRST_CHART_TYPE, reader.getAttrAsString(ATTR_FIRST_CHART_TYPE, StringUtils.EMPTY));
chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, reader.getAttrAsString(ATTR_OVER_CHART_TYPE_COUNT, "0"));
chartConsumingMap.put(ATTR_IS_NEW, reader.getAttrAsString(ATTR_IS_NEW, StringUtils.EMPTY));
chartConsumingMap.put(ATTR_IS_REUSE, reader.getAttrAsString(ATTR_IS_REUSE, StringUtils.EMPTY));
}
}
}
@ -231,8 +262,16 @@ public class ChartInfo extends AbstractPointInfo {
chartConsumingMap.put(ATTR_CHART_TYPE, chartType);
chartConsumingMap.put(ATTR_CHART_PROPERTY_FIRST_TIME, "");
chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, "");
String count = chartConsumingMap.get(ATTR_OVER_CHART_TYPE_COUNT);
count = StringUtils.isEmpty(count) ? "1" : String.valueOf(Integer.parseInt(count) + 1);
chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, count);
}
public void updateFirstType(String chartType) {
chartConsumingMap.put(ATTR_FIRST_CHART_TYPE, chartType);
}
@Override
public ChartInfo clone() {
ChartInfo chartInfo = new ChartInfo();

39
designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java

@ -53,21 +53,25 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
}
public void collection(ChartProvider chartProvider, String createTime) {
collection(chartProvider, createTime, false);
}
public void collection(ChartProvider chartProvider, String createTime, boolean isReuse) {
if (chartProvider instanceof VanChart) {
VanChart vanChart = (VanChart) chartProvider;
collection(vanChart.getUuid(), vanChart.getID(), createTime);
collection(vanChart.getUuid(), vanChart.getID(), createTime, isReuse);
}
}
/**
* 新建图表保存状态
*/
public void collection(String chartId, String chartType, String createTime) {
public void collection(String chartId, String chartType, String createTime, boolean isReuse) {
if (!shouldCollectInfo()) {
return;
}
ChartInfo chartInfo = ChartInfo.newInstance(chartId, chartType, createTime);
ChartInfo chartInfo = ChartInfo.newInstance(chartId, chartType, createTime, true, isReuse);
chartInfoCacheMap.put(chartId, chartInfo);
}
@ -85,7 +89,7 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
if (!shouldCollectInfo()) {
return;
}
ChartInfo chartInfo = getOrCreateChartInfo(chartId, chartType);
ChartInfo chartInfo = getOrCreateChartInfo(chartId, chartType, null);
//更新编辑时间
chartInfo.updatePropertyTime();
@ -94,22 +98,22 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
chartInfo.resetIdleDayCount();
}
public void updateChartTypeTime(ChartProvider chartProvider) {
public void updateChartTypeTime(ChartProvider chartProvider, String oldType) {
if (chartProvider instanceof VanChart) {
VanChart vanChart = (VanChart) chartProvider;
updateChartTypeTime(vanChart.getUuid(), vanChart.getID());
updateChartTypeTime(vanChart.getUuid(), vanChart.getID(), oldType);
}
}
/**
* 图表类型变化更新类型和类型确认时间
*/
public void updateChartTypeTime(String chartId, String chartType) {
public void updateChartTypeTime(String chartId, String chartType, String oldType) {
if (!shouldCollectInfo()) {
return;
}
ChartInfo chartInfo = getOrCreateChartInfo(chartId, chartType);
ChartInfo chartInfo = getOrCreateChartInfo(chartId, chartType, oldType);
//更新类型确认时间和类型
chartInfo.updateChartType(chartType);
@ -118,7 +122,7 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
chartInfo.resetIdleDayCount();
}
private ChartInfo getOrCreateChartInfo(String chartId, String chartType) {
private ChartInfo getOrCreateChartInfo(String chartId, String chartType, String oldType) {
//缓存中有从缓存中拿
if (chartInfoCacheMap.containsKey(chartId)) {
return chartInfoCacheMap.get(chartId);
@ -129,12 +133,27 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
chartInfoCacheMap.put(chartId, chartInfo);
return chartInfo;
}
//都有的话创建一个并加入到缓存中
//都有的话创建一个并加入到缓存中
ChartInfo chartInfo = ChartInfo.newInstance(chartId, chartType);
if (StringUtils.isNotEmpty(oldType)) {
chartInfo.updateFirstType(oldType);
}
chartInfoCacheMap.put(chartId, chartInfo);
return chartInfo;
}
public void checkTestChart(ChartProvider chartProvider) {
if (chartProvider instanceof VanChart) {
checkTestChart((VanChart) chartProvider);
}
}
public void checkTestChart(VanChart vanChart) {
boolean testChart = vanChart.isTestChart();
ChartInfo chartInfo = chartInfoCacheMap.get(vanChart.getUuid());
chartInfo.setTestChart(testChart);
}
/**
* 保存模板的时候将该模板中的图表埋点信息保存
*/

4
designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java

@ -6,7 +6,6 @@ import com.fr.chart.chartattr.ChartCollection;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.tabledata.Prepare4DataSourceChange;
import com.fr.design.dialog.BasicPane;
@ -20,9 +19,9 @@ import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.ChartOtherPane;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.ChartTypePane;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.vanchart.VanChart;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
@ -116,6 +115,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare
if (!ComparatorUtils.equals(collection, lastCollection)) {
try {
ChartInfoCollector.getInstance().checkTestChart(collection.getSelectedChartProvider(ChartProvider.class));
lastCollection = collection.clone();
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("error in clone ChartEditPane");

2
designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java

@ -111,7 +111,7 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Cha
//切换图表时,数据配置不变,分类个数也不变
newPlot.setCategoryNum(oldPlot.getCategoryNum());
//切换类型埋点
ChartInfoCollector.getInstance().updateChartTypeTime(chart);
ChartInfoCollector.getInstance().updateChartTypeTime(chart, oldPlot.getPlotID());
}
if(chart instanceof VanChart

17
designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.chart.BaseChartCollection;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.DesignModelAdapter;
@ -23,13 +24,14 @@ import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.design.utils.ComponentUtils;
import com.fr.form.share.SharableEditorProvider;
import com.fr.form.share.ShareLoader;
import com.fr.form.ui.ChartEditor;
import com.fr.form.ui.SharableWidgetBindInfo;
import com.fr.form.ui.Widget;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JWindow;
import java.util.List;
import java.util.Map;
import java.awt.Color;
import java.awt.Component;
@ -284,9 +286,16 @@ public class FormCreatorDropTarget extends DropTarget {
}
private void dealChartBuryingPoint(Widget widget) {
if (widget instanceof ChartEditor) {
ChartCollection chartCollection = (ChartCollection)((ChartEditor) widget).getChartCollection();
ChartInfoCollector.getInstance().collection(chartCollection.getSelectedChartProvider(ChartProvider.class), null);
List<BaseChartCollection> chartCollections = widget.getChartCollections();
for (BaseChartCollection baseChartCollection : chartCollections) {
ChartCollection chartCollection = (ChartCollection) baseChartCollection;
for (int i = 0, size = chartCollection.getChartCount(); i < size; i++) {
ChartProvider chart = chartCollection.getChart(i, ChartProvider.class);
//是否是共享的复用组件
boolean isReuse = StringUtils.isNotEmpty(this.addingModel.getXCreator().getShareId());
ChartInfoCollector.getInstance().collection(chart, null, isReuse);
ChartInfoCollector.getInstance().checkTestChart(chart);
}
}
}
}

Loading…
Cancel
Save