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; package com.fr.design.mainframe.templateinfo;
import com.fr.base.io.IOFile;
import com.fr.base.parameter.ParameterUI; import com.fr.base.parameter.ParameterUI;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.report.cellcase.CellCase; 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() { private void initForCollect() {
if (template.getTemplateID() == null) { template.initTemplateID(); // 为新模板设置 templateID 属性
template.initTemplateID(); // 为新模板设置 templateID 属性
}
if (openTime == 0) { if (openTime == 0) {
openTime = System.currentTimeMillis(); openTime = System.currentTimeMillis();
} }
@ -533,7 +531,7 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
boolean result = this.saveFile(); boolean result = this.saveFile();
if (result) { if (result) {
DesignerFrameFileDealerPane.getInstance().refresh(); DesignerFrameFileDealerPane.getInstance().refresh();
initForCollect(); // 如果是旧模板另存为新模板,则添加 templateID initForCollect(); // 如果另存为新模板,则添加 templateID
collectInfo(); 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.io.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.Calendar;
import java.util.HashMap;
/** /**
* 做模板的过程和耗时收集辅助类 * 做模板的过程和耗时收集辅助类
@ -27,6 +25,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
private static final String FILE_NAME = "tplInfo.ser"; private static final String FILE_NAME = "tplInfo.ser";
private static TemplateInfoCollector instance; private static TemplateInfoCollector instance;
private HashMap<String, HashMap<String, Object>> templateInfoList; private HashMap<String, HashMap<String, Object>> templateInfoList;
private Set<String> removedTemplates; // 已经从 templateInfoList 中删除过的 id 列表,防止重复收集数据
private String designerOpenDate; //设计器最近一次打开日期 private String designerOpenDate; //设计器最近一次打开日期
private static final int VALID_CELL_COUNT = 5; // 有效报表模板的格子数 private static final int VALID_CELL_COUNT = 5; // 有效报表模板的格子数
private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数 private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数
@ -36,6 +35,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private TemplateInfoCollector() { private TemplateInfoCollector() {
templateInfoList = new HashMap<>(); templateInfoList = new HashMap<>();
removedTemplates = new ListSet<>();
setDesignerOpenDate(); setDesignerOpenDate();
} }
@ -77,12 +77,15 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
return instance; 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(); return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv();
} }
public static void appendProcess(String log) { public void appendProcess(T t, String log) {
if (!shouldCollectInfo()) { if (!shouldCollectInfo(t)) {
return; return;
} }
// 获取当前编辑的模板 // 获取当前编辑的模板
@ -113,7 +116,14 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
private void saveInfo() { private void saveInfo() {
try { try {
ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(getInfoFile())); 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.writeObject(instance);
os.close(); os.close();
} catch (Exception ex) { } catch (Exception ex) {
@ -141,7 +151,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void collectInfo(T t, JTemplate jt, long openTime, long saveTime) { public void collectInfo(T t, JTemplate jt, long openTime, long saveTime) {
if (!shouldCollectInfo()) { if (!shouldCollectInfo(t)) {
return; return;
} }
@ -225,7 +235,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
if (sendSingleTemplateInfo(consumingUrl, jsonConsumingMap) && sendSingleTemplateInfo(processUrl, jsonProcessMap)) { if (sendSingleTemplateInfo(consumingUrl, jsonConsumingMap) && sendSingleTemplateInfo(processUrl, jsonProcessMap)) {
// 清空记录 // 清空记录
FRLogger.getLogger().info("successfully send " + templateInfo.get("templateID")); FRLogger.getLogger().info("successfully send " + templateInfo.get("templateID"));
templateInfoList.remove(templateInfo.get("templateID")); removeFromTemplateInfoList(templateInfo.get("templateID"));
} }
} }
saveInfo(); saveInfo();
@ -277,12 +287,18 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
} }
// 删除测试模板 // 删除测试模板
for (String key : testTemplateKeys) { for (String key : testTemplateKeys) {
templateInfoList.remove(key); removeFromTemplateInfoList(key);
// System.out.println(key + " is removed...");
} }
return completeTemplatesInfo; 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") @SuppressWarnings("unchecked")
private boolean isTestTemplate(HashMap<String, Object> templateInfo) { private boolean isTestTemplate(HashMap<String, Object> templateInfo) {
HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfo.get("processMap"); 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