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:
  使用JDateTime
  文件没有正常删除; 功能点上传的时候数据对不上;
  REPORT-16391 【10.03埋点-模板】已经存在的模板另存为,不会有originid
research/10.0
XiaXiang 6 years ago
parent
commit
4c3cdd0723
  1. 4
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java
  2. 5
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java
  3. 28
      designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java
  4. 4
      designer-base/src/test/resources/com/fr/design/mainframe/template/info/tpl.info
  5. 46
      designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/FileEntityBuilder.java
  6. 2
      designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/impl/AbstractSendDataToCloud.java
  7. 26
      designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/impl/FocusPointMessageUploader.java

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

@ -102,6 +102,10 @@ class TemplateInfo implements XMLReadable, XMLWriter {
return templateID; return templateID;
} }
String getOriginID() {
return originID;
}
int getTimeConsume() { int getTimeConsume() {
return (int)consumingMap.get(ATTR_TIME_CONSUME); return (int)consumingMap.get(ATTR_TIME_CONSUME);
} }

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

@ -75,11 +75,8 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter {
TemplateInfo templateInfo; TemplateInfo templateInfo;
if (this.contains(templateID)) { if (this.contains(templateID)) {
templateInfo = templateInfoMap.get(templateID); templateInfo = templateInfoMap.get(templateID);
} else if (!this.contains(originID)) {
templateInfo = TemplateInfo.newInstance(templateID);
templateInfoMap.put(templateID, templateInfo);
} else { } else {
int originTime = templateInfoMap.get(originID).getTimeConsume(); int originTime = this.contains(originID) ? templateInfoMap.get(originID).getTimeConsume() : 0;
templateInfo = TemplateInfo.newInstance(templateID, originID, originTime); templateInfo = TemplateInfo.newInstance(templateID, originID, originTime);
templateInfoMap.put(templateID, templateInfo); templateInfoMap.put(templateID, templateInfo);
} }

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

@ -66,9 +66,12 @@ public class TemplateInfoCollectorTest {
@Test @Test
public void testReadXML() { public void testReadXML() {
assertEquals(",,", DesignerOpenHistory.getInstance().toString());
TemplateInfoCollector collector = TemplateInfoCollector.getInstance(); TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
assertEquals("2019-04-18", Reflect.on(collector).field("designerOpenDate").get());
assertEquals(7, ((Map) Reflect.on(collector).field("templateInfoMap").get()).size()); assertEquals(7, ((Map) Reflect.on(collector).field("templateInfoMap").get()).size());
assertEquals("2019-04-08,2019-04-03,2019-03-29", DesignerOpenHistory.getInstance().toString());
} }
@Test @Test
@ -151,6 +154,29 @@ public class TemplateInfoCollectorTest {
assertEquals(129, consumingMap.get("originTime")); assertEquals(129, consumingMap.get("originTime"));
} }
@Test
public void testCollectInfoWhenSaveAsWithNoTrackOriginID() throws Exception {
setUpMockForNewInstance();
TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
String templateID = "423238d4-5223-22vj-vlsj-42jc49245iw3";
String originID = "3kha8jcs-31xw-42f5-h2ww-2ee84935312z";
int timeConsume = 200;
collector.collectInfo(templateID, originID, mockProcessInfo, timeConsume);
TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID);
assertEquals(templateID, templateInfo.getTemplateID());
assertEquals(originID, templateInfo.getOriginID());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
assertEquals(templateID, consumingMap.get("templateID"));
assertEquals(originID, consumingMap.get("originID"));
assertEquals(200, consumingMap.get("time_consume"));
assertEquals(0, consumingMap.get("originTime"));
}
@Test @Test
public void testAddIdleDateCount() { public void testAddIdleDateCount() {
String templateID = "16a988ce-8529-42f5-b17c-2ee849355071"; String templateID = "16a988ce-8529-42f5-b17c-2ee849355071";

4
designer-base/src/test/resources/com/fr/design/mainframe/template/info/tpl.info

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<TplInfo xmlVersion="20170720" releaseVersion="10.0.0"> <TplInfo xmlVersion="20170720" releaseVersion="10.0.0">
<DesignerOpenDate> <DesignerOpenHistory>
<![CDATA[2019-04-18]]></DesignerOpenDate> <![CDATA[2019-04-08,2019-04-03,2019-03-29]]></DesignerOpenHistory>
<TemplateInfoList> <TemplateInfoList>
<TemplateInfo templateID="16a988ce-8529-42f5-b17c-2ee849355071" day_count="9"> <TemplateInfo templateID="16a988ce-8529-42f5-b17c-2ee849355071" day_count="9">
<processMap process="" float_count="0" widget_count="0" cell_count="1" block_count="0" report_type="0"/> <processMap process="" float_count="0" widget_count="0" cell_count="1" block_count="0" report_type="0"/>

46
designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/FileEntityBuilder.java

@ -9,9 +9,9 @@ import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.CommonUtils; import com.fr.stable.CommonUtils;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.jodd.datetime.JDateTime;
import com.fr.third.org.apache.http.HttpEntity; import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpResponse; import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.client.HttpClient; import com.fr.third.org.apache.http.client.HttpClient;
@ -27,6 +27,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID;
import static com.fr.third.org.apache.http.HttpStatus.SC_OK; import static com.fr.third.org.apache.http.HttpStatus.SC_OK;
@ -41,41 +42,16 @@ public class FileEntityBuilder {
private static final String ATTR_SIGNATURE = "signature"; private static final String ATTR_SIGNATURE = "signature";
private static final String ATTR_KEY = "key"; private static final String ATTR_KEY = "key";
private static final String FOCUS_POINT_FILE_ROOT_PATH = "FocusPoint"; private static final String FOCUS_POINT_FILE_ROOT_PATH = "FocusPoint";
/**
* 文件名
*/
private String fileName;
/**
* 文件的完整路径
*/
private String pathName;
/** /**
* 文件夹路径 * 文件夹路径
*/ */
private String folderName; private String folderName;
public FileEntityBuilder(String fileName, String pathName, String folderName) { public FileEntityBuilder(String folderName) {
this.fileName = fileName;
this.pathName = pathName;
this.folderName = folderName; this.folderName = folderName;
} }
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getPathName() {
return pathName;
}
public void setPathName(String pathName) {
this.pathName = pathName;
}
public String getFolderName() { public String getFolderName() {
return folderName; return folderName;
} }
@ -97,14 +73,19 @@ public class FileEntityBuilder {
return zipFile; return zipFile;
} }
public void generateFile(JSONArray jsonArray, String pathName) { public void generateFile(JSONArray jsonArray, String folderName) {
if (jsonArray.size() == 0) {
return;
}
try { try {
String content = jsonArray.toString(); String content = jsonArray.toString();
File file = new File(pathName + ".json"); String fileName = String.valueOf(UUID.randomUUID());
File file = new File(folderName + File.separator + fileName + ".json");
StableUtils.makesureFileExist(file); StableUtils.makesureFileExist(file);
FileOutputStream out = new FileOutputStream(file); FileOutputStream out = new FileOutputStream(file);
InputStream in = new ByteArrayInputStream(content.getBytes(EncodeConstants.ENCODING_UTF_8)); InputStream in = new ByteArrayInputStream(content.getBytes(EncodeConstants.ENCODING_UTF_8));
IOUtils.copyBinaryTo(in, out); IOUtils.copyBinaryTo(in, out);
in.close();
out.close(); out.close();
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
@ -112,7 +93,7 @@ public class FileEntityBuilder {
} }
public void deleteFileAndZipFile(File zipFile, String pathName) { public void deleteFileAndZipFile(File zipFile, String pathName) {
File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), pathName)); File file = new File(pathName);
CommonUtils.deleteFile(file); CommonUtils.deleteFile(file);
CommonUtils.deleteFile(zipFile); CommonUtils.deleteFile(zipFile);
} }
@ -124,9 +105,10 @@ public class FileEntityBuilder {
* @throws IOException * @throws IOException
*/ */
public static void uploadFile(File file, String keyFileName) throws IOException { public static void uploadFile(File file, String keyFileName) throws IOException {
String today = new JDateTime().toString("YYYY-MM-DD");
HttpClient httpclient = new DefaultHttpClient(); HttpClient httpclient = new DefaultHttpClient();
try { try {
String signedUrl = generateSignedUploadUrl(FOCUS_POINT_FILE_ROOT_PATH + File.separator +keyFileName); String signedUrl = generateSignedUploadUrl(FOCUS_POINT_FILE_ROOT_PATH + File.separator + today + File.separator +keyFileName);
if(StringUtils.isEmpty(signedUrl)){ if(StringUtils.isEmpty(signedUrl)){
FineLoggerFactory.getLogger().error("signedUrl is null."); FineLoggerFactory.getLogger().error("signedUrl is null.");
return; return;

2
designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/impl/AbstractSendDataToCloud.java

@ -102,7 +102,7 @@ public abstract class AbstractSendDataToCloud implements XMLable {
try { try {
JSONArray jsonArray = dealWithSendFunctionContent(points); JSONArray jsonArray = dealWithSendFunctionContent(points);
//生成json文件 //生成json文件
fileEntityBuilder.generateFile(jsonArray, getFileEntityBuilder().getPathName()); fileEntityBuilder.generateFile(jsonArray, getFileEntityBuilder().getFolderName());
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }

26
designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/impl/FocusPointMessageUploader.java

@ -26,6 +26,7 @@ public class FocusPointMessageUploader extends AbstractSendDataToCloud {
private static final String TAG = "FocusPointMessageTag"; private static final String TAG = "FocusPointMessageTag";
private static final String SEPARATOR = "_"; private static final String SEPARATOR = "_";
private static final String FOCUS_POINT = "FocusPoint"; private static final String FOCUS_POINT = "FocusPoint";
private static final long DELTA = 24 * 3600 * 1000L;
private static volatile FocusPointMessageUploader instance; private static volatile FocusPointMessageUploader instance;
public static FocusPointMessageUploader getInstance() { public static FocusPointMessageUploader getInstance() {
@ -46,13 +47,13 @@ public class FocusPointMessageUploader extends AbstractSendDataToCloud {
FocusPoint focusPoint = (FocusPoint)t; FocusPoint focusPoint = (FocusPoint)t;
JSONObject jo = new JSONObject(); JSONObject jo = new JSONObject();
jo.put("id",focusPoint.getId()); jo.put("id",focusPoint.getId());
jo.put("text",focusPoint.getId()); jo.put("text",focusPoint.getText());
jo.put("source",focusPoint.getId()); jo.put("source",focusPoint.getSource());
jo.put("time",focusPoint.getId()); jo.put("time",focusPoint.getTime());
jo.put("username",focusPoint.getId()); jo.put("username",focusPoint.getUsername());
jo.put("ip",focusPoint.getId()); jo.put("ip",focusPoint.getIp());
jo.put("title",focusPoint.getId()); jo.put("title",focusPoint.getTitle());
jo.put("body",focusPoint.getId()); jo.put("body",focusPoint.getBody());
ja.put(jo); ja.put(jo);
} }
return ja; return ja;
@ -61,10 +62,13 @@ public class FocusPointMessageUploader extends AbstractSendDataToCloud {
public void sendToCloudCenter() { public void sendToCloudCenter() {
MessageCollectUtils.readXMLFile(instance, getLastTimeFile()); MessageCollectUtils.readXMLFile(instance, getLastTimeFile());
long currentTime = new Date().getTime(); long currentTime = new Date().getTime();
long lastTIme = MessageCollectUtils.getLastTimeMillis(lastTime); long lastTime = MessageCollectUtils.getLastTimeMillis(this.lastTime);
if (currentTime - lastTime <= DELTA) {
return;
}
try { try {
generatePath(); generatePath();
queryData(currentTime, lastTIme, FocusPoint.class); queryData(currentTime, lastTime, FocusPoint.class);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage()); FineLoggerFactory.getLogger().error(e.getMessage());
} }
@ -97,9 +101,7 @@ public class FocusPointMessageUploader extends AbstractSendDataToCloud {
append(ProductConstants.MINOR_VERSION).append(SEPARATOR). append(ProductConstants.MINOR_VERSION).append(SEPARATOR).
append(uuid).append(SEPARATOR).append(bbsUserName).append(SEPARATOR). append(uuid).append(SEPARATOR).append(bbsUserName).append(SEPARATOR).
append(UUID.randomUUID()); append(UUID.randomUUID());
String fileName = String.valueOf(UUID.randomUUID());
String pathName = StableUtils.pathJoin(ProductConstants.getEnvHome(), sb.toString(), fileName);
String folderName = StableUtils.pathJoin(ProductConstants.getEnvHome(), sb.toString()); String folderName = StableUtils.pathJoin(ProductConstants.getEnvHome(), sb.toString());
setFileEntityBuilder(new FileEntityBuilder(fileName, pathName, folderName)); setFileEntityBuilder(new FileEntityBuilder(folderName));
} }
} }

Loading…
Cancel
Save