|
|
@ -2,39 +2,59 @@ package com.fr.design.mainframe.templateinfo; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.FRContext; |
|
|
|
import com.fr.base.FRContext; |
|
|
|
import com.fr.base.io.IOFile; |
|
|
|
import com.fr.base.io.IOFile; |
|
|
|
import com.fr.config.ServerConfig; |
|
|
|
import com.fr.config.MarketConfig; |
|
|
|
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.design.mainframe.SiteCenterToken; |
|
|
|
import com.fr.design.mainframe.SiteCenterToken; |
|
|
|
import com.fr.env.RemoteEnv; |
|
|
|
import com.fr.env.RemoteEnv; |
|
|
|
import com.fr.general.*; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
|
|
|
|
import com.fr.general.FRLogger; |
|
|
|
|
|
|
|
import com.fr.general.GeneralUtils; |
|
|
|
|
|
|
|
import com.fr.general.IOUtils; |
|
|
|
|
|
|
|
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.xml.*; |
|
|
|
|
|
|
|
import com.fr.third.javax.xml.stream.XMLStreamException; |
|
|
|
|
|
|
|
import com.fr.json.JSONObject; |
|
|
|
import com.fr.json.JSONObject; |
|
|
|
|
|
|
|
import com.fr.stable.EncodeConstants; |
|
|
|
|
|
|
|
import com.fr.stable.ProductConstants; |
|
|
|
|
|
|
|
import com.fr.stable.StableUtils; |
|
|
|
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
import com.fr.stable.xml.XMLPrintWriter; |
|
|
|
|
|
|
|
import com.fr.stable.xml.XMLReadable; |
|
|
|
|
|
|
|
import com.fr.stable.xml.XMLTools; |
|
|
|
|
|
|
|
import com.fr.stable.xml.XMLWriter; |
|
|
|
|
|
|
|
import com.fr.stable.xml.XMLableReader; |
|
|
|
|
|
|
|
import com.fr.third.javax.xml.stream.XMLStreamException; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.*; |
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
import java.io.FileInputStream; |
|
|
|
|
|
|
|
import java.io.FileNotFoundException; |
|
|
|
|
|
|
|
import java.io.FileOutputStream; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
import java.io.InputStream; |
|
|
|
|
|
|
|
import java.io.InputStreamReader; |
|
|
|
|
|
|
|
import java.io.ObjectInputStream; |
|
|
|
|
|
|
|
import java.io.Serializable; |
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.Calendar; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 做模板的过程和耗时收集,辅助类 |
|
|
|
* 做模板的过程和耗时收集,辅助类 |
|
|
|
* Created by plough on 2017/2/21. |
|
|
|
* Created by plough on 2017/2/21. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class TemplateInfoCollector<T extends IOFile> implements Serializable, XMLReadable, XMLWriter { |
|
|
|
public class TemplateInfoCollector<T extends IOFile> implements Serializable, XMLReadable, XMLWriter { |
|
|
|
|
|
|
|
static final long serialVersionUID = 2007L; |
|
|
|
private static final String FILE_NAME = "tpl.info"; |
|
|
|
private static final String FILE_NAME = "tpl.info"; |
|
|
|
private static final String OBJECT_FILE_NAME = "tplInfo.ser"; |
|
|
|
private static final String OBJECT_FILE_NAME = "tplInfo.ser"; |
|
|
|
private static TemplateInfoCollector instance; |
|
|
|
|
|
|
|
private Map<String, HashMap<String, Object>> templateInfoList; |
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
private static final String XML_DESIGNER_OPEN_DATE = "DesignerOpenDate"; |
|
|
|
private static final String XML_DESIGNER_OPEN_DATE = "DesignerOpenDate"; |
|
|
|
private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList"; |
|
|
|
private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList"; |
|
|
|
private static final String XML_TEMPLATE_INFO = "TemplateInfo"; |
|
|
|
private static final String XML_TEMPLATE_INFO = "TemplateInfo"; |
|
|
@ -57,6 +77,9 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM |
|
|
|
private static final String ATTR_USERNAME = "username"; |
|
|
|
private static final String ATTR_USERNAME = "username"; |
|
|
|
private static final String JSON_CONSUMING_MAP = "jsonConsumingMap"; |
|
|
|
private static final String JSON_CONSUMING_MAP = "jsonConsumingMap"; |
|
|
|
private static final String JSON_PROCESS_MAP = "jsonProcessMap"; |
|
|
|
private static final String JSON_PROCESS_MAP = "jsonProcessMap"; |
|
|
|
|
|
|
|
private static TemplateInfoCollector instance; |
|
|
|
|
|
|
|
private Map<String, HashMap<String, Object>> templateInfoList; |
|
|
|
|
|
|
|
private String designerOpenDate; //设计器最近一次打开日期
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
@SuppressWarnings("unchecked") |
|
|
@ -65,21 +88,6 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM |
|
|
|
setDesignerOpenDate(); |
|
|
|
setDesignerOpenDate(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 把设计器最近打开日期设定为当前日期 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void setDesignerOpenDate() { |
|
|
|
|
|
|
|
designerOpenDate = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 判断今天是否第一次打开设计器 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private boolean designerOpenFirstTime() { |
|
|
|
|
|
|
|
String today = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()); |
|
|
|
|
|
|
|
return !ComparatorUtils.equals(today, designerOpenDate); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取缓存文件存放路径 |
|
|
|
* 获取缓存文件存放路径 |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -138,6 +146,26 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM |
|
|
|
return IOUtils.inputStream2String(is); |
|
|
|
return IOUtils.inputStream2String(is); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
|
|
|
|
TemplateInfoCollector tic = TemplateInfoCollector.getInstance(); |
|
|
|
|
|
|
|
tic.sendTemplateInfo(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 把设计器最近打开日期设定为当前日期 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void setDesignerOpenDate() { |
|
|
|
|
|
|
|
designerOpenDate = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 判断今天是否第一次打开设计器 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private boolean designerOpenFirstTime() { |
|
|
|
|
|
|
|
String today = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()); |
|
|
|
|
|
|
|
return !ComparatorUtils.equals(today, designerOpenDate); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean shouldCollectInfo() { |
|
|
|
private boolean shouldCollectInfo() { |
|
|
|
if (FRContext.getCurrentEnv() instanceof RemoteEnv) { // 远程设计不收集数据
|
|
|
|
if (FRContext.getCurrentEnv() instanceof RemoteEnv) { // 远程设计不收集数据
|
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -218,8 +246,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM |
|
|
|
HashMap<String, Object> consumingMap = (HashMap<String, Object>) templateInfo.get(XML_CONSUMING_MAP); |
|
|
|
HashMap<String, Object> consumingMap = (HashMap<String, Object>) templateInfo.get(XML_CONSUMING_MAP); |
|
|
|
timeConsume += (long) consumingMap.get(ATTR_TIME_CONSUME); // 加上之前的累计编辑时间
|
|
|
|
timeConsume += (long) consumingMap.get(ATTR_TIME_CONSUME); // 加上之前的累计编辑时间
|
|
|
|
consumingMap.put(ATTR_TIME_CONSUME, timeConsume); |
|
|
|
consumingMap.put(ATTR_TIME_CONSUME, timeConsume); |
|
|
|
} |
|
|
|
} else { // 新增
|
|
|
|
else { // 新增
|
|
|
|
|
|
|
|
templateInfo = new HashMap<>(); |
|
|
|
templateInfo = new HashMap<>(); |
|
|
|
templateInfo.put(XML_CONSUMING_MAP, getNewConsumingMap(templateID, openTime, timeConsume)); |
|
|
|
templateInfo.put(XML_CONSUMING_MAP, getNewConsumingMap(templateID, openTime, timeConsume)); |
|
|
|
} |
|
|
|
} |
|
|
@ -238,7 +265,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM |
|
|
|
private HashMap<String, Object> getNewConsumingMap(String templateID, long openTime, long timeConsume) { |
|
|
|
private HashMap<String, Object> getNewConsumingMap(String templateID, long openTime, long timeConsume) { |
|
|
|
HashMap<String, Object> consumingMap = new HashMap<>(); |
|
|
|
HashMap<String, Object> consumingMap = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
String username = ServerConfig.getInstance().getBbsUsername(); |
|
|
|
String username = MarketConfig.getInstance().getBbsUsername(); |
|
|
|
String uuid = DesignerEnvManager.getEnvManager().getUUID(); |
|
|
|
String uuid = DesignerEnvManager.getEnvManager().getUUID(); |
|
|
|
String activitykey = DesignerEnvManager.getEnvManager().getActivationKey(); |
|
|
|
String activitykey = DesignerEnvManager.getEnvManager().getActivationKey(); |
|
|
|
String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime()); |
|
|
|
String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime()); |
|
|
@ -435,7 +462,8 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM |
|
|
|
this.templateID = (String) processMap.get(ATTR_TEMPLATE_ID); |
|
|
|
this.templateID = (String) processMap.get(ATTR_TEMPLATE_ID); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public TemplateInfo() {} |
|
|
|
public TemplateInfo() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getTemplateID() { |
|
|
|
public String getTemplateID() { |
|
|
|
return templateID; |
|
|
|
return templateID; |
|
|
@ -518,10 +546,4 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
|
|
|
|
TemplateInfoCollector tic = TemplateInfoCollector.getInstance(); |
|
|
|
|
|
|
|
tic.sendTemplateInfo(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|