Browse Source

Pull request #2729: REPORT-42126 && REPORT-41929 && REPORT-41272【预定义样式】老jar下做的cpt模板,设置了单元格的样式,升级到最新,发现单元格预定义样式丢失了

Merge in DESIGN/design from ~KERRY/design_10.0:feature/10.0 to feature/10.0

* commit '526c36376d33f05ada80ccdeb2745f3477a8315f':
  REPORT-42126 && REPORT-41929 && REPORT-41272【预定义样式】老jar下做的cpt模板,设置了单元格的样式,升级到最新,发现单元格预定义样式丢失了
persist/11.0
kerry 4 years ago
parent
commit
28b0945709
  1. 5
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  2. 30
      designer-base/src/main/java/com/fr/design/mainframe/predefined/info/PredefinedStyleInfoCollector.java
  3. 2
      designer-base/src/test/java/com/fr/design/mainframe/predefined/info/PredefinedStyleInfoCollectorTest.java

5
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -160,7 +160,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
private void setPredefinedInfo(boolean isNewFile){ private void setPredefinedInfo(boolean isNewFile){
if (this.template.getAttrMark(PredefinedStyleAttrMark.XML_TAG) == null) { if (this.template.getAttrMark(PredefinedStyleAttrMark.XML_TAG) == null) {
PredefinedStyleAttrMark attrMark = new PredefinedStyleAttrMark(); PredefinedStyleAttrMark attrMark = PredefinedStyleAttrMark.createDefaultStyleMark();
if (!isNewFile || !DesignUtils.checkDesignerRemoteVersion()) { if (!isNewFile || !DesignUtils.checkDesignerRemoteVersion()) {
attrMark.setPreferenceStyleName(InterProviderFactory.getProvider().getLocText("Fine-Engine_Predefined_Style_Compatibility")); attrMark.setPreferenceStyleName(InterProviderFactory.getProvider().getLocText("Fine-Engine_Predefined_Style_Compatibility"));
} }
@ -821,6 +821,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
if (editingFILE == null || editingFILE instanceof MemFILE) { if (editingFILE == null || editingFILE instanceof MemFILE) {
return false; return false;
} }
PredefinedStyleInfoCollector.getInstance().collectUseNumber(this.getTemplatePredefinedStyle());
try { try {
this.getTarget().setPredefinedStyleName(this.getTemplatePredefinedStyle(), false); this.getTarget().setPredefinedStyleName(this.getTemplatePredefinedStyle(), false);
this.getTarget().export(editingFILE.asOutputStream()); this.getTarget().export(editingFILE.asOutputStream());
@ -1370,7 +1371,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
public String getTemplatePredefinedStyle(){ public String getTemplatePredefinedStyle(){
PredefinedStyleAttrMark attrMark = this.getTarget().getAttrMark(PredefinedStyleAttrMark.XML_TAG); PredefinedStyleAttrMark attrMark = this.getTarget().getAttrMark(PredefinedStyleAttrMark.XML_TAG);
if (attrMark == null){ if (attrMark == null){
attrMark = new PredefinedStyleAttrMark(); attrMark = PredefinedStyleAttrMark.createDefaultStyleMark();
} }
return attrMark.getPreferenceStyleName(); return attrMark.getPreferenceStyleName();
} }

30
designer-base/src/main/java/com/fr/design/mainframe/predefined/info/PredefinedStyleInfoCollector.java

@ -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();
} }
} }

2
designer-base/src/test/java/com/fr/design/mainframe/predefined/info/PredefinedStyleInfoCollectorTest.java

@ -59,7 +59,7 @@ public class PredefinedStyleInfoCollectorTest {
@Test @Test
public void testCollectUseNumber() { public void testCollectUseNumber() {
PredefinedStyleInfoCollector.getInstance().collectUseNumber(); PredefinedStyleInfoCollector.getInstance().collectUseNumber("test");
Assert.assertEquals(1, PredefinedStyleInfoCollector.getInstance().getUseNumber()); Assert.assertEquals(1, PredefinedStyleInfoCollector.getInstance().getUseNumber());
} }

Loading…
Cancel
Save