richie
5 years ago
7 changed files with 237 additions and 0 deletions
@ -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); |
||||
} |
||||
} |
@ -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<String, Object> map) { |
||||
super(templateWorkBook, map); |
||||
} |
||||
|
||||
/** |
||||
* 预览的方式,通常包括分页预览、分析预览、填报预览 |
||||
* |
||||
* @return 预览方式 |
||||
*/ |
||||
@Override |
||||
public abstract Actor getExeType(); |
||||
|
||||
/** |
||||
* 初始化用于装在结果集的对象 |
||||
* |
||||
* @param map 报表参数 |
||||
* @return 结果集 |
||||
*/ |
||||
@Override |
||||
public abstract ResultWorkBook initResultBook(Map<String, Object> map); |
||||
} |
@ -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<String, Object> map) { |
||||
super(templateWorkBook, map); |
||||
} |
||||
|
||||
@Override |
||||
public Actor getExeType() { |
||||
return ActorFactory.getActor(ActorConstants.TYPE_PAGE); |
||||
} |
||||
|
||||
@Override |
||||
public ResultWorkBook initResultBook(Map<String, Object> map) { |
||||
return new PageRWorkBook(map); |
||||
} |
||||
} |
@ -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<String, Object> map) { |
||||
super(templateWorkBook, map); |
||||
} |
||||
|
||||
@Override |
||||
public Actor getExeType() { |
||||
return ActorFactory.getActor("view"); |
||||
} |
||||
|
||||
@Override |
||||
public ResultWorkBook initResultBook(Map<String, Object> map) { |
||||
return new AnalyRWorkBook(map); |
||||
} |
||||
} |
@ -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<String, Object> map) { |
||||
super(templateWorkBook, map); |
||||
} |
||||
|
||||
@Override |
||||
public Actor getExeType() { |
||||
return ActorFactory.getActor(ActorConstants.TYPE_WRITE); |
||||
} |
||||
|
||||
@Override |
||||
public ResultWorkBook initResultBook(Map<String, Object> map) { |
||||
return new WriteRWorkBook(map); |
||||
} |
||||
} |
@ -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); |
||||
} |
Loading…
Reference in new issue