From 51f1caa26abe0513ec0eb38d3ab83d18ad7a261d Mon Sep 17 00:00:00 2001 From: plough Date: Wed, 5 Apr 2017 14:52:55 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-1916=20=E6=A8=A1=E6=9D=BF=E8=80=97?= =?UTF-8?q?=E6=97=B6=3D=E3=80=8B=E8=B0=83=E6=95=B4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E8=AE=A9designer=5Fbase=E4=B8=8D=E4=BE=9D=E8=B5=96eng?= =?UTF-8?q?ine=E5=92=8Cdesigner=5Fform?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java | 1 - .../com/fr/design/mainframe/templateinfo/JFormProcessInfo.java | 0 2 files changed, 1 deletion(-) rename {designer_base => designer}/src/com/fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java (98%) rename {designer_base => designer_form}/src/com/fr/design/mainframe/templateinfo/JFormProcessInfo.java (100%) diff --git a/designer_base/src/com/fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java b/designer/src/com/fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java similarity index 98% rename from designer_base/src/com/fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java rename to designer/src/com/fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java index 44522b8566..bf5d835d2a 100644 --- a/designer_base/src/com/fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java +++ b/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; diff --git a/designer_base/src/com/fr/design/mainframe/templateinfo/JFormProcessInfo.java b/designer_form/src/com/fr/design/mainframe/templateinfo/JFormProcessInfo.java similarity index 100% rename from designer_base/src/com/fr/design/mainframe/templateinfo/JFormProcessInfo.java rename to designer_form/src/com/fr/design/mainframe/templateinfo/JFormProcessInfo.java From ec76806d476de5ea50ceb6fed066ace0ae910e7a Mon Sep 17 00:00:00 2001 From: plough Date: Wed, 5 Apr 2017 15:42:49 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-1916=20=E6=A8=A1=E6=9D=BF=E8=80=97?= =?UTF-8?q?=E6=97=B6=3D=E3=80=8B=E8=A7=A3=E5=86=B3=E5=8F=A6=E5=AD=98?= =?UTF-8?q?=E4=B8=BA=E4=B8=8D=E4=BA=A7=E7=94=9F=E6=96=B0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=9A=84bug=EF=BC=9B=E5=BD=93id=E4=B8=BAnull=E6=97=B6=EF=BC=88?= =?UTF-8?q?=E6=97=A7=E6=A8=A1=E6=9D=BF=EF=BC=89=EF=BC=8C=E4=B8=8D=E6=90=9C?= =?UTF-8?q?=E9=9B=86=E6=95=B0=E6=8D=AE=EF=BC=9B=E8=B0=83=E6=95=B4=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=89=93=E5=8D=B0=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/mainframe/JTemplate.java | 9 +++++---- .../mainframe/templateinfo/TemplateInfoCollector.java | 9 ++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index b0b9f7b5a9..d6dc2f0b16 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JTemplate.java @@ -111,14 +111,15 @@ public abstract class JTemplate> ex // 为收集模版信息作准备 private void initForCollect() { - if (template.getTemplateID() == null) { - template.initTemplateID(); // 为新模板设置 templateID 属性 - } + template.initTemplateID(); // 为新模板设置 templateID 属性 if (openTime == 0) { openTime = System.currentTimeMillis(); } } private void collectInfo() { // 执行收集操作 + if (template.getTemplateID() == null) { // 旧模板 + return; + } long saveTime = System.currentTimeMillis(); // 保存模板的时间点 tic.collectInfo(template, this, openTime, saveTime); openTime = saveTime; // 更新 openTime,准备下一次计算 @@ -533,7 +534,7 @@ public abstract class JTemplate> ex boolean result = this.saveFile(); if (result) { DesignerFrameFileDealerPane.getInstance().refresh(); - initForCollect(); // 如果是旧模板另存为新模板,则添加 templateID + initForCollect(); // 如果另存为新模板,则添加 templateID collectInfo(); } //更换最近打开 diff --git a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java index 4f7069205c..39a7e22abd 100644 --- a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java +++ b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java @@ -113,7 +113,14 @@ public class TemplateInfoCollector 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) { From 28443f0c163bc298d006015392f62a2f810764ab Mon Sep 17 00:00:00 2001 From: plough Date: Wed, 5 Apr 2017 17:42:38 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-1916=20=E6=A8=A1=E6=9D=BF=E8=80=97?= =?UTF-8?q?=E6=97=B6=3D=E3=80=8B=E9=98=B2=E6=AD=A2=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E6=94=B6=E9=9B=86=E6=A8=A1=E6=9D=BF=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JTemplate.java | 3 -- .../templateinfo/TemplateInfoCollector.java | 29 ++++++++++++------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index d6dc2f0b16..37769cdbe8 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JTemplate.java @@ -117,9 +117,6 @@ public abstract class JTemplate> ex } } private void collectInfo() { // 执行收集操作 - if (template.getTemplateID() == null) { // 旧模板 - return; - } long saveTime = System.currentTimeMillis(); // 保存模板的时间点 tic.collectInfo(template, this, openTime, saveTime); openTime = saveTime; // 更新 openTime,准备下一次计算 diff --git a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java index 39a7e22abd..3cbc557f81 100644 --- a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java +++ b/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 implements Serializable { private static final String FILE_NAME = "tplInfo.ser"; private static TemplateInfoCollector instance; private HashMap> templateInfoList; + private Set 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 implements Serializable { @SuppressWarnings("unchecked") private TemplateInfoCollector() { templateInfoList = new HashMap<>(); + removedTemplates = new ListSet<>(); setDesignerOpenDate(); } @@ -77,12 +77,15 @@ public class TemplateInfoCollector 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; } // 获取当前编辑的模板 @@ -148,7 +151,7 @@ public class TemplateInfoCollector implements Serializable { */ @SuppressWarnings("unchecked") public void collectInfo(T t, JTemplate jt, long openTime, long saveTime) { - if (!shouldCollectInfo()) { + if (!shouldCollectInfo(t)) { return; } @@ -232,7 +235,7 @@ public class TemplateInfoCollector 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(); @@ -284,12 +287,18 @@ public class TemplateInfoCollector 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 templateInfo) { HashMap processMap = (HashMap) templateInfo.get("processMap");