Exemplo n.º 1
0
        /// <summary>
        /// 入库日期校验
        /// </summary>
        /// <param name="date"></param>
        /// <param name="linkData"></param>
        private string dateValitor(DateTime date, DynamicObjectCollection linkData)
        {
            string billNo = "";
            string sql    = string.Format("select FDATE,FBILLNO from T_PUR_Receive where FID in ({0})", string.Join(",", linkData.Select(s => Convert.ToInt32(s["SBillId"]))));
            DynamicObjectCollection reData = DBUtils.ExecuteDynamicObject(this.Context, sql);

            if (reData.Any(a => date < Convert.ToDateTime(a["FDATE"])))
            {
                billNo = Convert.ToString(reData.FirstOrDefault(f => date < Convert.ToDateTime(f["FDATE"]))["FBILLNO"]);
            }
            //foreach (DynamicObject item in linkData)
            //{
            //    int receiveId = Convert.ToInt32(item["SBillId"]);
            //    if (item["sTableName"].ToString() != "T_PUR_ReceiveEntry") continue;//跳过非收料单下推
            //    string sql = string.Format("select FDATE,FBILLNO from T_PUR_Receive where FID={0}", receiveId);
            //    DynamicObjectCollection reData = DBUtils.ExecuteDynamicObject(this.Context, sql);
            //    if (reData == null || reData.Count == 0) continue;
            //    DateTime receiveDate = Convert.ToDateTime(reData[0]["FDATE"]);
            //    if (date < receiveDate)
            //    {
            //        billNo = reData[0]["FBILLNO"].ToString();
            //        break;
            //    }
            //}
            return(billNo);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取物料信息
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="materilNo"></param>
        /// <returns></returns>
        public static Material GetMaterial(Context ctx, string materilNo)
        {
            Material material = null;

            if (!string.IsNullOrWhiteSpace(materilNo))
            {
                string sql = string.Format(@"/*dialect*/  select a.FNumber as FMaterialId,a.F_HS_IsOil,d.FNUMBER as F_HS_PRODUCTSTATUS
                                                from T_BD_MATERIAL a 
                                                inner join T_ORG_ORGANIZATIONS b on a.FUSEORGID=b.FORGID 
											    inner join T_BAS_ASSISTANTDATAENTRY_L c ON a.F_HS_PRODUCTSTATUS=c.FENTRYID
                                                inner join T_BAS_ASSISTANTDATAENTRY d ON c.FentryID=d.FentryID
                                                where b.FNUMBER='100' 
											    and a.FNUMBER not like '99.%'
											    and a.FNUMBER = '{0}'"                                            , materilNo);

                DynamicObjectCollection objs = GetObjects(ctx, sql);

                if (objs != null && objs.Count > 0)
                {
                    DynamicObject obj = objs.FirstOrDefault();

                    if (obj != null)
                    {
                        material                          = new Material();
                        material.FNumber                  = GetFieldValue(obj, "FMaterialId");
                        material.F_HS_IsOil               = GetFieldValue(obj, "F_HS_IsOil");
                        material.F_HS_PRODUCTSTATUS       = GetFieldValue(obj, "F_HS_PRODUCTSTATUS");
                        material.F_HS_DropShipOrderPrefix = GetFieldValue(obj, "F_HS_DropShipOrderPrefix");
                        return(material);
                    }
                }
            }

            return(material);
        }
Exemplo n.º 3
0
        public override void AfterBarItemClick(AfterBarItemClickEventArgs e)
        {
            base.AfterBarItemClick(e);

            /*因为上游单据下推收货通知、发货通知,生成的单据仅处于创建状态,未能自动提交及审核,后来在下游单据的保存操作列表中配了服务插件,实现了自动提交和审核;
             * 手工新增的收货、发货通知,因配置了服务插件,所以在点击保存后,也自动提交和审核了,而当前界面在保存后,审核状态等未做更新,导致操作人员不清楚当前单据状态,
             * 提交及审核按钮状态为激活状态,显示状态不对,所以增加了这个表单插件,保存后,自动刷新当前单据
             */
            if (e.BarItemKey == "tbSplitSave" || e.BarItemKey == "tbSave")
            {
                this.View.Refresh();
                //this.View.Model.SetValue("FRemark", ((DynamicObject)this.View.Model.GetValue("FBillTypeId"))["Name"].ToString()) ;

                if (((DynamicObject)this.View.Model.GetValue("FBillTypeId"))["Name"].ToString() != "简单生产入库-收货")
                {
                    return;
                }
                else
                {
                    //Entity entity = this.View.BusinessInfo.GetEntity("FEntity");
                    int iRowCount = this.View.Model.GetEntryRowCount("FEntity");

                    String EnableCapacity;

                    for (int iRowIndex = 0; iRowIndex < iRowCount; iRowIndex++)
                    {
                        DynamicObject FMaterialId = this.View.Model.GetValue("FMaterialId", iRowIndex) as DynamicObject;

                        DynamicObjectCollection WarehouseSub = FMaterialId["WarehouseSub"] as DynamicObjectCollection;

                        EnableCapacity = WarehouseSub.FirstOrDefault()["EnableCapacity"].ToString();

                        //生成条码信息 %单据编号%物料%跟踪号%数量%
                        String sCodeInfo = "%" + this.View.Model.GetValue("FBillNo", iRowIndex).ToString() + "%" + ((DynamicObject)this.View.Model.GetValue("FMaterialId", iRowIndex))["Number"].ToString() + " %" + this.View.Model.GetValue("FTrackNo", iRowIndex).ToString() + "%";

                        if (EnableCapacity == "False")
                        {
                            //sCodeInfo += this.View.Model.GetValue("FMQty", iRowIndex).ToString() + "%";
                            sCodeInfo += string.Format("{0:######}", double.Parse(this.View.Model.GetValue("FMQty", iRowIndex).ToString())) + "%";
                        }
                        else
                        {
                            //sCodeInfo += this.View.Model.GetValue("FCty", iRowIndex).ToString() + "%";
                            sCodeInfo += string.Format("{0:######}", double.Parse(this.View.Model.GetValue("FCty", iRowIndex).ToString())) + "%";
                        }


                        this.View.Model.SetValue("FPHMXCodeInfo", sCodeInfo, iRowIndex);
                    }
                    this.View.UpdateView();
                    this.View.InvokeFormOperation(FormOperationEnum.Save);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 最后触发:单据转换后事件
        /// </summary>
        /// <param name="e"/>
        public override void AfterConvert(Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args.AfterConvertEventArgs e)
        {
            ExtendedDataEntity[] array = e.Result.FindByEntityKey("FBillHead");

            foreach (ExtendedDataEntity extendedDataEntity in array)
            {
                long orgid = Convert.ToInt32(extendedDataEntity.DataEntity["FPAYORGID"]);
                DynamicObjectCollection dynamicObjectCollection = (extendedDataEntity.DataEntity["PAYBILLENTRY"] as DynamicObjectCollection);

                if (dynamicObjectCollection == null)
                {
                    continue;
                }

                BaseDataField priceListDataField = e.TargetBusinessInfo.GetField("FPriceListId") as BaseDataField;

                foreach (DynamicObject dyentry in dynamicObjectCollection)
                {
                    long materialid = Convert.ToInt32(dyentry["MaterialId_Id"]);

                    List <long> lMaterList = new List <long>();
                    lMaterList.Add(materialid);
                    DynamicObjectCollection bomDataCollection = CommonServiceHelper.GetAcctBookData(this.Context, orgid, materialid, materialid);
                    DynamicObject           listdObjects      = null;
                    if (bomDataCollection == null)
                    {
                        continue;
                    }

                    listdObjects = bomDataCollection.FirstOrDefault();
                    if (listdObjects != null)
                    {
                        decimal amount, Qty, Price;
                        Qty                 = Convert.ToDecimal(dyentry["Qty"]);
                        Price               = Convert.ToDecimal(listdObjects["FPRICE"]);
                        amount              = Qty * Price;
                        dyentry["Amount"]   = amount;
                        dyentry["Price"]    = listdObjects["FPRICE"];
                        dyentry["TaxPrice"] = listdObjects["FPRICE"];
                    }
                }
            }
        }
        public ServiceResult ExecuteService(string data)
        {
            ServiceResult result = new ServiceResult();

            if (data.IsNullOrEmptyOrWhiteSpace())
            {
                return(result);
            }
            String EnableCapacity;
            var    ctx = this.KDContext.Session.AppContext;

            // 检查传入字符串数据
            if (this.IsContextExpired(result))
            {
                return(result);
            }
            // 检查传入参数
            if (string.IsNullOrWhiteSpace(data))
            {
                result.Code    = (int)ResultCode.Fail;
                result.Message = "传入表单数据不能为空!";
                return(result);
            }
            try
            {
                //序列化
                JavaScriptSerializer Serializer = new JavaScriptSerializer();
                //List<InputData> input = JsonConvert.DeserializeObject<List<InputData>>(data);
                List <FinalInputData> FinalInput = new List <FinalInputData>();
                List <InputData>      Input      = Serializer.Deserialize <List <InputData> >(data);
                FinalInput = Input.GroupBy(x => x.FCONTACTID).Select(x => new FinalInputData {
                    FCONTACTID = x.Key, FinalInputDataGroupByContactId = x.ToList()
                }).ToList();

                foreach (var items in FinalInput)
                {
                    var formId      = "BAH_WMS_OutNotice";
                    var metadata    = FormMetaDataCache.GetCachedFormMetaData(ctx, formId);
                    var billView    = metadata.CreateBillView(ctx);
                    var billService = billView.AsDynamicFormViewService();
                    billView.AddNew();

                    billService.SetItemValueByNumber("FBillTypeId", items.FinalInputDataGroupByContactId.FirstOrDefault().FBillTypeNumber, -1);

                    billService.SetItemValueByID("FPHMXTargetFormId", items.FinalInputDataGroupByContactId.FirstOrDefault().FPHMXTargetFormId, -1); //



                    billService.SetItemValueByNumber("FPHMXConvertRuleId", items.FinalInputDataGroupByContactId.FirstOrDefault().FPHMXConvertRuleNumber, -1);

                    billService.SetItemValueByID("FBatchWHId", items.FinalInputDataGroupByContactId.FirstOrDefault().FWHID, -1);
                    billService.SetItemValueByID("FBatchOwnerId", items.FinalInputDataGroupByContactId.FirstOrDefault().FOWNERID, -1);
                    billService.SetItemValueByID("FContactId", items.FCONTACTID, -1);
                    billService.SetItemValueByNumber("FPHMXProduceId", items.FinalInputDataGroupByContactId.FirstOrDefault().FPHMXProduceId, -1);

                    billView.Model.BatchCreateNewEntryRow("FEntity", items.FinalInputDataGroupByContactId.Count());
                    for (int i = 0; i < items.FinalInputDataGroupByContactId.Count(); i++)
                    {
                        JSONObject datas = new JSONObject();
                        billView.Model.SetItemValueByID("FMaterialId", items.FinalInputDataGroupByContactId[i].FMaterialId, i);
                        billView.Model.SetItemValueByID("FLocId", items.FinalInputDataGroupByContactId[i].FFromLocId, i);
                        billView.Model.SetItemValueByID("FTrackNo", items.FinalInputDataGroupByContactId[i].FTrackNo, i);

                        DynamicObject           FMaterialId  = billView.Model.GetValue("FMaterialId", i) as DynamicObject;
                        DynamicObjectCollection WarehouseSub = FMaterialId["WarehouseSub"] as DynamicObjectCollection;
                        EnableCapacity = WarehouseSub.FirstOrDefault()["EnableCapacity"].ToString();
                        billView.Model.SetItemValueByID("FPackageId", items.FinalInputDataGroupByContactId[i].FPackageId, i);
                        //billView.Model.SetValue("FDirectionForQty", input[i].FDirectionForQty, i);
                        if (EnableCapacity == "False")
                        {
                            billView.Model.SetValue("FQty", items.FinalInputDataGroupByContactId[i].FQty, i);
                            billView.Model.SetItemValueByID("FUnitId", items.FinalInputDataGroupByContactId[i].FUnitId, i);
                        }
                        else
                        {
                            if (items.FinalInputDataGroupByContactId[i].FAvgCty == 0)
                            {
                                billView.Model.SetValue("FAvgCty", items.FinalInputDataGroupByContactId[i].FAvgCty, i);
                                billView.Model.SetValue("FCty", items.FinalInputDataGroupByContactId[i].FCty, i);
                            }
                            else
                            {
                                billView.Model.SetValue("FAvgCty", items.FinalInputDataGroupByContactId[i].FAvgCty, i);
                                billView.Model.SetValue("FQty", items.FinalInputDataGroupByContactId[i].FQty, i);
                                billView.Model.SetItemValueByID("FUnitId", items.FinalInputDataGroupByContactId[i].FUnitId, i);
                            }
                        }
                    } //
                    billView.Model.ClearNoDataRow();
                    //var op = billView.Model.DataObject.DoNothing(ctx, billView.BillBusinessInfo, "Upload");
                    bool op  = billView.InvokeFormOperation("Save");
                    bool op1 = billView.InvokeFormOperation("Submit");
                    bool op2 = billView.InvokeFormOperation("Audit");
                    List <OutboundDetailLinkInDetailDto.OutboundDetailEntryLinkInNotice> pushdatas = new List <OutboundDetailLinkInDetailDto.OutboundDetailEntryLinkInNotice>();

                    for (int i = 0; i < items.FinalInputDataGroupByContactId.Count(); i++)
                    {
                        OutboundDetailLinkInDetailDto.OutboundDetailEntryLinkInNotice pushdata = new OutboundDetailLinkInDetailDto.OutboundDetailEntryLinkInNotice();
                        pushdata.SourceEntryId = (long)billView.Model.GetEntryPKValue("FEntity", i);
                        pushdata.PHMXWgt       = items.FinalInputDataGroupByContactId[i].FPHMXWgt;
                        pushdatas.Add(pushdata);
                    }
                    var back = CreateNewBillsFromInNoticeEntities(ctx, pushdatas);
                    //foreach (var entry in billView.Model.)
                    //{

                    //}
                    result.Code    = op2 == true ? 1 : 0;
                    result.Message = op2 == true ? "成功生成" : "生成失败";
                    billView.Close();
                }
            }
            catch (Exception ex)
            {
                result.Code    = (int)ResultCode.Fail;
                result.Message = ex.Message;
                Logger.Error(this.GetType().AssemblyQualifiedName, ex.Message, ex);
            }
            return(result);
        }
Exemplo n.º 6
0
        public ServiceResult ExecuteService(string data)
        {
            ServiceResult result = new ServiceResult();
            String        EnableCapacity;

            if (data.IsNullOrEmptyOrWhiteSpace())
            {
                return(result);
            }

            var ctx = this.KDContext.Session.AppContext;

            // 检查传入字符串数据
            if (this.IsContextExpired(result))
            {
                return(result);
            }
            // 检查传入参数
            if (string.IsNullOrWhiteSpace(data))
            {
                result.Code    = (int)ResultCode.Fail;
                result.Message = "传入表单数据不能为空!";
                return(result);
            }
            try
            {
                //序列化
                JavaScriptSerializer Serializer = new JavaScriptSerializer();
                List <Ajust>         input      = Serializer.Deserialize <List <Ajust> >(data);
                //
                var formId      = "BAH_WMS_Move";
                var metadata    = FormMetaDataCache.GetCachedFormMetaData(ctx, formId);
                var billView    = metadata.CreateBillView(ctx);
                var billService = billView.AsDynamicFormViewService();
                billView.AddNew();
                var items = input[0];
                billService.SetItemValueByID("FBatchFromWHId", items.FFROMWHID, -1);
                billService.SetItemValueByID("FBatchFromOwnerId", items.FFROMOWNERID, -1);
                //
                billView.Model.ClearNoDataRow();
                billView.Model.BatchCreateNewEntryRow("FEntity", input.Count());
                for (int i = 0; i < input.Count(); i++)
                {
                    billView.Model.SetItemValueByID("FMaterialId", input[i].FMaterialId, i);
                    DynamicObject FMaterialId = billView.Model.GetValue("FMaterialId", i) as DynamicObject;
                    if (FMaterialId == null)
                    {
                        result.Code    = (int)ResultCode.Fail;
                        result.Message = "该物料不存在或已禁用!";
                        return(result);
                    }
                    else
                    {
                        DynamicObjectCollection WarehouseSub = FMaterialId["WarehouseSub"] as DynamicObjectCollection;
                        EnableCapacity = WarehouseSub.FirstOrDefault()["EnableCapacity"].ToString();
                    }

                    billView.Model.SetValue("FFromTrackNo", input[i].FFROMTrackNo, i);
                    billView.Model.SetItemValueByID("FFromLocId", input[i].FFROMLocId, i);
                    billView.Model.SetItemValueByID("FToLocId", input[i].FTOLocId, i);
                    billView.Model.SetValue("FToTrackNo", input[i].FTOTrackNo, i);
                    //billView.Model.SetItemValueByID("FPackageId",input[i].FPackageId, i);
                    billView.Model.SetItemValueByID("FFromPackageId", input[i].FFromPackageId, i);
                    billView.Model.SetValue("FExpPeriod", input[i].FExpPeriod, i);
                    billView.Model.SetValue("FExpUnit", input[i].FExpUnit, i);
                    if (EnableCapacity == "False")
                    {
                        billView.Model.SetValue("FFromQty", input[i].FFromQty, i);
                        billView.Model.SetItemValueByID("FFromUnitId", input[i].FFromUnitId, i);
                    }
                    else
                    {
                        if (input[i].FFromAvgCty > 0)
                        {
                            billView.Model.SetValue("FFromAvgCty", input[i].FFromAvgCty, i);
                            billView.Model.SetValue("FFromQty", input[i].FFromQty, i);
                            billView.Model.SetItemValueByID("FFromUnitId", input[i].FFromUnitId, i);
                        }
                        else
                        {
                            billView.Model.SetValue("FFromAvgCty", input[i].FFromAvgCty, i);
                            billView.Model.SetValue("FFromQty", input[i].FFromQty, i);
                            billView.Model.SetValue("FFromCty", input[i].FFromCty, i);
                        }
                    }
                    billView.Model.SetValue("FLotNo", input[i].FLotNo, i);
                    if (input[i].FProduceDate != null)
                    {
                        billView.Model.SetValue("FProduceDate", input[i].FProduceDate, i);
                    }
                }
                billView.Model.ClearNoDataRow();
                var op = billView.Model.DataObject.DoNothing(ctx, billView.BillBusinessInfo, "Upload");
                result.Code    = op.IsSuccess ? (int)ResultCode.Success : (int)ResultCode.Fail;
                result.Message = op.GetResultMessage();
            }
            catch (Exception ex)
            {
                result.Code    = (int)ResultCode.Fail;
                result.Message = ex.Message;
                Logger.Error(this.GetType().AssemblyQualifiedName, ex.Message, ex);
            }
            return(result);
        }
Exemplo n.º 7
0
        public override void BeforeExecuteOperationTransaction(BeforeExecuteOperationTransaction e)
        {
            base.BeforeExecuteOperationTransaction(e);

            IEnumerable <ExtendedDataEntity> extendedDataEntities = e.SelectedRows;

            foreach (ExtendedDataEntity extendedDataEntity in extendedDataEntities)
            {
                DynamicObject billInfo = extendedDataEntity.DataEntity;

                DynamicObject bomInfor = billInfo["FBOMID"] as DynamicObject;
                if (bomInfor == null)
                {
                    continue;
                }

                DynamicObjectCollection subItemInfo = bomInfor["TreeEntity"] as DynamicObjectCollection;
                if (subItemInfo == null || subItemInfo.Count == 0)
                {
                    continue;
                }

                DynamicObjectCollection entryRows = billInfo["PPBomEntry"] as DynamicObjectCollection;
                if (entryRows == null || entryRows.Count == 0)
                {
                    continue;
                }

                foreach (var item in entryRows)
                {
                    decimal qty = Convert.ToDecimal(item["FJNUnitEnzymes"]);
                    if (qty > 0)
                    {
                        continue;
                    }

                    var subQty = subItemInfo.FirstOrDefault(f => f["MATERIALIDCHILD_Id"].ToString() == item["MaterialID_Id"].ToString() &&
                                                            f["AuxPropID_Id"].ToString() == item["AuxPropId_Id"].ToString());
                    if (subQty != null)
                    {
                        var jnqty  = Convert.ToDecimal(subQty["FJNCompanyEA"]);
                        var bomQty = Convert.ToDecimal(item["F_JN_BOMQty"]);

                        item["FJNUnitEnzymes"]    = jnqty;
                        item["F_JN_EnzymeSumQty"] = jnqty * bomQty;

                        continue;
                    }

                    subQty = subItemInfo.FirstOrDefault(f => f["MATERIALIDCHILD_Id"].ToString() == item["MaterialID_Id"].ToString());
                    if (subQty != null)
                    {
                        var jnqty  = Convert.ToDecimal(subQty["FJNCompanyEA"]);
                        var bomQty = Convert.ToDecimal(item["F_JN_BOMQty"]);

                        item["FJNUnitEnzymes"]    = jnqty;
                        item["F_JN_EnzymeSumQty"] = jnqty * bomQty;
                    }
                }
            }
        }
Exemplo n.º 8
0
        //public IOperationResult CreateNewBillFromInNoticeEntry(Context ctx, PutDetailLinkInDetailDto.InDetailEntryLinkInNotice data)
        //{
        //    return this.CreateNewBillsFromInNoticeEntities(ctx, new PutDetailLinkInDetailDto.InDetailEntryLinkInNotice[] { data });
        //}//end method
        /// <summary>
        /// 关联发货明细批量新增拣货明细。
        /// </summary>
        /// <param name="ctx">上下文对象。</param>
        /// <param name="dataArray">拣货明细关联发货通知数据实体数组。</param>
        /// <returns>返回新建保存事务结果。</returns>
        public IOperationResult CreateNewBillsFromInNoticeEntities(Context ctx, IEnumerable <PickDetailLinkInDetailDto.PickDetailEntryLinkInNotice> dataArray)
        {
            //取默认转换规则。
            var rule = ConvertServiceHelper.GetConvertRules(ctx, "BAH_WMS_OutNotice", "BAH_WMS_Outbound")
                       .Where(element => element.IsDefault)
                       .FirstOrDefault();

            if (rule == null)
            {
                throw new KDBusinessException("RuleNotFound", "未找到发货通知至发货明细之间,启用的转换规则,无法自动下推!");
            }

            ListSelectedRowCollection listSelectedRowCollection = new ListSelectedRowCollection();

            foreach (var data in dataArray)
            {
                var row = new ListSelectedRow(data.SourceBillId.ToString(), data.SourceEntryId.ToString(), 0, rule.SourceFormId)
                {
                    EntryEntityKey = "FEntity"
                };
                listSelectedRowCollection.Add(row);
            }//end foreach

            //将需要传入的数量作为参数传递进下推操作,并执行下推操作。
            PushArgs args = new PushArgs(rule, listSelectedRowCollection.ToArray());
            var      inDetailDataObjects = ConvertServiceHelper.Push(ctx, args)
                                           .Adaptive(result => result.ThrowWhenUnSuccess(op => op.GetResultMessage()))
                                           .Adaptive(result => result.TargetDataEntities.Select(entity => entity.DataEntity).ToArray());

            //修改明细行数据包。
            var inDetailMetadata        = FormMetaDataCache.GetCachedFormMetaData(ctx, rule.TargetFormId);
            var inDetailBillView        = inDetailMetadata.CreateBillView(ctx);
            var inDetailDynamicFormView = inDetailBillView as IDynamicFormViewService;
            var inDetailBusinessInfo    = inDetailMetadata.BusinessInfo;
            var inDetailEntryEntity     = inDetailBusinessInfo.GetEntity("FEntity");
            var inDetailEntryLink       = inDetailBusinessInfo.GetForm().LinkSet.LinkEntitys.FirstOrDefault();

            foreach (var data in inDetailDataObjects)
            {
                //新建并加载已有数据包。
                inDetailBillView.AddNew(data);

                //逐行检索,并关联复制行。
                var entryCollection  = inDetailBillView.Model.GetEntityDataObject(inDetailEntryEntity);
                var entryMirrorArray = entryCollection.ToArray();
                foreach (var entry in entryMirrorArray)
                {
                    var sources = dataArray.Join(entry.Property <DynamicObjectCollection>(inDetailEntryLink.Key),
                                                 left => new { SourceEntryId = left.SourceEntryId, SourceBillId = left.SourceBillId },
                                                 right => new { SourceEntryId = right.Property <long>("SId"), SourceBillId = right.Property <long>("SBillId") },
                                                 (left, right) => left).ToArray();
                    for (int i = 0; i < sources.Count(); i++)
                    {
                        var entryIndex = entryCollection.IndexOf(entry);
                        var rowIndex   = entryIndex + i;
                        if (i > 0)
                        {
                            inDetailBillView.Model.CopyEntryRow("FEntity", entryIndex, rowIndex, true);
                        }//end if
                        DynamicObject           FMaterialId  = inDetailBillView.Model.GetValue("FMaterialId", rowIndex) as DynamicObject;
                        DynamicObjectCollection WarehouseSub = FMaterialId["WarehouseSub"] as DynamicObjectCollection;
                        string EnableCapacity = WarehouseSub.FirstOrDefault()["EnableCapacity"].ToString();
                        var    item           = sources.ElementAt(i);
                        inDetailDynamicFormView.SetItemValueByID("FPHMXWgt", item.PHMXWgt, rowIndex);


                        inDetailDynamicFormView.SetItemValueByID("FLocId", item.FromLocId, rowIndex);


                        if (EnableCapacity == "False")
                        {
                            inDetailDynamicFormView.SetItemValueByID("FUnitId", item.ToUnitId, rowIndex);
                            inDetailDynamicFormView.UpdateValue("FQty", rowIndex, item.ToQty);
                        }
                        else
                        {
                            if (item.ToAvgCty == 0)
                            {
                                inDetailDynamicFormView.UpdateValue("FCty", rowIndex, item.ToCty);
                            }
                            else
                            {
                                inDetailDynamicFormView.UpdateValue("FAvgCty", rowIndex, item.ToAvgCty);
                                inDetailDynamicFormView.SetItemValueByID("FUnitId", item.ToUnitId, rowIndex);
                                inDetailDynamicFormView.UpdateValue("FQty", rowIndex, item.ToQty);
                            }
                        }
                        //inDetailDynamicFormView.SetItemValueByID("FToUnitId", item.ToUnitId, rowIndex);
                        //inDetailDynamicFormView.UpdateValue("FToQty", rowIndex, item.ToQty);
                        //inDetailDynamicFormView.SetItemValueByID("FStockId", item.StockId, rowIndex);
                        //inDetailDynamicFormView.SetItemValueByID("FStockPlaceId", item.StockPlaceId, rowIndex);

                        //inDetailDynamicFormView.UpdateValue("FProduceDate", rowIndex, item.KFDate);
                        //inDetailDynamicFormView.UpdateValue("FExpPeriod", rowIndex, item.ExpPeriod);
                        //inDetailDynamicFormView.UpdateValue("FSerialNo", rowIndex, item.SerialNo);

                        //inDetailDynamicFormView.UpdateValue("FTrayNo", rowIndex, item.TrayNo);
                        //inDetailDynamicFormView.UpdateValue("FEntryRemark", rowIndex, item.Remark);
                    } //end for
                }     //end foreach
            }         //end foreach

            //调用上传操作,将暂存、保存、提交、审核操作放置在同一事务中执行。
            return(inDetailDataObjects.DoNothing(ctx, inDetailBusinessInfo, "Upload"));
        }//end method
        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);
                            }
                        }
                    }
                }
            }
        }