예제 #1
0
        //获取源单F_JN_Lot_Text
        private void GetSrcData(DynamicObjectCollection srcRows)
        {
            List <long> srcFIds = new List <long>();

            foreach (DynamicObject srcRow in srcRows)
            {
                if (srcRow == null)
                {
                    continue;
                }
                srcFIds.Add(Convert.ToInt64(srcRow["FEntity_FEntryID"]));
            }
            if (srcFIds.Count <= 0)
            {
                return;
            }
            string sql = string.Format(@" SELECT FENTRYID,F_JN_Lot_Text FROM T_PUR_ReqEntry  
                                          WHERE FENTRYID IN ({0})", string.Join <long>(",", srcFIds));
            DynamicObjectCollection dyn = DBUtils.ExecuteDynamicObject(this.Context, sql);

            if (dyn == null || dyn.Count <= 0)
            {
                return;
            }
            dicSrcLot = dyn.ToDictionary <DynamicObject, long, DynamicObject>(p => Convert.ToInt64(p["FENTRYID"]), p => p);
        }
예제 #2
0
        public override void AfterConvert(Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args.AfterConvertEventArgs e)
        {
            ExtendedDataEntity[] dataEntits    = e.Result.FindByEntityKey("FBillHead"); //取单据数据包
            List <long>          lstMoEntryIds = new List <long>();                     //生产订单分录id

            if (dataEntits != null && dataEntits.Count() > 0)
            {
                foreach (var entity in dataEntits)
                {
                    DynamicObjectCollection entry = entity["Entity"] as DynamicObjectCollection;
                    if (entry == null || entry.Count <= 0)
                    {
                        continue;
                    }
                    foreach (var item in entry)
                    {
                        lstMoEntryIds.Add(Convert.ToInt64(item["MoEntryId"]));//生产订单分录Id
                    }
                }
            }

            if (lstMoEntryIds.Count > 0)
            {
                Entity enitty = e.TargetBusinessInfo.GetEntity("FEntity");
                List <DynamicObject> lstEntry = new List <DynamicObject>();
                string sql = string.Format(@" SELECT DISTINCT FENTRYID,FLOT,FLOT_TEXT FROM T_PRD_MOENTRY 
                           WHERE FENTRYID IN ({0})", string.Join <long>(",", lstMoEntryIds));
                DynamicObjectCollection dyn = DBUtils.ExecuteDynamicObject(this.Context, sql);
                if (dyn != null && dyn.Count() > 0)
                {
                    Dictionary <long, DynamicObject> dicLot = dyn.ToDictionary <DynamicObject, long, DynamicObject>(p => Convert.ToInt64(p["FENTRYID"]), p => p);
                    if (dicLot.Count() > 0)
                    {
                        foreach (var entity in dataEntits)
                        {
                            DynamicObjectCollection entry = entity["Entity"] as DynamicObjectCollection;
                            if (entry == null || entry.Count <= 0)
                            {
                                continue;
                            }
                            foreach (var item in entry)
                            {
                                long entryId = Convert.ToInt64(item["MoEntryId"]);//生产订单分录Id
                                if (dicLot.ContainsKey(entryId))
                                {
                                    DynamicObject lot = dicLot[entryId];
                                    item["F_JN_MaterialLot_Id"]   = Convert.ToInt64(lot["FLOT"]);
                                    item["F_JN_MaterialLot_Text"] = Convert.ToString(lot["FLOT_TEXT"]);
                                    lstEntry.Add(item);
                                }
                            }
                        }
                    }
                }
                if (lstEntry.Count() > 0)
                {
                    Kingdee.BOS.Contracts.ServiceFactory.GetService <IDBService>(this.Context).LoadReferenceObject(base.Context, lstEntry.ToArray(), enitty.DynamicObjectType, false);
                }
            }

            base.AfterConvert(e);
        }