Browse Source

适配填报模式

master 3.1
richie 5 years ago
parent
commit
e4cafdc0f9
  1. BIN
      lib/finekit-10.0.jar
  2. 6
      plugin.xml
  3. 6
      src/main/java/com/fr/plugin/lazy/sheet/LazySheetActorBridge.java
  4. 4
      src/main/java/com/fr/plugin/lazy/sheet/fun/LazySheetViewActor.java
  5. 9
      src/main/java/com/fr/plugin/lazy/sheet/fun/LazySheetWorkBookViewExecutor.java
  6. 46
      src/main/java/com/fr/plugin/lazy/sheet/fun/LazySheetWorkBookWriteExecutor.java
  7. 32
      src/main/java/com/fr/plugin/lazy/sheet/fun/LazySheetWriteActor.java

BIN
lib/finekit-10.0.jar

Binary file not shown.

6
plugin.xml

@ -3,12 +3,13 @@
<id>com.fr.plugin.report.lazysheet</id>
<name><![CDATA[多sheet懒加载]]></name>
<active>yes</active>
<version>3.0</version>
<version>3.1</version>
<env-version>10.0</env-version>
<jartime>2015-08-09</jartime>
<vendor email="solution@finereport.com">solution.richie</vendor>
<description><![CDATA[多sheet报表仅仅只加载当前sheet(不支持sheet间运算)]]></description>
<change-notes><![CDATA[
[2019-10-14]支持填报模式。<br/>
[2019-10-12]适配10.0版本以及完全依赖FineKit。<br/>
[2016-04-11]增加插件API兼容性检测<br/>
]]></change-notes>
@ -21,5 +22,6 @@
<extra-designer>
<PreviewProvider class="com.fr.plugin.lazy.sheet.LazySheetPreviewBridge"/>
</extra-designer>
<function-recorder class="com.fr.plugin.lazy.sheet.fun.LazySheetActor"/>
<function-recorder class="com.fr.plugin.lazy.sheet.fun.LazySheetViewActor"/>
<function-recorder class="com.fr.plugin.lazy.sheet.fun.LazySheetWriteActor"/>
</plugin>

6
src/main/java/com/fr/plugin/lazy/sheet/LazySheetActorBridge.java

@ -1,6 +1,7 @@
package com.fr.plugin.lazy.sheet;
import com.fr.plugin.lazy.sheet.fun.LazySheetActor;
import com.fr.plugin.lazy.sheet.fun.LazySheetViewActor;
import com.fr.plugin.lazy.sheet.fun.LazySheetWriteActor;
import com.fr.report.fun.impl.AbstractActorProvider;
import com.fr.report.stable.fun.Actor;
@ -17,7 +18,8 @@ public class LazySheetActorBridge extends AbstractActorProvider {
@Override
public Actor[] createActor() {
return new Actor[]{
new LazySheetActor()
new LazySheetViewActor(),
new LazySheetWriteActor()
};
}
}

4
src/main/java/com/fr/plugin/lazy/sheet/fun/LazySheetActor.java → src/main/java/com/fr/plugin/lazy/sheet/fun/LazySheetViewActor.java

@ -12,7 +12,7 @@ import java.util.Map;
* Created by richie on 15/7/17.
*/
@EnableMetrics
public class LazySheetActor extends BaseViewActor {
public class LazySheetViewActor extends BaseViewActor {
@Override
@Focus(id = LazyConstants.PLUGIN_ID, text = "Plugin-Lazy_Load_Sheet")
@ -25,6 +25,6 @@ public class LazySheetActor extends BaseViewActor {
}
private ResultWorkBook lazyExecute(TemplateWorkBook workBook, Map parameterMap, int sheetIndex) {
return new LazySheetWorkBookExecutor(workBook, parameterMap, sheetIndex).execute();
return new LazySheetWorkBookViewExecutor(workBook, parameterMap, sheetIndex).execute();
}
}

9
src/main/java/com/fr/plugin/lazy/sheet/fun/LazySheetWorkBookExecutor.java → src/main/java/com/fr/plugin/lazy/sheet/fun/LazySheetWorkBookViewExecutor.java

@ -11,24 +11,23 @@ import java.util.Map;
/**
* Created by richie on 15/7/17.
*/
public class LazySheetWorkBookExecutor extends ViewWorkBookExecutor {
public class LazySheetWorkBookViewExecutor extends ViewWorkBookExecutor {
private int sheetIndex;
public LazySheetWorkBookExecutor(TemplateWorkBook workBook, Map<String, Object> parameterMap, int sheetIndex) {
public LazySheetWorkBookViewExecutor(TemplateWorkBook workBook, Map<String, Object> parameterMap, int sheetIndex) {
super(workBook, parameterMap);
this.sheetIndex = sheetIndex;
}
@Override
public Actor getExeType() {
return new LazySheetActor();
return new LazySheetViewActor();
}
protected void _execute() {
public void executeOnce() {
// 先按顺序来,其实这里就一个个塞进去,然后在这里面开始统一分步计算
TemplateReport report;
for (int i = 0, len = this.nameListMap.size(); i < len; i++) {
report = (TemplateReport) this.nameListMap.getByIndex(i);
Actor actor = getExeType();
if (i == sheetIndex) {

46
src/main/java/com/fr/plugin/lazy/sheet/fun/LazySheetWorkBookWriteExecutor.java

@ -0,0 +1,46 @@
package com.fr.plugin.lazy.sheet.fun;
import com.fanruan.api.report.executor.WriteWorkBookExecutor;
import com.fr.main.TemplateWorkBook;
import com.fr.report.report.ResultReport;
import com.fr.report.report.TemplateReport;
import com.fr.report.stable.fun.Actor;
import java.util.Map;
/**
* @author richie
* @version 10.0
* Created by richie on 2019/10/14
*/
public class LazySheetWorkBookWriteExecutor extends WriteWorkBookExecutor {
private int sheetIndex;
public LazySheetWorkBookWriteExecutor(TemplateWorkBook templateWorkBook, Map<String, Object> map, int sheetIndex) {
super(templateWorkBook, map);
this.sheetIndex = sheetIndex;
}
@Override
public Actor getExeType() {
return new LazySheetWriteActor();
}
@Override
public void executeOnce() {
TemplateReport report;
for (int i = 0, len = this.nameListMap.size(); i < len; i++) {
report = (TemplateReport) this.nameListMap.getByIndex(i);
Actor actor = getExeType();
if (i == sheetIndex) {
ResultReport resultReport = report.execute(parameterMap, actor);
if (null != resultReport) {
this.listForResultReport.set(i, resultReport);
}
} else {
this.listForResultReport.set(i, ResultReport.EMPTY);
}
}
}
}

32
src/main/java/com/fr/plugin/lazy/sheet/fun/LazySheetWriteActor.java

@ -0,0 +1,32 @@
package com.fr.plugin.lazy.sheet.fun;
import com.fanruan.api.report.write.BaseWriteActor;
import com.fr.intelli.record.Focus;
import com.fr.main.TemplateWorkBook;
import com.fr.main.workbook.ResultWorkBook;
import com.fr.record.analyzer.EnableMetrics;
import java.util.Map;
/**
* @author richie
* @version 10.0
* Created by richie on 2019/10/14
*/
@EnableMetrics
public class LazySheetWriteActor extends BaseWriteActor {
@Override
@Focus(id = LazyConstants.PLUGIN_ID, text = "Plugin-Lazy_Load_Sheet")
public ResultWorkBook run(TemplateWorkBook workBook, Map parameterMap, int sheetIndex) {
if (parameterMap.containsKey("__lazy__")) {
return lazyExecute(workBook, parameterMap, sheetIndex);
} else {
return super.executeWorkBook(workBook, parameterMap, sheetIndex);
}
}
private ResultWorkBook lazyExecute(TemplateWorkBook workBook, Map parameterMap, int sheetIndex) {
return new LazySheetWorkBookWriteExecutor(workBook, parameterMap, sheetIndex).execute();
}
}
Loading…
Cancel
Save