Browse Source

Merge pull request #787 in BA/design from ~PLOUGH/design:release to release

* commit '28443f0c163bc298d006015392f62a2f810764ab':
  REPORT-1916 模板耗时=》防止重复收集模板数据
  REPORT-1916 模板耗时=》解决另存为不产生新数据的bug;当id为null时(旧模板),不搜集数据;调整日志打印内容
  REPORT-1916 模板耗时=》调整代码,让designer_base不依赖engine和designer_form
master
superman 8 years ago
parent
commit
597f84f5f5
  1. 1
      designer/src/com/fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java
  2. 6
      designer_base/src/com/fr/design/mainframe/JTemplate.java
  3. 38
      designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java
  4. 0
      designer_form/src/com/fr/design/mainframe/templateinfo/JFormProcessInfo.java

1
designer_base/src/com/fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java → designer/src/com/fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java

@ -1,6 +1,5 @@
package com.fr.design.mainframe.templateinfo;
import com.fr.base.io.IOFile;
import com.fr.base.parameter.ParameterUI;
import com.fr.main.impl.WorkBook;
import com.fr.report.cellcase.CellCase;

6
designer_base/src/com/fr/design/mainframe/JTemplate.java

@ -111,9 +111,7 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
// 为收集模版信息作准备
private void initForCollect() {
if (template.getTemplateID() == null) {
template.initTemplateID(); // 为新模板设置 templateID 属性
}
template.initTemplateID(); // 为新模板设置 templateID 属性
if (openTime == 0) {
openTime = System.currentTimeMillis();
}
@ -533,7 +531,7 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
boolean result = this.saveFile();
if (result) {
DesignerFrameFileDealerPane.getInstance().refresh();
initForCollect(); // 如果是旧模板另存为新模板,则添加 templateID
initForCollect(); // 如果另存为新模板,则添加 templateID
collectInfo();
}
//更换最近打开

38
designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java

@ -15,9 +15,7 @@ import org.json.JSONObject;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.*;
/**
* 做模板的过程和耗时收集辅助类
@ -27,6 +25,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
private static final String FILE_NAME = "tplInfo.ser";
private static TemplateInfoCollector instance;
private HashMap<String, HashMap<String, Object>> templateInfoList;
private Set<String> removedTemplates; // 已经从 templateInfoList 中删除过的 id 列表,防止重复收集数据
private String designerOpenDate; //设计器最近一次打开日期
private static final int VALID_CELL_COUNT = 5; // 有效报表模板的格子数
private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数
@ -36,6 +35,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
@SuppressWarnings("unchecked")
private TemplateInfoCollector() {
templateInfoList = new HashMap<>();
removedTemplates = new ListSet<>();
setDesignerOpenDate();
}
@ -77,12 +77,15 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
return instance;
}
private static boolean shouldCollectInfo() {
private boolean shouldCollectInfo(T t) {
if (t.getTemplateID() == null || instance.removedTemplates.contains(t.getTemplateID())) { // 旧模板
return false;
}
return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv();
}
public static void appendProcess(String log) {
if (!shouldCollectInfo()) {
public void appendProcess(T t, String log) {
if (!shouldCollectInfo(t)) {
return;
}
// 获取当前编辑的模板
@ -113,7 +116,14 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
private void saveInfo() {
try {
ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(getInfoFile()));
FRLogger.getLogger().info("writing: " + instance.templateInfoList);
String log = "";
int count = 1;
for (String key : templateInfoList.keySet()) {
String createTime = ((HashMap)templateInfoList.get(key).get("consumingMap")).get("create_time").toString();
log += (count + ". id: " + key + " " + createTime + "\n" + templateInfoList.get(key).toString() + "\n");
count ++;
}
FRLogger.getLogger().info("writing tplInfo: \n" + log);
os.writeObject(instance);
os.close();
} catch (Exception ex) {
@ -141,7 +151,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
*/
@SuppressWarnings("unchecked")
public void collectInfo(T t, JTemplate jt, long openTime, long saveTime) {
if (!shouldCollectInfo()) {
if (!shouldCollectInfo(t)) {
return;
}
@ -225,7 +235,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
if (sendSingleTemplateInfo(consumingUrl, jsonConsumingMap) && sendSingleTemplateInfo(processUrl, jsonProcessMap)) {
// 清空记录
FRLogger.getLogger().info("successfully send " + templateInfo.get("templateID"));
templateInfoList.remove(templateInfo.get("templateID"));
removeFromTemplateInfoList(templateInfo.get("templateID"));
}
}
saveInfo();
@ -277,12 +287,18 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
}
// 删除测试模板
for (String key : testTemplateKeys) {
templateInfoList.remove(key);
// System.out.println(key + " is removed...");
removeFromTemplateInfoList(key);
}
return completeTemplatesInfo;
}
private void removeFromTemplateInfoList(String key) {
templateInfoList.remove(key);
removedTemplates.add(key);
FRLogger.getLogger().info(key + " is removed...");
FRLogger.getLogger().info("removedTemplates: " + removedTemplates);
}
@SuppressWarnings("unchecked")
private boolean isTestTemplate(HashMap<String, Object> templateInfo) {
HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfo.get("processMap");

0
designer_base/src/com/fr/design/mainframe/templateinfo/JFormProcessInfo.java → designer_form/src/com/fr/design/mainframe/templateinfo/JFormProcessInfo.java

Loading…
Cancel
Save