生产倒冲平台明细把生产订单里面的自定义字段也同步带过来

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-23浏览:1

  生产倒冲平台明细把生产订单里面的自定义字段也同步带过来

可参考以下示例代码:


using Kingdee.BOS.Core.DynamicForm.PlugIn;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.K3.Core.MFG.EntityHelper;
using Kingdee.K3.Core.MFG.EnumConst;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using Kingdee.BOS.Core.SqlBuilder;
using Kingdee.K3.Core.MFG;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS;
using Kingdee.BOS.ServiceHelper;
using Kingdee.K3.Core.MFG.PRD.BackFlush;
namespace JTSK.Kingdee.K3.MFG.PRD.Business.PlugIn.DynamicForm
{
    [Description("生产倒冲平台显示生产订单二开字段")]
    public class PrdBackFlushWork : AbstractDynamicFormPlugIn
    {
        public override void AfterBarItemClick(global::Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterBarItemClickEventArgs e)
        {
            base.AfterBarItemClick(e);
            switch (e.BarItemKey.ToUpperInvariant())
            {
                case "TBREFRESH":

                    Entity entity = this.View.BusinessInfo.GetEntity(CONST_PRD_BackFlush.CONST_FEntity.ENTITY_FEntity);
                    DynamicObjectCollection dynamicDatas = this.View.Model.GetEntityDataObject(entity);
                    List<long> subPPBOMEntryId = dynamicDatas.Select(s => s.GetDynamicValue<long>(CONST_PRD_BackFlush.CONST_FEntity.ORM_PPBOMEntryId)).Distinct().ToList();

                    //举例说明
                    string sql = string.Format(@"SELECT T1.FENTRYID AS PPBOMENTRYID,T.FTEXT FROM T_PRD_MOENTRY T INNER JOIN T_PRD_PPBOMENTRY T1 ON T.FENTRYID=T1.FMOENTRYID
                    INNER JOIN {0} TT ON T1.FENTRYID=TT.FID", StringUtils.GetSqlWithCardinality(subPPBOMEntryId.Distinct().Count(), "@PPBOMENTRYIDS", 1));
List<SqlParam> p = new List<SqlParam> { new SqlParam("@PPBOMENTRYIDS", KDDbType.udt_inttable, subPPBOMEntryId.Distinct().ToArray()) };
                    var ret = DBServiceHelper.ExecuteDynamicObject(this.Context, sql, null, null, System.Data.CommandType.Text, p.ToArray());
                    Dictionary<long, IGrouping<long, DynamicObject>> dicret = new Dictionary<long, IGrouping<long, DynamicObject>>();
                    if (!ret.IsEmpty())
                    {
                        dicret = ret.GroupBy(g => g.GetDynamicValue<long>("PPBOMENTRYID")).ToDictionary(d => d.Key);
                    }

                    foreach (var item in dynamicDatas)
                    {
                        long ppbomEntryId = item.GetDynamicValue<long>(CONST_SUB_BackFlush.CONST_FEntity.ORM_SUBPPBOMEntryId);
                        IGrouping<long, DynamicObject> igPPBOMDatas;
                        if (dicret.TryGetValue(ppbomEntryId, out igPPBOMDatas))
                        {
                            string text = igPPBOMDatas.FirstOrDefault().GetDynamicValue<string>("FTEXT");
                            int index = dynamicDatas.IndexOf(item);
                            this.View.Model.SetValue("FTEXT", text, index);
                        }
                    }

                    break;
                default:
                    break;
            }
        }
    }
}

生产倒冲平台明细把生产订单里面的自定义字段也同步带过来

可参考以下示例代码:using Kingdee.BOS.Core.DynamicForm.PlugIn;using System;using System.Collections.Generic;using System.Linq;usin...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息