获取替代按照优先级设置用料清单使用比例原创
11人赞赏了该文章
621次浏览
编辑于2022年09月15日 14:05:25
二开表单插件,生产用料清单获取替代根据优先级设置使用比例代码如下:
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Core.Metadata.EntityElement; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.Util; using Kingdee.K3.Core.MFG.EntityHelper; using Kingdee.K3.Core.MFG.EnumConst; using Kingdee.K3.MFG.BusinessCommon.BillPlugIn; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace test { public class Class1 : AbstractMFGBillPlugIn { public override void BeforeDoOperation(BeforeDoOperationEventArgs e) { List<DynamicObject> dataLst = this.View.GetSelectedRowDatas("Fentity").Where(w => w.GetDynamicValue<long>("MaterialID_Id") > 0 && w.GetDynamicValue<string>("MaterialType") == "1" && w.GetDynamicValue<string>("ReplacePolicy").IsNullOrEmptyOrWhiteSpace() && !w.GetDynamicValue<bool>("IsSkip")).ToList(); base.BeforeDoOperation(e); switch (e.Operation.FormOperation.Operation) { case "GETREPLACE": //替代获取 Entity treeEntity = this.View.BusinessInfo.GetEntity("FEntity"); DynamicObjectCollection entryCollection = this.Model.GetEntityDataObject(treeEntity); foreach (var selRow in dataLst) { //获取替代方式 if (selRow.GetDynamicValue<string>("ReplaceType") != "1") continue; //获得当前行项次 int groupIndex = selRow.GetDynamicValue<int>("ReplaceGroup"); //获取当前优先级 int priority = selRow.GetDynamicValue<int>("ReplacePriority"); var highPriorityDatas = entryCollection.Where(w => w.GetDynamicValue<int>("ReplaceGroup") == groupIndex && w.GetDynamicValue<int>("ReplacePriority") < priority).ToList(); if (highPriorityDatas != null && highPriorityDatas.Count > 0) { int minPriority = highPriorityDatas.Min(m => m.GetDynamicValue<int>("ReplacePriority")); DynamicObject minObj = highPriorityDatas.Where(w => w.GetDynamicValue<int>("ReplacePriority") == minPriority).ToList().FirstOrDefault(); if (!minObj.IsNullOrEmpty()) { this.View.Model.SetValue("FUseRate", 100, entryCollection.IndexOf(minObj)); } } } this.View.UpdateView("FENTITY"); break; } } } }
推荐阅读