【套打】针对部分数据源取部分行数套打

<0>背景
某些子表体数据过多,客户想要显示前X行数据即可;
更新记录:套打2103切换为后台任务生成页面(进度条打印),导致插件无法访问Http请求问题,如果使用异常可下载新版的插件使用。(后续修复针对后台任务传入Http上下文)
<1>实现方法
使用数据表格/简单数据表格过滤得到有效数字(字段非空),而后取前X行(插件实现)
(1)表单插件C#代码

代码调整:只需要调整三个位置,即装即用(python代码调整逻辑同理)
TargetDataSourceKey——干预的目标实体
TargetRowCnt——数据行数
EnableTemplate——启用模板集合

(2)Python插件
使用动态插件编译【工具分享】C#插件转Python工具,C#高效开发 + Python快速部署

<2>效果

附录
C#代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
namespace NotePrintPlugin.Sample
{
[Kingdee.BOS.Util.HotUpdate]
public class DisplayMaxRowCntSample : AbstractDynamicFormPlugIn
{
/*
* 功能:当分录大于目标数目时仅显示前X个行
*/
/// <summary>
/// 目标数据源标识
/// </summary>
private static readonly string TargetDataSourceKey = "FEntity";
/// <summary>
/// 目标行数
/// </summary>
private static readonly int TargetRowCnt = 5;
/// <summary>
/// 启用插件模板集合
/// </summary>
private static readonly HashSet<string> EnableTemplate = new HashSet<string>() {"c5fe55cb-b53b-4be7-8fbe-ffa8cde9254d"};
public override void OnPrepareNotePrintData(PreparePrintDataEventArgs e)
{
if (!EnableTemplate.Contains(e.NotePrintTplId))
return;
if (!e.DataSourceId.EqualsIgnoreCase(TargetDataSourceKey))
return;
if (e.DataObjects == null || e.DataObjects.Length <= TargetRowCnt)
return;
List<DynamicObject> filterRows = new List<DynamicObject>();
for (int curRowCnt = 0; curRowCnt < TargetRowCnt; ++curRowCnt)
{
filterRows.Add(e.DataObjects[curRowCnt]);
}
e.DataObjects = filterRows.ToArray();
}
}
}
附件Python代码:
code='''
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
namespace NotePrintPlugin.Sample
{
[Kingdee.BOS.Util.HotUpdate]
public class DisplayMaxRowCntSample : AbstractDynamicFormPlugIn
{
/*
* 功能:当分录大于目标数目时仅显示前X个行
*/
/// <summary>
/// 目标数据源标识
/// </summary>
private static readonly string TargetDataSourceKey = "FEntity";
/// <summary>
/// 目标行数
/// </summary>
private static readonly int TargetRowCnt = 5;
/// <summary>
/// 启用插件模板集合
/// </summary>
private static readonly HashSet<string> EnableTemplate = new HashSet<string>() {"c5fe55cb-b53b-4be7-8fbe-ffa8cde9254d"};
public override void OnPrepareNotePrintData(PreparePrintDataEventArgs e)
{
if (!EnableTemplate.Contains(e.NotePrintTplId))
return;
if (!e.DataSourceId.EqualsIgnoreCase(TargetDataSourceKey))
return;
if (e.DataObjects == null || e.DataObjects.Length <= TargetRowCnt)
return;
List<DynamicObject> filterRows = new List<DynamicObject>();
for (int curRowCnt = 0; curRowCnt < TargetRowCnt; ++curRowCnt)
{
filterRows.Add(e.DataObjects[curRowCnt]);
}
e.DataObjects = filterRows.ToArray();
}
}
}
'''
refDlls = '''
Kingdee.BOS
Kingdee.BOS.App
Kingdee.BOS.App.Core
Kingdee.BOS.Business.Bill
Kingdee.BOS.Core
Kingdee.BOS.DataEntity
Kingdee.BOS.M
【套打】针对部分数据源取部分行数套打
声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。



