Browse Source

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

* commit 'a256bd6a0eeb8e9e8e75fda58ecb30bb5ae62403':
  REPORT-15314 103模板信息收集=>修复报错&修正判定制作完成的逻辑
research/10.0
plough 6 years ago
parent
commit
7e0db1d24a
  1. 12
      designer-base/src/main/java/com/fr/design/mainframe/template/info/DesignerOpenHistory.java
  2. 2
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java
  3. 11
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java
  4. 12
      designer-base/src/test/java/com/fr/design/mainframe/template/info/DesignerOpenHistoryTest.java

12
designer-base/src/main/java/com/fr/design/mainframe/template/info/DesignerOpenHistory.java

@ -48,6 +48,18 @@ class DesignerOpenHistory implements XMLReadable, XMLWriter {
history[0] = today;
}
/**
* 设计器在 dayCount 时间内启动超过 X 目前定的 X = 3
*/
boolean isOpenEnoughTimesInPeriod(int dayCount) {
boolean enoughTimes = StringUtils.isNotEmpty(history[LENGTH - 1]);
if (!enoughTimes) {
return false;
}
return getHistorySpanDayCount() < dayCount;
}
/**
* 获取历史记录中囊括的日子数即最早的历史记录 history[LENGTH - 1]到最晚的记录 history[0] 之间的时间跨度
*/

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

@ -211,7 +211,7 @@ class TemplateInfo implements XMLReadable, XMLWriter {
// 条件 2. 设计器在这段未编辑的时间内启动超过 X 次(目前定的 X = 3)。即"设计器最近 X 次启动的时间跨度" < "未编辑时间";
return idleDayCount > COMPLETE_DAY_COUNT
&& DesignerOpenHistory.getInstance().getHistorySpanDayCount() < idleDayCount;
&& DesignerOpenHistory.getInstance().isOpenEnoughTimesInPeriod(idleDayCount);
}
String getConsumingMapJsonString() {

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

@ -20,6 +20,7 @@ import java.io.FileOutputStream;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -101,16 +102,22 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter {
removeTestTemplates();
List<String> removeLaterList = new ArrayList<>();
for (String key : templateInfoMap.keySet()) {
TemplateInfo templateInfo = templateInfoMap.get(key);
if (templateInfo.isReadyForSend()) {
if (SendHelper.sendTemplateInfo(templateInfo)) {
// 清空记录
removeFromTemplateInfoList(templateInfo.getTemplateID());
removeLaterList.add(key);
}
}
}
// 清空记录
for (String key : removeLaterList) {
removeFromTemplateInfoList(key);
}
saveInfo();
}

12
designer-base/src/test/java/com/fr/design/mainframe/template/info/DesignerOpenHistoryTest.java

@ -87,6 +87,18 @@ public class DesignerOpenHistoryTest {
}
}
@Test
public void testOpenEnoughTimesInPeriod() {
assertTrue(openHistory.isOpenEnoughTimesInPeriod(15));
assertFalse(openHistory.isOpenEnoughTimesInPeriod(3));
Reflect.on(openHistory).set("history", new String[] {"2019-05-03", "2019-05-02", ""});
assertFalse(openHistory.isOpenEnoughTimesInPeriod(15));
Reflect.on(openHistory).set("history", new String[] {"2019-05-03", "", ""});
assertFalse(openHistory.isOpenEnoughTimesInPeriod(15));
}
@Test
public void testHasOpenedToday() {
assertFalse(openHistory.hasOpenedToday());

Loading…
Cancel
Save