前言

使用商业分析中的扩展报表平台,可以很方便的进行数据分析,进行图表化直观展示。一般情况下使用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. [原]Android打包之Ant打包

    Android自动打包流程详细图: 使用Ant打包会简单很多,只要使用以下两个命令就可以搞定: android update project -p . --target android-18 ant ...

  2. 关于bootstrap-table服务端分页问题

    昨天项目中涉及到了前端表格分页问题.数据一共有1万多条,所以选择了后端分页. 之前用的都是前端分页,第一次使用后端分页.网上也找到了一些例子,最后做出来了. 这里用的是bootstrap-table插 ...

  3. iOS 代码混淆--pch实现

    之前实现代码的混淆一般是使用sh脚本,不过也是需要把一写需要混淆的方法写到一个文件中(除非是使用特定的命名规范统一混淆), 现在发现,实现代码的混淆pch 文件就可以轻松完成! 1,在新建的工程中 创 ...

  4. HDU 1711 Number Sequence 【KMP应用 求成功匹配子串的最小下标】

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1711 Number Sequence Time Limit: 10000/5000 MS (Java/O ...

  5. STL - set【集合】

    参考:http://www.cplusplus.com/reference/set/set/ 一.set 是按特定顺序存储唯一元素的容器 实现是一种非常高效的平衡检索二叉树:红黑树(Red-Black ...

  6. 使用MSF生成木马_入侵Windows

    1>生成木马 (123.exe)        -f 输出格式 -o 输出地址 2>启动msfconsole 3>进行设置&&启动攻击 4>木马运行&后 ...

  7. Strtus2框架使用HttpServletResponse响应数据

    -----------------------------------------------------------------------------------------jsp-------- ...

  8. 【luogu P3469 [POI2008]BLO-Blockade】 题解

    题目链接:https://www.luogu.org/problemnew/show/P3469 #include <cstdio> #include <cstring> #i ...

  9. detection工作

    今天看到YOLO2的工作还是很不错的,效果好,关键是速度也快,已经完胜SSD了感觉. 虽然faster rcnn各方面效果都不错,但是从简单粗暴的角度考虑,SSD和YOLO真的深得我心啊. 检测模型, ...

  10. c语言描述的数据结构的注意细节

    :顺序表使用基址来表示和存储 int *p; p=(int *)malloc(initsize*sizeof(int)); L—>p[x]=xx; :链表 在于除了更改数据还要更改前后与之关联的 ...