EAS BOS 报表开发

2024-03-16 07:18
文章标签 开发 报表 eas bos

本文主要是介绍EAS BOS 报表开发,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

EAS BOS 报表开发

只是做为新手BOS报表开发一个参考:

 

开发所需要新建的文件

  • ContractReportFilterUI:报表弹出的条件选择框,在新建时需要继承系统UI
    com.kingdee.eas.framework.report.client.CommRptBaseConditionUI 
  • ContractReportUI:用于报表展示,需要继承系统UI com.kingdee.eas.framework.report.client.CommRptBaseUI 
  • ContractReportFacade:用于调用系统查询的Facade,也需要继承系统类com.kingdee.eas.framework.report.app.CommRptBase 通用报表查询Facade,Facade可以没有添加方法。  
  • ContractReportBillViewUI 用于报表联查,新建时直接继承CoreUI即可。 

ContractReportFilterUI 方法说明及关键代码

新建UI发布之后,有3个方法是需要重写,getCustomCondition setCustomCondition onInit ,需要验证输入信息,再重写 verify方法即可

  • getCustomCondition:用于获取报表界面的界面参数,也可以理解成过滤信息
  • setCustomCondition: 用于将弹出UI的界面参数保存起来,和上面方法对应
  • onInit 系统初始化方法,你可以初始化控件,也可以初始化控件值

以下为完成代码:

/*** output package name*/package your package;import java.util.Map;import org.apache.log4j.Logger;import com.kingdee.bos.ui.face.CoreUIObject;import com.kingdee.eas.framework.report.util.RptConditionManager;import com.kingdee.eas.framework.report.util.RptParams;import com.kingdee.eas.util.SysUtil;import com.kingdee.eas.util.client.MsgBox;import com.kingdee.util.StringUtils;public class ContractReportFilterUI extends AbstractContractReportFilterUI {private static final Logger logger = CoreUIObject.getLogger(ContractReportFilterUI.class);public ContractReportFilterUI() throws Exception {super();initControl();}public void initControl() {ApF7InitUtils.initAdminF7(prmtAdmin, this, null, null);ApF7InitUtils.initCompanyF7(prmtFiCompany, this, null, null, false);txtStartDate.setValue(ApRptConstant.getFirstDay());txtEndDate.setValue(ApRptConstant.getLastDay());txtStatus.setSelectedItem(null);txtContractWay.setSelectedItem(null);}public RptParams getCustomCondition() {RptParams param = new RptParams();// 放置本界面的参数RptConditionManager rcm = new RptConditionManager();if (null != prmtFiCompany.getValue()) {rcm.setProperty("fiCompany", prmtFiCompany.getValue());} else {rcm.setProperty("fiCompany", null);}if (null != prmtAdmin.getValue()) {rcm.setProperty("admin", prmtAdmin.getValue());} else {rcm.setProperty("admin", null);}if (null != prmtType.getValue()) {rcm.setProperty("type", prmtType.getValue());} else {rcm.setProperty("type", null);}if (!StringUtils.isEmpty(txtNumber.getText())) {rcm.setProperty("number", txtNumber.getText());} else {rcm.setProperty("number", null);}if (!StringUtils.isEmpty(txtName.getText())) {rcm.setProperty("name", txtName.getText());} else {rcm.setProperty("name", null);}if (null != txtStartDate.getValue()) {rcm.setProperty("startDate", txtStartDate.getValue());} else {rcm.setProperty("startDate", null);}if (null != txtEndDate.getValue()) {rcm.setProperty("endDate", txtEndDate.getValue());} else {rcm.setProperty("endDate", null);}if (null != txtContractWay.getSelectedItem()) {rcm.setProperty("contractWay", txtContractWay.getSelectedItem());} else {rcm.setProperty("contractWay", null);}if (null != txtStatus.getSelectedItem()) {rcm.setProperty("status", txtStatus.getSelectedItem());} else {rcm.setProperty("status", null);}Map map = rcm.toMap();param.putAll(map);return param;}public void onInit(RptParams initParams) throws Exception {initControl();}public void setCustomCondition(RptParams params) {if (null != params.getObject("fiCompany")) {prmtFiCompany.setValue(params.getObject("fiCompany"));} else {prmtFiCompany.setValue(null);}if (null != params.getObject("admin")) {prmtAdmin.setValue(params.getObject("prmtAdmin"));} else {prmtAdmin.setValue(null);}if (null != params.getObject("type")) {prmtType.setValue(params.getObject("type"));} else {prmtType.setValue(null);}if (null != params.getObject("number")) {txtNumber.setText(params.getObject("number") + "");} else {txtNumber.setText(null);}if (null != params.getObject("name")) {txtName.setText(params.getObject("name") + "");} else {txtName.setText(null);}if (null != params.getObject("startDate")) {txtStartDate.setValue(params.getObject("startDate"));} else {txtStartDate.setValue(null);}if (null != params.getObject("endDate")) {txtEndDate.setValue(params.getObject("endDate"));} else {txtEndDate.setValue(null);}if (null != params.getObject("contractWay")) {txtContractWay.setSelectedItem(params.getObject("contractWay"));} else {txtContractWay.setSelectedItem(null);}if (null != params.getObject("status")) {txtStatus.setSelectedItem(params.getObject("status"));} else {txtStatus.setSelectedItem(null);}}public boolean verify() {if (null == prmtFiCompany.getValue()) {MsgBox.showError("请选择组织.");SysUtil.abort();}return super.verify();}}

 

ContractReportUI 方法说明及关键代码

新建完UI发布之后,同样的也是需要重写父类方法,其中包括:getParamsForInit,getQueryDialogUserPanel,getRemoteInstance,getTableForPrintSetting,query,下面分别简单说明下各方法的用途

  • getParamsForInit:从弹出UI获取界面参数
  • getQueryDialogUserPanel:指定弹出UI
  • getRemoteInstance:远程调用查询的接口
  • getTableForPrintSetting:获取表格打印设置
  • query:查询对话框点击确定后执行

另外我自己还添加一个功能,报表联查,方法名为:actionBillView_actionPerformed,完整示例请参考代码:

public class ContractReportUI extends AbstractContractReportUI
{private static final Logger logger = CoreUIObject.getLogger(ContractReportUI.class);public ContractReportUI() throws Exception{super();this.setUITitle("合同一览表");btnBillView.setEnabled(true);}protected void tblMain_tableClicked(com.kingdee.bos.ctrl.kdf.table.event.KDTMouseEvent e) throws Exception{if (e.getClickCount()==2) {actionBillView_actionPerformed(null);}}public void actionBillView_actionPerformed(ActionEvent e) throws Exception{int row = KDTableUtil.getSelectedRow(tblMain);if (row==-1) {MsgBox.showInfo("请选择行..");SysUtil.abort();}String orgId=null;if (null!=params.getObject("fiCompany")) {CompanyOrgUnitInfo object = (CompanyOrgUnitInfo)params.getObject("fiCompany");orgId=object.getId().toString();}String id = APRuleUtil.getString(tblMain.getCell(row, "ID").getValue());UIContext uiContext = new UIContext(this);uiContext.put("ID", id);uiContext.put("orgId", orgId);IUIWindow uiWindow = UIFactory.createUIFactory(UIFactoryName.EDITWIN).create(ContractReportBillViewUI.class.getName(), uiContext, null, OprtState.VIEW);uiWindow.show();}protected RptParams getParamsForInit() {return params;}protected CommRptBaseConditionUI getQueryDialogUserPanel() throws Exception {return new ContractReportFilterUI();}protected ICommRptBase getRemoteInstance() throws BOSException {return ContractReportFacadeFactory.getRemoteInstance();}protected KDTable getTableForPrintSetting() {return this.tblMain;}/*** 查询对话框点击确定后执行* @param params 查询条件*/protected void query() {//查询条件设置到界面initParamToUI(params);tblMain.checkParsed();tblMain.setEditable(false);try {//设置光标处于等待状态setCursorOfWair();//查询数据,在Facade查询方法里返回值是RptParams,需要把查询集保存到RptParams里,再通过界面取出即可RptParams rps = ((ICommRptBase)getRemoteInstance()).query(params);if(rps!=null){IRowSet conReport =  ((IRowSet)rps.getObject(ApRptConstant.RPT_PARAMETERS)) ;if(conReport!=null){fillTable(conReport);tblMain.getSelectManager().setSelectMode(KDTSelectManager.ROW_SELECT);}}} catch (Exception e) {e.printStackTrace();this.handUIException(e);} finally {this.setCursorOfDefault();}}private int fillTable(IRowSet rs) throws SQLException {tblMain.removeRows();while (rs.next()) {IRow row = tblMain.addRow();row.getCell("number").setValue(rs.getString("FNUMBER"));row.getCell("name").setValue(rs.getString("CFNAME"));row.getCell("ContractType").setValue(rs.getString("CONTRACTTYPE"));row.getCell("status").setValue(StatusEnum.getEnum(rs.getString("CFSTATUS")).getAlias());row.getCell("inOutType").setValue(rs.getString("INOUTTYPE"));row.getCell("contractWay").setValue(ContractTypeEnum.getEnum(rs.getString("CFCONTRACTWAY")).getAlias());row.getCell("customer").setValue(rs.getString("CUSTOMER"));row.getCell("supplier").setValue(rs.getString("SUPPLIER"));row.getCell("bizDate").setValue(rs.getString("FBIZDATE"));row.getCell("startDate").setValue(rs.getString("CFSTARTDATE"));row.getCell("endDate").setValue(rs.getString("CFENDDATE"));row.getCell("days").setValue(rs.getString("CFDAYS"));row.getCell("amount").setValue(rs.getBigDecimal("CFAMOUNT"));row.getCell("totalAmount").setValue(rs.getBigDecimal("CFTOTALAMOUNT"));row.getCell("unAmount").setValue(rs.getBigDecimal("CFUNAMOUNT"));row.getCell("person").setValue(rs.getString("CFPERSON"));row.getCell("department").setValue(rs.getString("DEPARTMENT"));row.getCell("createDate").setValue(rs.getString("FCREATETIME"));row.getCell("ID").setValue(rs.getString("ID"));}String [] cols=new String[]{"amount","totalAmount","unAmount"};ApRptConstant.formatTableNumber(tblMain, cols);ApRptConstant.appendFootRow(tblMain, cols);cols=new String[]{"bizDate","startDate","endDate","createDate"};ApRptConstant.formatTableDate(tblMain, cols);return tblMain.getRowCount();}public void initParamToUI(RptParams params) {if (null!=params.getObject("fiCompany")) {CompanyOrgUnitInfo object = (CompanyOrgUnitInfo)params.getObject("fiCompany");txtFiCompany.setText(object.getNumber()+"-"+object.getName());}else {txtFiCompany.setText("");}}

 

Facade关键代码

因为Facade已经继承了父类,所以这里不需要再新建方法,重写父类方法即可,整个Facade只需要写一个方法就好了。protected RptParams _query(Context ctx, RptParams params) 在方法中,需要先获取界面参数再拼SQL即可,参考代码如下:

@Overrideprotected RptParams _query(Context ctx, RptParams params)throws BOSException, EASBizException {if (null == params) {throw new EASBizException(new NumericExceptionSubItem("0003","请先设置过滤条件.."));}String fiCompanyId=null;if (null!=params.getObject("fiCompany")) {CompanyOrgUnitInfo object = (CompanyOrgUnitInfo)params.getObject("fiCompany");fiCompanyId=object.getId().toString();}String departmentId=null;if (null!=params.getObject("admin")) {AdminOrgUnitInfo object = (AdminOrgUnitInfo)params.getObject("prmtAdmin");departmentId=object.getId().toString();}String contractTypeId=null;if (null!=params.getObject("type")) {ContractTypeInfo object = (ContractTypeInfo)params.getObject("type");contractTypeId=object.getId().toString();}String number=null;if (null!=params.getObject("number")) {number=APRuleUtil.getString(params.getObject("number"));}String name=null;if (null!=params.getObject("name")) {name=APRuleUtil.getString(params.getObject("name"));}Date startDate=null;if (null!=params.getObject("startDate")) {startDate = APRuleUtil.getDateValue(params.getObject("startDate"));}Date endDate=null;if (null!=params.getObject("endDate")) {endDate = APRuleUtil.getDateValue(params.getObject("endDate"));}String contractWayId=null;if (null!=params.getObject("contractWay")) {ContractTypeEnum object = (ContractTypeEnum)params.getObject("contractWay");contractWayId = object.getValue();}String status=null;if (null!=params.getObject("status")) {StatusEnum object = (StatusEnum)params.getObject("status");status=object.getValue();}StringBuffer sql = new StringBuffer();SqlParams sp = new SqlParams();sql.append("SELECT A.FNUMBER,A.CFNAME,B.FNAME_L2 CONTRACTTYPE,A.CFSTATUS,C.FNAME_L2 INOUTTYPE,A.CFCONTRACTWAY ,D.FNAME_L2 CUSTOMER,E.FNAME_L2 SUPPLIER,A.FBIZDATE,\r\n");sql.append("A.CFSTARTDATE,A.CFENDDATE,A.CFDAYS,A.CFAMOUNT,A.CFTOTALAMOUNT,A.CFUNAMOUNT,A.CFPERSON,F.FNAME_L2 DEPARTMENT,A.FCREATETIME,A.FID ID FROM CT_AP_APPRAISE A \r\n");sql.append("LEFT JOIN CT_BD_ContractType b on a.CFContractTypeID=b.FID \r\n");sql.append("LEFT JOIN CT_BD_InOutType C ON C.FID=A.CFInOutTypeID \r\n");sql.append("LEFT JOIN T_BD_Customer D ON D.FID=A.CFCustomerID \r\n");sql.append("LEFT JOIN T_BD_Supplier E ON E.FID=A.CFSupplierID \r\n");sql.append("LEFT JOIN T_ORG_Admin F ON F.FID=A.CFDepartmentID \r\n");sql.append("WHERE 1=1 \r\n");if (null!=fiCompanyId) {sql.append("and a.CFFICompanyID=? \r\n");sp.addString(fiCompanyId);}if(null!=departmentId){sql.append("and a.CFDepartmentID=? \r\n");sp.addString(departmentId);}if(null!=contractTypeId){sql.append("and a.CFContractTypeID=? \r\n");sp.addString(contractTypeId);}if(null!=number){sql.append("and a.FNumber like '%"+number+"%' \r\n");//sp.addString(number);}if(null!=name){sql.append("and a.CFName like '%"+name+"%' \r\n");//sp.addString(name);}if(null!=startDate){sql.append("and a.FBizDate>=? \r\n");java.sql.Date date=new java.sql.Date(startDate.getTime());sp.addDate(date);}if(null!=endDate){sql.append("and a.FBizDate<=? \r\n");java.sql.Date date=new java.sql.Date(endDate.getTime());sp.addDate(date);}if(null!=contractWayId){sql.append("and a.CFContractWay=? \r\n");sp.addString(contractWayId);}if(null!=status){sql.append("and a.CFStatus=? \r\n");sp.addString(status);}sql.append("ORDER BY a.FNumber");IRowSet set = DbUtil.executeQuery(ctx, sql.toString(), sp.getParams());//这里返回值是RptParams,需要把查询集保存到RptParams里,再通过界面取出即可params.setObject(ApRptConstant.RPT_PARAMETERS, set);return params;}

另外在联查中,是通过调用之前已经新建好的单据的EditUI直接显示即可,也可以参考完整显示代码,

public class ContractReportBillViewUI extends AbstractContractReportBillViewUI{private static final Logger logger = CoreUIObject.getLogger(ContractReportBillViewUI.class);private AppraiseEditUI currentBaseUI=null;//基础资料private DepositRegisterListUI currentDepositUI=null;//保证金private ContractChangeListUI currentContractChangeUI=null;//合同变更private ReceiveBillListUI currentReceiveBillUI=null;//合同收款单private PaymentBillListUI currentPaymentBillUI=null;//合同付款单public ContractReportBillViewUI() throws Exception{super();Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setPreferredSize(screenSize);}public void onLoad() throws Exception {super.onLoad();kDTabbedPane1.remove(changeUI);//补充协议String ID = APRuleUtil.getString(getUIContext().get("ID"));String orgId = APRuleUtil.getString(getUIContext().get("orgId"));if (this.baseUI.getComponentCount() == 0) {currentBaseUI = ((AppraiseEditUI) UIFactoryHelper.initUIObject(AppraiseEditUI.class.getName(),getUIContext(), null, getOprtState()));currentBaseUI.repaint();baseUI.add(currentBaseUI);}if (DepositUI.getComponentCount()==0) {Map context = getUIContext();context.clear();context.put("appraise.id", ID);//context.put("orgId", orgId);//currentDepositUI = ((DepositRegisterListUI) UIFactoryHelper.initUIObject(DepositRegisterListUI.class.getName(),context, null, getOprtState()));currentDepositUI.repaint();DepositUI.add(currentDepositUI);}if (ContractChangeUI.getComponentCount()==0) {Map context = getUIContext();context.clear();context.put("appraise.id", ID);context.put("orgId", orgId);currentContractChangeUI = ((ContractChangeListUI) UIFactoryHelper.initUIObject(ContractChangeListUI.class.getName(),context, null, getOprtState()));currentContractChangeUI.repaint();ContractChangeUI.add(currentContractChangeUI);}if (ReceiveBillUI.getComponentCount()==0) {Map context = getUIContext();context.clear();context.put("appraise.id", ID);context.put("orgId", orgId);currentReceiveBillUI = ((ReceiveBillListUI) UIFactoryHelper.initUIObject(ReceiveBillListUI.class.getName(),context, null, getOprtState()));currentReceiveBillUI.repaint();ReceiveBillUI.add(currentReceiveBillUI);}if (PaymentBillUI.getComponentCount()==0) {Map context = getUIContext();context.clear();context.put("appraise.id", ID);context.put("orgId", orgId);currentPaymentBillUI = ((PaymentBillListUI) UIFactoryHelper.initUIObject(PaymentBillListUI.class.getName(),context, null, getOprtState()));currentPaymentBillUI.repaint();PaymentBillUI.add(currentPaymentBillUI);}}}

 

 

 

                                                                                         THE    END

这篇关于EAS BOS 报表开发的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/814712

相关文章

Spring Boot + MyBatis Plus 高效开发实战从入门到进阶优化(推荐)

《SpringBoot+MyBatisPlus高效开发实战从入门到进阶优化(推荐)》本文将详细介绍SpringBoot+MyBatisPlus的完整开发流程,并深入剖析分页查询、批量操作、动... 目录Spring Boot + MyBATis Plus 高效开发实战:从入门到进阶优化1. MyBatis

Python基于wxPython和FFmpeg开发一个视频标签工具

《Python基于wxPython和FFmpeg开发一个视频标签工具》在当今数字媒体时代,视频内容的管理和标记变得越来越重要,无论是研究人员需要对实验视频进行时间点标记,还是个人用户希望对家庭视频进行... 目录引言1. 应用概述2. 技术栈分析2.1 核心库和模块2.2 wxpython作为GUI选择的优

利用Python开发Markdown表格结构转换为Excel工具

《利用Python开发Markdown表格结构转换为Excel工具》在数据管理和文档编写过程中,我们经常使用Markdown来记录表格数据,但它没有Excel使用方便,所以本文将使用Python编写一... 目录1.完整代码2. 项目概述3. 代码解析3.1 依赖库3.2 GUI 设计3.3 解析 Mark

利用Go语言开发文件操作工具轻松处理所有文件

《利用Go语言开发文件操作工具轻松处理所有文件》在后端开发中,文件操作是一个非常常见但又容易出错的场景,本文小编要向大家介绍一个强大的Go语言文件操作工具库,它能帮你轻松处理各种文件操作场景... 目录为什么需要这个工具?核心功能详解1. 文件/目录存javascript在性检查2. 批量创建目录3. 文件

基于Python开发批量提取Excel图片的小工具

《基于Python开发批量提取Excel图片的小工具》这篇文章主要为大家详细介绍了如何使用Python中的openpyxl库开发一个小工具,可以实现批量提取Excel图片,有需要的小伙伴可以参考一下... 目前有一个需求,就是批量读取当前目录下所有文件夹里的Excel文件,去获取出Excel文件中的图片,并

基于Python开发PDF转PNG的可视化工具

《基于Python开发PDF转PNG的可视化工具》在数字文档处理领域,PDF到图像格式的转换是常见需求,本文介绍如何利用Python的PyMuPDF库和Tkinter框架开发一个带图形界面的PDF转P... 目录一、引言二、功能特性三、技术架构1. 技术栈组成2. 系统架构javascript设计3.效果图

基于Python开发PDF转Doc格式小程序

《基于Python开发PDF转Doc格式小程序》这篇文章主要为大家详细介绍了如何基于Python开发PDF转Doc格式小程序,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 用python实现PDF转Doc格式小程序以下是一个使用Python实现PDF转DOC格式的GUI程序,采用T

使用Python开发一个图像标注与OCR识别工具

《使用Python开发一个图像标注与OCR识别工具》:本文主要介绍一个使用Python开发的工具,允许用户在图像上进行矩形标注,使用OCR对标注区域进行文本识别,并将结果保存为Excel文件,感兴... 目录项目简介1. 图像加载与显示2. 矩形标注3. OCR识别4. 标注的保存与加载5. 裁剪与重置图像

Android开发中gradle下载缓慢的问题级解决方法

《Android开发中gradle下载缓慢的问题级解决方法》本文介绍了解决Android开发中Gradle下载缓慢问题的几种方法,本文给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧... 目录一、网络环境优化二、Gradle版本与配置优化三、其他优化措施针对android开发中Gradle下载缓慢的问

使用Go语言开发一个命令行文件管理工具

《使用Go语言开发一个命令行文件管理工具》这篇文章主要为大家详细介绍了如何使用Go语言开发一款命令行文件管理工具,支持批量重命名,删除,创建,移动文件,需要的小伙伴可以了解下... 目录一、工具功能一览二、核心代码解析1. 主程序结构2. 批量重命名3. 批量删除4. 创建文件/目录5. 批量移动三、如何安