From 74ebe8ddc471fc213c3c4bc5534a376e4b150702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Fri, 3 Apr 2020 16:05:30 +0800 Subject: [PATCH] =?UTF-8?q?CHART-13272=20=E5=9F=8B=E7=82=B9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BC=98=E5=8C=96=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=AD=97?= =?UTF-8?q?=E6=AE=B5&&=E6=B5=8B=E8=AF=95=E5=9B=BE=E8=A1=A8=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/chart/info/ChartInfo.java | 45 +++++++++++++++++-- .../chart/info/ChartInfoCollector.java | 39 +++++++++++----- .../design/mainframe/chart/ChartEditPane.java | 4 +- .../type/AbstractVanChartTypePane.java | 2 +- .../mainframe/FormCreatorDropTarget.java | 17 +++++-- 5 files changed, 87 insertions(+), 20 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 9d305ef1da..69e2c08029 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 @@ -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 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(); 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 d622c688a5..b1aec50363 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 @@ -53,21 +53,25 @@ public class ChartInfoCollector extends AbstractPointCollector { } 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 { 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.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.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 { 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); + } + /** * 保存模板的时候将该模板中的图表埋点信息保存 */ diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java index 0089785ce2..83e194c71d 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java +++ b/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"); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java index 36f34c9953..e9395ccb56 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java @@ -111,7 +111,7 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane 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); + } } } }