Browse Source

REPORT-1916 做模板的过程和耗时收集=》把统计格子数量的功能分离为单独的类;调整代码

master
plough 8 years ago
parent
commit
7049c30a4e
  1. 58
      designer/src/com/fr/design/mainframe/JWorkBook.java
  2. 1
      designer_base/src/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataPane.java
  3. 2
      designer_base/src/com/fr/design/extra/PluginHelper.java
  4. 13
      designer_base/src/com/fr/design/mainframe/JTemplate.java
  5. 42
      designer_base/src/com/fr/design/mainframe/templateinfo/JFormProcessInfo.java
  6. 75
      designer_base/src/com/fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java
  7. 39
      designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java
  8. 26
      designer_base/src/com/fr/design/mainframe/templateinfo/TemplateProcessInfo.java
  9. 32
      designer_form/src/com/fr/design/mainframe/JForm.java

58
designer/src/com/fr/design/mainframe/JWorkBook.java

@ -27,6 +27,8 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIModeControlContainer; import com.fr.design.gui.icontainer.UIModeControlContainer;
import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.mainframe.cell.QuickEditorRegion; import com.fr.design.mainframe.cell.QuickEditorRegion;
import com.fr.design.mainframe.templateinfo.JWorkBookProcessInfo;
import com.fr.design.mainframe.templateinfo.TemplateProcessInfo;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.*; import com.fr.design.menu.*;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
@ -130,59 +132,11 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
return centerPane; return centerPane;
} }
// 获取模板类型 public TemplateProcessInfo getProcessInfo() {
public int getReportType() { if (processInfo == null) {
return template.isElementCaseBook() ? 0 : 1; processInfo = new JWorkBookProcessInfo(template);
} }
return processInfo;
// 获取模板格子数
public int getCellCount() {
int cellCount = 0;
if (template.isElementCaseBook()) { // 如果是普通报表
for (int i = 0; i < template.getReportCount(); i++) {
WorkSheet r = (WorkSheet) template.getReport(i);
CellCase cc = r.getBlock().getCellCase();
for (int j = 0; j < cc.getRowCount(); j++) {
Iterator iter = cc.getRow(j);
while (iter.hasNext()) {
cellCount ++;
iter.next();
}
}
}
}
return cellCount;
}
// 获取模板悬浮元素个数
public int getFloatCount() {
int chartCount = 0;
if (template.isElementCaseBook()) { // 如果是普通报表
for (int i = 0; i < template.getReportCount(); i++) {
WorkSheet r = (WorkSheet) template.getReport(i);
Iterator fiter = r.getBlock().floatIterator();
while (fiter.hasNext()) {
chartCount ++;
fiter.next();
}
}
}
return chartCount;
}
// 获取模板聚合块个数
public int getBlockCount() {
int blockCount = 0;
if (!template.isElementCaseBook()) { // 如果是聚合报表
for (int i = 0; i < template.getReportCount(); i++) {
PolyWorkSheet r = (PolyWorkSheet) template.getReport(i);
blockCount += r.getBlockCount();
}
}
return blockCount;
}
// 获取模板控件数
public int getWidgetCount() {
ParameterUI pui = template.getReportParameterAttr().getParameterUI();
return pui == null ? 0 : (pui.getAllWidgets().length - 1);
} }
/** /**

1
designer_base/src/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataPane.java

@ -96,7 +96,6 @@ public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableDa
selectedChanged(); selectedChanged();
} }
}); });
dataJTable.addKeyListener(new KeyAdapter() { dataJTable.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent e) { public void keyTyped(KeyEvent e) {
selectedChanged(); selectedChanged();

2
designer_base/src/com/fr/design/extra/PluginHelper.java

@ -320,7 +320,7 @@ public class PluginHelper {
return ArrayUtils.EMPTY_STRING_ARRAY; return ArrayUtils.EMPTY_STRING_ARRAY;
} }
//卸载前监听 //卸载前监听
plugin.preUninstall(); // plugin.preUninstall();
PluginLoader.getLoader().deletePlugin(plugin); PluginLoader.getLoader().deletePlugin(plugin);
return env.deleteFileFromPluginAndLibFolder(plugin); return env.deleteFileFromPluginAndLibFolder(plugin);
} }

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

@ -28,6 +28,7 @@ import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; import com.fr.design.mainframe.templateinfo.TemplateInfoCollector;
import com.fr.design.mainframe.templateinfo.TemplateProcessInfo;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
import com.fr.design.menu.NameSeparator; import com.fr.design.menu.NameSeparator;
@ -74,6 +75,7 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
protected U undoState; protected U undoState;
protected U authorityUndoState = null; protected U authorityUndoState = null;
protected T template; // 当前模板 protected T template; // 当前模板
protected TemplateProcessInfo processInfo; // 模板过程的相关信息
private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复 private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复
private DesignModelAdapter<T, ?> designModel; private DesignModelAdapter<T, ?> designModel;
private PreviewProvider previewType; private PreviewProvider previewType;
@ -122,16 +124,7 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
openTime = saveTime; // 更新 openTime,准备下一次计算 openTime = saveTime; // 更新 openTime,准备下一次计算
} }
// 获取模板类型。0 代表普通报表,1 代表聚合报表,2 代表表单 public abstract TemplateProcessInfo getProcessInfo();
public abstract int getReportType();
// 获取模板格子数
public abstract int getCellCount();
// 获取模板悬浮元素个数
public abstract int getFloatCount();
// 获取模板聚合块个数
public abstract int getBlockCount();
// 获取模板控件数
public abstract int getWidgetCount();
// 追加过程记录 // 追加过程记录
public void appendProcess(String s) { public void appendProcess(String s) {

42
designer_base/src/com/fr/design/mainframe/templateinfo/JFormProcessInfo.java

@ -0,0 +1,42 @@
package com.fr.design.mainframe.templateinfo;
import com.fr.form.main.Form;
import com.fr.form.ui.container.WFitLayout;
/**
* Created by plough on 2017/3/17.
*/
public class JFormProcessInfo extends TemplateProcessInfo<Form> {
public JFormProcessInfo(Form form) {
super(form);
}
// 获取模板类型
public int getReportType() {
return 2;
}
// 获取模板格子数
public int getCellCount() {
return 0;
}
// 获取模板悬浮元素个数
public int getFloatCount() {
return 0;
}
// 获取模板聚合块个数
public int getBlockCount() {
return 0;
}
// 获取模板控件数
public int getWidgetCount() {
int widgetCount = 0;
for (int i = 0; i < template.getContainer().getWidgetCount(); i++) {
WFitLayout wf = (WFitLayout) template.getContainer().getWidget(i);
widgetCount += wf.getWidgetCount();
}
int a = 1;
int b = 2;
return widgetCount;
}
}

75
designer_base/src/com/fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java

@ -0,0 +1,75 @@
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;
import com.fr.report.poly.PolyWorkSheet;
import com.fr.report.worksheet.WorkSheet;
import java.util.Iterator;
/**
* Created by plough on 2017/3/17.
*/
public class JWorkBookProcessInfo extends TemplateProcessInfo<WorkBook> {
public JWorkBookProcessInfo(WorkBook wb) {
super(wb);
}
// 获取模板类型
public int getReportType() {
return template.isElementCaseBook() ? 0 : 1;
}
// 获取模板格子数
public int getCellCount() {
int cellCount = 0;
if (template.isElementCaseBook()) { // 如果是普通报表
for (int i = 0; i < template.getReportCount(); i++) {
WorkSheet r = (WorkSheet) template.getReport(i);
CellCase cc = r.getBlock().getCellCase();
for (int j = 0; j < cc.getRowCount(); j++) {
Iterator iter = cc.getRow(j);
while (iter.hasNext()) {
cellCount ++;
iter.next();
}
}
}
}
return cellCount;
}
// 获取模板悬浮元素个数
public int getFloatCount() {
int chartCount = 0;
if (template.isElementCaseBook()) { // 如果是普通报表
for (int i = 0; i < template.getReportCount(); i++) {
WorkSheet r = (WorkSheet) template.getReport(i);
Iterator fiter = r.getBlock().floatIterator();
while (fiter.hasNext()) {
chartCount ++;
fiter.next();
}
}
}
return chartCount;
}
// 获取模板聚合块个数
public int getBlockCount() {
int blockCount = 0;
if (!template.isElementCaseBook()) { // 如果是聚合报表
for (int i = 0; i < template.getReportCount(); i++) {
PolyWorkSheet r = (PolyWorkSheet) template.getReport(i);
blockCount += r.getBlockCount();
}
}
return blockCount;
}
// 获取模板控件数
public int getWidgetCount() {
ParameterUI pui = template.getReportParameterAttr().getParameterUI();
return pui == null ? 0 : (pui.getAllWidgets().length - 1);
}
}

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

@ -8,6 +8,7 @@ import com.fr.design.mainframe.JTemplate;
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;
import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.stable.*; import com.fr.stable.*;
import org.json.JSONObject; import org.json.JSONObject;
@ -27,6 +28,10 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
private static TemplateInfoCollector instance; private static TemplateInfoCollector instance;
private HashMap<String, HashMap<String, Object>> templateInfoList; private HashMap<String, HashMap<String, Object>> templateInfoList;
private String designerOpenDate; //设计器最近一次打开日期 private String designerOpenDate; //设计器最近一次打开日期
private static final int VALID_CELL_COUNT = 5; // 有效报表模板的格子数
private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数
private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数
private static final int ONE_THOUSAND = 1000;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private TemplateInfoCollector() { private TemplateInfoCollector() {
@ -108,11 +113,11 @@ 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()));
// System.out.println("写入:" + instance.templateInfoList); System.out.println("写入:" + instance.templateInfoList);
os.writeObject(instance); os.writeObject(instance);
os.close(); os.close();
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); FRLogger.getLogger().error(ex.getMessage());
} }
} }
@ -142,7 +147,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
HashMap<String, Object> templateInfo; HashMap<String, Object> templateInfo;
long timeConsume = ((saveTime - openTime) / 1000); // 制作模板耗时(单位:s) long timeConsume = ((saveTime - openTime) / ONE_THOUSAND); // 制作模板耗时(单位:s)
String templateID = t.getTemplateID(); String templateID = t.getTemplateID();
if (inList(t)) { // 已有记录 if (inList(t)) { // 已有记录
@ -195,11 +200,13 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
processMap.put("templateID", templateID); processMap.put("templateID", templateID);
processMap.put("process", jt.getProcess()); processMap.put("process", jt.getProcess());
processMap.put("report_type", jt.getReportType());
processMap.put("cell_count", jt.getCellCount()); TemplateProcessInfo info = jt.getProcessInfo();
processMap.put("float_count", jt.getFloatCount()); processMap.put("report_type", info.getReportType());
processMap.put("block_count", jt.getBlockCount()); processMap.put("cell_count", info.getCellCount());
processMap.put("widget_count", jt.getWidgetCount()); processMap.put("float_count", info.getFloatCount());
processMap.put("block_count", info.getBlockCount());
processMap.put("widget_count", info.getWidgetCount());
return processMap; return processMap;
} }
@ -209,15 +216,15 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
*/ */
public void sendTemplateInfo() { public void sendTemplateInfo() {
addDayCount(); addDayCount();
String consumingUrl = "http://cloud.fanruan.com/api/monitor/record_of_reports_consuming/single"; String consumingUrl = SiteCenter.getInstance().acquireUrlByKind("tempinfo.consuming") + "/single";
String processUrl = "http://cloud.fanruan.com/api/monitor/record_of_reports_process/single"; String processUrl = SiteCenter.getInstance().acquireUrlByKind("tempinfo.process") + "/single";
ArrayList<HashMap<String, String>> completeTemplatesInfo = getCompleteTemplatesInfo(); ArrayList<HashMap<String, String>> completeTemplatesInfo = getCompleteTemplatesInfo();
for (HashMap<String, String> templateInfo : completeTemplatesInfo) { for (HashMap<String, String> templateInfo : completeTemplatesInfo) {
String jsonConsumingMap = templateInfo.get("jsonConsumingMap"); String jsonConsumingMap = templateInfo.get("jsonConsumingMap");
String jsonProcessMap = templateInfo.get("jsonProcessMap"); String jsonProcessMap = templateInfo.get("jsonProcessMap");
if (sendSingleTemplateInfo(consumingUrl, jsonConsumingMap) && sendSingleTemplateInfo(processUrl, jsonProcessMap)) { if (sendSingleTemplateInfo(consumingUrl, jsonConsumingMap) && sendSingleTemplateInfo(processUrl, jsonProcessMap)) {
// 清空记录 // 清空记录
// System.out.println("success"); FRLogger.getLogger().info("successfully send " + templateInfo.get("templateID"));
templateInfoList.remove(templateInfo.get("templateID")); templateInfoList.remove(templateInfo.get("templateID"));
} }
} }
@ -251,7 +258,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
ArrayList<String> testTemplateKeys = new ArrayList<>(); // 保存测试模板的key ArrayList<String> testTemplateKeys = new ArrayList<>(); // 保存测试模板的key
for (String key : templateInfoList.keySet()) { for (String key : templateInfoList.keySet()) {
HashMap<String, Object> templateInfo = templateInfoList.get(key); HashMap<String, Object> templateInfo = templateInfoList.get(key);
if ((int)templateInfo.get("day_count") <= 15) { // 未完成模板 if ((int)templateInfo.get("day_count") <= COMPLETE_DAY_COUNT) { // 未完成模板
continue; continue;
} }
if (isTestTemplate(templateInfo)) { if (isTestTemplate(templateInfo)) {
@ -286,9 +293,9 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
int widgetCount = (int)processMap.get("widget_count"); int widgetCount = (int)processMap.get("widget_count");
boolean isTestTemplate = false; boolean isTestTemplate = false;
if (reportType == 0) { // 普通报表 if (reportType == 0) { // 普通报表
isTestTemplate = cellCount <= 5 && floatCount <= 1 && widgetCount <= 5; isTestTemplate = cellCount <= VALID_CELL_COUNT && floatCount <= 1 && widgetCount <= VALID_WIDGET_COUNT;
} else if (reportType == 1) { // 聚合报表 } else if (reportType == 1) { // 聚合报表
isTestTemplate = blockCount <= 1 && widgetCount <= 5; isTestTemplate = blockCount <= 1 && widgetCount <= VALID_WIDGET_COUNT;
} else { // 表单(reportType == 2) } else { // 表单(reportType == 2)
isTestTemplate = widgetCount <= 1; isTestTemplate = widgetCount <= 1;
} }
@ -296,7 +303,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
} }
public static void main(String[] args) { public static void main(String[] args) {
// TemplateInfoCollector tic = TemplateInfoCollector.getInstance(); TemplateInfoCollector tic = TemplateInfoCollector.getInstance();
// tic.sendTemplateInfo(); tic.sendTemplateInfo();
} }
} }

26
designer_base/src/com/fr/design/mainframe/templateinfo/TemplateProcessInfo.java

@ -0,0 +1,26 @@
package com.fr.design.mainframe.templateinfo;
import com.fr.base.io.IOFile;
/**
* Created by plough on 2017/3/17.
*/
public abstract class TemplateProcessInfo<T extends IOFile> {
protected T template;
public TemplateProcessInfo(T template) {
this.template = template;
}
// 获取模板类型。0 代表普通报表,1 代表聚合报表,2 代表表单
public abstract int getReportType();
// 获取模板格子数
public abstract int getCellCount();
// 获取模板悬浮元素个数
public abstract int getFloatCount();
// 获取模板聚合块个数
public abstract int getBlockCount();
// 获取模板控件数
public abstract int getWidgetCount();
}

32
designer_form/src/com/fr/design/mainframe/JForm.java

@ -23,6 +23,8 @@ import com.fr.design.mainframe.actions.EmbeddedFormExportExportAction;
import com.fr.design.mainframe.actions.TemplateParameterAction; import com.fr.design.mainframe.actions.TemplateParameterAction;
import com.fr.design.mainframe.form.FormECCompositeProvider; import com.fr.design.mainframe.form.FormECCompositeProvider;
import com.fr.design.mainframe.form.FormECDesignerProvider; import com.fr.design.mainframe.form.FormECDesignerProvider;
import com.fr.design.mainframe.templateinfo.JFormProcessInfo;
import com.fr.design.mainframe.templateinfo.TemplateProcessInfo;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
@ -89,33 +91,11 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
return DesignState.JFORM; return DesignState.JFORM;
} }
// 获取模板类型 public TemplateProcessInfo getProcessInfo() {
public int getReportType() { if (processInfo == null) {
return 2; processInfo = new JFormProcessInfo(template);
} }
return processInfo;
// 获取模板格子数
public int getCellCount() {
return 0;
}
// 获取模板悬浮元素个数
public int getFloatCount() {
return 0;
}
// 获取模板聚合块个数
public int getBlockCount() {
return 0;
}
// 获取模板控件数
public int getWidgetCount() {
int widgetCount = 0;
for (int i = 0; i < template.getContainer().getWidgetCount(); i++) {
WFitLayout wf = (WFitLayout) template.getContainer().getWidget(i);
widgetCount += wf.getWidgetCount();
}
int a = 1;
int b = 2;
return widgetCount;
} }
@Override @Override

Loading…
Cancel
Save