|
|
@ -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") |
|
|
|