Browse Source

Merge branch 'feature/10.0' of http://cloud.finedevelop.com:2015/scm/~xiaoxia/design into feature/10.0

* 'feature/10.0' of http://cloud.finedevelop.com:2015/scm/~xiaoxia/design:
  REPORT-16456 【10.0.3埋点-模板】远程设计不生效
  REPORT-16494 模板信息收集, 设计器启动有报错=>调整代码
  REPORT-16494 模板信息收集, 设计器启动有报错=>调整代码
  REPORT-16494 模板信息收集, 设计器启动有报错
research/10.0
XiaXiang 6 years ago
parent
commit
055ee6386f
  1. 11
      designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java
  2. 4
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java
  3. 35
      designer-base/src/test/java/com/fr/design/mainframe/template/info/SendHelperTest.java

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

@ -5,9 +5,10 @@ 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;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
/** /**
* 负责向服务器发送信息 * 负责向服务器发送信息
@ -30,14 +31,16 @@ class SendHelper {
} }
private static boolean sendSingleTemplateInfo(String url, String content) { private static boolean sendSingleTemplateInfo(String url, String content) {
HashMap<String, String> para = new HashMap<>(); Map<String, Object> para = new HashMap<>();
para.put("token", SiteCenterToken.generateToken()); para.put("token", SiteCenterToken.generateToken());
para.put("content", content); para.put("content", content);
try { try {
String res = HttpToolbox.get(url, para); String res = HttpToolbox.post(url, para);
return ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); return ComparatorUtils.equals(new JSONObject(res).get("status"), "success");
} catch (IOException ignore) { } catch (Throwable e) {
// 客户不需要关心,错误等级为 debug 就行了
FineLoggerFactory.getLogger().debug(e.getMessage(), e);
} }
return false; return false;
} }

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

@ -145,10 +145,6 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter {
} }
private boolean shouldCollectInfo() { private boolean shouldCollectInfo() {
//只收集本地环境的
if (!WorkContext.getCurrent().isLocal()) {
return false;
}
return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv();
} }

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

@ -0,0 +1,35 @@
package com.fr.design.mainframe.template.info;
import com.fr.invoke.Reflect;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.javax.xml.stream.XMLStreamException;
import java.io.StringReader;
import static org.junit.Assert.assertTrue;
/**
* Created by plough on 2019/4/25.
*/
public class SendHelperTest {
private static final String CONSUMING_URL = "http://cloud.fanruan.com/api/monitor/record_of_reports_consuming/single";
private static final String PROCESS_URL = "http://cloud.fanruan.com/api/monitor/record_of_reports_process/single";
private static final String NORMAL_INFO = "<TemplateInfo templateID=\"16a988ce-8529-42f5-b17c-2ee849355071\" day_count=\"9\">\n" +
"<processMap process=\"\" float_count=\"0\" widget_count=\"0\" cell_count=\"1\" block_count=\"0\" report_type=\"0\"/>\n" +
"<consumingMap activitykey=\"2e0ea413-fa9c241e0-9723-4354fce51e81\" jar_time=\"不是安装版本\" create_time=\"2019-03-26 16:13\" uuid=\"476ca2cc-f789-4c5d-8e89-ef146580775c\" time_consume=\"129\" version=\"10.0\" username=\"plough\"/>\n" +
"</TemplateInfo>";
// 只在调试的时候运行,不需要每次都自动运行
public static void main(String[] args) throws XMLStreamException {
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();
assertTrue(res);
boolean res2 = Reflect.on(SendHelper.class).call("sendSingleTemplateInfo", PROCESS_URL, templateInfo.getProcessMapJsonString()).get();
assertTrue(res2);
}
}
Loading…
Cancel
Save