Browse Source

CHART-12746 埋点接口

feature/big-screen
白岳 5 years ago
parent
commit
23e5b5a1dd
  1. 2
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  2. 130
      designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java
  3. 55
      designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointInfo.java
  4. 23
      designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointCollector.java
  5. 35
      designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointInfo.java
  6. 45
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java
  7. 129
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java
  8. 27
      designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java
  9. 63
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java
  10. 154
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java
  11. 9
      designer-base/src/test/java/com/fr/design/mainframe/template/info/SendHelperTest.java
  12. 23
      designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java
  13. 22
      designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTest.java
  14. 4
      designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java

2
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -165,7 +165,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
}
private void collectInfo(String originID) { // 执行收集操作
ChartInfoCollector.getInstance().collectInfo(template.getTemplateID(), originID, getProcessInfo());
ChartInfoCollector.getInstance().collectInfo(template.getTemplateID(), originID, getProcessInfo(), 0);
if (!consumeTimer.isEnabled()) {
return;
}

130
designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java

@ -0,0 +1,130 @@
package com.fr.design.mainframe.burying.point;
import com.fr.base.FRContext;
import com.fr.base.io.XMLReadHelper;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.template.info.SendHelper;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.javax.xml.stream.XMLStreamException;
import com.fr.third.org.apache.commons.io.FileUtils;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-02-21
*/
public abstract class AbstractPointCollector<T extends AbstractPointInfo> implements BasePointCollector {
protected Map<String, T> pointInfoMap;
private static final int MAX_SIZE = 512 * 1024 * 1024;
public AbstractPointCollector() {
pointInfoMap = new ConcurrentHashMap<>();
loadFromFile();
}
/**
* 获取是否满足触发埋点的要求
*/
protected boolean shouldCollectInfo() {
return FileUtils.sizeOf(getInfoFile()) <= MAX_SIZE && DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv();
}
@Override
public void sendPointInfo() {
addIdleDayCount();
List<String> removeList = new ArrayList<>();
List<String> sendList = new ArrayList<>();
for (String key : pointInfoMap.keySet()) {
AbstractPointInfo pointInfo = pointInfoMap.get(key);
pointInfo.selectPoint(removeList, sendList);
}
// 发送记录
for (String key : sendList) {
if(SendHelper.sendPointInfo(pointInfoMap.get(key))){
removeList.add(key);
}
}
// 清空记录
for (String key : removeList) {
pointInfoMap.remove(key);
}
saveInfo();
}
/**
* 从文件中读取埋点信息
*/
protected void loadFromFile() {
if (!getInfoFile().exists()) {
return;
}
XMLableReader reader = null;
try (InputStream in = new FileInputStream(getInfoFile())) {
// XMLableReader 还是应该考虑实现 Closable 接口的,这样就能使用 try-with 语句了
reader = XMLReadHelper.createXMLableReader(in, XMLPrintWriter.XML_ENCODER);
if (reader == null) {
return;
}
reader.readXMLObject(this);
} catch (FileNotFoundException e) {
// do nothing
} catch (XMLStreamException | IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (XMLStreamException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
/**
* 保存埋点信息到文件中
*/
protected void saveInfo() {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
XMLTools.writeOutputStreamXML(this, out);
out.flush();
out.close();
String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8);
FileUtils.writeStringToFile(getInfoFile(), fileContent, StandardCharsets.UTF_8);
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage());
}
}
/**
* 获取缓存文件存放路径
*/
protected abstract File getInfoFile();
protected abstract void addIdleDayCount();
}

55
designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointInfo.java

@ -0,0 +1,55 @@
package com.fr.design.mainframe.burying.point;
import java.util.List;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-02-21
*/
public abstract class AbstractPointInfo implements BasePointInfo {
protected int idleDayCount; // 到现在为止,埋点闲置的天数
@Override
public void resetIdleDayCount() {
this.idleDayCount = 0;
}
@Override
public void addIdleDayCountByOne() {
this.idleDayCount += 1;
}
/**
* 上传前判断该埋点是否需要被上传或者删除或者什么都不做
*/
@Override
public void selectPoint(List<String> removeList, List<String> sendList) {
//埋点还未完成,直接返回
if (!isComplete()) {
return;
}
//属于测试模板,直接删除,否则发送信息
if (isTestTemplate()) {
removeList.add(key());
} else {
sendList.add(key());
}
}
/**
* 是否为测试模板
*/
protected abstract boolean isTestTemplate();
/**
* 是否已经制作完成
*/
protected abstract boolean isComplete();
/**
* 埋点记录的主键
*/
protected abstract String key();
}

23
designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointCollector.java

@ -0,0 +1,23 @@
package com.fr.design.mainframe.burying.point;
import com.fr.design.mainframe.template.info.TemplateProcessInfo;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLWriter;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-02-21
*/
public interface BasePointCollector extends XMLReadable, XMLWriter {
/**
* 发送埋点信息到服务器
*/
public void sendPointInfo();
/**
* 保存埋点的信息到本地
*/
public void collectInfo(String templateID, String originID, TemplateProcessInfo processInfo, int timeConsume);
}

35
designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointInfo.java

@ -0,0 +1,35 @@
package com.fr.design.mainframe.burying.point;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLWriter;
import java.util.List;
import java.util.Map;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-02-21
*/
public interface BasePointInfo extends XMLReadable, XMLWriter {
/**
* 重置埋点的未编辑天数
*/
void resetIdleDayCount();
/**
* 增加一天埋点的未编辑天数
*/
void addIdleDayCountByOne();
/**
* 上传前判断该埋点是否需要被上传或者删除或者什么都不做
*/
void selectPoint(List<String> removeList, List<String> sendList);
/**
* 获取要上传的内容key上传路径value上传内容
*/
Map<String, String> getSendInfo();
}

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

@ -5,13 +5,13 @@ import com.fr.config.MarketConfig;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.burying.point.AbstractPointInfo;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralUtils;
import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.joda.time.DateTime;
@ -23,8 +23,10 @@ import java.util.Map;
* @version 10.0
* Created by Bjorn on 2020-02-17
*/
public class ChartInfo implements XMLReadable, XMLWriter {
public class ChartInfo extends AbstractPointInfo {
public static final String XML_TAG = "ChartInfo";
private static final String CHART_CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("chartinfo.consuming") + "/single";
private static final String XML_CHART_CONSUMING_MAP = "chartConsumingMap";
private static final String ATTR_TEST_TEMPLATE = "testTemplate";
@ -45,8 +47,6 @@ public class ChartInfo implements XMLReadable, XMLWriter {
private static final int COMPLETE_DAY_COUNT = 3; // 判断图表是否可以上传的天数
private int idleDayCount; // 到现在为止,图表闲置(上次保存后没有再编辑过)的天数
private String chartId = StringUtils.EMPTY;
private String templateId = StringUtils.EMPTY;
@ -57,6 +57,8 @@ public class ChartInfo implements XMLReadable, XMLWriter {
private boolean testTemplate;
private int idleDayCount; // 到现在为止,埋点闲置的天数
private ChartInfo() {
}
@ -70,6 +72,11 @@ public class ChartInfo implements XMLReadable, XMLWriter {
return chartId;
}
@Override
protected String key() {
return chartId;
}
public String getTemplateId() {
return templateId;
}
@ -84,6 +91,7 @@ public class ChartInfo implements XMLReadable, XMLWriter {
return book;
}
@Override
public boolean isTestTemplate() {
return testTemplate;
}
@ -107,7 +115,7 @@ public class ChartInfo implements XMLReadable, XMLWriter {
String username = MarketConfig.getInstance().getBbsUsername();
String uuid = DesignerEnvManager.getEnvManager().getUUID();
String activitykey = DesignerEnvManager.getEnvManager().getActivationKey();
String activityKey = DesignerEnvManager.getEnvManager().getActivationKey();
BaseBook book = DesignModelAdapter.getCurrentModelAdapter().getBook();
String templateId = book.getTemplateID();
@ -121,7 +129,7 @@ public class ChartInfo implements XMLReadable, XMLWriter {
String version = ProductConstants.VERSION;
chartConsumingMap.put(ATTR_USERNAME, username);
chartConsumingMap.put(ATTR_UUID, uuid);
chartConsumingMap.put(ATTR_ACTIVITYKEY, activitykey);
chartConsumingMap.put(ATTR_ACTIVITYKEY, activityKey);
chartConsumingMap.put(ATTR_TEMPLATE_ID, templateId);
chartConsumingMap.put(ATTR_REPORT_TYPE, String.valueOf(reportType));
chartConsumingMap.put(ATTR_CHART_ID, chartId);
@ -139,7 +147,7 @@ public class ChartInfo implements XMLReadable, XMLWriter {
return chartInfo;
}
@Override
public void writeXML(XMLPrintWriter writer) {
writer.startTAG(XML_TAG);
if (StringUtils.isNotEmpty(chartId)) {
@ -168,6 +176,7 @@ public class ChartInfo implements XMLReadable, XMLWriter {
writer.end();
}
@Override
public void readXML(XMLableReader reader) {
if (!reader.isChildNode()) {
@ -195,25 +204,17 @@ public class ChartInfo implements XMLReadable, XMLWriter {
}
}
public void resetIdleDayCount() {
this.idleDayCount = 0;
}
public void addIdleDayCountByOne() {
this.idleDayCount += 1;
}
public int getIdleDayCount() {
return this.idleDayCount;
}
@Override
public boolean isComplete() {
// 连续3天打开了设计器但是没有编辑
return idleDayCount > COMPLETE_DAY_COUNT;
}
public String getChartConsumingMapJsonString() {
return new JSONObject(chartConsumingMap).toString();
@Override
public Map<String, String> getSendInfo() {
Map<String, String> sendMap = new HashMap<>();
sendMap.put(CHART_CONSUMING_URL, new JSONObject(chartConsumingMap).toString());
return sendMap;
}
public void updatePropertyTime() {

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

@ -1,11 +1,8 @@
package com.fr.design.mainframe.chart.info;
import com.fr.base.FRContext;
import com.fr.base.io.BaseBook;
import com.fr.base.io.XMLReadHelper;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.template.info.SendHelper;
import com.fr.design.mainframe.burying.point.AbstractPointCollector;
import com.fr.design.mainframe.template.info.TemplateInfo;
import com.fr.design.mainframe.template.info.TemplateProcessInfo;
import com.fr.general.ComparatorUtils;
@ -15,46 +12,27 @@ import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.javax.xml.stream.XMLStreamException;
import com.fr.third.org.apache.commons.io.FileUtils;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-02-18
*/
public class ChartInfoCollector implements XMLReadable, XMLWriter {
public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
private static final String XML_TAG = "ChartInfoCollector";
private static final String XML_LAST_EDIT_DAY = "lastEditDay";
private static final String XML_CHART_INFO_LIST = "ChartInfoList";
private static final String XML_FILE_NAME = "chart.info";
private static final int VALID_CELL_COUNT = 5; // 有效报表模板的格子数
private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数
private static ChartInfoCollector instance;
private static final int MAX_SIZE = 512 * 1024 * 1024;
private Map<String, ChartInfo> chartInfoMap;
private Map<String, ChartInfo> chartInfoCacheMap;
@ -65,9 +43,7 @@ public class ChartInfoCollector implements XMLReadable, XMLWriter {
}
private void init() {
chartInfoMap = new ConcurrentHashMap<>();
chartInfoCacheMap = new HashMap<>();
loadFromFile();
}
public static ChartInfoCollector getInstance() {
@ -149,8 +125,8 @@ public class ChartInfoCollector implements XMLReadable, XMLWriter {
return chartInfoCacheMap.get(chartId);
}
//缓存中没有从文件中读取的信息中拷贝到缓存
if (chartInfoMap.containsKey(chartId)) {
ChartInfo chartInfo = chartInfoMap.get(chartId).clone();
if (pointInfoMap.containsKey(chartId)) {
ChartInfo chartInfo = pointInfoMap.get(chartId).clone();
chartInfoCacheMap.put(chartId, chartInfo);
return chartInfo;
}
@ -163,7 +139,8 @@ public class ChartInfoCollector implements XMLReadable, XMLWriter {
/**
* 保存模板的时候将该模板中的图表埋点信息保存
*/
public void collectInfo(String templateId, String originID, TemplateProcessInfo processInfo) {
@Override
public void collectInfo(String templateId, String originID, TemplateProcessInfo processInfo, int timeConsume) {
if (!shouldCollectInfo()) {
return;
}
@ -172,7 +149,7 @@ public class ChartInfoCollector implements XMLReadable, XMLWriter {
}
boolean testTemplate = isTestTemplate(processInfo);
for (ChartInfo chartInfo : chartInfoMap.values()) {
for (ChartInfo chartInfo : pointInfoMap.values()) {
if (originID.equals(chartInfo.getTemplateId())) {
chartInfo.setTemplateId(templateId);
chartInfo.setTestTemplate(testTemplate);
@ -185,7 +162,7 @@ public class ChartInfoCollector implements XMLReadable, XMLWriter {
originID.equals(chartInfo.getTemplateId())) {
chartInfo.setTemplateId(templateId);
chartInfo.setTestTemplate(testTemplate);
chartInfoMap.put(chartInfo.getChartId(), chartInfo);
pointInfoMap.put(chartInfo.getChartId(), chartInfo);
}
}
@ -203,83 +180,28 @@ public class ChartInfoCollector implements XMLReadable, XMLWriter {
return TemplateInfo.isTestTemplate(reportType, cellCount, floatCount, blockCount, widgetCount);
}
/**
* 发送本地图表信息到服务器并清空已发送图表的本地记录
*/
public void sendChartInfo() {
addIdleDayCount();
List<String> removeLaterList = new ArrayList<>();
for (String key : chartInfoMap.keySet()) {
ChartInfo chartInfo = chartInfoMap.get(key);
if (chartInfo.isComplete()) {
if (!chartInfo.isTestTemplate()) {
if (SendHelper.sendChartInfo(chartInfo)) {
removeLaterList.add(key);
}
} else {
removeLaterList.add(key);
}
}
}
// 清空记录
for (String key : removeLaterList) {
chartInfoMap.remove(key);
}
saveInfo();
}
/**
* 更新 day_count打开设计器却未编辑图表的连续日子
*/
private void addIdleDayCount() {
@Override
protected void addIdleDayCount() {
// 判断今天是否第一次打开设计器,为了防止同一天内,多次 addIdleDayCount
String today = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
if (ComparatorUtils.equals(today, lastEditDay)) {
return;
}
for (ChartInfo chartInfo : chartInfoMap.values()) {
for (ChartInfo chartInfo : pointInfoMap.values()) {
chartInfo.addIdleDayCountByOne();
}
lastEditDay = today;
}
private void loadFromFile() {
if (!getInfoFile().exists()) {
return;
}
XMLableReader reader = null;
try (InputStream in = new FileInputStream(getInfoFile())) {
// XMLableReader 还是应该考虑实现 Closable 接口的,这样就能使用 try-with 语句了
reader = XMLReadHelper.createXMLableReader(in, XMLPrintWriter.XML_ENCODER);
if (reader == null) {
return;
}
reader.readXMLObject(this);
} catch (FileNotFoundException e) {
// do nothing
} catch (XMLStreamException | IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (XMLStreamException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
/**
* 获取缓存文件存放路径
*/
private static File getInfoFile() {
@Override
protected File getInfoFile() {
File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), XML_FILE_NAME));
try {
if (!file.exists()) {
@ -291,27 +213,6 @@ public class ChartInfoCollector implements XMLReadable, XMLWriter {
return file;
}
private boolean shouldCollectInfo() {
return FileUtils.sizeOf(getInfoFile()) <= MAX_SIZE && DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv();
}
/**
* 将包含所有信息的对象保存到文件
*/
private void saveInfo() {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
XMLTools.writeOutputStreamXML(this, out);
out.flush();
out.close();
String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8);
FileUtils.writeStringToFile(getInfoFile(), fileContent, StandardCharsets.UTF_8);
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage());
}
}
@Override
public void readXML(XMLableReader reader) {
if (reader.isChildNode()) {
@ -319,7 +220,7 @@ public class ChartInfoCollector implements XMLReadable, XMLWriter {
String name = reader.getTagName();
if (ChartInfo.XML_TAG.equals(name)) {
ChartInfo chartInfo = ChartInfo.newInstanceByRead(reader);
chartInfoMap.put(chartInfo.getChartId(), chartInfo);
pointInfoMap.put(chartInfo.getChartId(), chartInfo);
} else if (XML_LAST_EDIT_DAY.equals(name)) {
lastEditDay = reader.getElementValue();
}
@ -338,7 +239,7 @@ public class ChartInfoCollector implements XMLReadable, XMLWriter {
writer.end();
writer.startTAG(XML_CHART_INFO_LIST);
for (ChartInfo chartInfo : chartInfoMap.values()) {
for (ChartInfo chartInfo : pointInfoMap.values()) {
chartInfo.writeXML(writer);
}
writer.end();

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

@ -1,8 +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.design.mainframe.burying.point.BasePointInfo;
import com.fr.general.ComparatorUtils;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONObject;
@ -16,27 +15,19 @@ import java.util.Map;
* Created by plough on 2019/4/18.
*/
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);
public static boolean sendPointInfo(BasePointInfo pointInfo) {
boolean success = true;
Map<String, String> sendInfo = pointInfo.getSendInfo();
for (Map.Entry<String, String> entry : sendInfo.entrySet()) {
if (!sendSinglePointInfo(entry.getKey(), entry.getValue())) {
success = false;
}
private static boolean sendProcessInfo(String content) {
return sendSingleTemplateInfo(PROCESS_URL, content);
}
static boolean sendTemplateInfo(TemplateInfo templateInfo) {
return SendHelper.sendConsumingInfo(templateInfo.getConsumingMapJsonString()) && SendHelper.sendProcessInfo(templateInfo.getProcessMapJsonString());
}
public static boolean sendChartInfo(ChartInfo chartInfo) {
return sendSingleTemplateInfo(CHART_CONSUMING_URL, chartInfo.getChartConsumingMapJsonString());
return success;
}
private static boolean sendSingleTemplateInfo(String url, String content) {
private static boolean sendSinglePointInfo(String url, String content) {
Map<String, Object> para = new HashMap<>();
para.put("token", SiteCenterToken.generateToken());
para.put("content", content);

63
designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java

@ -2,13 +2,13 @@ package com.fr.design.mainframe.template.info;
import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.burying.point.AbstractPointInfo;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralUtils;
import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader;
import java.text.SimpleDateFormat;
@ -20,9 +20,12 @@ import java.util.Map;
* 对应一张模版的记录
* Created by plough on 2019/4/18.
*/
public class TemplateInfo implements XMLReadable, XMLWriter {
public class TemplateInfo extends AbstractPointInfo {
static final String XML_TAG = "TemplateInfo";
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 XML_PROCESS_MAP = "processMap";
private static final String XML_CONSUMING_MAP = "consumingMap";
private static final String ATTR_DAY_COUNT = "day_count";
@ -47,7 +50,6 @@ public class TemplateInfo implements XMLReadable, XMLWriter {
private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数
private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数
private int idleDayCount; // 到现在为止,模版闲置(上次保存后没有再编辑过)的天数
private String templateID = StringUtils.EMPTY;
private String originID = StringUtils.EMPTY;
// todo: processMap 和 consumingMap 还可以再拆解为小类,以后继续重构
@ -62,17 +64,22 @@ public class TemplateInfo implements XMLReadable, XMLWriter {
this.originID = originID;
}
static TemplateInfo newInstanceByRead(XMLableReader reader) {
@Override
protected String key() {
return templateID;
}
public static TemplateInfo newInstanceByRead(XMLableReader reader) {
TemplateInfo templateInfo = new TemplateInfo();
reader.readXMLObject(templateInfo);
return templateInfo;
}
static TemplateInfo newInstance(String templateID) {
public static TemplateInfo newInstance(String templateID) {
return newInstance(templateID, StringUtils.EMPTY, 0);
}
static TemplateInfo newInstance(String templateID, String originID, int originTime) {
public static TemplateInfo newInstance(String templateID, String originID, int originTime) {
HashMap<String, Object> consumingMap = new HashMap<>();
String username = MarketConfig.getInstance().getBbsUsername();
@ -107,9 +114,10 @@ public class TemplateInfo implements XMLReadable, XMLWriter {
}
int getTimeConsume() {
return (int)consumingMap.get(ATTR_TIME_CONSUME);
return (int) consumingMap.get(ATTR_TIME_CONSUME);
}
@Override
public void writeXML(XMLPrintWriter writer) {
writer.startTAG(XML_TAG);
if (StringUtils.isNotEmpty(templateID)) {
@ -144,13 +152,14 @@ public class TemplateInfo implements XMLReadable, XMLWriter {
writer.attr(ATTR_JAR_TIME, (String) consumingMap.get(ATTR_JAR_TIME));
writer.attr(ATTR_CREATE_TIME, (String) consumingMap.get(ATTR_CREATE_TIME));
writer.attr(ATTR_UUID, (String) consumingMap.get(ATTR_UUID));
writer.attr(ATTR_TIME_CONSUME, (int)consumingMap.get(ATTR_TIME_CONSUME));
writer.attr(ATTR_ORIGIN_TIME, (int)consumingMap.get(ATTR_ORIGIN_TIME));
writer.attr(ATTR_TIME_CONSUME, (int) consumingMap.get(ATTR_TIME_CONSUME));
writer.attr(ATTR_ORIGIN_TIME, (int) consumingMap.get(ATTR_ORIGIN_TIME));
writer.attr(ATTR_VERSION, (String) consumingMap.get(ATTR_VERSION));
writer.attr(ATTR_USERNAME, (String) consumingMap.get(ATTR_USERNAME));
writer.end();
}
@Override
public void readXML(XMLableReader reader) {
if (!reader.isChildNode()) {
idleDayCount = reader.getAttrAsInt(ATTR_DAY_COUNT, 0);
@ -185,7 +194,8 @@ public class TemplateInfo implements XMLReadable, XMLWriter {
}
}
boolean isTestTemplate() {
@Override
protected boolean isTestTemplate() {
if (!isComplete()) {
return false;
}
@ -198,7 +208,7 @@ public class TemplateInfo implements XMLReadable, XMLWriter {
return isTestTemplate(reportType, cellCount, floatCount, blockCount, widgetCount);
}
public static boolean isTestTemplate(int reportType, int cellCount, int floatCount, int blockCount, int widgetCount){
public static boolean isTestTemplate(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;
@ -210,7 +220,8 @@ public class TemplateInfo implements XMLReadable, XMLWriter {
return isTestTemplate;
}
boolean isComplete() {
@Override
protected boolean isComplete() {
// 条件 1. 超过15天未编辑
// 条件 2. 设计器在这段未编辑的时间内启动超过 X 次(目前定的 X = 3)。即"设计器最近 X 次启动的时间跨度" < "未编辑时间";
@ -218,20 +229,16 @@ public class TemplateInfo implements XMLReadable, XMLWriter {
&& DesignerOpenHistory.getInstance().isOpenEnoughTimesInPeriod(idleDayCount);
}
String getConsumingMapJsonString() {
return new JSONObject(consumingMap).toString();
}
String getProcessMapJsonString() {
return new JSONObject(processMap).toString();
}
boolean isReadyForSend() {
return isComplete() && !isTestTemplate();
@Override
public Map<String, String> getSendInfo() {
Map<String, String> sendMap = new HashMap<>();
sendMap.put(CONSUMING_URL, new JSONObject(consumingMap).toString());
sendMap.put(PROCESS_URL, new JSONObject(processMap).toString());
return sendMap;
}
void addTimeConsume(int timeConsume) {
timeConsume += (int)consumingMap.get(ATTR_TIME_CONSUME); // 加上之前的累计编辑时间
timeConsume += (int) consumingMap.get(ATTR_TIME_CONSUME); // 加上之前的累计编辑时间
consumingMap.put(ATTR_TIME_CONSUME, timeConsume);
}
@ -250,14 +257,6 @@ public class TemplateInfo implements XMLReadable, XMLWriter {
this.processMap = processMap;
}
void resetIdleDayCount() {
this.idleDayCount = 0;
}
void addIdleDayCountByOne() {
this.idleDayCount += 1;
}
int getIdleDayCount() {
return this.idleDayCount;
}

154
designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java

@ -1,54 +1,26 @@
package com.fr.design.mainframe.template.info;
import com.fr.base.FRContext;
import com.fr.base.io.XMLReadHelper;
import com.fr.design.DesignerEnvManager;
import com.fr.log.FineLoggerFactory;
import com.fr.design.mainframe.burying.point.AbstractPointCollector;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.javax.xml.stream.XMLStreamException;
import com.fr.third.org.apache.commons.io.FileUtils;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 做模板的过程和耗时收集辅助类
* Created by plough on 2017/2/21.
*/
public class TemplateInfoCollector implements XMLReadable, XMLWriter {
public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo> {
private static final String XML_TAG = "TplInfo";
private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList";
private static final String XML_FILE_NAME = "tpl.info";
private static TemplateInfoCollector instance;
private static final int MAX_SIZE = 512 * 1024 * 1024;
private Map<String, TemplateInfo> templateInfoMap;
private DesignerOpenHistory designerOpenHistory;
private TemplateInfoCollector() {
init();
}
private void init() {
templateInfoMap = new HashMap<>();
designerOpenHistory = DesignerOpenHistory.getInstance();
loadFromFile();
}
public static TemplateInfoCollector getInstance() {
@ -62,17 +34,19 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter {
* 根据模板ID是否在收集列表中判断是否需要收集当前模板的信息
*/
public boolean contains(String templateID) {
return StringUtils.isNotEmpty(templateID) && templateInfoMap.containsKey(templateID);
return StringUtils.isNotEmpty(templateID) && pointInfoMap.containsKey(templateID);
}
/**
* 收集模板信息如果之前没有记录则新增如果已有记录则更新
* 同时将最新数据保存到文件中
*
* @param templateID 模版id
* @param originID 模版的原始id仅对另存为的模版有效对于非另存为的模版值总是为空
* @param processInfo 包含模版的一些基本信息如模版类型包含控件数量等
* @param timeConsume 本次制作耗时单位为 s
*/
@Override
public void collectInfo(String templateID, String originID, TemplateProcessInfo processInfo, int timeConsume) {
if (!shouldCollectInfo()) {
return;
@ -80,11 +54,11 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter {
TemplateInfo templateInfo;
if (this.contains(templateID)) {
templateInfo = templateInfoMap.get(templateID);
templateInfo = pointInfoMap.get(templateID);
} else {
int originTime = this.contains(originID) ? templateInfoMap.get(originID).getTimeConsume() : 0;
int originTime = this.contains(originID) ? pointInfoMap.get(originID).getTimeConsume() : 0;
templateInfo = TemplateInfo.newInstance(templateID, originID, originTime);
templateInfoMap.put(templateID, templateInfo);
pointInfoMap.put(templateID, templateInfo);
}
// 收集制作耗时
@ -98,137 +72,51 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter {
saveInfo();
}
/**
* 发送本地模板信息到服务器并清空已发送模版的本地记录
*/
public void sendTemplateInfo() {
// 每次启动设计器后,都会执行这个函数(被 InformationCollector 的 collectStartTime 调用)
addIdleDayCount();
removeTestTemplates();
List<String> removeLaterList = new ArrayList<>();
for (String key : templateInfoMap.keySet()) {
TemplateInfo templateInfo = templateInfoMap.get(key);
if (templateInfo.isReadyForSend()) {
if (SendHelper.sendTemplateInfo(templateInfo)) {
removeLaterList.add(key);
}
}
}
// 清空记录
for (String key : removeLaterList) {
removeFromTemplateInfoList(key);
}
saveInfo();
}
/**
* 获取缓存文件存放路径
*/
private static File getInfoFile() {
@Override
protected File getInfoFile() {
return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), XML_FILE_NAME));
}
void loadFromFile() {
if (!getInfoFile().exists()) {
return;
}
XMLableReader reader = null;
try (InputStream in = new FileInputStream(getInfoFile())) {
// XMLableReader 还是应该考虑实现 Closable 接口的,这样就能使用 try-with 语句了
reader = XMLReadHelper.createXMLableReader(in, XMLPrintWriter.XML_ENCODER);
reader.readXMLObject(this);
} catch (FileNotFoundException e) {
// do nothing
} catch (XMLStreamException | IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (XMLStreamException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
TemplateInfo getOrCreateTemplateInfoByID(String templateID) {
if (templateInfoMap.containsKey(templateID)) {
return templateInfoMap.get(templateID);
if (pointInfoMap.containsKey(templateID)) {
return pointInfoMap.get(templateID);
}
TemplateInfo templateInfo = TemplateInfo.newInstance(templateID);
templateInfoMap.put(templateID, templateInfo);
pointInfoMap.put(templateID, templateInfo);
return templateInfo;
}
private boolean shouldCollectInfo() {
return FileUtils.sizeOf(getInfoFile()) <= MAX_SIZE && DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv();
}
/**
* 将包含所有信息的对象保存到文件
*/
private void saveInfo() {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
XMLTools.writeOutputStreamXML(this, out);
out.flush();
out.close();
String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8);
FileUtils.writeStringToFile(getInfoFile(), fileContent, StandardCharsets.UTF_8);
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage());
}
}
/**
* 更新 day_count打开设计器却未编辑模板的连续日子
*/
private void addIdleDayCount() {
@Override
protected void addIdleDayCount() {
// 判断今天是否第一次打开设计器,为了防止同一天内,多次 addIdleDayCount
if (designerOpenHistory.hasOpenedToday()) {
return;
}
for (TemplateInfo templateInfo : templateInfoMap.values()) {
for (TemplateInfo templateInfo : pointInfoMap.values()) {
templateInfo.addIdleDayCountByOne();
}
designerOpenHistory.update();
}
// 删除所有已完成的测试模版
private void removeTestTemplates() {
ArrayList<String> testTemplateKeys = new ArrayList<>(); // 保存测试模板的key
for (String key : templateInfoMap.keySet()) {
if (templateInfoMap.get(key).isTestTemplate()) {
testTemplateKeys.add(key);
}
}
// 删除测试模板
for (String key : testTemplateKeys) {
removeFromTemplateInfoList(key);
}
}
private void removeFromTemplateInfoList(String key) {
templateInfoMap.remove(key);
}
@Override
public void readXML(XMLableReader reader) {
if (reader.isChildNode()) {
try {
String name = reader.getTagName();
if (DesignerOpenHistory.XML_TAG.equals(name)) {
if (designerOpenHistory == null) {
designerOpenHistory = DesignerOpenHistory.getInstance();
}
reader.readXMLObject(designerOpenHistory);
} else if (TemplateInfo.XML_TAG.equals(name)) {
TemplateInfo templateInfo = TemplateInfo.newInstanceByRead(reader);
templateInfoMap.put(templateInfo.getTemplateID(), templateInfo);
pointInfoMap.put(templateInfo.getTemplateID(), templateInfo);
}
} catch (Exception ex) {
// 什么也不做,使用默认值
@ -243,7 +131,7 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter {
designerOpenHistory.writeXML(writer);
writer.startTAG(XML_TEMPLATE_INFO_LIST);
for (TemplateInfo templateInfo : templateInfoMap.values()) {
for (TemplateInfo templateInfo : pointInfoMap.values()) {
templateInfo.writeXML(writer);
}
writer.end();

9
designer-base/src/test/java/com/fr/design/mainframe/template/info/SendHelperTest.java

@ -1,10 +1,12 @@
package com.fr.design.mainframe.template.info;
import com.fr.invoke.Reflect;
import com.fr.json.JSONObject;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.javax.xml.stream.XMLStreamException;
import java.io.StringReader;
import java.util.Map;
import static org.junit.Assert.assertTrue;
@ -25,11 +27,12 @@ public class SendHelperTest {
StringReader sr = new StringReader(NORMAL_INFO);
XMLableReader xmlReader = XMLableReader.createXMLableReader(sr);
TemplateInfo templateInfo = TemplateInfo.newInstanceByRead(xmlReader);
boolean res = Reflect.on(SendHelper.class).call("sendSingleTemplateInfo", CONSUMING_URL, templateInfo.getConsumingMapJsonString()).get();
Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
Map processMap = Reflect.on(templateInfo).field("processMap").get();
boolean res = Reflect.on(SendHelper.class).call("sendSinglePointInfo", CONSUMING_URL, new JSONObject(consumingMap).toString()).get();
assertTrue(res);
boolean res2 = Reflect.on(SendHelper.class).call("sendSingleTemplateInfo", PROCESS_URL, templateInfo.getProcessMapJsonString()).get();
boolean res2 = Reflect.on(SendHelper.class).call("sendSinglePointInfo", PROCESS_URL, new JSONObject(processMap).toString()).get();
assertTrue(res2);
}
}

23
designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java

@ -3,6 +3,7 @@ package com.fr.design.mainframe.template.info;
import com.fr.config.MarketConfig;
import com.fr.general.GeneralUtils;
import com.fr.invoke.Reflect;
import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.FileUtils;
@ -71,7 +72,7 @@ public class TemplateInfoCollectorTest {
assertEquals(",,", DesignerOpenHistory.getInstance().toString());
TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
assertEquals(7, ((Map) Reflect.on(collector).field("templateInfoMap").get()).size());
assertEquals(7, ((Map) Reflect.on(collector).field("pointInfoMap").get()).size());
assertEquals("2019-04-08,2019-04-03,2019-03-29", DesignerOpenHistory.getInstance().toString());
}
@ -86,18 +87,21 @@ public class TemplateInfoCollectorTest {
collector.collectInfo(templateID, StringUtils.EMPTY, mockProcessInfo, timeConsume);
// 检查是否写入成功
collector.loadFromFile();
Reflect.on(collector).call("loadFromFile");
TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID);
Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
Map processMap = Reflect.on(templateInfo).field("processMap").get();
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," +
"\"cell_count\":13,\"block_count\":3,\"report_type\":0," +
"\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"}", templateInfo.getProcessMapJsonString());
"\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"}", new JSONObject(processMap).toString());
assertJsonStringEquals("{\"activitykey\":\"2e0ea413-fa9c241e0-9723-4354fce51e81\"," +
"\"jar_time\":\"不是安装版本\",\"create_time\":\"2019-03-26 16:13\"," +
"\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\",\"originID\":\"\"," +
"\"uuid\":\"476ca2cc-f789-4c5d-8e89-ef146580775c\",\"time_consume\":329,\"originTime\":0," +
"\"version\":\"10.0\",\"username\":\"plough\"}", templateInfo.getConsumingMapJsonString());
"\"version\":\"10.0\",\"username\":\"plough\"}", new JSONObject(consumingMap).toString());
}
@Test
@ -112,15 +116,17 @@ public class TemplateInfoCollectorTest {
collector.collectInfo(templateID, StringUtils.EMPTY, mockProcessInfo, timeConsume);
// 检查是否写入成功
collector.loadFromFile();
Reflect.on(collector).call("loadFromFile");
assertTrue(collector.contains(templateID));
TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID);
Map processMap = Reflect.on(templateInfo).field("processMap").get();
assertEquals(templateID, templateInfo.getTemplateID());
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," +
"\"cell_count\":13,\"block_count\":3,\"report_type\":0," +
"\"templateID\":\"73a97777-8jnk-47cd-b57c-2ee89991279796\"}", templateInfo.getProcessMapJsonString());
"\"templateID\":\"73a97777-8jnk-47cd-b57c-2ee89991279796\"}", new JSONObject(processMap).toString());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
assertEquals(templateID, consumingMap.get("templateID"));
@ -142,12 +148,13 @@ public class TemplateInfoCollectorTest {
collector.collectInfo(templateID, originID, mockProcessInfo, timeConsume);
// 检查是否写入成功
collector.loadFromFile();
Reflect.on(collector).call("loadFromFile");
TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID);
Map processMap = Reflect.on(templateInfo).field("processMap").get();
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," +
"\"cell_count\":13,\"block_count\":3,\"report_type\":0," +
"\"templateID\":\"423238d4-5223-22vj-vlsj-42jc49245iw3\"}", templateInfo.getProcessMapJsonString());
"\"templateID\":\"423238d4-5223-22vj-vlsj-42jc49245iw3\"}", new JSONObject(processMap).toString());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
assertEquals(templateID, consumingMap.get("templateID"));

22
designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTest.java

@ -3,6 +3,7 @@ package com.fr.design.mainframe.template.info;
import com.fr.config.MarketConfig;
import com.fr.general.GeneralUtils;
import com.fr.invoke.Reflect;
import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLableReader;
@ -55,7 +56,6 @@ public class TemplateInfoTest {
assertEquals(templateID, templateInfo.getTemplateID());
assertEquals(StringUtils.EMPTY, Reflect.on(templateInfo).field("originID").get());
assertEquals(0, (int) Reflect.on(templateInfo).field("idleDayCount").get());
assertEquals("{}", templateInfo.getProcessMapJsonString());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
assertEquals(templateID, consumingMap.get("templateID"));
@ -78,7 +78,6 @@ public class TemplateInfoTest {
assertEquals(templateID, templateInfo.getTemplateID());
assertEquals(originID, Reflect.on(templateInfo).field("originID").get());
assertEquals(0, (int) Reflect.on(templateInfo).field("idleDayCount").get());
assertEquals("{}", templateInfo.getProcessMapJsonString());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
assertEquals(templateID, consumingMap.get("templateID"));
@ -97,24 +96,25 @@ public class TemplateInfoTest {
}
@Test
public void testGetConsumingMapJsonString() {
public void testGetSendInfo() {
Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
Map processMap = Reflect.on(templateInfo).field("processMap").get();
Map consumingMap1 = Reflect.on(templateInfoSaveAs).field("consumingMap").get();
Map processMap1 = Reflect.on(templateInfoSaveAs).field("processMap").get();
assertJsonStringEquals("{\"activitykey\":\"2e0ea413-fa9c241e0-9723-4354fce51e81\",\"jar_time\":\"不是安装版本\"," +
"\"create_time\":\"2019-03-26 16:13\",\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\",\"originID\":\"\"," +
"\"uuid\":\"476ca2cc-f789-4c5d-8e89-ef146580775c\",\"time_consume\":129,\"originTime\":0,\"version\":\"10.0\"," +
"\"username\":\"plough\"}", templateInfo.getConsumingMapJsonString());
"\"username\":\"plough\"}", new JSONObject(consumingMap).toString());
assertJsonStringEquals("{\"activitykey\":\"2e0ea413-fa9c241e0-9723-4354fce51e81\",\"jar_time\":\"不是安装版本\"," +
"\"create_time\":\"2019-03-26 16:13\",\"templateID\":\"49avd2c4-1104-92j2-wx24-3dd0k2136080\",\"originID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"," +
"\"uuid\":\"476ca2cc-f789-4c5d-8e89-ef146580775c\",\"time_consume\":429,\"originTime\":129,\"version\":\"10.0\"," +
"\"username\":\"plough\"}", templateInfoSaveAs.getConsumingMapJsonString());
}
@Test
public void testGetProcessMapJsonString() {
"\"username\":\"plough\"}", new JSONObject(consumingMap1).toString());
assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":1," +
"\"block_count\":0,\"report_type\":0,\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"}", templateInfo.getProcessMapJsonString());
"\"block_count\":0,\"report_type\":0,\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"}", new JSONObject(processMap).toString());
assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":1," +
"\"block_count\":0,\"report_type\":0,\"templateID\":\"49avd2c4-1104-92j2-wx24-3dd0k2136080\"}", templateInfoSaveAs.getProcessMapJsonString());
"\"block_count\":0,\"report_type\":0,\"templateID\":\"49avd2c4-1104-92j2-wx24-3dd0k2136080\"}", new JSONObject(processMap1).toString());
}
private TemplateInfo createTemplateInfo(String xmlContent) throws XMLStreamException {

4
designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java

@ -235,8 +235,8 @@ public class InformationCollector implements XMLReadable, XMLWriter {
SolidCollector.getInstance().sendToCloudCenterAndDeleteFile();
sendUserInfo();
FocusPointMessageUploader.getInstance().sendToCloudCenter();
TemplateInfoCollector.getInstance().sendTemplateInfo();
ChartInfoCollector.getInstance().sendChartInfo();
TemplateInfoCollector.getInstance().sendPointInfo();
ChartInfoCollector.getInstance().sendPointInfo();
ErrorInfoUploader.getInstance().sendErrorInfo();
}
}, SEND_DELAY, TimeUnit.MILLISECONDS);

Loading…
Cancel
Save