Browse Source

CHART-12746

feature/big-screen
白岳 5 years ago
parent
commit
e73a8bbdea
  1. 2
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java
  2. 14
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java
  3. 40
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartSendHelper.java
  4. 8
      designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java
  5. 6
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java

2
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; return idleDayCount > COMPLETE_DAY_COUNT;
} }
String getChartConsumingMapJsonString() { public String getChartConsumingMapJsonString() {
return new JSONObject(chartConsumingMap).toString(); return new JSONObject(chartConsumingMap).toString();
} }

14
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.BaseBook;
import com.fr.base.io.XMLReadHelper; import com.fr.base.io.XMLReadHelper;
import com.fr.design.DesignerEnvManager; 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.design.mainframe.template.info.TemplateProcessInfo;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -177,15 +179,7 @@ public class ChartInfoCollector implements XMLReadable, XMLWriter {
int blockCount = processInfo.getBlockCount(); int blockCount = processInfo.getBlockCount();
int widgetCount = processInfo.getWidgetCount(); int widgetCount = processInfo.getWidgetCount();
boolean isTestTemplate; return TemplateInfo.judgeTestTemplate(reportType, cellCount, floatCount, blockCount, widgetCount);
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;
} }
/** /**
@ -201,7 +195,7 @@ public class ChartInfoCollector implements XMLReadable, XMLWriter {
ChartInfo chartInfo = chartInfoMap.get(key); ChartInfo chartInfo = chartInfoMap.get(key);
if (chartInfo.isComplete()) { if (chartInfo.isComplete()) {
if (!chartInfo.isTestTemplate()) { if (!chartInfo.isTestTemplate()) {
if (ChartSendHelper.sendChartInfo(chartInfo)) { if (SendHelper.sendChartInfo(chartInfo)) {
removeLaterList.add(key); removeLaterList.add(key);
} }
} else { } else {

40
designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartSendHelper.java

@ -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<String, Object> 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;
}
}

8
designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe.template.info; package com.fr.design.mainframe.template.info;
import com.fr.design.mainframe.SiteCenterToken; import com.fr.design.mainframe.SiteCenterToken;
import com.fr.design.mainframe.chart.info.ChartInfo;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.http.HttpToolbox; import com.fr.general.http.HttpToolbox;
@ -14,9 +15,10 @@ import java.util.Map;
* 负责向服务器发送信息 * 负责向服务器发送信息
* Created by plough on 2019/4/18. * 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 CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("tempinfo.consuming") + "/single";
private static final String PROCESS_URL = CloudCenter.getInstance().acquireUrlByKind("tempinfo.process") + "/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) { private static boolean sendConsumingInfo(String content) {
return sendSingleTemplateInfo(CONSUMING_URL, content); return sendSingleTemplateInfo(CONSUMING_URL, content);
@ -30,6 +32,10 @@ class SendHelper {
return SendHelper.sendConsumingInfo(templateInfo.getConsumingMapJsonString()) && SendHelper.sendProcessInfo(templateInfo.getProcessMapJsonString()); 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) { private static boolean sendSingleTemplateInfo(String url, String content) {
Map<String, Object> para = new HashMap<>(); Map<String, Object> para = new HashMap<>();
para.put("token", SiteCenterToken.generateToken()); para.put("token", SiteCenterToken.generateToken());

6
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. * Created by plough on 2019/4/18.
*/ */
class TemplateInfo implements XMLReadable, XMLWriter { public class TemplateInfo implements XMLReadable, XMLWriter {
static final String XML_TAG = "TemplateInfo"; static final String XML_TAG = "TemplateInfo";
private static final String XML_PROCESS_MAP = "processMap"; 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 floatCount = (int) processMap.get(ATTR_FLOAT_COUNT);
int blockCount = (int) processMap.get(ATTR_BLOCK_COUNT); int blockCount = (int) processMap.get(ATTR_BLOCK_COUNT);
int widgetCount = (int) processMap.get(ATTR_WIDGET_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; boolean isTestTemplate;
if (reportType == 0) { // 普通报表 if (reportType == 0) { // 普通报表
isTestTemplate = cellCount <= VALID_CELL_COUNT && floatCount <= 1 && widgetCount <= VALID_WIDGET_COUNT; isTestTemplate = cellCount <= VALID_CELL_COUNT && floatCount <= 1 && widgetCount <= VALID_WIDGET_COUNT;

Loading…
Cancel
Save