该实例采用单选辅助资料列表来举例,其他字段类似
1、生产订单明细新增单选辅助资料,标识名为FFZZL,生产用料清单表体明细新增单选辅助资料,标知名与订单保持一致
2、二开生产用料清单的保存插件,代码实例如下:
[Description("生产订单计划确认跳层携带订单字段到用料清单上")]
public class PPBomGetMoData : AbstractOperationServicePlugIn
{
public override void BeginOperationTransaction(global::Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeginOperationTransactionArgs e) {
base.BeginOperationTransaction(e);
if (e.DataEntitys.IsEmpty()) return;
var ppbomEntryDatas = from datatity in e.DataEntitys
from row in datatity.GetDynamicObjectItemValue<DynamicObjectCollection>("PPBomEntry") select row;
if (ppbomEntryDatas.IsEmpty()) return;
List<long> moEntryIds = ppbomEntryDatas.Select(s => s.GetDynamicValue<long>("MoEntryId")).ToList();
//生产订单新增的字段,取名加FFZZL
string sql = string.Format("SELECT FENTRYID,FFZZL FROM T_PRD_MOENTRY T INNER JOIN {0} TT ON T.FENTRYID=TT.FID", StringUtils.GetSqlWithCardinality(moEntryIds.Distinct().Count(), "@MOENTRYIDS", 1));
List<SqlParam> paramLists = new List<SqlParam>();
paramLists.Add(new SqlParam("@MOENTRYIDS", KDDbType.udt_inttable, moEntryIds.Distinct().ToArray())); DynamicObjectCollection dyMoDatas = AppServiceContext.DbUtils.ExecuteDynamicObject(this.Context, sql, paramLists.ToArray());
if (dyMoDatas.IsEmpty()) return;
Dictionary<long, IGrouping<long, DynamicObject>> dicMoDatas = dyMoDatas.GroupBy(g => g.GetDynamicValue<long>("FENTRYID")).ToDictionary(d => d.Key);
foreach (var data in e.DataEntitys)
{
DynamicObjectCollection entryDatas = data.GetDynamicValue<DynamicObjectCollection>("PPBomEntry");
foreach (DynamicObject entryData in entryDatas)
{
long moEntryId = entryData.GetDynamicValue<long>("MoEntryId");
IGrouping<long, DynamicObject> igDatas;
if (dicMoDatas.TryGetValue(moEntryId, out igDatas))
{
string fzzl = igDatas.FirstOrDefault().GetDynamicValue<string>("FFZZL");
entryData.SetDynamicObjectItemValue("FZZL_ID", fzzl);
}
}
}
}
}
推荐阅读