Browse Source

Merge pull request #834 in DESIGN/design from ~PLOUGH/10-design:feature/10.0 to feature/10.0

* commit 'a74462497d009febbba793f947a1e1e1a46ec1df':
  REPORT-16391 【10.03埋点-模板】已经存在的模板另存为,不会有originid
research/10.0
plough 6 years ago
parent
commit
ca916a2f38
  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

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"/>

Loading…
Cancel
Save