Browse Source

Merging in latest from upstream (BA/design:refs/heads/release)

* commit '44aa95bd8fd4e68081b65380bf65199d0f7762b2':
  REPORT-1916 模板耗时=》给TemplateInfoCollector加上serialVersionUID
  调整代码
  REPORT-1916 模板耗时=》调整代码;发送数据失败时,输出日志
  REPORT-1916 模板耗时=》修改算法,将上传后的模板视为旧模板,不再收集数据
  REPORT-1916 模板耗时=》如果 TemplateInfoCollecor 类结构有改动,则放弃之前收集的数据,保证正常启动设计器
  REPORT-1916 模板耗时=》远程设计时不收集模板数据
master
yaoh.wu 8 years ago
parent
commit
ede5a64246
  1. 7
      designer_base/src/com/fr/design/mainframe/JTemplate.java
  2. 27
      designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java

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

@ -85,7 +85,7 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
public JTemplate(T t, String defaultFileName) { public JTemplate(T t, String defaultFileName) {
this(t, new MemFILE(newTemplateNameByIndex(defaultFileName)), true); this(t, new MemFILE(newTemplateNameByIndex(defaultFileName)), true);
initForCollect(); openTime = System.currentTimeMillis();
} }
public JTemplate(T t, FILE file) { public JTemplate(T t, FILE file) {
@ -117,6 +117,9 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
} }
} }
private void collectInfo() { // 执行收集操作 private void collectInfo() { // 执行收集操作
if (openTime == 0) { // 旧模板,不收集数据
return;
}
long saveTime = System.currentTimeMillis(); // 保存模板的时间点 long saveTime = System.currentTimeMillis(); // 保存模板的时间点
tic.collectInfo(template, this, openTime, saveTime); tic.collectInfo(template, this, openTime, saveTime);
openTime = saveTime; // 更新 openTime,准备下一次计算 openTime = saveTime; // 更新 openTime,准备下一次计算
@ -531,7 +534,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();
} }
//更换最近打开 //更换最近打开

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

@ -5,6 +5,7 @@ import com.fr.base.io.IOFile;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.env.RemoteEnv;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
@ -25,17 +26,16 @@ 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; // 有效报表模板的控件数
private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数 private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数
private static final int ONE_THOUSAND = 1000; private static final int ONE_THOUSAND = 1000;
static final long serialVersionUID = 2007L;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private TemplateInfoCollector() { private TemplateInfoCollector() {
templateInfoList = new HashMap<>(); templateInfoList = new HashMap<>();
removedTemplates = new ListSet<>();
setDesignerOpenDate(); setDesignerOpenDate();
} }
@ -70,22 +70,29 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
// 如果之前没有存储过,则创建新对象 // 如果之前没有存储过,则创建新对象
instance = new TemplateInfoCollector(); instance = new TemplateInfoCollector();
} catch (Exception ex) { } catch (InvalidClassException ex) {
// 如果 TemplateInfoCollecor 类结构有改动,则放弃之前收集的数据(下次保存时覆盖)
// 这种情况主要在开发、测试过程中遇到,正式上线后不应该出现
FRLogger.getLogger().info(ex.getMessage());
FRLogger.getLogger().info("use a new instance");
instance = new TemplateInfoCollector();
}
catch (Exception ex) {
FRLogger.getLogger().error(ex.getMessage(), ex); FRLogger.getLogger().error(ex.getMessage(), ex);
} }
} }
return instance; return instance;
} }
private boolean shouldCollectInfo(T t) { private boolean shouldCollectInfo() {
if (t.getTemplateID() == null || instance.removedTemplates.contains(t.getTemplateID())) { // 旧模板 if (FRContext.getCurrentEnv() instanceof RemoteEnv) { // 远程设计不收集数据
return false; return false;
} }
return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv();
} }
public void appendProcess(T t, String log) { public void appendProcess(String log) {
if (!shouldCollectInfo(t)) { if (!shouldCollectInfo()) {
return; return;
} }
// 获取当前编辑的模板 // 获取当前编辑的模板
@ -151,7 +158,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(t)) { if (!shouldCollectInfo()) {
return; return;
} }
@ -236,6 +243,8 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
// 清空记录 // 清空记录
FRLogger.getLogger().info("successfully send " + templateInfo.get("templateID")); FRLogger.getLogger().info("successfully send " + templateInfo.get("templateID"));
removeFromTemplateInfoList(templateInfo.get("templateID")); removeFromTemplateInfoList(templateInfo.get("templateID"));
} else {
FRLogger.getLogger().info("send template info failed, will try next time, " + templateInfo.get("templateID"));
} }
} }
saveInfo(); saveInfo();
@ -294,9 +303,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
private void removeFromTemplateInfoList(String key) { private void removeFromTemplateInfoList(String key) {
templateInfoList.remove(key); templateInfoList.remove(key);
removedTemplates.add(key);
FRLogger.getLogger().info(key + " is removed..."); FRLogger.getLogger().info(key + " is removed...");
FRLogger.getLogger().info("removedTemplates: " + removedTemplates);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

Loading…
Cancel
Save