获取替代按照优先级设置用料清单使用比例原创
金蝶云社区-亦木丶
亦木丶
11人赞赏了该文章 689次浏览 未经作者许可,禁止转载编辑于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;
            }
        }
    }
}


图标赞 11
11人点赞
还没有人点赞,快来当第一个点赞的人吧!
图标打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!