コード例 #1
0
        /// <summary>
        /// 关联发货明细批量新增发货明细。
        /// </summary>
        /// <param name="ctx">上下文对象。</param>
        /// <param name="dataArray">发货明细关联发货通知数据实体数组。</param>
        /// <returns>返回新建保存事务结果。</returns>
        public IOperationResult CreateNewBillsFromInNoticeEntities(Context ctx, DynamicObjectCollection dataArray)
        {
            //取默认转换规则。
            var rule = ConvertServiceHelper.GetConvertRules(ctx, "BAH_WMS_Pickup", "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();



            //调用上传操作,将暂存、保存、提交、审核操作放置在同一事务中执行。
            return(inDetailDataObjects.DoNothing(ctx, inDetailBusinessInfo, "Upload"));
        }//end method
コード例 #2
0
        ///// <summary>
        ///// 关联到货通知新增收货明细。
        ///// </summary>
        ///// <param name="ctx">上下文对象。</param>
        ///// <param name="data">收货明细关联到货通知数据实体。</param>
        ///// <returns>返回新建保存事务结果。</returns>s
        //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 <PutDetailLinkInDetailDto.PutDetailEntryLinkInNotice> dataArray)
        {
            //取默认转换规则。
            var rule = ConvertServiceHelper.GetConvertRules(ctx, "BAH_WMS_Inbound", "BAH_WMS_Putaway")
                       .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

                        var item = sources.ElementAt(i);
                        inDetailDynamicFormView.UpdateValue("FFromTrackNo", rowIndex, item.FromTrackNo);
                        inDetailDynamicFormView.UpdateValue("FToTrackNo", rowIndex, item.ToTrackNo);
                        inDetailDynamicFormView.SetItemValueByID("FToLocId", item.ToLocId, rowIndex);
                        if (item.ToAvgCty == 0)
                        {
                            inDetailDynamicFormView.UpdateValue("FFromCty", rowIndex, item.ToCty);
                            inDetailDynamicFormView.SetItemValueByID("FFromUnitId", item.ToUnitId, rowIndex);
                            inDetailDynamicFormView.UpdateValue("FFromQty", rowIndex, item.ToQty);
                        }
                        else
                        {
                            inDetailDynamicFormView.UpdateValue("FFromAvgCty", rowIndex, item.ToAvgCty);
                            inDetailDynamicFormView.SetItemValueByID("FFromUnitId", item.ToUnitId, rowIndex);
                            inDetailDynamicFormView.UpdateValue("FFromQty", rowIndex, item.ToQty);
                        }
                        //inDetailDynamicFormView.SetItemValueByID("FStockId", item.StockId, rowIndex);
                        //inDetailDynamicFormView.SetItemValueByID("FStockPlaceId", item.StockPlaceId, rowIndex);
                        //inDetailDynamicFormView.UpdateValue("FLotNo", rowIndex, item.BatchNo);
                        //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
コード例 #3
0
        /// <summary>
        /// 根据单据唯一标识下推单据
        /// </summary>
        private void PushFormByFormId()
        {
            string status = this.View.BillModel.GetValue("FDocumentStatus").ToString();

            if (status == "Z")
            {
                return;
            }
            string formId       = this.View.BillView.GetFormId();
            string targetFormId = "k0c6b452fa8154c4f8e8e5f55f96bcfac"; // 个人资金
            var    rules        = ConvertServiceHelper.GetConvertRules(this.View.Context, formId, targetFormId);
            var    rule         = rules.FirstOrDefault(t => t.IsDefault);
            string fid          = this.View.BillModel.GetPKValue().ToString();

            ListSelectedRow[] selectedRows;
            if (formId == "k0c30c431418e4cf4a60d241a18cb241c") // 出差申请
            {
                int count = this.View.BillModel.GetEntryRowCount("FEntity");
                selectedRows = new ListSelectedRow[count];
                for (int i = 0; i < count; i++)
                {
                    string entryId = this.View.BillModel.GetEntryPKValue("FEntryID", i).ToString();
                    selectedRows[i] = new ListSelectedRow(fid, entryId, i, formId);
                }
            }
            else
            {
                ListSelectedRow row = new ListSelectedRow(fid, string.Empty, 0, formId);
                selectedRows = new ListSelectedRow[] { row };
            }

            // 调用下推服务,生成下游单据数据包
            ConvertOperationResult operationResult = null;
            PushArgs pushArgs = new PushArgs(rule, selectedRows)
            {
                TargetBillTypeId = "",
                TargetOrgId      = 0,
            };

            try
            {
                //执行下推操作,并获取下推结果
                operationResult = ConvertServiceHelper.Push(this.View.Context, pushArgs, OperateOption.Create());
            }
            catch (KDExceptionValidate ex)
            {
                this.View.ShowErrMessage(ex.Message, ex.ValidateString);
                return;
            }
            catch (Exception ex)
            {
                this.View.ShowErrMessage(ex.Message);
                return;
            }

            // 获取生成的目标单据数据包
            DynamicObject[] objs = operationResult.TargetDataEntities.Select(p => p.DataEntity).ToArray();
            // 读取目标单据元数据
            var           targetBillMeta = MetaDataServiceHelper.Load(this.View.Context, targetFormId) as FormMetadata;
            OperateOption option         = OperateOption.Create();

            // 忽略全部需要交互性质的提示
            option.SetIgnoreWarning(true);
            // 暂存数据
            var    saveResult = BusinessDataServiceHelper.Draft(this.View.Context, targetBillMeta.BusinessInfo, objs, option);
            string targetId   = saveResult.SuccessDataEnity.Select(item => item["Id"].ToString()).Distinct().FirstOrDefault();

            // 打开目标单据
            if (targetId != null)
            {
                MobileShowParameter param = new MobileShowParameter();
                param.Caption            = "个人资金申请";
                param.FormId             = "ora_GRZJJZ";
                param.PKey               = targetId;
                param.ParentPageId       = this.View.PageId;
                param.Status             = OperationStatus.EDIT;
                param.OpenStyle.ShowType = ShowType.Default;

                this.View.ShowForm(param);
            }
        }