private void BuildSerial(ExtendedDataEntity[] entryDataes)
        {
            List <long> col = (from s in entryDataes
                               from ss in s.DataEntity["FEntity_Link"] as DynamicObjectCollection
                               select ss.GetDynamicObjectItemValue <long>("SId", 0L)).Distinct <long>().ToList <long>();

            if (!col.IsEmpty <long>())
            {
                IEnumerable <DynamicObject> purSNInfo = Kingdee.K3.MFG.App.AppServiceContext.GetService <IInspectSrcService>().GetPurSNInfo(base.Context, col);
                if (purSNInfo.IsEmpty <DynamicObject>())
                {
                    foreach (ExtendedDataEntity entity in entryDataes)
                    {
                        entity.DataEntity.SetDynamicObjectItemValue("SNUnitID_Id", 0);
                        entity.DataEntity.SetDynamicObjectItemValue("SNUnitID", null);
                    }
                }
                else
                {
                    Dictionary <long, IGrouping <long, DynamicObject> > dictionary = (from g in purSNInfo
                                                                                      where g.GetDynamicValue <long>("FIBENTRYID", 0L) <= 0L
                                                                                      group g by g.GetDynamicValue <long>("FENTRYID", 0L)).ToDictionary <IGrouping <long, DynamicObject>, long>(d => d.Key);
                    FormMetadata metadata = (FormMetadata)Kingdee.K3.MFG.App.AppServiceContext.MetadataService.Load(base.Context, "QM_InspectBill", true);
                    Entity       entity2  = metadata.BusinessInfo.GetEntity("FEntity");
                    foreach (ExtendedDataEntity entity3 in entryDataes)
                    {
                        DynamicObject           dataEntity = entity3.DataEntity;
                        DynamicObjectCollection objects    = dataEntity.GetDynamicValue <DynamicObjectCollection>("FEntity_Link", null);
                        dataEntity.GetDynamicValue <long>("SrcEntryId", 0L);
                        DynamicObjectCollection source = dataEntity.GetDynamicValue <DynamicObjectCollection>("PolicyDetail", null);
                        DynamicObject           obj3   = source.First <DynamicObject>() as DynamicObject;
                        List <DynamicObject>    list2  = new List <DynamicObject>();
                        foreach (DynamicObject obj4 in objects)
                        {
                            long key = obj4.GetDynamicValue <long>("SId", 0L);
                            IGrouping <long, DynamicObject> grouping = null;
                            if (dictionary.TryGetValue(key, out grouping))
                            {
                                foreach (DynamicObject obj5 in grouping)
                                {
                                    list2.Add(obj5);
                                }
                            }
                        }
                        if (list2.All <DynamicObject>(a => a.GetDynamicValue <long>("FSERIALID", 0L) <= 0L))
                        {
                            dataEntity.SetDynamicObjectItemValue("SNUnitID_Id", 0);
                            dataEntity.SetDynamicObjectItemValue("SNUnitID", null);
                        }
                        else
                        {
                            source.Clear();
                            List <DynamicObject> list3 = (from s in list2
                                                          orderby s.GetDynamicValue <string>("FSERIALNO", null)
                                                          select s).ToList <DynamicObject>();
                            List <DynamicObject> list4 = (from s in list3
                                                          where !s.GetDynamicValue <string>("FSERIALNO", null).IsNullOrEmptyOrWhiteSpace()
                                                          select s).ToList <DynamicObject>();
                            List <DynamicObject> collection = (from s in list3
                                                               where s.GetDynamicValue <string>("FSERIALNO", null).IsNullOrEmptyOrWhiteSpace()
                                                               select s).ToList <DynamicObject>();
                            list4.AddRange(collection);
                            int           num2         = 1;
                            DynamicObject baseUnitInfo = dataEntity.GetDynamicValue <DynamicObject>("BaseUnitId", null);
                            DynamicObject unitInfo     = dataEntity.GetDynamicValue <DynamicObject>("SNUnitID", null);
                            foreach (DynamicObject obj8 in list4)
                            {
                                DynamicObject dynamicObject = obj3 as DynamicObject;
                                dynamicObject.SetDynamicObjectItemValue("PolicyQty", 1);
                                decimal num3 = MFGQtyConvertUtil.getToBasePrecisionQty(base.Context, dynamicObject.GetDynamicValue <long>("PolicyMaterialId_Id", 0L), unitInfo, baseUnitInfo, 1M);
                                dynamicObject.SetDynamicObjectItemValue("BasePolicyQty", num3);
                                dynamicObject.SetDynamicObjectItemValue("Seq", num2++);
                                if (obj8.GetDynamicValue <int>("FSERIALID", 0) != 0)
                                {
                                    dynamicObject.SetDynamicObjectItemValue("SerialId_Id", obj8.GetDynamicValue <int>("FSERIALID", 0));
                                }
                                source.Add(dynamicObject);
                            }
                        }
                    }
                    Kingdee.K3.MFG.App.AppServiceContext.DBService.LoadReferenceObject(base.Context, (from s in entryDataes select s.DataEntity).ToArray <DynamicObject>(), entity2.DynamicObjectType, true);
                    foreach (ExtendedDataEntity entity4 in entryDataes)
                    {
                        DynamicObject obj10 = entity4.DataEntity;
                        DynamicObject obj11 = obj10.GetDynamicValue <DynamicObject>("BaseUnitId", null);
                        DynamicObject obj12 = obj10.GetDynamicValue <DynamicObject>("SNUnitID", null);
                        if (!obj12.IsNullOrEmpty())
                        {
                            DynamicObjectCollection objects3 = obj10.GetDynamicValue <DynamicObjectCollection>("PolicyDetail", null);
                            decimal num4 = MFGQtyConvertUtil.getToBasePrecisionQty(base.Context, objects3.FirstOrDefault <DynamicObject>().GetDynamicValue <long>("PolicyMaterialId_Id", 0L), obj12, obj11, 1M);
                            foreach (DynamicObject obj13 in objects3)
                            {
                                obj13.SetDynamicObjectItemValue("BasePolicyQty", num4);
                            }
                        }
                    }
                }
            }
        }