二开案例.账表.加载时动态设置分组显示
**【应用场景】**
账表过滤条件框不设置分组汇总,在账表加载时动态进行设置。
**【案例演示】**
<1>编写账表服务插件,代码如下。
``` csharp
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Contracts.Report;
using Kingdee.BOS.Core.Metadata.FieldElement;
using Kingdee.BOS.Core.Report;
using Kingdee.BOS.Util;
using System.Collections.Generic;
using System.ComponentModel;
namespace Kingdee.BOS.PlugInTest
{
[Description("【账表服务器插件】动态设置分组字段"), HotUpdate]
public class GroupReportService : SysReportBaseService
{
/// <summary>
/// 初始化
/// </summary>
public override void Initialize()
{
base.Initialize();
// 简单账表类型:普通、树形、分页
this.ReportProperty.ReportType = ReportType.REPORTTYPE_NORMAL;
// 报表名称
this.ReportProperty.ReportName = new LocaleValue("日采购报表", base.Context.UserLocale.LCID);
// 是否由插件创建临时表
this.IsCreateTempTableByPlugin = true;
// 报表列是否通过UI设计
this.ReportProperty.IsUIDesignerColumns = false;
// 报表是否支持分组汇总
this.ReportProperty.IsGroupSummary = true;
// 是否锁定表格列
this.ReportProperty.SimpleAllCols = false;
// 报表是否默认只现实合计和明细数据
this.ReportProperty.IsDefaultOnlyDspSumAndDetailData = true;
// 设置精度控制
List<DecimalControlField> list = new List<DecimalControlField>();
// 数量
list.Add(new DecimalControlField
{
ByDecimalControlFieldName = "FQty",
DecimalControlFieldName = "FUnitPrecision"
});
// 单价
list.Add(new DecimalControlField
{
ByDecimalControlFieldName = "FTAXPRICE",
DecimalControlFieldName = "FPRICEDIGITS"
});
// 金额
list.Add(new DecimalControlField
{
ByDecimalControlFieldName = "FALLAMOUNT",
DecimalControlFieldName = "FAMOUNTDIGITS"
});
this.ReportProperty.DecimalControlFieldList = list;
}
/// <summary>
/// 构建报表临时表
/// </summary>
/// <param name="filter"></param>
/// <param name="tableName"></param>
public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName)
{
base.BuilderReportSqlAndTempTable(filter, tableName);
// 设置分组列
filter.FilterParameter.SummaryRows.Clear();
var summaryField1 = new Core.CommonFilter.SummaryField(new LocaleValue("单据编号"), "FBILLNO");
summaryField1.Key = "FBILLNO";
summaryField1.EntityKey = string.Empty;
summaryField1.Field = new Field("FBILLNO");
filter.FilterParameter.SummaryRows.Add(summaryField1);
var summaryField2 = new Core.CommonFilter.SummaryField(new LocaleValue("物料"), "FMaterialName");
summaryField2.Key = "FMaterialName";
summaryField2.EntityKey = string.Empty;
summaryField2.Field = new Field("FMaterialName");
filter.FilterParameter.SummaryRows.Add(summaryField2);
// 设置分组字符串
filter.FilterParameter.GroupbyString = "FBILLNO,FMaterialName";
// 取数SQL
// FID, FEntryId, 编号、状态、物料、数量、单位、单位精度、单价、价税合计
string sql = string.Format(@"/*dialect*/
select t0.FID
,t1.FENTRYID
,t0.FBILLNO
,t0.FDate
,t0.FDOCUMENTSTATUS
,t2.FLOCALCURRID
,ISNULL(t20.FPRICEDIGITS,4) AS FPRICEDIGITS
,ISNULL(t20.FAMOUNTDIGITS,2) AS FAMOUNTDIGITS
,t1.FMATERIALID
,t1M_L.FNAME as FMaterialName
,t1.FQTY
,t1u.FPRECISION as FUnitPrecision
,t1U_L.FNAME as FUnitName
,t1f.FTAXPRICE
,t1f.FALLAMOUNT
,ROW_NUMBER() OVER(ORDER BY t0.FID,t1.FENTRYID) FIDENTITYID
into {0}
from T_PUR_POORDER t0
inner join T_PUR_POORDERFIN t2 on (t0.FID = t2.FID)
left join T_BD_CURRENCY t20 on (t2.FLOCALCURRID = t20.FCURRENCYID)
inner join T_PUR_POORDERENTRY t1 on (t0.FID = t1.FID)
left join T_BD_MATERIAL_L t1M_L on (t1.FMATERIALID = t1m_l.FMATERIALID and t1M_L.FLOCALEID = 2052)
inner join T_PUR_POORDERENTRY_F t1F on (t1.FENTRYID = t1f.FENTRYID)
left join T_BD_UNIT t1U on (t1f.FPRICEUNITID = t1u.FUNITID)
left join T_BD_UNIT_L t1U_L on (t1U.FUNITID = t1U_L.FUNITID and t1U_L.FLOCALEID = 2052)
where t0.FDOCUMENTSTATUS<>'Z'",
tableName);
DBUtils.ExecuteDynamicObject(this.Context, sql);
}
/// <summary>
/// 报表列头
/// </summary>
/// <param name="filter"></param>
/// <returns></returns>
public override ReportHeader GetReportHeaders(IRptParams filter)
{
ReportHeader header = new ReportHeader();
header.AddChild("FBillNo", new LocaleValue("单据编号"));
header.AddChild("FDocumentStatus", new LocaleValue("状态"));
header.AddChild("FMaterialName", new LocaleValue("物料"));
header.AddChild("FQty", new LocaleValue("数量"), SqlStorageType.SqlDecimal);
header.AddChild("FUnitName", new LocaleValue("单位"));
header.AddChild("FTAXPRICE", new LocaleValue("含税价"), SqlStorageType.SqlDecimal);
header.AddChild("FALLAMOUNT", new LocaleValue("价税合计"), SqlStorageType.SqlDecimal);
return header;
}
/// <summary>
/// 设置报表合计列
/// </summary>
/// <param name="filter"></param>
/// <returns></returns>
public override List<SummaryField> GetSummaryColumnInfo(IRptParams filter)
{
var result = base.GetSummaryColumnInfo(filter);
result.Add(new SummaryField("FQty", Kingdee.BOS.Core.Enums.BOSEnums.Enu_SummaryType.SUM));
result.Add(new SummaryField("FALLAMOUNT", Kingdee.BOS.Core.Enums.BOSEnums.Enu_SummaryType.SUM));
return result;
}
}
}
```
<2>拷贝插件组件到应用站点的WebSite\Bin目录下,重启IIS。
<3>注册插件。
![注册插件.webp](/download/01004e475f16931b489183b8335e55616bae.webp)
<4>现在可以登业务站点,验证一下结果。
![加载时动态设置分组显示.webp](/download/0100552369a7d9ba4864bd70e67c29c22457.webp)
二开案例.账表.加载时动态设置分组显示
**【应用场景】** 账表过滤条件框不设置分组汇总,在账表加载时动态进行设置。**【案例演示】** <1>编写账表服务插件,代码如下...
点击下载文档
本文2024-09-23 04:15:56发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-164195.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章