【仅供内部供应商使用,不提供对外解答和培训】
...
| Code Block | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
package com.fr.schedule.extension.report.result;
import com.fr.schedule.extension.report.ScheduleShowType;
import com.fr.stable.web.Weblet;
import javax.servlet.http.HttpServletRequest;
/**
* 声明自定义结果类型访问方法的接口.
*
* <p>
* 通过实现该接口自定义结果的访问逻辑,注册进ScheduleResultBox从而自定义结果的访问逻辑
* </p>
*
* Created by Zed on 2018/4/16.
*/
public interface ScheduleResultProvider {
String getResultSuffix();
Weblet accessResult(HttpServletRequest req, String path, String fileName, ScheduleShowType showType) throws Exception;
}
|
产品线 | 版本 | 支持情况 | 备注 |
|---|---|---|---|
| FR | 10.0 | 支持 |
| Code Block | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
<extra-decision>
<ReportScheduleResultProvider class="your class name"/>
</extra-decision> |
...
| Code Block | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
package com.fr.schedule.extension.report.result;
...
/**
* Created by Zed on 2018/03/26.
* 定时任务报表结果访问
*/
public class ReportletResult extends TaskResult {
...
@Override
public void accessResult(HttpServletRequest req,
HttpServletResponse res,
Map<String, Object> param) throws Exception {
String username = (String) param.get(ScheduleConstants.USERNAME);
String taskName = (String) param.get(ScheduleConstants.TASK_NAME);
String resultPath = (String) param.get(ScheduleConstants.TASK_RESULT_PATH);
String showType = (String) param.get(ScheduleConstants.SHOW_TYPE);
// 包含有cpr、frr的目录
String path;
...
String[] files = ResourceIOUtils.list(path);
req.setAttribute(ScheduleConstants.USERNAME, username);
req.setAttribute(ScheduleConstants.TASK_NAME, taskName);
req.setAttribute(ScheduleConstants.SHOW_TYPE, showType);
req.setAttribute(ScheduleConstants.TASK_RESULT_PATH, path);
addTaskPara(req, path);
WebletDealWith.dealWithWeblet(req, res, this.getResultFile(req, files, path, showType));
}
private Weblet getResultFile(HttpServletRequest req, String[] files, String path, String showType) throws Exception {
for (String file : files) {
ScheduleResultProvider provider = ScheduleResultBox.formSuffix(this.getFileSuffix(file));
if (provider != null) {
return provider.accessResult(req, StableUtils.pathJoin(path, file), file, this.getShowType(showType));
}
}
// 没有cpr、frr
throw new ResultFileNotExistException("Fine-Schedule_Result_File_Not_Exist");
}
...
}
|
在对产品固有的推送信息的调整时,OutputFormulaProvider接口可以单独使用。此时开发者不需要直接去继承AbstractOutputFormulaProvider或AbstractReportOutputFormulaProvider。而应该继承要修改的附件处理类型的公式处理类。诸如:EmailFormula、SmsFormula之类的
如果是要在新增推送类型中处理对应的公式,OutputFormulaProvider接口就不再单独使用,而作为辅助接口配合其他推送客户端扩展接口生效【接口非常多,会在专题中进行整合介绍】。
由ReportletResult第26行所示 String[] files = ResourceIOUtils.list(path); 可知,最终开发者实现的接口是否会生效,取决于这里的files列表。在getResultFile方法中,会按照files的顺序逐一匹配,直到有一个ScheduleResultProvider被匹配到。而匹配规则本身又是根据文件的后缀来匹配的。这也就导致这个接口变得十分的不稳定了,如果开发者的目标是把files里面再cpr或frr之后的文件转换成自己定义的展现快照,那么就必须先保证附件里面没有这两个文件,否则就无法实现了。
所以这个接口使用时需要考虑到这个不稳定的因素!谨慎使用。getActionClassName的返回值,是BaseOutputAction的一个派生子类类名,必须与dealWithFormulaParam接口方法的第一个参数(T)的对象的类名一致。
入门demo地址:demo-outputreport-schedule-formularesult-provider
免责声明:所有文档中的开源示例,均为开发者自行开发并提供。仅用于参考和学习使用,开发者和官方均无义务对开源案例所涉及的所有成果进行教学和指导。若作为商用一切后果责任由使用者自行承担。
...