1、二开动态表单插件,挂在BOM同步更新用料清单界面,如下图:
2、二开动态表单代码实例如下:
using Kingdee.K3.MFG.ENG.Business.PlugIn.DynamicForm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kingdee.K3.Core.MFG.EntityHelper;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS;
using Kingdee.BOS.Util;
using Kingdee.K3.MFG.App;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Core.Metadata;
using Kingdee.K3.Core.MFG;
namespace JTSK.Kingdee.K3.MFG.PRD.Business.PlugIn.DynamicForm
{
public class BomSynsUpdatePPBOMCompary : BomSynsUpdatePpBom
{
public List oldPPBOMDatas = new List();//生产用料清单
public List oldSubPPBOMDatas = new List();//委外用料清单
public FormMetadata ppbomMetaData; //生产用料清单
public FormMetadata subPPBOMMetaData;//委外用料清单
public override void ButtonClick(global::Kingdee.BOS.Core.DynamicForm.PlugIn.Args.ButtonClickEventArgs e)
{
base.ButtonClick(e);
switch (e.Key)
{
case "FBTNOK":
if (!moDatas.IsEmpty())
{
//更新之前通过生产订单分录内码获取用料清单的数据
List<long> moEntryIds = moDatas.Select(s => s.GetDynamicValue<long>("MoEntryID")).Distinct().ToList(); //获取生产订单分录内码
//通过生产订单,委外订单分录内码获取生产,委外用料清单的数据包
string sql1 = string.Format("SELECT T.FID AS PPBOMID FROM T_PRD_PPBOM T INNER JOIN {0} TT ON T.FMOENTRYID=TT.FID", StringUtils.GetSqlWithCardinality(moEntryIds.Distinct().Count(), "@MOENTRYIDS", 1));
List<SqlParam> paramLists1 = new List<SqlParam>();
paramLists1.Add(new SqlParam("@MOENTRYIDS", KDDbType.udt_inttable, moEntryIds.Distinct().ToArray()));
DynamicObjectCollection objs1 = AppServiceContext.DbUtils.ExecuteDynamicObject(this.Context, sql1, paramLists1.ToArray());
if (objs1.IsEmpty()) return;
List<object> ppbomIds = objs1.Select(s => s.GetDynamicValue<object>("PPBOMID")).Distinct().ToList();
//用料清单的元数据
ppbomMetaData = (FormMetadata)MetaDataServiceHelper.Load(this.Context, MFGFormIdConst.SubSys_PRD.PPBOMBill);
oldPPBOMDatas = BusinessDataServiceHelper.Load(this.Context, ppbomIds.ToArray(), ppbomMetaData.BusinessInfo.GetDynamicObjectType()).ToList();
}
if (!subDatas.IsEmpty())
{
//更新之前通过委外订单分录内码获取用料清单的数据
List<long> subEntryIds = subDatas.Select(s => s.GetDynamicValue<long>("SubEntryID")).Distinct().ToList(); //获取委外订单分录内码
//通过委外订单,委外订单分录内码获取生产,委外用料清单的数据包
string sql1 = string.Format("SELECT T.FID AS PPBOMID FROM T_SUB_PPBOM T INNER JOIN {0} TT ON T.FSUBREQENTRYID=TT.FID", StringUtils.GetSqlWithCardinality(subEntryIds.Distinct().Count(), "@SUBENTRYIDS", 1));
List<SqlParam> paramLists1 = new List<SqlParam>();
paramLists1.Add(new SqlParam("@SUBENTRYIDS", KDDbType.udt_inttable, subEntryIds.Distinct().ToArray()));
DynamicObjectCollection objs1 = AppServiceContext.DbUtils.ExecuteDynamicObject(this.Context, sql1, paramLists1.ToArray());
if (objs1.IsEmpty()) return;
List<object> ppbomIds = objs1.Select(s => s.GetDynamicValue<object>("PPBOMID")).Distinct().ToList();
//用料清单的元数据
subPPBOMMetaData = (FormMetadata)MetaDataServiceHelper.Load(this.Context, MFGFormIdConst.SubSys_SUB.PPBOMBill);
oldSubPPBOMDatas = BusinessDataServiceHelper.Load(this.Context, ppbomIds.ToArray(), subPPBOMMetaData.BusinessInfo.GetDynamicObjectType()).ToList();
}
break;
default:
break;
}
}
protected override void DoEmptyFunction()
{
base.DoEmptyFunction();
if (!moDatas.IsEmpty())
{
//这里处理回调
List<long> moEntryIds = moDatas.Select(s => s.GetDynamicValue<long>("MoEntryID")).Distinct().ToList(); //获取生产订单分录内码
//更新完成之后获取用料清单的数据跟更新之前的用料清单进行比对
string sql1 = string.Format("SELECT T.FID AS PPBOMID FROM T_PRD_PPBOM T INNER JOIN {0} TT ON T.FMOENTRYID=TT.FID", StringUtils.GetSqlWithCardinality(moEntryIds.Distinct().Count(), "@MOENTRYIDS", 1));
List<SqlParam> paramLists1 = new List<SqlParam>();
paramLists1.Add(new SqlParam("@MOENTRYIDS", KDDbType.udt_inttable, moEntryIds.Distinct().ToArray()));
DynamicObjectCollection objs1 = AppServiceContext.DbUtils.ExecuteDynamicObject(this.Context, sql1, paramLists1.ToArray());
if (objs1.IsEmpty()) return;
List<object> ppbomIds = objs1.Select(s => s.GetDynamicValue<object>("PPBOMID")).Distinct().ToList();
List<DynamicObject> newPPBOMDatas = BusinessDataServiceHelper.Load(this.Context, ppbomIds.ToArray(), ppbomMetaData.BusinessInfo.GetDynamicObjectType()).ToList();
//更新后的用料清单与更新前的oldPPBOMDatas对比
}
if (!subDatas.IsEmpty())
{
//更新之前通过委外订单分录内码获取用料清单的数据
List<long> subEntryIds = subDatas.Select(s => s.GetDynamicValue<long>("SubEntryID")).Distinct().ToList(); //获取委外订单分录内码
//通过委外订单,委外订单分录内码获取生产,委外用料清单的数据包
string sql1 = string.Format("SELECT T.FID AS PPBOMID FROM T_SUB_PPBOM T INNER JOIN {0} TT ON T.FSUBREQENTRYID=TT.FID", StringUtils.GetSqlWithCardinality(subEntryIds.Distinct().Count(), "@SUBENTRYIDS", 1));
List<SqlParam> paramLists1 = new List<SqlParam>();
paramLists1.Add(new SqlParam("@SUBENTRYIDS", KDDbType.udt_inttable, subEntryIds.Distinct().ToArray()));
DynamicObjectCollection objs1 = AppServiceContext.DbUtils.ExecuteDynamicObject(this.Context, sql1, paramLists1.ToArray());
if (objs1.IsEmpty()) return;
List<object> ppbomIds = objs1.Select(s => s.GetDynamicValue<object>("PPBOMID")).Distinct().ToList();
List<DynamicObject> newSubPPBOMDatas = BusinessDataServiceHelper.Load(this.Context, ppbomIds.ToArray(), subPPBOMMetaData.BusinessInfo.GetDynamicObjectType()).ToList();
}
}
}
}
}
本文转载自:11
作者:11
原文链接:11
推荐阅读