前言

使用商业分析中的扩展报表平台,可以很方便的进行数据分析,进行图表化直观展示。一般情况下使用SQL数据集进行SQL的编写,进而配合扩展报表平台进行数据分析图表的绘制,但SQL数据集针对固定的参数进行条件查询,当需要动态条件查询,查询条件的不同,进而需要SQL根据不同的条件,拼接组装不同的查询SQL。此时,JavaSet就派上用场了。

使用文档介绍

标准接口

 /**
* 缓存过滤参数Map(key, String)<br>
* key:参数页签定义的参数名称<br>
* String:参数值,字符串形式传入,其中,日期为:yyyy-MM-dd, 时间戳为:yyyy-MM-dd HH:mm:ss, 时间为: HH:mm:ss
*/
public void setFilterParam(Map filterParamMap); /**
* 返回拼装好的SQL语句
*
* @param parent
* @return
* @throws Exception
*/
public String getCustomSQL(Window parent) throws Exception; /**
* 返回IRowSet数组
*
* @param parent
* @param otherDataCenter :外部数据中心标识,为null或者空,使用本地登录的数据中心
* @return
* @throws Exception
*/
public IRowSet[] getCustomRowSet(Window parent, String otherDataCenter) throws Exception;
/**
* 返回输出参数
*
* @return
*/
public Map getOutputParam() throws Exception;

既然要使用JavaSet,那就得继承标准给定的抽象类AbstractJavaDataSet或者实现接口IJavaDataSet。为了保持扩展性,建议必须实现抽象类!

Demo:

 public class JavaDataSetDemo extends AbstractJavaDataSet
{
/**
* 返回拼装好的SQL语句
*
* @see com.kingdee.eas.rpts.ctrlsqldesign.param.AbstractJavaDataSet#getCustomSQL(java.awt.Window)
*/
public String getCustomSQL(Window parent) throws Exception
{
// 弹出用户自定义的过滤界面
KDPanel customUI = new KDPanel();
customUI.setLayout(new BorderLayout());
customUI.setSize(450, 350);
KDLabel label = new KDLabel();
label.setText("用户自定义过滤界面, 把过滤值作为输出参数显示到报表");
customUI.add(label);
ReportDialog.showDialog(customUI, "自定义过滤界面", true, false, parent);// 请换成自己的弹出过滤框代码 // 判断过滤参数,拼装SQL,如果是方言,记得加入/*dialect*/
StringBuffer sbSQL = new StringBuffer();
sbSQL.append("SELECT FID, FNumber, FName_L2, FGender, FBirthday FROM T_BD_Person Where 0=0"); Object value = this.filterParamMap.get("number"); // 是否存在编码
if (value != null && ((String) value).length() > 0)
{
sbSQL.append(" AND FNumber = '").append((String) value).append("'");
} value = this.filterParamMap.get("name"); // 是否存在姓名
if (value != null && ((String) value).length() > 0)
{
sbSQL.append(" AND FName_L2 like '%").append((String) value).append("%'");
} value = this.filterParamMap.get("sex");
if (value != null && ((String) value).length() > 0)
{
sbSQL.append(" AND FGender = ").append((String) value);
} value = this.filterParamMap.get("dateFrom");
if (value != null && ((String) value).length() > 0)
{
sbSQL.append(" AND FBirthday >= {d '").append((String) value).append("'}");
} value = this.filterParamMap.get("dateTo");
if (value != null && ((String) value).length() > 0)
{
sbSQL.append(" AND FBirthday <= {d '").append((String) value).append("'}");
} return sbSQL.toString();
} /**
* 返回IRowSet数组,当前版本仅支持一个结果集
*
* @see com.kingdee.eas.rpts.ctrlsqldesign.param.AbstractJavaDataSet#getCustomRowSet(java.awt.Window, java.lang.String)
*/
public IRowSet[] getCustomRowSet(Window parent, String otherDataCenter) throws Exception
{
String sql = this.getCustomSQL(parent); // 可以使用ExtDBUtil提供的executeQuery(Context ctx, String sql)返回结果集,也可以自己另写代码返回结果集
IRowSet irs = ExtDBUtil.executeQuery(null, sql, otherDataCenter); // 得到的结果集,进行其他操作处理,例如合并多个结果集等操作 IRowSet[] iRowSets = new IRowSet[1]; // 当前版本仅支持一个结果集
iRowSets[0] = irs; return iRowSets;
}
/**
* 返回输出参数
*
* @see com.kingdee.eas.rpts.ctrlsqldesign.param.AbstractJavaDataSet#getOutputParam()
*/
public Map getOutputParam() throws Exception
{
HashMap outputParamMap = new HashMap(); // 字符串输出参数,名称是title,在公示中可以用 =@title 取到
outputParamMap.put("title", "扩展报表题头示例"); // 数值型
outputParamMap.put("count", "2");
outputParamMap.put("pi", "3.14159"); // 日期,必须是yyyy-MM-dd格式
outputParamMap.put("dateFrom", "2009-09-09"); // 时间戳,必须是yyyy-MM-dd HH:mm:ss格式
outputParamMap.put("dateTimeFrom", "2009-09-09 09:09:09"); // 时间,必须是HH:mm:ss格式
outputParamMap.put("timeFrom", "09:09:09"); return outputParamMap;
}
}

项目中实际开发应用:

插曲:刚开始写的时候,继承的抽象类,我自己把  AbstractJavaDataSet 给复制到自己定义的package里面了,导致数据集不起作用。(好傻逼。。。)直接继承,导包即可,包里是存在这个抽象类的!

 package com.kingdee.eas.custom.report;

 import java.awt.BorderLayout;
import java.awt.Window;
import java.util.HashMap;
import java.util.Map; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import com.kingdee.bos.ctrl.swing.KDLabel;
import com.kingdee.bos.ctrl.swing.KDPanel;
import com.kingdee.eas.rpts.ctrlreport.client.ReportDialog;
import com.kingdee.eas.rpts.ctrlsqldesign.model.ExtDBUtil;
import com.kingdee.eas.rpts.ctrlsqldesign.param.AbstractJavaDataSet;
import com.kingdee.jdbc.rowset.IRowSet; public class JavaDataSetRiskItem extends AbstractJavaDataSet {
Logger LOGGER = LoggerFactory.getLogger(JavaDataSetRiskItem.class); /**
* (非 Javadoc)
* <p>
* Title: getCustomRowSet
* </p>
* <p>
* Description:
* </p>
* 返回IRowSet数组,当前版本仅支持一个结果集
*
* @param parent
* @param otherDataCenter
* @return
* @throws Exception
* @see com.kingdee.eas.custom.report.AbstractJavaDataSet#getCustomRowSet(java.awt.Window,
* java.lang.String)
*/
@Override
public IRowSet[] getCustomRowSet(Window parent, String otherDataCenter)
throws Exception {
String customSQL = this.getCustomSQL(parent);
IRowSet irs = ExtDBUtil.executeQuery(null, customSQL, otherDataCenter); IRowSet[] iRowSets = new IRowSet[1]; // 当前版本仅支持一个结果集
iRowSets[0] = irs; return iRowSets;
} /**
* (非 Javadoc)
* <p>
* Title: getCustomSQL
* </p>
* <p>
* Description:
* </p>
* 返回拼装好的SQL语句
*
* @param parent
* @return
* @throws Exception
* @see com.kingdee.eas.custom.report.AbstractJavaDataSet#getCustomSQL(java.awt.Window)
*/
@Override
public String getCustomSQL(Window parent) throws Exception {
// 弹出用户自定义的过滤界面
/*
* KDPanel customUI = new KDPanel(); customUI.setLayout(new
* BorderLayout()); customUI.setSize(450, 350); KDLabel label = new
* KDLabel();
* label.setText(" 用户自定义过滤界面, 把过滤值作为输出参数显示到报表");
* customUI.add(label); ReportDialog.showDialog(customUI, "自定义过滤界面",
* true, false, parent);// 请换成自己的弹出过滤框代码
*/ // 判断过滤参数,拼装SQL,如果是方言,记得加入/*dialect*/
/*
* 公司名称:companyName 预警指标(item) 年(year) 起始月(startMon) 结束月(endMon)
*/
StringBuffer sbSQL = new StringBuffer();
sbSQL.append(" select ");
sbSQL.append(" cfmonth as 月份, ");
sbSQL.append(" CT_FIN_SasacEntry.cfpoor as 平均值, ");
sbSQL.append(" CT_FIN_SasacEntry.cfaverage as 较差值, "); /* 组装主查询 */
String item = (String) this.filterParamMap.get("item");
if (item != null && item.length() > 0) {
if (item.equals("资产负债率")) {
sbSQL.append(" cftotalLiabilites/cftotalAssets as 企业数据 ");
} else if (item.equals("营业利润")) {
sbSQL.append(" cftrafficProfit/10000 as 企业数据 ");
} else if (item.equals("己获利息倍数")) {
sbSQL
.append(" (cftotalProfit+cfinterestExpense)/cfinterestExpense as 企业数据 ");
} else if (item.equals("流动比率")) {
sbSQL.append(" cfcurrentAssets/cfcurrentLiabilities as 企业数据 ");
} else if (item.equals("两金占流动资产比重")) {
sbSQL
.append(" (cfaccountReceivable+cfstock)/cfcurrentAssets as 企业数据 ");
} else if (item.equals("速动比率")) {
sbSQL
.append(" (cfcurrentAssets-cfstock)/cfcurrentLiabilities as 企业数据 ");
} else if (item.equals("现金流动负债比率")) {
sbSQL.append(" cfoperaCashFlow/cfcurrentLiabilities as 企业数据 ");
} else if (item.equals("带息负债比率")) {
sbSQL
.append(" (cfshortLoan+CFOneYearLongLiabilities+cflongLoan+CFBondsPayable+CFInterestPayable)/cftotalLiabilites as 企业数据 ");
} else if (item.equals("或有负债比率")) {
sbSQL
.append(" (CFDraft+CFBalance+CFAmountOfmatter+CFContingentLiabilities)/cfownerRights as 企业数据 ");
} else if (item.equals("平均融资成本率")) {
sbSQL.append(" CFTotalCosts/CFFinancingCost as 企业数据 ");
}
} // 组装表 条件查询
sbSQL.append(" FROM CT_FIN_RiskItem as CT_FIN_RiskItem ");
sbSQL
.append(" INNER join CT_FIN_Sasac as CT_FIN_Sasac on CT_FIN_RiskItem.cfyear = CT_FIN_Sasac.cfyear ");
sbSQL
.append(" INNER join CT_FIN_SasacEntry as CT_FIN_SasacEntry on CT_FIN_Sasac.fid = CT_FIN_SasacEntry.fparentid ");
sbSQL.append(" WHERE 1=1 "); String companyName = (String) this.filterParamMap.get("companyName");
if (companyName != null && companyName.length() > 0) {
sbSQL.append(" and CT_FIN_RiskItem.cfcompanyName = " + "'"
+ companyName + "'");
} String year = (String) this.filterParamMap.get("year");
if (year != null && year.length() > 0) {
sbSQL.append(" and CT_FIN_RiskItem.cfyear = " + year);
} if (item != null && item.length() > 0) {
sbSQL.append(" and CT_FIN_SasacEntry.cfname = " + "'" + item + "'");
} String monStart = (String) this.filterParamMap.get("monStart");
if (monStart != null && monStart.length() > 0) {
sbSQL.append(" and CT_FIN_RiskItem.cfmonth >= " + monStart);
} String monEnd = (String) this.filterParamMap.get("monEnd");
if (monEnd != null && monEnd.length() > 0) {
sbSQL.append(" and CT_FIN_RiskItem.cfmonth <= " + monEnd);
} LOGGER.info(sbSQL.toString());
return sbSQL.toString();
} /**
* (非 Javadoc)
* <p>
* Title: getOutputParam
* </p>
* <p>
* Description:
* </p>
* 返回输出参数
*
* @return
* @throws Exception
* @see com.kingdee.eas.custom.report.AbstractJavaDataSet#getOutputParam()
*/
@Override
public Map getOutputParam() throws Exception {
HashMap outputParamMap = new HashMap(); // 字符串输出参数,名称是title,在公示中可以用 =@title 取到
outputParamMap.put("title", "扩展报表题头示例"); // 数值型
outputParamMap.put("count", "2");
outputParamMap.put("pi", "3.14159"); // 日期,必须是yyyy-MM-dd格式
outputParamMap.put("dateFrom", "2009-09-09"); // 时间戳,必须是yyyy-MM-dd HH:mm:ss格式
outputParamMap.put("dateTimeFrom", "2009-09-09 09:09:09"); // 时间,必须是HH:mm:ss格式
outputParamMap.put("timeFrom", "09:09:09"); return outputParamMap;
} /**
* (非 Javadoc)
* <p>
* Title: isUIType
* </p>
* <p>
* Description:
* </p>
* 不是GUI 所用数据集就返回false
*
* @return
* @see com.kingdee.eas.rpts.ctrlsqldesign.param.AbstractJavaDataSet#isUIType()
*/
@Override
public boolean isUIType() {
return false;
} }

扩展报表-JavaSet的更多相关文章

  1. EAS_BI(扩展报表)

    case when 的使用 1. 扩展报表,一张收费单据中,下面分为分录 问题描述: 收费单中有一个分录用于记录检测的项目名称以及标准费用.收费单有自己的主键,分录中的外键即是收费单的主键,然后分录表 ...

  2. 查看表之间的关系 需要在eas中的商业分析-扩展报表中心-报表平台下的语义层方案管理

    查看表之间的关系 需要在eas中的商业分析-扩展报表中心-报表平台下的语义层方案管理

  3. MyBean通用报表插件介绍

    特性: 1.基于MyBean插件平台.可以在任何插件中无缝调用显示. 2.其他窗体中无需引用报表控件.就可以拥有报表的设计预览打印等功能. 3.甚至可以不用带包,制作报表插件,也就是说你可以将RM的报 ...

  4. VUE 开发报表,非编码方式

    官网:http://doc.sougn.com 下载地址:https://pan.baidu.com/share/init?surl=P0O9sjfzC8nuQxirDfjW1A  密码:4oev 先 ...

  5. 试图使用未在此报表服务器中注册或此版 Reporting Services 不支持的数据扩展插件“Devart.Data.PostgreSql”

    数据源用的是Postgresql 我在Deploy Report的时候出现这条ErrorMessage Error 2 试图使用未在此报表服务器中注册或此版 Reporting Services 不支 ...

  6. 报表开发之扩展GROUP BY

    在实际运用中.比方在数据仓库中,常常须要对数据进行多维分析.不仅须要标准分组的结果(相当于 GROUP BY),还须要不同维度的小计(简单 GROUP BY 中取部分列分组)和合计(不分组).从而 提 ...

  7. cassandra mongodb选择——cassandra:分布式扩展好,写性能强,以及可以预料的查询;mongodb:非事务,支持复杂查询,但是不适合报表

    Of course, like any technology MongoDB has its strengths and weaknesses. MongoDB is designed for OLT ...

  8. 如何配置报表服务器扩展部署(Reporting Services 配置)

    Reporting Services 支持扩展部署模式.该模式允许运行共享单个报表服务器数据库的多个报表服务器实例. 若要创建扩展部署,请使用安装程序和 Reporting Services 配置工具 ...

  9. AX2012R2使用SQL Server2014安装报表扩展报错

    尝试在SQL Server2014上安装AX2012 R2的Reporting Services扩展失败,出现如下错误: "Could not load file or assembly ' ...

随机推荐

  1. bpexpdate – 更改映像目录库中备份的截止日期以及介质目录库中介质的截止日期nbu

    1.根据bpdbjobs查找backupidbpdbjobs -jobid xxx -all_columns|grep backupid 2.查看数据保留时间[root@backup]# bpimag ...

  2. IO缓冲区

    标准IO提供的三种类型的缓冲模式: (1)按块缓存:在填满缓冲区后才进行实际的设备读写操作 (2)按行缓存:指在接收到换行符('\n’)之前,数据都是先缓存在缓冲区的 (3)不缓存:允许你直接读写设备 ...

  3. 基于Qt搭建ROS开发环境

    参考的博客: http://blog.csdn.net/u013453604/article/details/52186375 http://blog.csdn.net/dxuehui/article ...

  4. 论文笔记:Progressive Differentiable Architecture Search:Bridging the Depth Gap between Search and Evaluation

    Progressive Differentiable Architecture Search:Bridging the Depth Gap between Search and Evaluation ...

  5. HttpHandler使用Session

    继承自IHttpHandler的类要实现两个接口:ProcessRequest和IsReusable但还不能使用Session,要使用Session需要下面的步骤处理: 1.先引用System.Web ...

  6. Android学习笔记_JNI_c调用java代码

    1.编写native方法(java2c)和非native方法(c2java): package com.example.provider; public class CallbackJava { // ...

  7. VisualSVN Server更改SVN版本库存放路径的方法

    来源:http://blog.csdn.net/tcjy1000/article/details/42023849 最近也玩起了SVN软件版本管理,在本机上安装了VisualSVN Server+To ...

  8. c语言描述的顺序栈实现

    #include<stdio.h> #include<stdlib.h> #define initsize 100 #define ok 1 #define error 0 t ...

  9. 优雅的QSignleton (五) 优雅地进行GameObject命名

      这段时间空调吹感冒了,休息了好久 ​ 本篇介绍QSingleton最重要的功能,是它让QSingleton称得上优雅.相关内容之前介绍过. 代码如下: MonoSingletonPath.cs n ...

  10. Spring Boot学习笔记(二二) - 与Mybatis集成

    Mybatis集成 Spring Boot中的JPA部分默认是使用的hibernate,而如果想使用Mybatis的话就需要自己做一些配置.使用方式有两种,第一种是Mybatis官方提供的 mybat ...