From e73a8bbdea728a3217a7ebf81a58a0a0b903e0f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Wed, 19 Feb 2020 19:07:44 +0800 Subject: [PATCH] CHART-12746 --- .../mainframe/chart/info/ChartInfo.java | 2 +- .../chart/info/ChartInfoCollector.java | 14 ++----- .../mainframe/chart/info/ChartSendHelper.java | 40 ------------------- .../mainframe/template/info/SendHelper.java | 8 +++- .../mainframe/template/info/TemplateInfo.java | 6 ++- 5 files changed, 17 insertions(+), 53 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartSendHelper.java 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 c7232b7010..eb81d4fd80 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 @@ -212,7 +212,7 @@ public class ChartInfo implements XMLReadable, XMLWriter { return idleDayCount > COMPLETE_DAY_COUNT; } - String getChartConsumingMapJsonString() { + public String getChartConsumingMapJsonString() { return new JSONObject(chartConsumingMap).toString(); } 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 e7330d137d..0fc0501ac6 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 @@ -4,6 +4,8 @@ import com.fr.base.FRContext; import com.fr.base.io.BaseBook; import com.fr.base.io.XMLReadHelper; import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.template.info.SendHelper; +import com.fr.design.mainframe.template.info.TemplateInfo; import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; @@ -177,15 +179,7 @@ public class ChartInfoCollector implements XMLReadable, XMLWriter { int blockCount = processInfo.getBlockCount(); int widgetCount = processInfo.getWidgetCount(); - boolean isTestTemplate; - if (reportType == 0) { // 普通报表 - isTestTemplate = cellCount <= VALID_CELL_COUNT && floatCount <= 1 && widgetCount <= VALID_WIDGET_COUNT; - } else if (reportType == 1) { // 聚合报表 - isTestTemplate = blockCount <= 1 && widgetCount <= VALID_WIDGET_COUNT; - } else { // 表单(reportType == 2) - isTestTemplate = widgetCount <= 1; - } - return isTestTemplate; + return TemplateInfo.judgeTestTemplate(reportType, cellCount, floatCount, blockCount, widgetCount); } /** @@ -201,7 +195,7 @@ public class ChartInfoCollector implements XMLReadable, XMLWriter { ChartInfo chartInfo = chartInfoMap.get(key); if (chartInfo.isComplete()) { if (!chartInfo.isTestTemplate()) { - if (ChartSendHelper.sendChartInfo(chartInfo)) { + if (SendHelper.sendChartInfo(chartInfo)) { removeLaterList.add(key); } } else { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartSendHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartSendHelper.java deleted file mode 100644 index 6c5b4676fa..0000000000 --- a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartSendHelper.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.fr.design.mainframe.chart.info; - -import com.fr.design.mainframe.SiteCenterToken; -import com.fr.general.CloudCenter; -import com.fr.general.ComparatorUtils; -import com.fr.general.http.HttpToolbox; -import com.fr.json.JSONObject; -import com.fr.log.FineLoggerFactory; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Bjorn - * @version 10.0 - * Created by Bjorn on 2020-02-19 - */ -class ChartSendHelper { - private static final String CHART_CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("chartinfo.consuming") + "/single"; - - static boolean sendChartInfo(ChartInfo chartInfo) { - return sendSingleChartInfo(CHART_CONSUMING_URL, chartInfo.getChartConsumingMapJsonString()); - } - - private static boolean sendSingleChartInfo(String url, String content) { - Map para = new HashMap<>(); - para.put("token", SiteCenterToken.generateToken()); - para.put("content", content); - - try { - String res = HttpToolbox.post(url, para); - return ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); - } catch (Throwable e) { - // 客户不需要关心,错误等级为 debug 就行了 - FineLoggerFactory.getLogger().debug(e.getMessage(), e); - } - return false; - } - -} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java index db489fb3c5..fafd4f1e20 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.template.info; import com.fr.design.mainframe.SiteCenterToken; +import com.fr.design.mainframe.chart.info.ChartInfo; import com.fr.general.CloudCenter; import com.fr.general.ComparatorUtils; import com.fr.general.http.HttpToolbox; @@ -14,9 +15,10 @@ import java.util.Map; * 负责向服务器发送信息 * Created by plough on 2019/4/18. */ -class SendHelper { +public class SendHelper { private static final String CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("tempinfo.consuming") + "/single"; private static final String PROCESS_URL = CloudCenter.getInstance().acquireUrlByKind("tempinfo.process") + "/single"; + private static final String CHART_CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("chartinfo.consuming") + "/single"; private static boolean sendConsumingInfo(String content) { return sendSingleTemplateInfo(CONSUMING_URL, content); @@ -30,6 +32,10 @@ class SendHelper { return SendHelper.sendConsumingInfo(templateInfo.getConsumingMapJsonString()) && SendHelper.sendProcessInfo(templateInfo.getProcessMapJsonString()); } + public static boolean sendChartInfo(ChartInfo chartInfo) { + return sendSingleTemplateInfo(CHART_CONSUMING_URL, chartInfo.getChartConsumingMapJsonString()); + } + private static boolean sendSingleTemplateInfo(String url, String content) { Map para = new HashMap<>(); para.put("token", SiteCenterToken.generateToken()); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java index 900210bd0c..334aaf509a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java @@ -20,7 +20,7 @@ import java.util.Map; * 对应一张模版的记录 * Created by plough on 2019/4/18. */ -class TemplateInfo implements XMLReadable, XMLWriter { +public class TemplateInfo implements XMLReadable, XMLWriter { static final String XML_TAG = "TemplateInfo"; private static final String XML_PROCESS_MAP = "processMap"; @@ -195,6 +195,10 @@ class TemplateInfo implements XMLReadable, XMLWriter { int floatCount = (int) processMap.get(ATTR_FLOAT_COUNT); int blockCount = (int) processMap.get(ATTR_BLOCK_COUNT); int widgetCount = (int) processMap.get(ATTR_WIDGET_COUNT); + return judgeTestTemplate(reportType, cellCount, floatCount, blockCount, widgetCount); + } + + public static boolean judgeTestTemplate(int reportType, int cellCount, int floatCount, int blockCount, int widgetCount){ boolean isTestTemplate; if (reportType == 0) { // 普通报表 isTestTemplate = cellCount <= VALID_CELL_COUNT && floatCount <= 1 && widgetCount <= VALID_WIDGET_COUNT;