Browse Source

Merge pull request #684 in DESIGN/design from ~ALEX.SUNG/design:release/10.0 to release/10.0

REPORT-13431 功能点记录, 需要合并发送

* commit 'f6d06b6d5d862c4bf97f027cc33a279f7a5a70ac':
  REPORT-13431 功能点记录, 需要合并发送 1.用户信息原先收集在feedback,10.0需要适配 2.功能点从metric取数,条件传入Date从12月10号开始就拿不到数据了,换用long是可以的
bugfix/10.0
Alex.Sung 6 years ago
parent
commit
2fef156265
  1. 32
      designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java

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

@ -170,7 +170,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
} }
private byte[] getJSONContentAsByte(){ private JSONObject getJSONContentAsByte(){
JSONObject content = new JSONObject(); JSONObject content = new JSONObject();
JSONArray startStopArray = new JSONArray(); JSONArray startStopArray = new JSONArray();
@ -192,13 +192,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
FRContext.getLogger().error(e.getMessage(), e); FRContext.getLogger().error(e.getMessage(), e);
} }
} }
return content;
try {
return content.toString().getBytes(EncodeConstants.ENCODING_UTF_8);
} catch (UnsupportedEncodingException e) {
FRContext.getLogger().error(e.getMessage(), e);
return ArrayUtils.EMPTY_BYTE_ARRAY;
}
} }
private void sendUserInfo(){ private void sendUserInfo(){
@ -208,19 +202,17 @@ public class InformationCollector implements XMLReadable, XMLWriter {
if (currentTime - lastTime <= DELTA) { if (currentTime - lastTime <= DELTA) {
return; return;
} }
byte[] content = getJSONContentAsByte(); JSONObject content = getJSONContentAsByte();
HttpClient hc = new HttpClient(CloudCenter.getInstance().acquireUrlByKind("user.info")); String url = CloudCenter.getInstance().acquireUrlByKind("user.info.v10");
hc.setContent(content);
if (!hc.isServerAlive()) {
return;
}
String res = hc.getResponseText();
//服务器返回true,说明已经取得成功,清空当前记录的信息
boolean success = false; boolean success = false;
try { try {
HashMap<String, Object> para = new HashMap<>();
para.put("token", SiteCenterToken.generateToken());
para.put("content", content);
String res = HttpToolbox.post(url, para);
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success");
} catch (JSONException e) { } catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
if (success){ if (success){
this.reset(); this.reset();
@ -236,7 +228,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
} }
JSONArray content = null; JSONArray content = null;
try { try {
content = getFunctionsContent(current, new Date(lastTime)); content = getFunctionsContent(currentTime, lastTime);
} catch (JSONException e) { } catch (JSONException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
@ -451,7 +443,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
}); });
} }
public static JSONArray getFunctionsContent(Date current, Date last) throws JSONException{ public static JSONArray getFunctionsContent(long current, long last) throws JSONException{
//记录当前条数,达到200条合并成一个请求 //记录当前条数,达到200条合并成一个请求
int count = 0; int count = 0;
JSONArray functionArray = new JSONArray(); JSONArray functionArray = new JSONArray();

Loading…
Cancel
Save