From f1d5e1686eaf97f3e68cba6927814c6ba526dfcb Mon Sep 17 00:00:00 2001 From: richie Date: Sat, 12 Oct 2019 16:20:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=87=92=E5=8A=A0=E8=BD=BD=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 1 + .../java/com/fanruan/api/report/ActorKit.java | 68 +++++++++++++++++++ .../report/executor/BaseWorkBookExecutor.java | 38 +++++++++++ .../report/executor/PageWorkBookExecutor.java | 33 +++++++++ .../report/executor/ViewWorkBookExecutor.java | 33 +++++++++ .../executor/WriteWorkBookExecutor.java | 33 +++++++++ .../api/report/view/BaseViewActor.java | 31 +++++++++ 7 files changed, 237 insertions(+) create mode 100644 src/main/java/com/fanruan/api/report/ActorKit.java create mode 100644 src/main/java/com/fanruan/api/report/executor/BaseWorkBookExecutor.java create mode 100644 src/main/java/com/fanruan/api/report/executor/PageWorkBookExecutor.java create mode 100644 src/main/java/com/fanruan/api/report/executor/ViewWorkBookExecutor.java create mode 100644 src/main/java/com/fanruan/api/report/executor/WriteWorkBookExecutor.java create mode 100644 src/main/java/com/fanruan/api/report/view/BaseViewActor.java diff --git a/readme.md b/readme.md index b95bd96..3b0aa77 100644 --- a/readme.md +++ b/readme.md @@ -94,3 +94,4 @@ mvn javadoc:javadoc |http认证简化插件|https://git.fanruan.com/fanruan/demo-auth-http| |xml导出插件|https://git.fanruan.com/fanruan/demo-export-xml| |echarts图表插件|https://git.fanruan.com/fanruan/demo-chart-pie| +|多sheet懒加载|https://git.fanruan.com/fanruan/plugin-report-lazy-sheet| diff --git a/src/main/java/com/fanruan/api/report/ActorKit.java b/src/main/java/com/fanruan/api/report/ActorKit.java new file mode 100644 index 0000000..56fd114 --- /dev/null +++ b/src/main/java/com/fanruan/api/report/ActorKit.java @@ -0,0 +1,68 @@ +package com.fanruan.api.report; + +import com.fr.report.stable.fun.Actor; +import com.fr.stable.ActorFactory; + +import javax.servlet.http.HttpServletRequest; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019/10/12 + * 预览类型工具类 + */ +public class ActorKit { + + private ActorKit() { + + } + + /** + * 获取指定类型的预览类型对象 + * + * @param type 指定的类型 + */ + public static Actor getActor(String type) { + return ActorFactory.getActor(type); + } + + /** + * 根据预览类型对象获取表示预览类型的字符串 + * + * @param actor 预览类型对象 + * @return 表示预览类型的字符串 + */ + public static String getType(Actor actor) { + return ActorFactory.getType(actor); + } + + /** + * 获取指定类型的预览类型对象 + * + * @param type 指定的类型 + * @param isMobile 是否为移动端预览 + * @param isNoPage 是否为不分页预览 + */ + public static Actor getActor(String type, boolean isMobile, boolean isNoPage) { + return ActorFactory.getActor(type, isMobile, isNoPage); + } + + /** + * 从http请求中获取预览类型对象 + * + * @param req http请求 + */ + public static Actor getActor(HttpServletRequest req) { + return ActorFactory.getActor(req); + } + + /** + * 从http请求中获取预览类型对象 + * + * @param req http请求 + * @param defaultActor 默认的预览类型 + */ + public static Actor getActor(HttpServletRequest req, Actor defaultActor) { + return ActorFactory.getActor(req, defaultActor); + } +} diff --git a/src/main/java/com/fanruan/api/report/executor/BaseWorkBookExecutor.java b/src/main/java/com/fanruan/api/report/executor/BaseWorkBookExecutor.java new file mode 100644 index 0000000..c57e0ec --- /dev/null +++ b/src/main/java/com/fanruan/api/report/executor/BaseWorkBookExecutor.java @@ -0,0 +1,38 @@ +package com.fanruan.api.report.executor; + +import com.fr.main.TemplateWorkBook; +import com.fr.main.workbook.ResultWorkBook; +import com.fr.report.core.sheet.AbstractWorkBookExecutor; +import com.fr.report.stable.fun.Actor; + +import java.util.Map; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019/10/12 + * 将模板按指定的预览方式计算成结果集的执行器 + */ +public abstract class BaseWorkBookExecutor extends AbstractWorkBookExecutor { + + public BaseWorkBookExecutor(TemplateWorkBook templateWorkBook, Map map) { + super(templateWorkBook, map); + } + + /** + * 预览的方式,通常包括分页预览、分析预览、填报预览 + * + * @return 预览方式 + */ + @Override + public abstract Actor getExeType(); + + /** + * 初始化用于装在结果集的对象 + * + * @param map 报表参数 + * @return 结果集 + */ + @Override + public abstract ResultWorkBook initResultBook(Map map); +} diff --git a/src/main/java/com/fanruan/api/report/executor/PageWorkBookExecutor.java b/src/main/java/com/fanruan/api/report/executor/PageWorkBookExecutor.java new file mode 100644 index 0000000..9cb6d8f --- /dev/null +++ b/src/main/java/com/fanruan/api/report/executor/PageWorkBookExecutor.java @@ -0,0 +1,33 @@ +package com.fanruan.api.report.executor; + +import com.fr.main.TemplateWorkBook; +import com.fr.main.workbook.PageRWorkBook; +import com.fr.main.workbook.ResultWorkBook; +import com.fr.report.stable.fun.Actor; +import com.fr.stable.ActorConstants; +import com.fr.stable.ActorFactory; + +import java.util.Map; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019/10/12 + * 分页预览执行器 + */ +public class PageWorkBookExecutor extends BaseWorkBookExecutor { + + public PageWorkBookExecutor(TemplateWorkBook templateWorkBook, Map map) { + super(templateWorkBook, map); + } + + @Override + public Actor getExeType() { + return ActorFactory.getActor(ActorConstants.TYPE_PAGE); + } + + @Override + public ResultWorkBook initResultBook(Map map) { + return new PageRWorkBook(map); + } +} diff --git a/src/main/java/com/fanruan/api/report/executor/ViewWorkBookExecutor.java b/src/main/java/com/fanruan/api/report/executor/ViewWorkBookExecutor.java new file mode 100644 index 0000000..5c9833c --- /dev/null +++ b/src/main/java/com/fanruan/api/report/executor/ViewWorkBookExecutor.java @@ -0,0 +1,33 @@ +package com.fanruan.api.report.executor; + +import com.fanruan.api.report.executor.BaseWorkBookExecutor; +import com.fr.main.TemplateWorkBook; +import com.fr.main.workbook.AnalyRWorkBook; +import com.fr.main.workbook.ResultWorkBook; +import com.fr.report.stable.fun.Actor; +import com.fr.stable.ActorFactory; + +import java.util.Map; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019/10/12 + * 分析预览执行器 + */ +public class ViewWorkBookExecutor extends BaseWorkBookExecutor { + + public ViewWorkBookExecutor(TemplateWorkBook templateWorkBook, Map map) { + super(templateWorkBook, map); + } + + @Override + public Actor getExeType() { + return ActorFactory.getActor("view"); + } + + @Override + public ResultWorkBook initResultBook(Map map) { + return new AnalyRWorkBook(map); + } +} diff --git a/src/main/java/com/fanruan/api/report/executor/WriteWorkBookExecutor.java b/src/main/java/com/fanruan/api/report/executor/WriteWorkBookExecutor.java new file mode 100644 index 0000000..2a6ec45 --- /dev/null +++ b/src/main/java/com/fanruan/api/report/executor/WriteWorkBookExecutor.java @@ -0,0 +1,33 @@ +package com.fanruan.api.report.executor; + +import com.fr.main.TemplateWorkBook; +import com.fr.main.workbook.ResultWorkBook; +import com.fr.report.stable.fun.Actor; +import com.fr.stable.ActorConstants; +import com.fr.stable.ActorFactory; +import com.fr.write.main.WriteRWorkBook; + +import java.util.Map; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019/10/12 + * 填报预览执行器 + */ +public class WriteWorkBookExecutor extends BaseWorkBookExecutor { + + public WriteWorkBookExecutor(TemplateWorkBook templateWorkBook, Map map) { + super(templateWorkBook, map); + } + + @Override + public Actor getExeType() { + return ActorFactory.getActor(ActorConstants.TYPE_WRITE); + } + + @Override + public ResultWorkBook initResultBook(Map map) { + return new WriteRWorkBook(map); + } +} diff --git a/src/main/java/com/fanruan/api/report/view/BaseViewActor.java b/src/main/java/com/fanruan/api/report/view/BaseViewActor.java new file mode 100644 index 0000000..4bd4722 --- /dev/null +++ b/src/main/java/com/fanruan/api/report/view/BaseViewActor.java @@ -0,0 +1,31 @@ +package com.fanruan.api.report.view; + +import com.fr.main.TemplateWorkBook; +import com.fr.main.workbook.ResultWorkBook; +import com.fr.stable.ViewActor; + +import java.util.Map; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019/10/12 + * 分析预览接口 + */ +public abstract class BaseViewActor extends ViewActor { + + @Override + public final ResultWorkBook executeWorkBook(TemplateWorkBook templateWorkBook, Map map, int sheetIndex) { + return run(templateWorkBook, map, sheetIndex); + } + + /** + * 将模板计算为结果结果集 + * + * @param templateWorkBook 模板 + * @param map 参数 + * @param sheetIndex sheet编号 + * @return 结果集 + */ + public abstract ResultWorkBook run(TemplateWorkBook templateWorkBook, Map map, int sheetIndex); +}