Browse Source

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

persist/11.0
kerry 4 years ago
parent
commit
526c36376d
  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){
if (this.template.getAttrMark(PredefinedStyleAttrMark.XML_TAG) == null) {
PredefinedStyleAttrMark attrMark = new PredefinedStyleAttrMark();
PredefinedStyleAttrMark attrMark = PredefinedStyleAttrMark.createDefaultStyleMark();
if (!isNewFile || !DesignUtils.checkDesignerRemoteVersion()) {
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) {
return false;
}
PredefinedStyleInfoCollector.getInstance().collectUseNumber(this.getTemplatePredefinedStyle());
try {
this.getTarget().setPredefinedStyleName(this.getTemplatePredefinedStyle(), false);
this.getTarget().export(editingFILE.asOutputStream());
@ -1370,7 +1371,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
public String getTemplatePredefinedStyle(){
PredefinedStyleAttrMark attrMark = this.getTarget().getAttrMark(PredefinedStyleAttrMark.XML_TAG);
if (attrMark == null){
attrMark = new PredefinedStyleAttrMark();
attrMark = PredefinedStyleAttrMark.createDefaultStyleMark();
}
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.design.DesignerEnvManager;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.burying.point.AbstractPointCollector;
import com.fr.design.mainframe.template.info.SendHelper;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.json.JSONObject;
import com.fr.stable.xml.XMLPrintWriter;
@ -15,6 +17,9 @@ import com.fr.third.joda.time.DateTime;
* Created by kerry on 2020-09-04
*/
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 XML_TAG = "PredefinedStyleInfo";
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_USE_NUMBER = "useNumber";
private static final String ATTR_TIME = "time";
private static final String XML_LAST_TIME = "lastSendTime";
/**
* 上一次的发送时间
*/
private long lastSendTime;
private int clickNumber = 0;
@ -61,8 +72,11 @@ public class PredefinedStyleInfoCollector extends AbstractPointCollector {
saveInfo();
}
public void collectUseNumber() {
useNumber++;
public void collectUseNumber(String predefinedName) {
if (!ComparatorUtils.equals(Toolkit.i18nText("Fine-Engine_Predefined_Style_Compatibility"), predefinedName) &&
!ComparatorUtils.equals(Toolkit.i18nText("Fine-Engine_Report_DEFAULT"), predefinedName)) {
useNumber++;
}
saveInfo();
}
@ -78,9 +92,15 @@ public class PredefinedStyleInfoCollector extends AbstractPointCollector {
@Override
public void sendPointInfo() {
if (System.currentTimeMillis() - lastSendTime < DELTA) {
return;
}
String content = generateTotalInfo();
SendHelper.sendSinglePointInfo(CLOUD_URL, content);
this.lastSendTime = System.currentTimeMillis();
this.clickNumber = 0;
this.useNumber = 0;
saveInfo();
}
public String generateTotalInfo() {
@ -105,6 +125,7 @@ public class PredefinedStyleInfoCollector extends AbstractPointCollector {
if (XML_TAG.equals(name)) {
this.clickNumber = reader.getAttrAsInt(ATTR_CLICK_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
public void writeXML(XMLPrintWriter writer) {
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();
}
}

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

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

Loading…
Cancel
Save