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

相关文章

这15个Vue指令,让你的项目开发爽到爆

1. V-Hotkey 仓库地址: github.com/Dafrok/v-ho… Demo: 戳这里 https://dafrok.github.io/v-hotkey 安装: npm install --save v-hotkey 这个指令可以给组件绑定一个或多个快捷键。你想要通过按下 Escape 键后隐藏某个组件,按住 Control 和回车键再显示它吗?小菜一碟: <template

Hadoop企业开发案例调优场景

需求 (1)需求:从1G数据中,统计每个单词出现次数。服务器3台,每台配置4G内存,4核CPU,4线程。 (2)需求分析: 1G / 128m = 8个MapTask;1个ReduceTask;1个mrAppMaster 平均每个节点运行10个 / 3台 ≈ 3个任务(4    3    3) HDFS参数调优 (1)修改:hadoop-env.sh export HDFS_NAMENOD

嵌入式QT开发:构建高效智能的嵌入式系统

摘要: 本文深入探讨了嵌入式 QT 相关的各个方面。从 QT 框架的基础架构和核心概念出发,详细阐述了其在嵌入式环境中的优势与特点。文中分析了嵌入式 QT 的开发环境搭建过程,包括交叉编译工具链的配置等关键步骤。进一步探讨了嵌入式 QT 的界面设计与开发,涵盖了从基本控件的使用到复杂界面布局的构建。同时也深入研究了信号与槽机制在嵌入式系统中的应用,以及嵌入式 QT 与硬件设备的交互,包括输入输出设

OpenHarmony鸿蒙开发( Beta5.0)无感配网详解

1、简介 无感配网是指在设备联网过程中无需输入热点相关账号信息,即可快速实现设备配网,是一种兼顾高效性、可靠性和安全性的配网方式。 2、配网原理 2.1 通信原理 手机和智能设备之间的信息传递,利用特有的NAN协议实现。利用手机和智能设备之间的WiFi 感知订阅、发布能力,实现了数字管家应用和设备之间的发现。在完成设备间的认证和响应后,即可发送相关配网数据。同时还支持与常规Sof

活用c4d官方开发文档查询代码

当你问AI助手比如豆包,如何用python禁止掉xpresso标签时候,它会提示到 这时候要用到两个东西。https://developers.maxon.net/论坛搜索和开发文档 比如这里我就在官方找到正确的id描述 然后我就把参数标签换过来

Linux_kernel驱动开发11

一、改回nfs方式挂载根文件系统         在产品将要上线之前,需要制作不同类型格式的根文件系统         在产品研发阶段,我们还是需要使用nfs的方式挂载根文件系统         优点:可以直接在上位机中修改文件系统内容,延长EMMC的寿命         【1】重启上位机nfs服务         sudo service nfs-kernel-server resta

【区块链 + 人才服务】区块链集成开发平台 | FISCO BCOS应用案例

随着区块链技术的快速发展,越来越多的企业开始将其应用于实际业务中。然而,区块链技术的专业性使得其集成开发成为一项挑战。针对此,广东中创智慧科技有限公司基于国产开源联盟链 FISCO BCOS 推出了区块链集成开发平台。该平台基于区块链技术,提供一套全面的区块链开发工具和开发环境,支持开发者快速开发和部署区块链应用。此外,该平台还可以提供一套全面的区块链开发教程和文档,帮助开发者快速上手区块链开发。

Vue3项目开发——新闻发布管理系统(六)

文章目录 八、首页设计开发1、页面设计2、登录访问拦截实现3、用户基本信息显示①封装用户基本信息获取接口②用户基本信息存储③用户基本信息调用④用户基本信息动态渲染 4、退出功能实现①注册点击事件②添加退出功能③数据清理 5、代码下载 八、首页设计开发 登录成功后,系统就进入了首页。接下来,也就进行首页的开发了。 1、页面设计 系统页面主要分为三部分,左侧为系统的菜单栏,右侧

v0.dev快速开发

探索v0.dev:次世代开发者之利器 今之技艺日新月异,开发者之工具亦随之进步不辍。v0.dev者,新兴之开发者利器也,迅速引起众多开发者之瞩目。本文将引汝探究v0.dev之基本功能与优势,助汝速速上手,提升开发之效率。 何谓v0.dev? v0.dev者,现代化之开发者工具也,旨在简化并加速软件开发之过程。其集多种功能于一体,助开发者高效编写、测试及部署代码。无论汝为前端开发者、后端开发者

pico2 开发环境搭建-基于ubuntu

pico2 开发环境搭建-基于ubuntu 安装编译工具链下载sdk 和example编译example 安装编译工具链 sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib 注意cmake的版本,需要在3.17 以上 下载sdk 和ex