Browse Source

REPORT-67790;修改开启新引擎的逻辑(原来的以第一个sheet设置为准,改为只要有一个sheet设置了新引擎,就走新引擎逻辑)

bugfix/11.0
fly.li 3 years ago
parent
commit
a11ab9ba8a
  1. 29
      designer-base/src/main/java/com/fr/nx/app/designer/utils/CptAndCptxCompatibilityUtil.java

29
designer-base/src/main/java/com/fr/nx/app/designer/utils/CptAndCptxCompatibilityUtil.java

@ -3,7 +3,9 @@ package com.fr.nx.app.designer.utils;
import com.fr.base.extension.FileExtension; import com.fr.base.extension.FileExtension;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.main.FineBook;
import com.fr.main.TemplateWorkBook; import com.fr.main.TemplateWorkBook;
import com.fr.report.core.ReportUtils;
import com.fr.report.report.Report; import com.fr.report.report.Report;
import com.fr.report.stable.LayerReportAttr; import com.fr.report.stable.LayerReportAttr;
import com.fr.report.worksheet.WorkSheet; import com.fr.report.worksheet.WorkSheet;
@ -30,7 +32,7 @@ public class CptAndCptxCompatibilityUtil {
} }
/** /**
* 判断是不是cptx模板或者开启了新引擎的cpt模板的另存为操作 * 判断是不是cptx模板或者开启了新引擎的cpt模板的另存为操作
**/ **/
private static boolean isSaveAs(JTemplate jTemplate, String oldName, String newName){ private static boolean isSaveAs(JTemplate jTemplate, String oldName, String newName){
return isEngineXEnable(jTemplate.getTarget(), newName) && ((FileExtension.CPTX.matchExtension(oldName) && FileExtension.CPTX.matchExtension(newName)) || (FileExtension.CPT.matchExtension(oldName) && FileExtension.CPT.matchExtension(newName))); return isEngineXEnable(jTemplate.getTarget(), newName) && ((FileExtension.CPTX.matchExtension(oldName) && FileExtension.CPTX.matchExtension(newName)) || (FileExtension.CPT.matchExtension(oldName) && FileExtension.CPT.matchExtension(newName)));
@ -40,7 +42,7 @@ public class CptAndCptxCompatibilityUtil {
* cptx另存为cpt需要修改报表引擎属性 * cptx另存为cpt需要修改报表引擎属性
**/ **/
private static boolean setFrEngineAttr(JTemplate jTemplate){ private static boolean setFrEngineAttr(JTemplate jTemplate){
WorkSheet workSheet = gainWorkSheet(jTemplate.getTarget()); WorkSheet workSheet = getFirstWorkSheet(jTemplate.getTarget());
if (workSheet == null){ if (workSheet == null){
return false; return false;
}else { }else {
@ -49,8 +51,7 @@ public class CptAndCptxCompatibilityUtil {
layerReportAttr = new LayerReportAttr(); layerReportAttr = new LayerReportAttr();
workSheet.setLayerReportAttr(layerReportAttr); workSheet.setLayerReportAttr(layerReportAttr);
} }
layerReportAttr.setClientPaging(true); layerReportAttr.enableEngineX();
layerReportAttr.setEngineState(0);
return true; return true;
} }
} }
@ -60,29 +61,17 @@ public class CptAndCptxCompatibilityUtil {
* cptx自动走新引擎非兼容模式cpt需要进行设置 * cptx自动走新引擎非兼容模式cpt需要进行设置
* */ * */
public static boolean isEngineXEnable(Object workBook, String fileName){ public static boolean isEngineXEnable(Object workBook, String fileName){
WorkSheet workSheet = gainWorkSheet(workBook); if (workBook == null || !(workBook instanceof FineBook)){
LayerReportAttr layerReportAttr = gainLayerReportAttr(workSheet); return false;
return isEngineXEnable(layerReportAttr, fileName);
}
private static LayerReportAttr gainLayerReportAttr(WorkSheet workSheet){
if (workSheet != null){
LayerReportAttr layerReportAttr = workSheet.getLayerReportAttr();
return layerReportAttr;
} else {
return null;
} }
return ReportUtils.hasEngineXReport4Template((FineBook) workBook) || FileExtension.CPTX.matchExtension(fileName);
} }
private static WorkSheet gainWorkSheet(Object workBook){ private static WorkSheet getFirstWorkSheet(Object workBook){
if (workBook == null || !(workBook instanceof TemplateWorkBook)){ if (workBook == null || !(workBook instanceof TemplateWorkBook)){
return null; return null;
} }
Report report = ((TemplateWorkBook) workBook).getReport(0); Report report = ((TemplateWorkBook) workBook).getReport(0);
return report instanceof WorkSheet ? (WorkSheet)report : null; return report instanceof WorkSheet ? (WorkSheet)report : null;
} }
private static boolean isEngineXEnable(LayerReportAttr layerReportAttr, String fileName){
return (layerReportAttr!= null && layerReportAttr.isClientPaging() && layerReportAttr.getEngineState() == LayerReportAttr.ENGINE_X) || FileExtension.CPTX.matchExtension(fileName);
}
} }

Loading…
Cancel
Save