@ -2,9 +2,11 @@ package com.fr.design.mainframe.predefined.info;
import com.fr.config.MarketConfig ;
import com.fr.config.MarketConfig ;
import com.fr.design.DesignerEnvManager ;
import com.fr.design.DesignerEnvManager ;
import com.fr.design.i18n.Toolkit ;
import com.fr.design.mainframe.burying.point.AbstractPointCollector ;
import com.fr.design.mainframe.burying.point.AbstractPointCollector ;
import com.fr.design.mainframe.template.info.SendHelper ;
import com.fr.design.mainframe.template.info.SendHelper ;
import com.fr.general.CloudCenter ;
import com.fr.general.CloudCenter ;
import com.fr.general.ComparatorUtils ;
import com.fr.general.GeneralUtils ;
import com.fr.general.GeneralUtils ;
import com.fr.json.JSONObject ;
import com.fr.json.JSONObject ;
import com.fr.stable.xml.XMLPrintWriter ;
import com.fr.stable.xml.XMLPrintWriter ;
@ -15,6 +17,9 @@ import com.fr.third.joda.time.DateTime;
* Created by kerry on 2020 - 09 - 04
* Created by kerry on 2020 - 09 - 04
* /
* /
public class PredefinedStyleInfoCollector extends AbstractPointCollector {
public class PredefinedStyleInfoCollector extends AbstractPointCollector {
//每三天上传一次
private static final long DELTA = 3 * 24 * 3600 * 1000L ;
private static final String SIMPLE_DATE_PATTERN = "yyyy-MM-dd" ;
private static final String SIMPLE_DATE_PATTERN = "yyyy-MM-dd" ;
private static final String XML_TAG = "PredefinedStyleInfo" ;
private static final String XML_TAG = "PredefinedStyleInfo" ;
private static final String XML_FILE_NAME = "predefinedStyle.info" ;
private static final String XML_FILE_NAME = "predefinedStyle.info" ;
@ -31,6 +36,12 @@ public class PredefinedStyleInfoCollector extends AbstractPointCollector {
private static final String ATTR_CLICK_NUMBER = "clickNumber" ;
private static final String ATTR_CLICK_NUMBER = "clickNumber" ;
private static final String ATTR_USE_NUMBER = "useNumber" ;
private static final String ATTR_USE_NUMBER = "useNumber" ;
private static final String ATTR_TIME = "time" ;
private static final String ATTR_TIME = "time" ;
private static final String XML_LAST_TIME = "lastSendTime" ;
/ * *
* 上一次的发送时间
* /
private long lastSendTime ;
private int clickNumber = 0 ;
private int clickNumber = 0 ;
@ -61,8 +72,11 @@ public class PredefinedStyleInfoCollector extends AbstractPointCollector {
saveInfo ( ) ;
saveInfo ( ) ;
}
}
public void collectUseNumber ( ) {
public void collectUseNumber ( String predefinedName ) {
useNumber + + ;
if ( ! ComparatorUtils . equals ( Toolkit . i18nText ( "Fine-Engine_Predefined_Style_Compatibility" ) , predefinedName ) & &
! ComparatorUtils . equals ( Toolkit . i18nText ( "Fine-Engine_Report_DEFAULT" ) , predefinedName ) ) {
useNumber + + ;
}
saveInfo ( ) ;
saveInfo ( ) ;
}
}
@ -78,9 +92,15 @@ public class PredefinedStyleInfoCollector extends AbstractPointCollector {
@Override
@Override
public void sendPointInfo ( ) {
public void sendPointInfo ( ) {
if ( System . currentTimeMillis ( ) - lastSendTime < DELTA ) {
return ;
}
String content = generateTotalInfo ( ) ;
String content = generateTotalInfo ( ) ;
SendHelper . sendSinglePointInfo ( CLOUD_URL , content ) ;
SendHelper . sendSinglePointInfo ( CLOUD_URL , content ) ;
this . lastSendTime = System . currentTimeMillis ( ) ;
this . clickNumber = 0 ;
this . useNumber = 0 ;
saveInfo ( ) ;
}
}
public String generateTotalInfo ( ) {
public String generateTotalInfo ( ) {
@ -105,6 +125,7 @@ public class PredefinedStyleInfoCollector extends AbstractPointCollector {
if ( XML_TAG . equals ( name ) ) {
if ( XML_TAG . equals ( name ) ) {
this . clickNumber = reader . getAttrAsInt ( ATTR_CLICK_NUMBER , 0 ) ;
this . clickNumber = reader . getAttrAsInt ( ATTR_CLICK_NUMBER , 0 ) ;
this . useNumber = reader . getAttrAsInt ( ATTR_USE_NUMBER , 0 ) ;
this . useNumber = reader . getAttrAsInt ( ATTR_USE_NUMBER , 0 ) ;
this . lastSendTime = reader . getAttrAsLong ( XML_LAST_TIME , System . currentTimeMillis ( ) ) ;
}
}
}
}
}
}
@ -112,7 +133,8 @@ public class PredefinedStyleInfoCollector extends AbstractPointCollector {
@Override
@Override
public void writeXML ( XMLPrintWriter writer ) {
public void writeXML ( XMLPrintWriter writer ) {
writer . startTAG ( XML_TAG ) ;
writer . startTAG ( XML_TAG ) ;
writer . attr ( ATTR_CLICK_NUMBER , this . clickNumber ) . attr ( ATTR_USE_NUMBER , this . useNumber ) ;
writer . attr ( ATTR_CLICK_NUMBER , this . clickNumber ) . attr ( ATTR_USE_NUMBER , this . useNumber )
. attr ( XML_LAST_TIME , this . lastSendTime ) ;
writer . end ( ) ;
writer . end ( ) ;
}
}
}
}