通过二开列表过滤插件实现列表过滤,下面以生产用料清单举例(根据生产订单的结案类型来过滤生产用料清单)
第一步:设置过滤方案,如下图:
第二步:代码实例如下:
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.K3.Core.MFG.EntityHelper;
using System.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Util;
using Kingdee.K3.Core.BD.ServiceArgs;
using Kingdee.K3.MFG.Common.BusinessEntity.PRD;
using Kingdee.K3.BD.ServiceHelper; using Kingdee.K3.Core.BD;
using Kingdee.BOS.Core.List.PlugIn;
using Kingdee.BOS.Orm;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Log; using Kingdee.K3.Core.MFG;
using Kingdee.BOS.Core.SqlBuilder;
using Kingdee.BOS.Core.Metadata;
using Kingdee.K3.MFG.ServiceHelper;
using Kingdee.BOS;
namespace JTSK.Kingdee.K3.MFG.PRD.Business.PlugIn
{
[Description("生产用料清单列表过滤")]
public class PPBOMListFilter : AbstractListPlugIn
{
public override void PrepareFilterParameter(global::Kingdee.BOS.Core.List.PlugIn.Args.FilterArgs e)
{
base.PrepareFilterParameter(e);
//如果过滤条件含有最新结果关键字,则在此基础上处理,以支持最新结果内置方案另存增加条件(关键字是根据生产订单状态过滤)
if (!e.FilterString.IsNullOrEmptyOrWhiteSpace() && e.FilterString.IndexOf("MoFilter") >= 0)
{
List<string> lstSelectFields = new List<string>(); lstSelectFields.Add("FTreeEntity_FEntryId AS MOENTRYID"); QueryBuilderParemeter para = new QueryBuilderParemeter() {
FormId = MFGFormIdConst.SubSys_PRD.MOBill,
SelectItems = SelectorItemInfo.CreateItems(lstSelectFields.ToArray()), FilterClauseWihtKey = string.Format(" FSTATUS='6' AND FCLOSETYPE='C'") //强制结案 };
DynamicObjectCollection objs = MFGServiceHelper.GetDynamicObjectCollection(this.Context, para); if (!objs.IsEmpty())
{
List<long> moEntryIds = objs.Select(s => s.GetDynamicValue<long>("MOENTRYID")).ToList();
SqlParam sqlParam = new SqlParam("@PKValue", KDDbType.udt_inttable, moEntryIds.Distinct().ToArray());
e.SqlParams = new List<SqlParam>(); e.SqlParams.Add(sqlParam);
var cardSql = StringUtils.GetSqlWithCardinality(moEntryIds.Distinct().Count(), "@PKValue", 1);
ExtJoinTableDescription joinTable = new ExtJoinTableDescription(); joinTable.TableName = cardSql;
joinTable.ScourceKey = "FMOENTRYID"; joinTable.FieldName = "FID";
joinTable.TableNameAs = "Tmp";
e.ExtJoinTables = new List<ExtJoinTableDescription>(); e.ExtJoinTables.Add(joinTable);
e.FilterString = e.FilterString.Replace("MoFilter", "");
}
}
}
}
}