插件获取金蝶字段报表数据并改造显示

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

插件获取金蝶字段报表数据并改造显示

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using Kingdee.BOS.Core.Bill.PlugIn;

using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;

using Kingdee.BOS.Orm.DataEntity;

using System.ComponentModel;

using System.Dynamic;

using Kingdee.BOS.JSON;

using Kingdee.BOS.Util;

using Kingdee.BOS.Core.Bill;

using Kingdee.BOS.Core.DynamicForm;

using Kingdee.BOS.Core.DynamicForm.PlugIn;

using Kingdee.BOS.Core.Report;

using Kingdee.BOS.Core.ReportFilter;

using Kingdee.BOS.ServiceHelper;

using Kingdee.BOS;

using Kingdee.BOS.Contracts;

using Kingdee.BOS.Core;

using Kingdee.BOS.Model.CommonFilter;

using Kingdee.BOS.Model.ReportFilter;

using Kingdee.BOS.Core.Metadata;

using System.Data;

using Kingdee.BOS.Core.Permission;

using Kingdee.BOS.App.Data;

namespace Jac.XkDemo.BOS.Business.PlugIn

{

    public class OpenUrlBillPlugIn :  AbstractDynamicFormPlugIn

    {

   

        public override void BarItemClick(BarItemClickEventArgs e)

        {

            base.BarItemClick(e);

            if (e.BarItemKey.EqualsIgnoreCase("tbExportRpt"))

            {

             GetReportData();

            }


        }


        private void GetReportData()

        {

            ISysReportService sysReporSservice = ServiceFactory.GetSysReportService(this.Context);


            IPermissionService permissionService = ServiceFactory.GetPermissionService(this.Context);

            var filterMetadata = FormMetaDataCache.GetCachedFilterMetaData(this.Context);//加载字段比较条件元数据。

            var reportMetadata = FormMetaDataCache.GetCachedFormMetaData(this.Context, "GL_RPT_AccountingItemsBalance");//加载余额表元数据。


            var reportFilterMetadata = FormMetaDataCache.GetCachedFormMetaData(this.Context, "GL_RPT_AccountingItemsBalanceFilter");//加载余额过滤条件元数据。


            var reportFilterServiceProvider = reportFilterMetadata.BusinessInfo.GetForm().GetFormServiceProvider();

            var model = new SysReportFilterModel();

            model.SetContext(this.Context, reportFilterMetadata.BusinessInfo, reportFilterServiceProvider);

            model.FormId = reportFilterMetadata.BusinessInfo.GetForm().Id;

            model.FilterObject.FilterMetaData = filterMetadata;

            model.InitFieldList(reportMetadata, reportFilterMetadata);

            model.GetSchemeList();


            var entity = model.Load("6580ee50f8482e");//过滤方案的主键值,可通过该SQL语句查询得到:SELECT * FROM T_BAS_FILTERSCHEME


            var filter = model.GetFilterParameter();


            IRptParams p = new RptParams();


            p.FormId = reportFilterMetadata.BusinessInfo.GetForm().Id;


            p.StartRow = 1;


            p.EndRow = int.MaxValue;//StartRow和EndRow是报表数据分页的起始行数和截至行数,一般取所有数据,所以EndRow取int最大值。


            p.FilterParameter = filter;


            p.FilterFieldInfo = model.FilterFieldInfo;


            p.BaseDataTempTable.AddRange(permissionService.GetBaseDataTempTable(this.Context, reportMetadata.BusinessInfo.GetForm().Id));


            using (DataTable dt = sysReporSservice.GetData(this.Context, reportMetadata.BusinessInfo, p))

            {

              //TMPAccountingItemsBalance 定义一个临时表 保存查询报表数据 用来存储获取查询报表数据

                string sql = string.Format(@"/*dialect*/delete from TMPAccountingItemsBalance ");

                DBUtils.Execute(this.Context, sql);

                dt.TableName = "TMPAccountingItemsBalance";

                DBUtils.BulkInserts(this.Context, dt);

            }


                ServiceFactory.CloseService(sysReporSservice);


            ServiceFactory.CloseService(permissionService);

        }

    }

}


插件获取金蝶字段报表数据并改造显示

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using Kingdee...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息