Esempio n. 1
0
        public void BuildF8(ExtensionItem extension)
        {
            BaseDataField propField = (BaseDataField)ObjectUtils.CreateCopy(modelF8Field);

            propField.DynamicProperty = null;
            propField.ChildrenFields.Clear();
            propField.EntityKey = currEntityKey;
            propField.Entity    = currEntity;
            if (propField.UpdateActions != null)
            {
                propField.UpdateActions.Clear();
            }

            // 必改属性,涉及到数据的加载
            propField.Key                    = extension.Key;
            propField.FieldName              = extension.Key.ToUpperInvariant();
            propField.PropertyName           = extension.Key;
            propField.Name                   = new LocaleValue(extension.Name);
            propField.LookUpObject.FormId    = extension.F8FormId;
            propField.LookUpObject.TableName = extension.F8TableName;

            FormMetadata materialMetada =
                MetaDataServiceHelper.Load(this.Context, extension.F8FormId) as FormMetadata;


            propField.RefFormDynamicObjectType = materialMetada.BusinessInfo.GetDynamicObjectType();
            propField.TableName = extension.F8TableName;
            //  propField.RefFormDynamicObjectType = new DynamicObjectType(extension.F8FormId);

            _currBusinessInfo.Add(propField);
        }
Esempio n. 2
0
 public override void BeginOperationTransaction(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeginOperationTransactionArgs e)
 {
     base.BeginOperationTransaction(e);
     if (e.DataEntitys == null || e.DataEntitys.Count() <= 0)
     {
         return;
     }
     foreach (DynamicObject data in e.DataEntitys)
     {
         string        FCONTACTUNITTYPE = Convert.ToString(data["CONTACTUNITTYPE"]);
         int           FCONTACTUNIT_Id  = Convert.ToInt32(data["CONTACTUNIT_Id"]);
         DynamicObject FCONTACTUNIT     = data["CONTACTUNIT"] as DynamicObject;
         DynamicObject FJNFistSaler     = data["FJNFistSaler"] as DynamicObject;
         if (FCONTACTUNITTYPE == "BD_Customer" && FCONTACTUNIT != null && FJNFistSaler == null)
         {
             FormMetadata  formMetadata = MetaDataServiceHelper.Load(this.Context, "BD_Customer") as FormMetadata;
             DynamicObject CustObject   = BusinessDataServiceHelper.LoadSingle(
                 this.Context,
                 FCONTACTUNIT_Id,
                 formMetadata.BusinessInfo.GetDynamicObjectType());
             if (CustObject != null)
             {
                 DynamicObject Saler = CustObject["JN_SalesId"] as DynamicObject;
                 if (Saler != null)
                 {
                     int    Saler_Id = Convert.ToInt32(Saler["id"]);
                     int    billid   = Convert.ToInt32(data["id"]);
                     string strSQL   = string.Format("/*dialect*/update T_AR_RECEIVEBILL set FJNFISTSALER ={0} where fid={1}", Saler_Id, billid);
                     DBUtils.Execute(this.Context, strSQL);
                 }
             }
         }
         //AppServiceContext.SaveService.Save(this.Context, formMetadata.BusinessInfo, dataObjects);
     }
 }
Esempio n. 3
0
        public override void BeforeExecuteOperationTransaction(BeforeExecuteOperationTransaction e)
        {
            base.BeforeExecuteOperationTransaction(e);

            if (e.DataEntitys.Count() < 1)
            {
                return;
            }
            var dataEntities = e.DataEntitys.ToArray();

            foreach (DynamicObject dataEntry in dataEntities)
            {
                DynamicObject BillEntry = dataEntry["BillEntry"].AsType <DynamicObjectCollection>().First();
                //获取收货通知数据
                string OrginBillNo  = BillEntry["OriginBillNo"].ToString();
                string OriginFormId = "BAH_WMS_InNotice";

                FormMetadata          meta       = MetaDataServiceHelper.Load(this.Context, OriginFormId) as FormMetadata;
                QueryBuilderParemeter queryParam = new QueryBuilderParemeter();
                queryParam.FormId       = OriginFormId;
                queryParam.BusinessInfo = meta.BusinessInfo;

                queryParam.FilterClauseWihtKey = string.Format(" {0} = '{1}' ", meta.BusinessInfo.GetBillNoField().Key, OrginBillNo);

                var objs = BusinessDataServiceHelper.Load(this.Context, meta.BusinessInfo.GetDynamicObjectType(), queryParam);

                if (objs[0]["FBAHGenTargetStatus"].ToString().Equals('B') == true)
                {
                    throw new Exception(string.Format("编号为{0}的收货通知已生成目标单据,不允许反审核!", OrginBillNo));
                }
            }
        }
Esempio n. 4
0
        public DynamicObject GetSimpleExtensionByNumber(String number)
        {
            FormMetadata meta = MetaDataServiceHelper.Load(context, Constant.FormID.WJ_Extension) as FormMetadata;

            // 构建查询参数,设置过滤条件
            QueryBuilderParemeter queryParam = new QueryBuilderParemeter
            {
                FormId       = Constant.FormID.WJ_Extension,
                BusinessInfo = meta.BusinessInfo,

                FilterClauseWihtKey = string.Format(" {0} = '{1}' ",
                                                    meta.BusinessInfo.GetForm().NumberFieldKey,
                                                    number)
            };

            var bdObjs = BusinessDataServiceHelper.Load(context,
                                                        meta.BusinessInfo.GetDynamicObjectType(),
                                                        queryParam);

            if (bdObjs.Length == 1)
            {
                return(bdObjs.FirstOrDefault());
            }
            else if (bdObjs.Length == 0)
            {
                return(null);
            }
            else
            {
                throw new Exception("编码 " + number + " formId " + Constant.FormID.WJ_Extension + "找到多个数据");
            }
        }
Esempio n. 5
0
 public static ExpTransContext CreateContext(Context ctx, string formId)
 {
     if (string.IsNullOrWhiteSpace(formId))
     {
         return(null);
     }
     return(new ExpTransContext(((FormMetadata)MetaDataServiceHelper.Load(ctx, formId, true)).BusinessInfo));
 }
Esempio n. 6
0
        public DynamicObject installCostRequestPackage(Context ctx, string FormID, Action <IDynamicFormViewService> fillBillPropertys, string BillTypeId = "")
        {
            //IMetaDataService metaService = ServiceHelper.GetService<IMetaDataService>();//元数据服务
            //FormMetadata Meta = metaService.Load(ctx, FormID) as FormMetadata;//获取元数据
            FormMetadata            Meta = MetaDataServiceHelper.Load(ctx, FormID) as FormMetadata;//获取元数据
            Form                    form = Meta.BusinessInfo.GetForm();
            IDynamicFormViewService dynamicFormViewService = (IDynamicFormViewService)Activator.CreateInstance(Type.GetType("Kingdee.BOS.Web.Import.ImportBillView,Kingdee.BOS.Web"));
            // 创建视图加载参数对象,指定各种参数,如FormId, 视图(LayoutId)等
            BillOpenParameter openParam = new BillOpenParameter(form.Id, Meta.GetLayoutInfo().Id);

            openParam.Context      = ctx;
            openParam.ServiceName  = form.FormServiceName;
            openParam.PageId       = Guid.NewGuid().ToString();
            openParam.FormMetaData = Meta;
            openParam.Status       = OperationStatus.ADDNEW;
            openParam.CreateFrom   = CreateFrom.Default;
            // 单据类型
            openParam.DefaultBillTypeId = BillTypeId;
            openParam.SetCustomParameter("ShowConfirmDialogWhenChangeOrg", false);
            // 插件
            List <AbstractDynamicFormPlugIn> plugs = form.CreateFormPlugIns();

            openParam.SetCustomParameter(FormConst.PlugIns, plugs);
            PreOpenFormEventArgs args = new PreOpenFormEventArgs(ctx, openParam);

            foreach (var plug in plugs)
            {
                plug.PreOpenForm(args);
            }
            // 动态领域模型服务提供类,通过此类,构建MVC实例
            IResourceServiceProvider provider = form.GetFormServiceProvider(false);

            dynamicFormViewService.Initialize(openParam, provider);
            IBillView billView = dynamicFormViewService as IBillView;

            ((IBillViewService)billView).LoadData();

            // 触发插件的OnLoad事件:
            // 组织控制基类插件,在OnLoad事件中,对主业务组织改变是否提示选项进行初始化。
            // 如果不触发OnLoad事件,会导致主业务组织赋值不成功
            DynamicFormViewPlugInProxy eventProxy = billView.GetService <DynamicFormViewPlugInProxy>();

            eventProxy.FireOnLoad();
            if (fillBillPropertys != null)
            {
                fillBillPropertys(dynamicFormViewService);
            }
            // 设置FormId
            form = billView.BillBusinessInfo.GetForm();
            if (form.FormIdDynamicProperty != null)
            {
                form.FormIdDynamicProperty.SetValue(billView.Model.DataObject, form.Id);
            }
            return(billView.Model.DataObject);
        }
        private void GetF8Value(string strFormId, string strFieldOfName, string strFieldOfId, string strFilter)
        {
            ListShowParameter param = new ListShowParameter
            {
                FormId         = strFormId,
                MultiSelect    = false,
                IsShowApproved = false,
                IsShowUsed     = true,
                IsLookUp       = true
            };
            FormMetadata metadata     = (FormMetadata)MetaDataServiceHelper.Load(base.Context, strFormId, true);
            BusinessInfo businessInfo = metadata.BusinessInfo;
            //string str = CRMAllocationServiceHelper.GetFilter(base.Context, businessInfo, param.SqlParams);
            string str = CRMAllocationServiceHelper.GetFilter(base.Context, businessInfo);

            if (str.Length > 0)
            {
                if (strFilter.Length > 0)
                {
                    strFilter = strFilter + " AND " + str;
                }
                else
                {
                    strFilter = str;
                }
            }
            param.ListFilterParameter.Filter = strFilter;
            param.PageId       = Guid.NewGuid().ToString();
            param.ParentPageId = base.View.PageId;
            param.ListType     = 2;
            base.View.ShowForm(param, delegate(FormResult result) {
                if (result.ReturnData != null)
                {
                    ListSelectedRowCollection returnData = result.ReturnData as ListSelectedRowCollection;
                    if (returnData.Count != 0)
                    {
                        ListSelectedRow row = returnData[0];
                        this.View.Model.SetValue(strFieldOfId, row.PrimaryKeyValue);
                        this.View.Model.BeginIniti();
                        this.View.Model.SetValue(strFieldOfName, row.Name);
                        this.View.Model.EndIniti();
                        this.View.UpdateView(strFieldOfName);
                        if (strFieldOfName.ToUpperInvariant() == "FCUSTOMERNAME")
                        {
                            this.GetCustInfo(Convert.ToInt64(row.PrimaryKeyValue));
                        }
                        else if (strFieldOfName.ToUpperInvariant() == "FCONTACTNAME")
                        {
                            this.GetContactInfo(Convert.ToInt64(row.PrimaryKeyValue));
                        }
                    }
                }
            });
        }
        private IBillView CreateBillView()
        {
            FormMetadata      meta      = MetaDataServiceHelper.Load(this.Context, "scfg_MaterialConvertRate") as FormMetadata;
            Form              form      = meta.BusinessInfo.GetForm();
            Type              type      = Type.GetType("Kingdee.BOS.Web.Import.ImportBillView,Kingdee.BOS.Web");
            var               billView  = (IDynamicFormViewService)Activator.CreateInstance(type);
            BillOpenParameter openParam = CreateOpenParameter(meta);
            var               provider  = form.GetFormServiceProvider();

            billView.Initialize(openParam, provider);
            return(billView as IBillView);
        }
Esempio n. 9
0
        //创建目标数据对象
        private IBillView CreateBillView(Kingdee.BOS.Context ctx)
        {
            FormMetadata      meta      = MetaDataServiceHelper.Load(ctx, "BOS_ASSISTANTDATA_DETAIL") as FormMetadata;
            Form              form      = meta.BusinessInfo.GetForm();
            Type              type      = Type.GetType("Kingdee.BOS.Web.Import.ImportBillView,Kingdee.BOS.Web");
            var               billView  = (IDynamicFormViewService)Activator.CreateInstance(type);
            BillOpenParameter openParam = CreateOpenParameter(ctx, meta);
            var               provider  = form.GetFormServiceProvider();

            billView.Initialize(openParam, provider);
            return(billView as IBillView);
        }
Esempio n. 10
0
        private IBillView CreateBillView()
        {
            //读取单据的元数据
            FormMetadata meta = MetaDataServiceHelper.Load(this.Context, "kd015e925f51e411b8408c1f8e7fcb066") as FormMetadata;
            Form         form = meta.BusinessInfo.GetForm();
            // 创建用于引入数据的单据view
            Type type     = Type.GetType("Kingdee.BOS.Web.Import.ImportBillView,Kingdee.BOS.Web");
            var  billView = (IDynamicFormViewService)Activator.CreateInstance(type);
            // 开始初始化billView:
            // 创建视图加载参数对象,指定各种参数,如FormId, 视图(LayoutId)等
            BillOpenParameter openParam = CreateOpenParameter(meta);
            // 动态领域模型服务提供类,通过此类,构建MVC实例
            var provider = form.GetFormServiceProvider();

            billView.Initialize(openParam, provider);
            return(billView as IBillView);
        }
Esempio n. 11
0
        public static DynamicObject[] GetDynamicObjects(Context ctx, string formId, string filterClauseWihtKey)
        {
            if (!string.IsNullOrEmpty(formId))
            {
                FormMetadata          metaData       = MetaDataServiceHelper.Load(ctx, formId) as FormMetadata;
                DynamicObjectType     type           = metaData.BusinessInfo.GetDynamicObjectType();
                QueryBuilderParemeter queryParemeter = new QueryBuilderParemeter();
                queryParemeter.FormId = formId;

                if (!string.IsNullOrEmpty(filterClauseWihtKey))
                {
                    queryParemeter.FilterClauseWihtKey = filterClauseWihtKey;
                }

                DynamicObject[] objects = BusinessDataServiceHelper.Load(ctx, type, queryParemeter);
                return(objects);
            }

            return(null);
        }
        /// <summary>
        /// 打开PC的Web页面,暂时不好用
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="FormId"></param>
        /// <param name="pkid"></param>
        /// <returns></returns>
        private IDynamicFormView OpenWebView(Context ctx, string FormId, string pkid = null)
        {
            var          meta = MetaDataServiceHelper.Load(ctx, FormId) as FormMetadata;
            BusinessInfo info = meta.BusinessInfo;
            var          form = info.GetForm();

            BillOpenParameter param = new BillOpenParameter(form.Id, null);

            //param.SetCustomParameter("formID", form.Id);
            //param.SetCustomParameter("status", (pkid != null ? "View" : "AddNew"));
            //param.SetCustomParameter("formID", form.CreateFormPlugIns());
            param.Context               = ctx;
            param.ServiceName           = form.FormServiceName;
            param.PageId                = Guid.NewGuid().ToString();
            param.FormMetaData          = meta;
            param.LayoutId              = param.FormMetaData.GetLayoutInfo().Id;
            param.Status                = pkid != null ? OperationStatus.EDIT : OperationStatus.ADDNEW;
            param.PkValue               = pkid;
            param.CreateFrom            = CreateFrom.Default;
            param.ParentId              = 0;
            param.GroupId               = "";
            param.DefaultBillTypeId     = null;
            param.DefaultBusinessFlowId = null;
            param.SetCustomParameter("ShowConfirmDialogWhenChangeOrg", false);

            //IResourceServiceProvider provider = form.GetFormServiceProvider();
            //IDynamicFormView bv = provider.GetService(typeof(IDynamicFormView)) as IDynamicFormView;
            //(bv as IBillViewService).Initialize(param, provider);
            //(bv as IDynamicFormView).RegisterPlugIn(getFormStatePlugIn);
            Type             type = Type.GetType("Kingdee.BOS.Web.Import.ImportBillView,Kingdee.BOS.Web");
            IDynamicFormView bv   = (IDynamicFormView)Activator.CreateInstance(type);
            var provider          = form.GetFormServiceProvider();

            (bv as IBillViewService).Initialize(param, provider);
            (bv as IBillView).CreateNewModelData();
            if (param.Status != OperationStatus.ADDNEW)
            {
                (bv as IBillViewService).LoadData();
            }
            return(bv);
        }
Esempio n. 13
0
        //创建销售预测变更单
        private void CreateForecastChangeBill()
        {
            //分组集合
            List <string> lstGroups = new List <string>();
            string        sGroup    = string.Empty;

            foreach (DynamicObject lstEntry in lstEntrys)
            {
                sGroup = Convert.ToString(lstEntry["FSaleOrgId_ID"]) + "+" + Convert.ToString(lstEntry["FSaleDeptId_ID"]) + "+" +
                         Convert.ToString(lstEntry["FSaleGroupId_ID"]) + "+" + Convert.ToString(lstEntry["FSalerId_ID"]);
                if (!lstGroups.Contains(sGroup))
                {
                    lstGroups.Add(sGroup);
                }
            }

            //插入数据

            //销售预测变更单的信息
            BusinessInfo businessInfo = ((FormMetadata)MetaDataServiceHelper.Load(this.Context, "JN_YDL_SAL_ForecastChange", true)).BusinessInfo;

            DynamicObject           billHead   = null;
            DynamicObjectCollection billEntrys = null;
            List <DynamicObject>    lstBills   = new List <DynamicObject>();
            List <DynamicObject>    lstSelectEntrys;

            long lSaleOrgId   = 0;
            long lSaleDeptId  = 0;
            long lSaleGroupId = 0;
            long lSalerId     = 0;

            foreach (string lstGroup in lstGroups)
            {
                //单据头
                billHead = businessInfo.GetDynamicObjectType().CreateInstance() as DynamicObject;
                //单据体
                billEntrys = billHead["FEntity"] as DynamicObjectCollection;

                if (billHead == null || billEntrys == null)
                {
                    continue;
                }

                string[] sGroupSplit = lstGroup.Split('+');

                if (sGroupSplit == null || sGroupSplit.Count() != 4)
                {
                    continue;
                }

                lSaleOrgId   = Convert.ToInt64(sGroupSplit[0]);
                lSaleDeptId  = Convert.ToInt64(sGroupSplit[1]);
                lSaleGroupId = Convert.ToInt64(sGroupSplit[2]);
                lSalerId     = Convert.ToInt64(sGroupSplit[3]);

                billHead["FBillTypeID_Id"]    = "58b2a721c7f776";
                billHead["FJNSaleOrgId_Id"]   = lSaleOrgId;
                billHead["FJNSaleDeptId_Id"]  = lSaleDeptId;
                billHead["FJNSaleGroupId_Id"] = lSaleGroupId;
                billHead["FJNSalerId_Id"]     = lSalerId;
                billHead["FDocumentStatus"]   = "A";
                billHead["FJNDate"]           = DateTime.Now;
                billHead["FDirection"]        = sAdjustType == "A" ? "B" : "A";
                billHead["FCreateDate"]       = DateTime.Now;
                billHead["FCreatorId_Id"]     = this.Context.UserId;

                lstSelectEntrys = lstEntrys.Where(p => Convert.ToInt64(p["FSaleOrgId_Id"]) == lSaleOrgId && Convert.ToInt64(p["FSaleDeptId_Id"]) == lSaleDeptId && Convert.ToInt64(p["FSaleGroupId_Id"]) == lSaleGroupId && Convert.ToInt64(p["FSalerId_Id"]) == lSalerId).ToList();

                if (lstSelectEntrys == null || lstSelectEntrys.Count() <= 0)
                {
                    continue;
                }

                int seq = 1;
                foreach (DynamicObject entry in lstSelectEntrys)
                {
                    DynamicObject billEntry = new DynamicObject(billEntrys.DynamicCollectionItemPropertyType);
                    billEntry["Seq"] = seq;
                    billEntry["FJNMaterialId_Id"] = entry["FMaterialId_Id"];
                    billEntry["FJNAUXPROP_Id"]    = entry["FAuxPropId_Id"];
                    billEntry["FJNForecastQty"]   = entry["FAdjustQty"];
                    billEntry["FJNUnitID_Id"]     = entry["FUnitID_Id"];
                    billEntry["FJNBaseUnitID_Id"] = entry["FUnitID_Id"];
                    billEntry["FJNBaseUnitQty"]   = entry["FAdjustQty"];

                    billEntry["FJNStockOrg_Id"]  = this.Context.CurrentOrganizationInfo.ID;
                    billEntry["FJNSettleOrg_Id"] = this.Context.CurrentOrganizationInfo.ID;
                    billEntry["FJNSupplyOrg_Id"] = this.Context.CurrentOrganizationInfo.ID;
                    DynamicObject material = entry["FMaterialId"] as DynamicObject;
                    if (material != null)
                    {
                        string Materialname = material["Name"].ToString();
                        string sql          = "";
                        if (Materialname.IndexOf("(内蒙)") > 0 || Materialname.IndexOf("(内蒙)") > 0 || Materialname.IndexOf("(内蒙)") > 0)
                        {
                            billEntry["FJNSupplyOrg_Id"] = 100063;
                            sql = string.Format(@"select t2.FWORKSHOPID  as FWORKSHOPID from T_BD_MATERIAL  t1
join T_BD_MATERIALPRODUCE t2 on t1.FMATERIALID=t2.FMATERIALID
where t1.FMASTERID in(
select FMASTERID from T_BD_MATERIAL where FMATERIALID={0})
and t1.FUSEORGID={1}", Convert.ToInt32(entry["FMaterialId_Id"]), 100063);
                        }
                        else
                        {
                            billEntry["FJNSupplyOrg_Id"] = 100062;
                            sql = string.Format(@"select t2.FWORKSHOPID  as FWORKSHOPID from T_BD_MATERIAL  t1
join T_BD_MATERIALPRODUCE t2 on t1.FMATERIALID=t2.FMATERIALID
where t1.FMASTERID in(
select FMASTERID from T_BD_MATERIAL where FMATERIALID={0})
and t1.FUSEORGID={1}", Convert.ToInt32(entry["FMaterialId_Id"]), 100062);
                        }

                        DynamicObjectCollection FWORKSHOPID = DBServiceHelper.ExecuteDynamicObject(this.Context, sql);
                        if (FWORKSHOPID.Count > 0)
                        {
                            int WORKSHOP = Convert.ToInt32(FWORKSHOPID[0]["FWORKSHOPID"]);
                            billEntry["F_VTR_PrdDeptId_Id"] = WORKSHOP;
                        }

                        /* else
                         * {
                         *   billEntry["F_VTR_PrdDeptId"] = 0;
                         * }*/
                    }

                    billEntrys.Add(billEntry);
                    seq++;
                }

                lstBills.Add(billHead);
            }

            if (lstBills.Count <= 0)
            {
                return;
            }

            //生成编码
            MakeBillNo(lstBills);

            Kingdee.BOS.ServiceHelper.DBServiceHelper.LoadReferenceObject(this.Context, lstBills.ToArray(), businessInfo.GetDynamicObjectType(), false);
            DynamicObject[] billDatas = BusinessDataServiceHelper.Save(this.Context, lstBills.ToArray());

            if (billDatas == null || billDatas.Count() <= 0)
            {
                //K3DisplayerModel model = K3DisplayerModel.Create(this.Context, "调整失败,未成功创建销售预测变更单");
                //// 创建一个交互提示错误对象,并设置错误来源,相互隔离
                //KDInteractionException ie = new KDInteractionException("错误提示");
                //ie.InteractionContext.InteractionFormId = FormIdConst.BOS_K3Displayer; // 提示信息显示界面
                //ie.InteractionContext.K3DisplayerModel = model; // 提示内容
                //ie.InteractionContext.IsInteractive = true; // 是否需要交互
                //throw ie; // 抛出错误,终止流程
                this.OperationResult.OperateResult[0].SuccessStatus = false;
                this.OperationResult.OperateResult[0].Message       = "创建销售预测变更单失败";
            }
            else
            {
                OperateResult result;
                foreach (var item in billDatas)
                {
                    result = new OperateResult
                    {
                        SuccessStatus = true,
                        Message       = "创建销售预测变更单成功",
                        MessageType   = MessageType.Normal,
                        Name          = "生成销售预测变更单:" + Convert.ToString(item["FBillNo"]) + "成功",
                        PKValue       = item
                    };
                    this.OperationResult.OperateResult.Add(result);
                }
            }
            this.OperationResult.IsShowMessage = true;
        }
Esempio n. 14
0
        /// <summary>
        /// 输入收货明细fid,entryid,输出收货明细详情
        /// </summary>
        /// <param name="billno">收货明细编号</param>
        /// <returns>返回服务结果。</returns>
        public ServiceResult ExecuteService(string SourceBillId, string SourceEntryId)
        {
            var result = new ServiceResult <JSONObject>();
            var ctx    = this.KDContext.Session.AppContext;

            // 检查上下文对象
            if (this.IsContextExpired(result))
            {
                return(result);
            }
            // 检查传入参数
            //if (string.IsNullOrWhiteSpace(billno))
            //{
            //    result.Code = (int)ResultCode.Fail;
            //    result.Message = "收货明细编号不能为空!";
            //    return result;
            //}
            //获取相关信息
            try
            {
                //TODO:通过平台动态引擎获取数据


                JSONObject return_data = new JSONObject();

                //客户编码和物料编码

                string sqlSelect = string.Format(@"/*dialect*/
               
               SELECT t.FQty, t.FUnitId,  t4.FNAME AS FUnitName,t.FMQty,T.FMUNITID,t9.FNAME AS FMUnitName, t.FPackageId,
	            t5.FHasJoinMQty,(t.FMQTY - t5.FHasJoinMQty) AS FNeedINBOUNDMQTY,
	            t.FAVGCTY,t.FCTY
                FROM dbo.BAH_T_WMS_INBOUNDENTRY t
	            LEFT JOIN dbo.BAH_V_BD_UNIT_L t4 ON t.FUNITID = t4.fid
	            LEFT JOIN dbo.BAH_T_WMS_INBOUNDENTRY_W t5 ON t.FENTRYID = t5.FENTRYID
                LEFT JOIN dbo.BAH_V_BD_UNIT_L t9 ON t.FMUNITID = t9.fid
                WHERE  t5.FJOINSTATUS = 'A'
	            AND t.FID =  '{0}' 
	            AND T.FENTRYID =  '{1}'
                order by t.FSEQ
                   
                 ;", SourceBillId, SourceEntryId);// or a.num is null

                DynamicObjectCollection mat_objc = DBUtils.ExecuteDynamicObject(ctx, sqlSelect, null, null);
                if (mat_objc.Count == 0)
                {
                    result.Code    = (int)ResultCode.Fail;
                    result.Message = "未检索到对应信息!";
                }
                else
                {
                    List <JSONObject> detail_list = new List <JSONObject>(); //明细信息
                    foreach (DynamicObject data in mat_objc)
                    {
                        JSONObject      each_detail = new JSONObject();
                        IPackageService pkgService  = null;
                        String          FMQtyForShow;
                        String          FHASMQTYForShow;
                        String          FNeedMQTYForShow;
                        try
                        {
                            FormMetadata          meta       = MetaDataServiceHelper.Load(ctx, "BAH_BD_Package") as FormMetadata;
                            QueryBuilderParemeter queryParam = new QueryBuilderParemeter();
                            queryParam.FormId       = "BAH_BD_Package";
                            queryParam.BusinessInfo = meta.BusinessInfo;

                            queryParam.FilterClauseWihtKey = " FID ='" + data["FPackageId"].ToString() + "' ";

                            var objs = BusinessDataServiceHelper.Load(ctx,
                                                                      meta.BusinessInfo.GetDynamicObjectType(),
                                                                      queryParam).FirstOrDefault();

                            pkgService = PIBDServiceFactory.Instance.GetService <IPackageService>(ctx);
                            var Marray = pkgService.Expand(ctx, objs, decimal.Parse(data["FMQty"].ToString()));
                            var Harray = pkgService.Expand(ctx, objs, decimal.Parse(data["FHasJoinMQty"].ToString()));
                            var Narray = pkgService.Expand(ctx, objs, decimal.Parse(data["FNeedINBOUNDMQTY"].ToString()));
                            FMQtyForShow     = string.Join("", Marray.Select(item => string.Concat(item.Qty.ToTrimEndZeroString(), item.Name.Value(ctx))).ToArray());
                            FHASMQTYForShow  = string.Join("", Harray.Select(item => string.Concat(item.Qty.ToTrimEndZeroString(), item.Name.Value(ctx))).ToArray());
                            FNeedMQTYForShow = string.Join("", Narray.Select(item => string.Concat(item.Qty.ToTrimEndZeroString(), item.Name.Value(ctx))).ToArray());
                        }
                        finally
                        {
                            PIBDServiceFactory.Instance.CloseService(pkgService);
                        }

                        each_detail.Add("FQty", data["FQty"]);
                        each_detail.Add("FUnitId", data["FUnitId"]);
                        each_detail.Add("FUnitName", data["FUnitName"]);
                        each_detail.Add("FMQty", data["FMQty"]);
                        each_detail.Add("FMUNITID", data["FMUNITID"]);
                        each_detail.Add("FMUnitName", data["FMUnitName"]);
                        each_detail.Add("FMQtyForShow", FMQtyForShow);
                        each_detail.Add("FHASMQTYForShow", FHASMQTYForShow);
                        each_detail.Add("FNeedMQTYForShow", FNeedMQTYForShow);
                        each_detail.Add("FHASPutMQTY", data["FHasJoinMQty"]);
                        each_detail.Add("FNeedPutMQTY", data["FNeedINBOUNDMQTY"]);
                        each_detail.Add("FAVGCTY", data["FAVGCTY"]);
                        each_detail.Add("FCTY", data["FCTY"]);


                        detail_list.Add(each_detail);
                    }
                    return_data.Add("DetailList", detail_list);
                }


                //返回数据
                result.Code    = (int)ResultCode.Success;
                result.Data    = return_data;
                result.Message = "成功返回数据!";
            }
            catch (Exception ex)
            {
                result.Code    = (int)ResultCode.Fail;
                result.Message = ex.Message;
            }
            return(result);
        }
Esempio n. 15
0
        private DynamicObject getbandobject(Context ctx, JNBandPara actband)
        {
            int actbandid = actband.bandid;

            DynamicObject[] bandIDs = BusinessDataServiceHelper.Load(ctx, new object[] { actbandid }, (MetaDataServiceHelper.Load(ctx, "CN_BANKACNT") as FormMetadata).BusinessInfo.GetDynamicObjectType());
            return(bandIDs.FirstOrDefault());
        }
Esempio n. 16
0
        /// <summary>
        /// 反审核并删除需要删除的销售订单
        /// </summary>
        /// <param name="pkids"></param>
        /// <param name="p"></param>
        /// <param name="ctx"></param>
        private void UnAuditBill(Context ctx, string p, string[] pkids)
        {
            //反审核服务
            FormMetadata  meta          = MetaDataServiceHelper.Load(ctx, p, true) as FormMetadata;
            OperateOption UnAuditOption = OperateOption.Create();
            var           UnAuditResult = BusinessDataServiceHelper.UnAudit(ctx, meta.BusinessInfo, pkids, UnAuditOption);

            if (UnAuditResult.IsSuccess)
            {
                //删除服务
                OperateOption deleteOption = OperateOption.Create();
                var           delectResult = BusinessDataServiceHelper.Delete(ctx, meta.BusinessInfo, pkids, deleteOption);
                //删除成功将成功信息及状态返回写中间表
                if (delectResult.IsSuccess)
                {
                    OperateResultCollection successResult = delectResult.OperateResult;
                    List <string>           succSql       = new List <string>();
                    foreach (OperateResult item in successResult)
                    {
                        if ("SAL_SaleOrder".Equals(p))
                        {
                            string strSql = string.Format(@"/*dialect*/UPDATE SALE_MAIN@ZyK3Link
                                                                              SET FFLAG = '3', FUPDATEDATE = '{0}', FERRORMESSAGE = '{1}'
                                                                              WHERE FSALBILLNO = '{2}'
                                                                             ", System.DateTime.Now.ToString(), item.Number.ToString() + "销售订单删除成功",
                                                          item.Number);
                            succSql.Add(strSql);
                        }
                        if ("ENG_BOM".Equals(p))
                        {
                            string strSql = string.Format(@"/*dialect*/UPDATE BOM_MAIN@ZyK3Link
                                                                             SET FFLAG = '3', FUPDATEDATE = '{0}', FERRORMESSAGE = '{1}'
                                                                             WHERE FSALBILLNO = '{2}'
                                                                           ", System.DateTime.Now.ToString(), item.Number.ToString() + "物料清单删除成功",
                                                          item.Number);
                            succSql.Add(strSql);
                        }
                        if ("BD_MATERIAL".Equals(p))
                        {
                            string strSql = string.Format(@"/*dialect*/UPDATE PRD_MAIN@ZyK3Link
                                                                              SET FFLAG = '3', FUPDATEDATE = '{0}', FERRORMESSAGE = '{1}'
                                                                              WHERE FSALBILLNO = '{2}'
                                                                            ", System.DateTime.Now.ToString(), item.Number.ToString() + "物料删除成功",
                                                          item.Number);
                            succSql.Add(strSql);
                        }
                    }
                    Kingdee.BOS.Log.Logger.Info(DateTime.Now.ToString() + "deleteSucc", succSql.ToString(), true);
                    DBUtils.ExecuteBatch(ctx, succSql, 100);
                }
                else
                {
                    //多条记录被删除,一部分删除成功,一部分删除失败,将成功和失败的信息及状态都返写回中间表
                    List <ValidationErrorInfo> errorDeleteList = new List <ValidationErrorInfo>();
                    errorDeleteList = delectResult.ValidationErrors;//删除失败记录返写中间表
                    if (errorDeleteList != null && errorDeleteList.Count() > 0)
                    {
                        List <string> errorSql = new List <string>();
                        for (int k = 0; k < errorDeleteList.Count(); k++)
                        {
                            if ("SAL_SaleOrder".Equals(p))
                            {
                                string strSql = string.Format(@"/*dialect*/UPDATE SALE_MAIN@ZyK3Link
                                                                              SET FFLAG = '2', FUPDATEDATE = '{0}', FERRORMESSAGE = '{1}'
                                                                              WHERE FSALBILLNO = (SELECT FBILLNO FROM T_SAL_ORDER WHERE FID = '{2}')
                                                                             ", System.DateTime.Now.ToString(), errorDeleteList[k].Message, errorDeleteList[k].BillPKID);
                                errorSql.Add(strSql);
                            }
                            if ("ENG_BOM".Equals(p))
                            {
                                string strSql = string.Format(@"/*dialect*/UPDATE BOM_MAIN@ZyK3Link
                                                                             SET FFLAG = '2', FUPDATEDATE = '{0}', FERRORMESSAGE = '{1}'
                                                                             WHERE FSALBILLNO = (SELECT FNUMBER FROM T_ENG_BOM WHERE FID = '{2}')
                                                                           ", System.DateTime.Now.ToString(), errorDeleteList[k].Message, errorDeleteList[k].BillPKID);
                                errorSql.Add(strSql);
                            }
                            if ("BD_MATERIAL".Equals(p))
                            {
                                string strSql = string.Format(@"/*dialect*/UPDATE PRD_MAIN@ZyK3Link
                                                                              SET FFLAG = '2', FUPDATEDATE = '{0}', FERRORMESSAGE = '{1}'
                                                                              WHERE FSALBILLNO = (SELECT FNUMBER FROM T_BD_MATERIAL WHERE FID = '{2}')
                                                                            ", System.DateTime.Now.ToString(), errorDeleteList[k].Message, errorDeleteList[k].BillPKID);
                                errorSql.Add(strSql);
                            }
                        }
                        Kingdee.BOS.Log.Logger.Error(DateTime.Now.ToString() + "deleteError", errorSql.ToString(), new Exception());
                        DBUtils.ExecuteBatch(ctx, errorSql, 100);
                    }
                    //删除成功记录返回写中间表
                    OperateResultCollection successResult = delectResult.OperateResult;
                    if (successResult != null && successResult.Count() > 0)
                    {
                        List <string> succSql = new List <string>();
                        foreach (OperateResult item in successResult)
                        {
                            if ("SAL_SaleOrder".Equals(p))
                            {
                                string strSql = string.Format(@"/*dialect*/UPDATE SALE_MAIN@ZyK3Link
                                                                              SET FFLAG = '3', FUPDATEDATE = '{0}', FERRORMESSAGE = '{1}'
                                                                              WHERE FSALBILLNO = '{2}'
                                                                             ", System.DateTime.Now.ToString(), item.Number.ToString() + "销售订单删除成功",
                                                              item.Number);
                                succSql.Add(strSql);
                            }
                            if ("ENG_BOM".Equals(p))
                            {
                                string strSql = string.Format(@"/*dialect*/UPDATE BOM_MAIN@ZyK3Link
                                                                             SET FFLAG = '3', FUPDATEDATE = '{0}', FERRORMESSAGE = '{1}'
                                                                             WHERE FSALBILLNO = '{2}'
                                                                           ", System.DateTime.Now.ToString(), item.Number.ToString() + "物料清单删除成功",
                                                              item.Number);
                                succSql.Add(strSql);
                            }
                            if ("BD_MATERIAL".Equals(p))
                            {
                                string strSql = string.Format(@"/*dialect*/UPDATE PRD_MAIN@ZyK3Link
                                                                              SET FFLAG = '3', FUPDATEDATE = '{0}', FERRORMESSAGE = '{1}'
                                                                              WHERE FSALBILLNO = '{2}'
                                                                            ", System.DateTime.Now.ToString(), item.Number.ToString() + "物料删除成功",
                                                              item.Number);
                                succSql.Add(strSql);
                            }
                            Kingdee.BOS.Log.Logger.Info(DateTime.Now.ToString() + "deleteSucc", succSql.ToString(), true);
                            DBUtils.ExecuteBatch(ctx, succSql, 100);
                        }
                    }
                }
            }
            else
            {
                //审核失败记录的信息及状态反写回中间表
                List <ValidationErrorInfo> errorUnAuditList = new List <ValidationErrorInfo>();
                errorUnAuditList = UnAuditResult.ValidationErrors;
                List <string> errorSql = new List <string>();
                for (int k = 0; k < errorUnAuditList.Count(); k++)
                {
                    if ("SAL_SaleOrder".Equals(p))
                    {
                        string strSql = string.Format(@"/*dialect*/UPDATE SALE_MAIN@ZyK3Link
                                                                          SET FFLAG = '2', FUPDATEDATE = '{0}', FERRORMESSAGE = '{1}'
                                                                          WHERE FSALBILLNO = (SELECT FBILLNO FROM T_SAL_ORDER WHERE FID = '{2}')
                                                                        ", System.DateTime.Now.ToString(), errorUnAuditList[k].Message, errorUnAuditList[k].BillPKID);
                        errorSql.Add(strSql);
                    }
                    if ("ENG_BOM".Equals(p))
                    {
                        string strSql = string.Format(@"/*dialect*/UPDATE BOM_MAIN@ZyK3Link
                                                                          SET FFLAG = '2', FUPDATEDATE = '{0}', FERRORMESSAGE = '{1}'
                                                                          WHERE FSALBILLNO = (SELECT FNUMBER FROM T_ENG_BOM WHERE FID = '{2}')
                                                                        ", System.DateTime.Now.ToString(), errorUnAuditList[k].Message, errorUnAuditList[k].BillPKID);
                        errorSql.Add(strSql);
                    }
                    if ("BD_MATERIAL".Equals(p))
                    {
                        string strSql = string.Format(@"/*dialect*/UPDATE PRD_MAIN@ZyK3Link
                                                                          SET FFLAG = '2', FUPDATEDATE = '{0}', FERRORMESSAGE = '{1}'
                                                                          WHERE FSALBILLNO = (SELECT FNUMBER FROM T_BD_MATERIAL WHERE FID = '{2}')
                                                                          ", System.DateTime.Now.ToString(), errorUnAuditList[k].Message, errorUnAuditList[k].BillPKID);
                        errorSql.Add(strSql);
                    }
                }
                Kingdee.BOS.Log.Logger.Error(DateTime.Now.ToString() + "UnAuditError", errorSql.ToString(), new Exception());
                DBUtils.ExecuteBatch(ctx, errorSql, 100);
            }
        }
Esempio n. 17
0
        /// <summary>

        /// 实际运行的Run 方法

        /// </summary>

        /// <param name="ctx"></param>

        /// <param name="schedule"></param>

        public void Run(Context ctx, Schedule schedule)
        {
            DateTime   currentTime     = new System.DateTime();
            JNBandPara actband         = new JNBandPara();
            JNBand     findbandservice = new JNBand();

            currentTime = TimeServiceHelper.GetSystemDateTime(ctx);
            string sql = "";

            sql = string.Format(@"select t1.FENTRYID,t1.F_JNOBSSID,t2.FACCOUNTID from T_AP_PAYBILLENTRY_B t1 
join T_AP_PAYBILLENTRY t2 on t2.fid=t1.fid
join T_AP_PAYBILL t3 on t1.FID=t3.FID where  DATEDIFF(DAY,GETDATE(),FAPPROVEDATE)>-10
and (t1.F_JNOBSSID is not null and  t1.F_JNOBSSID <>'')");
            DynamicObjectCollection rundatas = DBUtils.ExecuteDynamicObject(ctx, sql);
            string token = "";
            int    i     = 0;

            foreach (var rundata in rundatas)
            {
                FormMetadata  formMetadata = MetaDataServiceHelper.Load(ctx, "CN_BANKACNT") as FormMetadata;
                DynamicObject FrACCOUNT    = BusinessDataServiceHelper.LoadSingle(
                    ctx,
                    rundata["FACCOUNTID"],
                    formMetadata.BusinessInfo.GetDynamicObjectType());
                DynamicObject FrBAND = FrACCOUNT["BANKID"] as DynamicObject;
                actband.bandid = Convert.ToInt32(FrACCOUNT["Id"]);
                //actband.addr = Convert.ToString(FrACCOUNT["BANKADDRESS"]);
                actband.name     = Convert.ToString(FrACCOUNT["Name"]);
                actband.bandnum  = Convert.ToString(FrACCOUNT["ACNTBRANCHNUMBER"]);
                actband.cn       = Convert.ToString(FrACCOUNT["NUMBER"]);
                actband.bandname = Convert.ToString(FrBAND["Name"]);
                string obssid = Convert.ToString(rundata["F_JNOBSSID"]);
                if (i == 0)//首行获取令牌
                {
                    token = findbandservice.checkin(ctx, actband);
                    i++;
                }
                string result = "";
                if (obssid.Length > 1)
                {
                    result = findbandservice.findPay(ctx, actband, obssid, token);
                }
                if (result.Length > 0)
                {
                    switch (result)
                    {
                    default:
                        BusinessDataServiceHelper.SetState(ctx, "T_AP_PAYBILLENTRY_B", "FBankStatus", "A", "F_JNOBSSID", new object[] { obssid });
                        break;

                    case "待授权":
                        BusinessDataServiceHelper.SetState(ctx, "T_AP_PAYBILLENTRY_B", "FBankStatus", "B", "F_JNOBSSID", new object[] { obssid });
                        break;

                    case "ok":
                        BusinessDataServiceHelper.SetState(ctx, "T_AP_PAYBILLENTRY_B", "FBankStatus", "C", "F_JNOBSSID", new object[] { obssid });
                        break;

                    case "授权拒绝":
                        BusinessDataServiceHelper.SetState(ctx, "T_AP_PAYBILLENTRY_B", "FBankStatus", "D", "F_JNOBSSID", new object[] { obssid });
                        break;

                    case "交易处理中":
                        BusinessDataServiceHelper.SetState(ctx, "T_AP_PAYBILLENTRY_B", "FBankStatus", "B", "F_JNOBSSID", new object[] { obssid });
                        break;
                    }
                }

                //Thread.Sleep(5000);
            }
            //throw new NotImplementedException();
            if (token.Length > 1)
            {
                findbandservice.checkout(ctx, actband);
            }
        }
Esempio n. 18
0
        /// <summary>
        /// 获取库存明细
        /// </summary>
        ///参数为跟踪号或库位编码
        /// <returns>返回服务结果。</returns>
        public ServiceResult ExecuteService(string materialid, string ownerid, string whid)
        {
            var result = new ServiceResult <List <JSONObject> >();
            var ctx    = this.KDContext.Session.AppContext;

            // 检查上下文对象
            if (this.IsContextExpired(result))
            {
                return(result);
            }


            //获取相关信息
            try
            {
                JSONObject        Finaldata   = new JSONObject();
                List <JSONObject> return_data = new List <JSONObject>();
                // TODO: 通过平台动态引擎获取数据
                string sqlSelect = string.Format(@"/*dialect*/
                 SELECT DISTINCT t.FMATERIALID,T3.FNAME AS FMATERIALNAME,T2.FNUMBER AS FMATERIALNUMBER ,t3.FSPECIFICATION,
      CASE T10.FIGNOREINVENTORYTRACKNO WHEN 1 then 'True' ELSE 'False' END AS FIGNOREINVENTORYTRACKNO,
      CASE T11.FENABLELOT WHEN 1 then 'True' ELSE 'False' END AS FENABLELOT ,
	            CASE T11.FENABLEEXPIRY WHEN 1 then 'True' ELSE 'False' END AS FENABLEEXPIRY,
	            CASE T11.FENABLECAPACITY WHEN 1 then 'True' ELSE 'False' END AS FENABLECAPACITY,
	            t11.FCAPACITYSCALE,t12.FCAPACITYUNIT,
      t.FBILLNO AS FTrackNo,T.FLOTNO,FPRODUCEDATE,FEXPIRYDATE,FMQTY,FMAINUNITID, t8.FNAME AS FMainUnitNAME,
      t.FEXPPERIOD, 'D' AS FEXPUNIT,T.FAVGCTY,T.FCTY,
      FLOCID,t6.FNUMBER AS FLocNumber,t5.FNAME AS FLocName, t.FPACKAGEID,t4.FNUMBER AS FPackageNumber ,t7.FNAME AS FPackageName
                FROM dbo.BAH_V_WMS_INVENTORY t
                LEFT JOIN dbo.BAH_T_BD_MATERIAL t2 ON t.FMATERIALID = t2.FID
	            LEFT JOIN dbo.BAH_T_BD_MATERIAL_L t3 ON t.FMATERIALID = t3.FID
	            LEFT JOIN dbo.BAH_T_BD_PACKAGE T4 ON T.FPACKAGEID = T4.FID
	            LEFT JOIN dbo.BAH_T_BD_LOCATION_L t5 ON t.FLOCID = t5.FID
	            LEFT JOIN dbo.BAH_T_BD_LOCATION t6 ON t.FLOCID = t6.FID
	            LEFT JOIN dbo.BAH_T_BD_PACKAGE_L T7 ON T.FPACKAGEID = T7.FID
	            LEFT JOIN dbo.BAH_T_BD_PKGUOM_L T8 ON T4.FMAINUNITID = t8.FENTRYID
	            LEFT JOIN dbo.BAH_T_BD_LOCBASE T9 ON T6.FID = T9.FID
                INNER JOIN BAH_T_BD_LOCCONTROL T10 ON T6.FID = T10.FID
               INNER JOIN dbo.BAH_T_BD_MATWAREHOUSE T11 ON T2.FID = T11.FID
               LEFT JOIN dbo.BAH_T_BD_MATWAREHOUSE_L T12 ON T11.FENTRYID = T12.FENTRYID
	            where  (t2.FNUMBER = '{0}' or t.FBILLNO = '{0}' or t6.FNUMBER = '{0}' ) AND (t9.FUSE = 'Storage' or t9.FUSE = 'Pick') AND T.FOWNERID = '{1}' AND t.fwhid = '{2}'
                 ;", materialid, ownerid, whid);// or a.num is null

                DynamicObjectCollection dataObjectCollection = DBUtils.ExecuteDynamicObject(ctx, sqlSelect, null, null);
                if (dataObjectCollection.Count == 0)
                {
                    result.Code    = (int)ResultCode.Fail;
                    result.Message = "未检索到对应信息!";
                }
                else
                {
                    foreach (DynamicObject dataObject in dataObjectCollection)
                    {
                        JSONObject      data       = new JSONObject();
                        IPackageService pkgService = null;
                        String          FMQtyForShow;
                        try
                        {
                            FormMetadata          meta       = MetaDataServiceHelper.Load(ctx, "BAH_BD_Package") as FormMetadata;
                            QueryBuilderParemeter queryParam = new QueryBuilderParemeter();
                            queryParam.FormId              = "BAH_BD_Package";
                            queryParam.BusinessInfo        = meta.BusinessInfo;
                            queryParam.FilterClauseWihtKey = " FID ='" + dataObject["FPackageId"].ToString() + "' ";
                            var objs = BusinessDataServiceHelper.Load(ctx,
                                                                      meta.BusinessInfo.GetDynamicObjectType(),
                                                                      queryParam).FirstOrDefault();

                            pkgService = PIBDServiceFactory.Instance.GetService <IPackageService>(ctx);
                            var Marray = pkgService.Expand(ctx, objs, decimal.Parse(dataObject["FMQty"].ToString()));
                            FMQtyForShow = string.Join("", Marray.Select(item => string.Concat(item.Qty.ToTrimEndZeroString(), item.Name.Value(ctx))).ToArray());
                        }
                        finally
                        {
                            PIBDServiceFactory.Instance.CloseService(pkgService);
                        }
                        data.Add("FMATERIALID", dataObject["FMATERIALID"].ToString());
                        data.Add("FMATERIALNAME", dataObject["FMATERIALNAME"]);
                        data.Add("FMATERIALNUMBER", dataObject["FMATERIALNUMBER"]);
                        data.Add("FSPECIFICATION", dataObject["FSPECIFICATION"]);

                        data.Add("FIGNOREINVENTORYTRACKNO", dataObject["FIGNOREINVENTORYTRACKNO"]);
                        data.Add("FENABLELOT", dataObject["FENABLELOT"]);
                        data.Add("FENABLEEXPIRY", dataObject["FENABLEEXPIRY"]);
                        data.Add("FENABLECAPACITY", dataObject["FENABLECAPACITY"]);

                        data.Add("FCAPACITYSCALE", dataObject["FCAPACITYSCALE"]);
                        data.Add("FCAPACITYUNIT", dataObject["FCAPACITYUNIT"]);

                        data.Add("FTrackNo", dataObject["FTrackNo"]);
                        data.Add("FLotNo", dataObject["FLotNo"].ToString());

                        if (dataObject["FProduceDate"].ToString() == "0001-01-01 00:00:00")
                        {
                            data.Add("FProduceDate", "");
                        }
                        else
                        {
                            data.Add("FProduceDate", Convert.ToDateTime(dataObject["FProduceDate"].ToString()).ToString("yyyy-MM-dd"));
                        }

                        if (dataObject["FExpiryDate"].ToString() == "0001-01-01 00:00:00")
                        {
                            data.Add("FExpiryDate", "");
                        }
                        else
                        {
                            data.Add("FExpiryDate", Convert.ToDateTime(dataObject["FExpiryDate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss.fff"));
                        }

                        data.Add("FMQty", dataObject["FMQty"].ToString());
                        data.Add("FMainUnitId", dataObject["FMainUnitId"]);
                        data.Add("FMainUnitNAME", dataObject["FMainUnitNAME"]);

                        data.Add("FAVGCTY", dataObject["FAVGCTY"]);
                        data.Add("FCTY", dataObject["FCTY"]);
                        data.Add("FEXPPERIOD", dataObject["FEXPPERIOD"]);
                        data.Add("FEXPUNIT", dataObject["FEXPUNIT"]);

                        data.Add("FLocId", dataObject["FLocId"]);
                        data.Add("FLocNumber", dataObject["FLocNumber"]);
                        data.Add("FLocName", dataObject["FLocName"]);

                        data.Add("FPackageId", dataObject["FPackageId"]);
                        data.Add("FPackageNumber", dataObject["FPackageNumber"]);
                        data.Add("FPackageName", dataObject["FPackageName"]);
                        data.Add("FMQtyForShow", FMQtyForShow);
                        return_data.Add(data);
                    }
                }

                //返回数据
                result.Code    = (int)ResultCode.Success;
                result.Data    = return_data;
                result.Message = "成功返回数据!";
            }
            catch (Exception ex)
            {
                result.Code    = (int)ResultCode.Fail;
                result.Message = ex.Message;
            }
            return(result);
        }
Esempio n. 19
0
        /// <summary>
        /// 输入收货通知编号,仓库id,库区id,货主id,输出收货通知详情
        /// </summary>
        /// <param name="billno">收货通知编号</param>
        /// <returns>返回服务结果。</returns>
        public ServiceResult ExecuteService(string whid, string areaid, string ownerid, string billno)
        {
            DynamicObjectCollection dataObjectCollection;
            var result = new ServiceResult <List <JSONObject> >();
            List <JSONObject> Final_data = new List <JSONObject>();
            var ctx = this.KDContext.Session.AppContext;

            // 检查上下文对象
            if (this.IsContextExpired(result))
            {
                return(result);
            }
            // 检查传入参数
            if (string.IsNullOrWhiteSpace(billno))
            {
                result.Code    = (int)ResultCode.Fail;
                result.Message = "收货通知编号不能为空!";
                return(result);
            }
            //获取相关信息
            try
            {
                string sqlSelect1 = string.Format(@"/*dialect*/
                                                    SELECT distinct t0.FID fid, t0.FBILLNO fbillno, t5.FNAME fbatchwhid_fname,t7.FNAME fbatchownerid_fname, t9.FNAME fcontactid_fname 
                FROM  dbo.BAH_T_WMS_INNOTICE t0
                LEFT JOIN dbo.BAH_T_WMS_INNOTICEENTRY t ON t0.FID = t.FID
	            LEFT JOIN dbo.BAH_T_BD_LOCATION_L t1 ON t.FLOCID = t1.FID
	            LEFT JOIN dbo.BAH_T_WMS_INNOTICEENTRY_W t2 ON t.FENTRYID = t2.FENTRYID
	            LEFT JOIN dbo.BAH_T_BD_LOCATION t3 ON t.FLOCID = t3.FID
	            LEFT JOIN dbo.BAH_T_BD_LOCBASE T30 ON T3.FID = T30.FID
	            LEFT JOIN dbo.BAH_T_BD_WAREHOUSE t4 on t0.FWHID = t4.FID
	            INNER JOIN dbo.BAH_T_BD_WAREHOUSE_L t5 on t4.FID = t5.FID
	            LEFT JOIN dbo.BAH_V_BD_OWNER t6 ON t0.FOWNERID = t6.FID
	            INNER JOIN dbo.BAH_V_BD_OWNER_L T7 ON T6.FID = T7.FID
	            LEFT JOIN dbo.BAH_V_BD_CONTACT T8 ON T0.FCONTACTID = T8.FID
	            INNER JOIN dbo.BAH_V_BD_CONTACT_L T9 ON T8.FID = T9.FID
                LEFT JOIN dbo.BAH_T_BD_MATERIAL t10 ON t.FMATERIALID = t10.FID
	            INNER JOIN dbo.BAH_T_BD_MATWAREHOUSE T11 ON T10.FID = T11.FID
                WHERE  T0.FWHID LIKE '%{0}%' AND T0.FOWNERID LIKE '%{2}%' AND T30.FAREAID LIKE '%{1}%' and (t0.FBILLNO = '{3}' or t2.FSOURCEBILLNO = '{3}' or t0.FORDERNO = '{3}' )
                AND t0.FDOCUMENTSTATUS = 'C' AND t2.FJOINSTATUS = 'A' AND t.FMANUALCLOSE = 'A' 
                AND ((T2.FHASINBOUNDMQTY >= 0 AND T2.FHASINBOUNDMQTY < T.FMQTY AND T11.FENABLECAPACITY = 0)  OR (T11.FENABLECAPACITY = 1 AND (T2.FHASINBOUNDCTY = 0 OR T2.FHASINBOUNDCTY < T.FCTY)) )      
                              
                 ;", whid, areaid, ownerid, billno); // or a.num is null
                                                     //库区为零的情况
                string sqlSelect2 = string.Format(@"/*dialect*/
                                                    SELECT distinct t0.FID fid, t0.FBILLNO fbillno, t5.FNAME fbatchwhid_fname,t7.FNAME fbatchownerid_fname, t9.FNAME fcontactid_fname 
                FROM  dbo.BAH_T_WMS_INNOTICE t0
                LEFT JOIN dbo.BAH_T_WMS_INNOTICEENTRY t ON t0.FID = t.FID
	            LEFT JOIN dbo.BAH_T_BD_LOCATION_L t1 ON t.FLOCID = t1.FID
	            LEFT JOIN dbo.BAH_T_WMS_INNOTICEENTRY_W t2 ON t.FENTRYID = t2.FENTRYID
	            LEFT JOIN dbo.BAH_T_BD_LOCATION t3 ON t.FLOCID = t3.FID
	            LEFT JOIN dbo.BAH_T_BD_LOCBASE T30 ON T3.FID = T30.FID
	            LEFT JOIN dbo.BAH_T_BD_WAREHOUSE t4 on t0.FWHID = t4.FID
	            INNER JOIN dbo.BAH_T_BD_WAREHOUSE_L t5 on t4.FID = t5.FID
	            LEFT JOIN dbo.BAH_V_BD_OWNER t6 ON t0.FOWNERID = t6.FID
	            INNER JOIN dbo.BAH_V_BD_OWNER_L T7 ON T6.FID = T7.FID
	            LEFT JOIN dbo.BAH_V_BD_CONTACT T8 ON T0.FCONTACTID = T8.FID
	            INNER JOIN dbo.BAH_V_BD_CONTACT_L T9 ON T8.FID = T9.FID
                LEFT JOIN dbo.BAH_T_BD_MATERIAL t10 ON t.FMATERIALID = t10.FID
	            INNER JOIN dbo.BAH_T_BD_MATWAREHOUSE T11 ON T10.FID = T11.FID
                WHERE  T0.FWHID LIKE '%{0}%' AND T0.FOWNERID LIKE '%{2}%' AND (t0.FBILLNO = '{3}' or t2.FSOURCEBILLNO = '{3}' or t0.FORDERNO = '{3}' )
                AND t0.FDOCUMENTSTATUS = 'C' AND t2.FJOINSTATUS = 'A' AND t.FMANUALCLOSE = 'A' 
                AND ((T2.FHASINBOUNDMQTY >= 0 AND T2.FHASINBOUNDMQTY < T.FMQTY AND T11.FENABLECAPACITY = 0)  OR (T11.FENABLECAPACITY = 1 AND (T2.FHASINBOUNDCTY = 0 OR T2.FHASINBOUNDCTY < T.FCTY)) )      
                                   
                 ;", whid, areaid, ownerid, billno); // or a.num is null
                //TODO:通过平台动态引擎获取数据
                if (areaid == "")
                {
                    dataObjectCollection = DBUtils.ExecuteDynamicObject(ctx, sqlSelect2, null, null);
                }
                else
                {
                    dataObjectCollection = DBUtils.ExecuteDynamicObject(ctx, sqlSelect1, null, null);
                }
                foreach (DynamicObject dataObject in dataObjectCollection)
                {
                    JSONObject return_data = new JSONObject();
                    return_data.Add("Fid", dataObject["Fid"]);
                    return_data.Add("FBillNo", billno);
                    return_data.Add("FInNoticeBillNo", dataObject["fbillno"]);
                    return_data.Add("FBatchWHName", dataObject["FBatchWHId_FName"]);
                    return_data.Add("FBatchOwnerIdName", dataObject["FBatchOwnerId_FName"]);
                    return_data.Add("FContactIdName", dataObject["FContactId_FName"]);
                    //客户编码和物料编码

                    string sqlSelect = string.Format(@"/*dialect*/
              SELECT t.FENTRYID, t.FSEQ, t.FLocId, t6.FNUMBER AS FlocIdNumber, t1.FNAME AS FlocIdName
	            ,t2.FID AS FMaterialFID, t2.FNUMBER AS FMaterialNumber, t3.FNAME AS FMaterialName, t3.FSPECIFICATION, t.FPackageId,T7.FNAME AS FPackageName, t.FQty
	            , t.FUnitId, t4.FNAME AS FUnitName,t.FMQty, T.FMUNITID,t9.FNAME AS FMUnitName,    t.FLotNo,
	            CASE T8.FENABLELOT WHEN 1 then 'True' ELSE 'False' END AS FENABLELOT ,
	            CASE T8.FENABLEEXPIRY WHEN 1 then 'True' ELSE 'False' END AS FENABLEEXPIRY,
	            CASE T8.FENABLECAPACITY WHEN 1 then 'True' ELSE 'False' END AS FENABLECAPACITY,
	            t8.FCAPACITYSCALE,t10.FCAPACITYUNIT,t8.FEXPPERIOD,t8.FEXPUNIT,
                t5.FHASINBOUNDMQTY,(t.FMQTY - t5.FHASINBOUNDMQTY) AS FNeedINBOUNDMQTY,
                t.FAVGCTY,t.FCty,t.FTRACKNO,
                 t5.FHASINBOUNDCTY,(t.FCTY - t5.FHASINBOUNDCTY) AS FNeedINBOUNDCTY
                FROM dbo.BAH_T_WMS_INNOTICEENTRY t
	            LEFT JOIN dbo.BAH_T_BD_LOCATION_L t1 ON t.FLOCID = t1.FID
	            LEFT JOIN dbo.BAH_T_BD_MATERIAL t2 ON t.FMATERIALID = t2.FID
	            LEFT JOIN dbo.BAH_T_BD_MATERIAL_L t3 ON t.FMATERIALID = t3.FID
	            LEFT JOIN dbo.BAH_V_BD_UNIT_L t4 ON t.FUNITID = t4.fid
	            LEFT JOIN dbo.BAH_T_WMS_INNOTICEENTRY_W t5 ON t.FENTRYID = t5.FENTRYID
	            LEFT JOIN dbo.BAH_T_BD_LOCATION t6 ON t.FLOCID = t6.FID
	            LEFT JOIN dbo.BAH_T_BD_PACKAGE_L T7 ON T.FPACKAGEID = T7.FID
	            INNER JOIN dbo.BAH_T_BD_MATWAREHOUSE T8 ON T2.FID = T8.FID
	            LEFT JOIN dbo.BAH_V_BD_UNIT_L t9 ON t.FMUNITID = t9.fid
	            LEFT JOIN dbo.BAH_T_BD_MATWAREHOUSE_L T10 ON T8.FENTRYID = T10.FENTRYID
                LEFT JOIN dbo.BAH_T_BD_PACKAGE T11 ON T.FPACKAGEID = T11.FID
	            
                WHERE t.FMANUALCLOSE = 'A'
	            AND t5.FJOINSTATUS = 'A'
	            AND t.FID = '{0}'
                AND ((T5.FHASINBOUNDMQTY >= 0 AND T5.FHASINBOUNDMQTY < T.FMQTY AND T8.FENABLECAPACITY = 0)  OR (T8.FENABLECAPACITY = 1 AND (T5.FHASINBOUNDCTY = 0 OR T5.FHASINBOUNDCTY < T.FCTY)))
                order by t.FSEQ 
                 ;", dataObject["Fid"].ToString());// or a.num is null
                    DynamicObjectCollection mat_objc = DBUtils.ExecuteDynamicObject(ctx, sqlSelect, null, null);
                    if (mat_objc.Count == 0)
                    {
                        result.Code    = (int)ResultCode.Fail;
                        result.Message = "未检索到对应信息!";
                    }
                    else
                    {
                        List <JSONObject> detail_list = new List <JSONObject>(); //明细信息
                        foreach (DynamicObject data in mat_objc)
                        {
                            JSONObject      each_detail = new JSONObject();
                            IPackageService pkgService  = null;
                            String          FMQtyForShow;
                            String          FHASINBOUNDMQTYForShow;
                            String          FNeedINBOUNDMQTYForShow;
                            try
                            {
                                FormMetadata          meta       = MetaDataServiceHelper.Load(ctx, "BAH_BD_Package") as FormMetadata;
                                QueryBuilderParemeter queryParam = new QueryBuilderParemeter();
                                queryParam.FormId              = "BAH_BD_Package";
                                queryParam.BusinessInfo        = meta.BusinessInfo;
                                queryParam.FilterClauseWihtKey = " FID ='" + data["FPackageId"].ToString() + "' ";
                                var objs = BusinessDataServiceHelper.Load(ctx,
                                                                          meta.BusinessInfo.GetDynamicObjectType(),
                                                                          queryParam).FirstOrDefault();
                                pkgService = PIBDServiceFactory.Instance.GetService <IPackageService>(ctx);
                                var Marray = pkgService.Expand(ctx, objs, decimal.Parse(data["FMQty"].ToString()));
                                var Harray = Convert.ToDecimal(data["FHASINBOUNDMQTY"]) == 0 ? null : pkgService.Expand(ctx, objs, decimal.Parse(data["FHASINBOUNDMQTY"].ToString()));
                                var Narray = pkgService.Expand(ctx, objs, decimal.Parse(data["FNeedINBOUNDMQTY"].ToString()));
                                FMQtyForShow            = string.Join("", Marray.Select(item => string.Concat(item.Qty.ToTrimEndZeroString(), item.Name.Value(ctx))).ToArray());
                                FHASINBOUNDMQTYForShow  = Convert.ToDecimal(data["FHASINBOUNDMQTY"]) == 0 ? "0" + data["FMUnitName"] : string.Join("", Harray.Select(item => string.Concat(item.Qty.ToTrimEndZeroString(), item.Name.Value(ctx))).ToArray());
                                FNeedINBOUNDMQTYForShow = string.Join("", Narray.Select(item => string.Concat(item.Qty.ToTrimEndZeroString(), item.Name.Value(ctx))).ToArray());
                                if (Narray.Count() == 1)
                                {
                                    each_detail.Add("FNeedQTY", Narray.FirstOrDefault().Qty);
                                    each_detail.Add("FNeedUNITID", Narray.FirstOrDefault().Id);
                                    each_detail.Add("FNeedName", Narray.FirstOrDefault().Name.Value(2052));
                                }
                                else
                                {
                                    each_detail.Add("FNeedQTY", data["FNeedINBOUNDMQTY"]);
                                    each_detail.Add("FNeedUNITID", data["FMUNITID"]);
                                    each_detail.Add("FNeedName", data["FMUnitName"]);
                                }
                            }
                            finally
                            {
                                PIBDServiceFactory.Instance.CloseService(pkgService);
                            }

                            each_detail.Add("FENTRYID", data["FENTRYID"]);
                            each_detail.Add("FSEQ", data["FSEQ"]);
                            each_detail.Add("FLocId", data["FLocId"]);
                            each_detail.Add("FlocIdNumber", data["FlocIdNumber"]);
                            each_detail.Add("FlocIdName", data["FlocIdName"]);
                            each_detail.Add("FMaterialFID", data["FMaterialFID"]);
                            each_detail.Add("FMaterialNumber", data["FMaterialNumber"]);
                            each_detail.Add("FMaterialName", data["FMaterialName"]);
                            each_detail.Add("FSPECIFICATION", data["FSPECIFICATION"]);
                            each_detail.Add("FPackageId", data["FPackageId"]);
                            each_detail.Add("FPackageName", data["FPackageName"]);
                            each_detail.Add("FQty", data["FQty"]);
                            each_detail.Add("FUnitId", data["FUnitId"]);
                            each_detail.Add("FUnitName", data["FUnitName"]);
                            each_detail.Add("FMQty", data["FMQty"]);
                            each_detail.Add("FMUNITID", data["FMUNITID"]);
                            each_detail.Add("FMUnitName", data["FMUnitName"]);
                            each_detail.Add("FMQtyForShow", FMQtyForShow);
                            each_detail.Add("FHASINBOUNDMQTYForShow", FHASINBOUNDMQTYForShow);
                            each_detail.Add("FNeedINBOUNDMQTYForShow", FNeedINBOUNDMQTYForShow);
                            each_detail.Add("FNeedINBOUNDMQTY", data["FNeedINBOUNDMQTY"]);
                            each_detail.Add("FLotNo", data["FLotNo"]);
                            each_detail.Add("FENABLELOT", data["FENABLELOT"]);
                            each_detail.Add("FENABLEEXPIRY", data["FENABLEEXPIRY"]);
                            each_detail.Add("FENABLECAPACITY", data["FENABLECAPACITY"]);
                            each_detail.Add("FCAPACITYUNIT", data["FCAPACITYUNIT"]);
                            each_detail.Add("FCAPACITYSCALE", data["FCAPACITYSCALE"]);
                            each_detail.Add("FAVGCTY", data["FAVGCTY"]);
                            each_detail.Add("FCTY", data["FCTY"]);
                            each_detail.Add("FEXPPERIOD", data["FEXPPERIOD"]);
                            each_detail.Add("FEXPUNIT", data["FEXPUNIT"]);
                            each_detail.Add("FTRACKNO", data["FTRACKNO"]);
                            each_detail.Add("FHASINBOUNDCTY", data["FHASINBOUNDCTY"]);
                            each_detail.Add("FNeedINBOUNDCTY", data["FNeedINBOUNDCTY"]);

                            int count = ReturnFLOCID(whid, areaid, ownerid, data["FMaterialFID"].ToString()).Count;
                            if (count == 0)
                            {
                                each_detail.Add("InventeryForAdvise", ReturnInventery(whid, areaid, ownerid, data["FMaterialFID"].ToString()));
                            }
                            else
                            {
                                each_detail.Add("InventeryForAdvise", ReturnFLOCID(whid, areaid, ownerid, data["FMaterialFID"].ToString()));
                            }
                            detail_list.Add(each_detail);
                        }
                        return_data.Add("DetailList", detail_list);
                    }
                    //返回数据
                    Final_data.Add(return_data);
                }
                //循环以外
                result.Code    = (int)ResultCode.Success;
                result.Data    = Final_data;
                result.Message = "成功返回数据!";
            }
            catch (Exception ex)
            {
                result.Code    = (int)ResultCode.Fail;
                result.Message = ex.Message;
            }
            if (result.Message == "未将对象引用设置到对象的实例。")
            {
                result.Message = "未检索到对应信息!";
            }
            return(result);
        }
Esempio n. 20
0
        public override void DataChanged(BOS.Core.DynamicForm.PlugIn.Args.DataChangedEventArgs e)
        {
            if (this.View.UserParameterKey.Equals("SAL_OUTSTOCK") || this.View.UserParameterKey.Equals("SP_ReturnMtrl") || this.View.UserParameterKey.Equals("SAL_RETURNSTOCK") ||
                this.View.UserParameterKey.Equals("STK_MisDelivery") || this.View.UserParameterKey.Equals("STK_OEMInStockRETURN") || this.View.UserParameterKey.Equals("SAL_SaleOrder"))
            {
                if (e.Field.Key.EqualsIgnoreCase("FLot"))
                {
                    string sFlot     = "";
                    string sMaterial = "";
                    Object lot       = this.View.Model.GetValue(e.Field.Key, e.Row);
                    if (null != lot && null != lot as DynamicObject)
                    {
                        DynamicObject lotObj = lot as DynamicObject;
                        sFlot = lotObj.DynamicObjectType.Properties.Contains("Number") ? lotObj["Number"].ToString() : null;
                    }
                    else
                    {
                        sFlot = Convert.ToString(this.View.Model.GetValue(e.Field.Key, e.Row));
                    }
                    object material = this.View.Model.GetValue("FMaterialID", e.Row);
                    if (null != material && null != material as DynamicObject)
                    {
                        DynamicObject materialObj = material as DynamicObject;
                        sMaterial = materialObj.DynamicObjectType.Properties.Contains("msterID") ? materialObj["msterID"].ToString() : null;
                    }
                    //       queryParam.FilterClauseWihtKey = " FNUMBER = @FNUMBER AND FCREATEORGID = @FCREATEORGID AND FMaterialID=@FMaterialID AND FBIZTYPE = 1";
                    //     queryParam.SqlParams.Add(new SqlParam("@FMaterialID", KDDbType.Int64, Convert.ToInt64(mainOrg["msterID"])));

                    DynamicObject lotEntity = null;
                    if (!sFlot.IsNullOrEmptyOrWhiteSpace())
                    {
                        FormMetadata          metadata   = MetaDataServiceHelper.Load(this.Context, "BD_BatchMainFile") as FormMetadata;
                        List <SqlParam>       lstParams  = new List <SqlParam>();
                        QueryBuilderParemeter queryParam = new QueryBuilderParemeter();
                        queryParam.BusinessInfo        = metadata.BusinessInfo;
                        queryParam.FilterClauseWihtKey = " FNUMBER = @FNUMBER AND FMaterialID = @FMaterialID AND FBIZTYPE = 1";
                        queryParam.SqlParams.Add(new SqlParam("@FNUMBER", KDDbType.String, sFlot));
                        string        mainOrgKey = this.View.BusinessInfo.MainOrgField.Key;
                        DynamicObject mainOrg    = this.View.Model.GetValue(mainOrgKey) as DynamicObject;
                        queryParam.SqlParams.Add(new SqlParam("@FMaterialID", KDDbType.String, sMaterial));
                        DynamicObject[] orgs = BusinessDataServiceHelper.Load(this.Context, metadata.BusinessInfo.GetDynamicObjectType(), queryParam);
                        if (orgs.Count() > 0)
                        {
                            lotEntity = orgs.FirstOrDefault();
                        }
                    }
                    if (null != lotEntity)
                    {
                        //长度
                        this.View.Model.SetValue("F_Length", lotEntity["F_Length"], e.Row);
                        //宽度
                        this.View.Model.SetValue("F_Width", lotEntity["F_Width"], e.Row);
                        //厚度
                        this.View.Model.SetValue("F_Thinkness", lotEntity["F_Thinkness"], e.Row);
                        //实长
                        this.View.Model.SetValue("F_RealLength", lotEntity["F_RealLength"], e.Row);
                        //实宽
                        this.View.Model.SetValue("F_RealWidth", lotEntity["F_RealWidth"], e.Row);
                        //实厚
                        this.View.Model.SetValue("F_RealThinkness", lotEntity["F_RealThinkness"], e.Row);
                        //规格
                        this.View.Model.SetValue("F_Specification", lotEntity["F_Specification"], e.Row);
                        //计重方式
                        this.View.Model.SetValue("F_WeightMethod", lotEntity["F_WeightMethod"], e.Row);
                        //质量等级
                        this.View.Model.SetValue("F_QualityLevel", lotEntity["F_QualityLevel"], e.Row);
                        //边部状况
                        this.View.Model.SetValue("F_EdgeState", lotEntity["F_EdgeState"], e.Row);
                        ////表面
                        //this.View.Model.SetValue("F_Surface", lotEntity["F_Surface"], e.Row);
                        ////材质
                        //this.View.Model.SetValue("F_MQuailty", lotEntity["F_MQuailty"], e.Row);
                        ////类别
                        //this.View.Model.SetValue("F_Category", lotEntity["F_Category"], e.Row);
                        //标准
                        this.View.Model.SetValue("F_Standard", lotEntity["F_Standard"], e.Row);
                        //碳含量
                        this.View.Model.SetValue("F_CContent", lotEntity["F_CContent"], e.Row);
                        //铬含量
                        this.View.Model.SetValue("F_CrContent", lotEntity["F_CrContent"], e.Row);
                        //成份备注
                        this.View.Model.SetValue("F_ElementRemark", lotEntity["F_ElementRemark"], e.Row);
                        //性能备注
                        this.View.Model.SetValue("F_PerRemark", lotEntity["F_PerRemark"], e.Row);
                        //表面备注
                        this.View.Model.SetValue("F_Thinkness", lotEntity["F_Thinkness"], e.Row);
                        //其他备注
                        this.View.Model.SetValue("F_SurfaceRemark", lotEntity["F_SurfaceRemark"], e.Row);
                        //产地
                        this.View.Model.SetValue("F_Origin", lotEntity["F_Origin"], e.Row);
                        //质保书号
                        this.View.Model.SetValue("F_QANo", lotEntity["F_QANo"], e.Row);
                        //成品类别
                        this.View.Model.SetValue("F_PCategory", lotEntity["F_PCategory"], e.Row);
                    }
                }
            }
        }
Esempio n. 21
0
        /// <summary>
        /// 目标单单据构建完毕,且已经创建好与源单的关联关系之后,触发此事件
        /// </summary>
        /// <param name="e"></param>
        /// <remarks>
        /// 本事件的时机,刚好能够符合需求,
        /// 而AfterConvert事件,则在执行表单服务策略之后
        /// </remarks>
        public override void OnAfterCreateLink(CreateLinkEventArgs e)
        {
            // 目标单单据体元数据
            Entity entity = e.TargetBusinessInfo.GetEntity("FEntity");
            Entity es     = e.SourceBusinessInfo.GetEntity("FSaleOrderEntry");

            // 读取已经生成的付款单
            ExtendedDataEntity[] bills = e.TargetExtendedDataEntities.FindByEntityKey("FBillHead");

            // 定义一个集合,存储新拆分出来的单据体行
            List <ExtendedDataEntity> newRows = new List <ExtendedDataEntity>();

            // 对目标单据进行循环
            foreach (var bill in bills)
            {
                // 取单据体集合
                DynamicObjectCollection rowObjs = entity.DynamicProperty.GetValue(bill.DataEntity)
                                                  as DynamicObjectCollection;
                // 对单据体进行循环:从后往前循环,新拆分的行,避开循环
                int      rowCount    = rowObjs.Count;
                int      newRowCount = 1;
                DateTime CreateDate  = Convert.ToDateTime(bill["CreateDate"]);
                for (int i = rowCount - 1; i >= 0; i--)
                {
                    DynamicObject rowObj = rowObjs[i];
                    //获取ID为149808的供应商(内蒙)
                    DynamicObject[] superIDs = BusinessDataServiceHelper.Load(this.Context, new object[] { 149808 }, (MetaDataServiceHelper.Load(this.Context, "BD_Supplier") as FormMetadata).BusinessInfo.GetDynamicObjectType());
                    rowObj["SuggestSupplierId"]    = superIDs[0];
                    rowObj["SuggestSupplierId_Id"] = 149808;
                    rowObj["SupplierId"]           = superIDs[0];
                    rowObj["SupplierId_Id"]        = 149808;

                    long          MaterialId = Convert.ToInt64(rowObj["MaterialId_Id"]);
                    long          SupplierId = 149808;
                    DynamicObject auxprop    = rowObj["AuxpropId"] as DynamicObject;
                    string        auxpropId  = "";
                    if (auxprop != null)
                    {
                        auxpropId = Convert.ToString(auxprop["F100001_Id"]);
                    }
                    DynamicObjectCollection prices = ServiceHelper.YDLCommServiceHelper.GetAuxpropPriceListId(this.Context, MaterialId, auxpropId, SupplierId, CreateDate);
                    if (prices.Count > 0)
                    {
                        rowObj["FTAXPRICE"]     = prices[0][2];
                        rowObj["EvaluatePrice"] = prices[0][1];
                        rowObj["FTAXRATE"]      = 17;
                    }
                }
            }
        }
Esempio n. 22
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);
            }
        }
Esempio n. 23
0
        /// <summary>
        /// 生成方案
        /// </summary>
        /// <returns></returns>
        public ReturnParam GenerateSolutions(ReturnInfo returnInfo, Context context)
        {
            string      sql         = string.Empty;
            ReturnParam returnParam = new ReturnParam();

            try
            {
                string Fnumber = returnInfo.Fnumber;
                int    qty     = returnInfo.Qty;
                string dengji  = returnInfo.FGG;
                //截取等级
                string[] array = Regex.Split(dengji, ",", RegexOptions.IgnoreCase);
                //等级
                List <Level> dj = new List <Level>()
                {
                    new Level()
                    {
                        Id = "100002", FAUXPTYNUMBER = "A"
                    },
                    new Level()
                    {
                        Id = "100003", FAUXPTYNUMBER = "B"
                    },
                    new Level()
                    {
                        Id = "100004", FAUXPTYNUMBER = "F"
                    },
                    new Level()
                    {
                        Id = "100005", FAUXPTYNUMBER = "N"
                    },
                    new Level()
                    {
                        Id = "100006", FAUXPTYNUMBER = "TB"
                    },
                    new Level()
                    {
                        Id = "100007", FAUXPTYNUMBER = "T"
                    },
                    new Level()
                    {
                        Id = "100008", FAUXPTYNUMBER = "P"
                    },
                    new Level()
                    {
                        Id = "100009", FAUXPTYNUMBER = "TB/B"
                    },
                    new Level()
                    {
                        Id = "100010", FAUXPTYNUMBER = "B/F"
                    },
                    new Level()
                    {
                        Id = "100011", FAUXPTYNUMBER = "F/N"
                    },
                };
                string        sqldj = "";
                List <string> vs    = new List <string>();
                for (int j = 0; j < array.Length; j++)
                {
                    Level level = dj.SingleOrDefault(p => p.FAUXPTYNUMBER == array[j].ToString());
                    if (level != null)
                    {
                        if (j == 0)
                        {
                            sqldj += "  t1.FMATERIALID=" + Fnumber + " and t1.FBASEQTY > 0 and t1.FAUXPROPID='" + level.Id + "' ";
                        }
                        else
                        {
                            sqldj += " or t1.FMATERIALID=" + Fnumber + " and t1.FBASEQTY > 0 and t1.FAUXPROPID='" + level.Id + "' ";
                        }
                    }
                }
                double PCSCONVERT = 1;
                double FDXQTY     = 1;
                //获取库存数据
                sql = "select t1.FMATERIALID,t1.FLOT,t2.FNUMBER,t1.FBASEQTY, t4.FDATE ,t5.FPCSCONVERT,t5.FDXQTY,t1.FAUXPROPID   From  T_STK_INVENTORY t1" +
                      " left  join  T_BD_LOTMASTER t2 on t1.FLOT = t2.FLOTID" +
                      " left join T_STK_INSTOCKENTRY t3 on  t3.FLOT = t1.FLOT and t3.FMATERIALID = t1.FMATERIALID" +
                      " left join t_STK_InStock t4 on t3.FID = t4.FID" +
                      " left join  T_BD_MATERIAL t5 on t5.FMATERIALID=t1.FMATERIALID" +
                      " where ";
                string sqlend = " order by t4.FDATE asc";
                if (string.IsNullOrEmpty(dengji))
                {
                    sqldj = "t1.FMATERIALID=" + Fnumber + " and t1.FBASEQTY > 0 " + sqlend;
                    sql   = sql + sqldj;
                }
                else
                {
                    sql = sql + sqldj + sqlend;
                }
                DataSet   ds = DBServiceHelper.ExecuteDataSet(context, sql);
                DataTable dt = ds.Tables[0];
                #region 方法二: 创建视图、模型,模拟手工新增,会触发大部分的表单服务和插件
                FormMetadata             meta = MetaDataServiceHelper.Load(context, "PAEZ_OrderPlan") as FormMetadata;
                BusinessInfo             info = meta.BusinessInfo;
                IResourceServiceProvider formServiceProvider = meta.BusinessInfo.GetForm().GetFormServiceProvider(true);
                IBillViewService         billViewService     = formServiceProvider.GetService(typeof(IDynamicFormView)) as IBillViewService;

                /******创建单据打开参数*************/
                Form form = meta.BusinessInfo.GetForm();
                BillOpenParameter billOpenParameter = new BillOpenParameter(form.Id, meta.GetLayoutInfo().Id);
                billOpenParameter                       = new BillOpenParameter(form.Id, string.Empty);
                billOpenParameter.Context               = context;
                billOpenParameter.ServiceName           = form.FormServiceName;
                billOpenParameter.PageId                = Guid.NewGuid().ToString();
                billOpenParameter.FormMetaData          = meta;
                billOpenParameter.LayoutId              = meta.GetLayoutInfo().Id;
                billOpenParameter.Status                = OperationStatus.ADDNEW;
                billOpenParameter.PkValue               = null;
                billOpenParameter.CreateFrom            = CreateFrom.Default;
                billOpenParameter.ParentId              = 0;
                billOpenParameter.GroupId               = "";
                billOpenParameter.DefaultBillTypeId     = null;
                billOpenParameter.DefaultBusinessFlowId = null;
                billOpenParameter.SetCustomParameter("ShowConfirmDialogWhenChangeOrg", false);
                List <AbstractDynamicFormPlugIn> value = form.CreateFormPlugIns();
                billOpenParameter.SetCustomParameter(FormConst.PlugIns, value);

                ((IDynamicFormViewService)billViewService).Initialize(billOpenParameter, formServiceProvider);

                IBillView bill_view = (IBillView)billViewService;

                bill_view.CreateNewModelData();

                DynamicFormViewPlugInProxy proxy = bill_view.GetService <DynamicFormViewPlugInProxy>();
                proxy.FireOnLoad();
                bill_view.Model.SetItemValueByID("FSaleOrgId", context.CurrentOrganizationInfo.ID, 0);
                bill_view.Model.SetValue("FDate", DateTime.Now.ToString());
                List <OrderPlan> orderPlans = new List <OrderPlan>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    OrderPlan order = new OrderPlan();
                    bill_view.Model.CreateNewEntryRow("FEntity");
                    bill_view.Model.SetValue("FMATERIALID", dt.Rows[i]["FMATERIALID"].ToString(), i);
                    string[] str = Regex.Split(dt.Rows[i]["FNUMBER"].ToString(), "_", RegexOptions.IgnoreCase);
                    // string level= dj.Select(x => x.Id = dt.Rows[i]["FAUXPROPID"].ToString()).First();
                    Level level = dj.SingleOrDefault(p => p.Id == dt.Rows[i]["FAUXPROPID"].ToString());
                    if (level != null)
                    {
                        //等级
                        bill_view.Model.SetItemValueByNumber("$$FAUXPROPID__FF100001", level.FAUXPTYNUMBER, i);
                    }
                    bill_view.Model.SetValue("FINVOICE", str[0].ToString(), i);
                    //板号
                    bill_view.Model.SetValue("FBoardNo", str[1].ToString(), i);
                    //箱号
                    bill_view.Model.SetValue("FCartonNo", str[2].ToString(), i);
                    //库存数量
                    bill_view.Model.SetValue("FQTY", dt.Rows[i]["FBASEQTY"].ToString(), i);
                    //入库日期
                    bill_view.Model.SetValue("FInboundDate", dt.Rows[i]["FDATE"].ToString(), i);
                    //下单数量
                    bill_view.Model.SetValue("FOrderQty", qty, i);
                    //批号
                    bill_view.Model.SetValue("FLOT", dt.Rows[i]["FLOT"].ToString(), i);
                    double FPCSCONVERT = 1;
                    if (string.IsNullOrEmpty(dt.Rows[i]["FPCSCONVERT"].ToString()))
                    {
                        FPCSCONVERT = Convert.ToDouble(dt.Rows[i]["FBASEQTY"].ToString());
                    }
                    else
                    {
                        PCSCONVERT  = Convert.ToDouble(dt.Rows[i]["FPCSCONVERT"].ToString());
                        FPCSCONVERT = Convert.ToDouble(dt.Rows[i]["FPCSCONVERT"].ToString()) * Convert.ToDouble(dt.Rows[i]["FBASEQTY"].ToString());
                    }
                    FDXQTY = Convert.ToDouble(dt.Rows[i]["FDXQTY"].ToString());
                    //转化pcs数量
                    bill_view.Model.SetValue("FPCSQTY", FPCSCONVERT, i);
                    //保存数据
                    order.FMATERIALID  = dt.Rows[i]["FMATERIALID"].ToString();
                    order.FINVOICE     = str[0].ToString();
                    order.FBoardNo     = str[1].ToString();
                    order.FCartonNo    = str[2].ToString();
                    order.FQTY         = Convert.ToDouble(dt.Rows[i]["FBASEQTY"].ToString());
                    order.FInboundDate = dt.Rows[i]["FDATE"].ToString();
                    order.FOrderQty    = qty;
                    order.FLOT         = dt.Rows[i]["FLOT"].ToString();
                    order.FPCSCONVERT  = FPCSCONVERT;
                    order.FAUXPROPID   = dt.Rows[i]["FAUXPROPID"].ToString();
                    orderPlans.Add(order);
                }

                //计算出最优方案 1.计算是刚好等于西单数量的 2.计算出最靠近下单数量的

                // 单箱的pcs
                double SingleFCartonNo = PCSCONVERT * FDXQTY;

                int TotalFCartonNo = Convert.ToInt32(Math.Floor(qty / SingleFCartonNo));

                //剩余数量
                double    RemainQty         = qty % SingleFCartonNo;
                OrderPlan order2            = new OrderPlan();
                bool      Isminimum         = false;
                OrderPlan order3            = new OrderPlan();
                double    differenceQty     = 0;
                double    olddifferenceQty  = 0;
                double    newdifferenceQty2 = 0;
                if (RemainQty != 0)
                {
                    #region  计算出最靠近剩余数量的数并多于下单数量(最右原则)
                    foreach (var item in orderPlans)
                    {
                        if (differenceQty == 0 && item.FPCSCONVERT - RemainQty >= 0)
                        {
                            differenceQty       = item.FPCSCONVERT - RemainQty;
                            order2.FMATERIALID  = item.FMATERIALID;
                            order2.FINVOICE     = item.FINVOICE;
                            order2.FBoardNo     = item.FBoardNo;
                            order2.FCartonNo    = item.FCartonNo;
                            order2.FQTY         = item.FQTY;
                            order2.FInboundDate = item.FInboundDate;
                            order2.FOrderQty    = item.FOrderQty;
                            order2.FLOT         = item.FLOT;
                            order2.FAUXPROPID   = item.FAUXPROPID;
                            order2.FPCSCONVERT  = item.FPCSCONVERT;
                        }
                        else
                        {
                            double newdifferenceQty = item.FPCSCONVERT - RemainQty;
                            if (newdifferenceQty > 0 && newdifferenceQty < differenceQty)
                            {
                                differenceQty       = newdifferenceQty;
                                order2.FMATERIALID  = item.FMATERIALID;
                                order2.FINVOICE     = item.FINVOICE;
                                order2.FBoardNo     = item.FBoardNo;
                                order2.FCartonNo    = item.FCartonNo;
                                order2.FQTY         = item.FQTY;
                                order2.FInboundDate = item.FInboundDate;
                                order2.FOrderQty    = item.FOrderQty;
                                order2.FLOT         = item.FLOT;
                                order2.FAUXPROPID   = item.FAUXPROPID;
                                order2.FPCSCONVERT  = item.FPCSCONVERT;
                            }
                        }
                    }

                    #endregion

                    #region  计算最靠近的数量并小于下单数量(最左原则)
                    foreach (var item in orderPlans)
                    {
                        newdifferenceQty2 = item.FPCSCONVERT - RemainQty;
                        if (newdifferenceQty2 <= 0)
                        {
                            if (olddifferenceQty != 0)
                            {
                                if (Math.Abs(newdifferenceQty2) < Math.Abs(olddifferenceQty))
                                {
                                    olddifferenceQty    = newdifferenceQty2;
                                    order3.FMATERIALID  = item.FMATERIALID;
                                    order3.FINVOICE     = item.FINVOICE;
                                    order3.FBoardNo     = item.FBoardNo;
                                    order3.FCartonNo    = item.FCartonNo;
                                    order3.FQTY         = item.FQTY;
                                    order3.FInboundDate = item.FInboundDate;
                                    order3.FOrderQty    = item.FOrderQty;
                                    order3.FLOT         = item.FLOT;
                                    order3.FPCSCONVERT  = item.FPCSCONVERT;
                                    order3.FAUXPROPID   = item.FAUXPROPID;
                                    Isminimum           = true;
                                }
                            }
                            else
                            {
                                olddifferenceQty    = newdifferenceQty2;
                                order3.FMATERIALID  = item.FMATERIALID;
                                order3.FINVOICE     = item.FINVOICE;
                                order3.FBoardNo     = item.FBoardNo;
                                order3.FCartonNo    = item.FCartonNo;
                                order3.FQTY         = item.FQTY;
                                order3.FInboundDate = item.FInboundDate;
                                order3.FOrderQty    = item.FOrderQty;
                                order3.FLOT         = item.FLOT;
                                order3.FAUXPROPID   = item.FAUXPROPID;
                                order3.FPCSCONVERT  = item.FPCSCONVERT;
                                Isminimum           = true;
                            }
                        }
                    }

                    #endregion
                }
                #region 组装数据
                //当前库存不够发
                if (orderPlans.Count < TotalFCartonNo)
                {
                    returnParam.status = true;
                    returnParam.msg    = "当前库存数量不够发货";
                    return(returnParam);
                }
                else
                {
                    //排除非整箱
                    List <OrderPlan> orderPlan  = orderPlans.FindAll(t => t.FLOT != order2.FLOT);
                    List <OrderPlan> orderPlan3 = orderPlans.FindAll(t => t.FLOT != order3.FLOT);
                    int j = 0;
                    #region 最右原则
                    foreach (var item in orderPlan)
                    {
                        if (j == TotalFCartonNo)
                        {
                            break;
                        }
                        else
                        {
                            if (item.FPCSCONVERT == SingleFCartonNo)
                            {
                                bill_view.Model.CreateNewEntryRow("F_PAEZ_Entity");
                                bill_view.Model.SetValue("FMATERIALID2", item.FMATERIALID, j);
                                //等级
                                //bill_view.Model.SetItemValueByID("FAUXPROPID2", item.FAUXPROPID, j);

                                Level level = dj.SingleOrDefault(p => p.Id == item.FAUXPROPID);
                                if (level != null)
                                {
                                    //等级
                                    bill_view.Model.SetItemValueByNumber("$$FAUXPROPID2__FF100001", level.FAUXPTYNUMBER, j);
                                }
                                bill_view.Model.SetValue("FINVOICE2", item.FINVOICE, j);
                                //板号
                                bill_view.Model.SetValue("FBoardNo2", item.FBoardNo, j);
                                //箱号
                                bill_view.Model.SetValue("FCartonNo2", item.FCartonNo, j);
                                //库存数量
                                bill_view.Model.SetValue("FQTY2", item.FQTY, j);
                                //入库日期
                                bill_view.Model.SetValue("FInboundDate2", item.FInboundDate, j);
                                //下单数量
                                bill_view.Model.SetValue("FOrderQty2", item.FOrderQty, j);
                                //批号
                                bill_view.Model.SetValue("FLOT2", item.FLOT, j);
                                //转化pcs数量
                                bill_view.Model.SetValue("FPCSQTY2", item.FPCSCONVERT, j);
                                j++;
                            }
                        }
                    }
                    //加入剩余数量
                    if (RemainQty != 0)
                    {
                        bill_view.Model.CreateNewEntryRow("F_PAEZ_Entity");
                        bill_view.Model.SetValue("FMATERIALID2", order2.FMATERIALID, j);
                        //等级
                        if (!string.IsNullOrEmpty(order2.FAUXPROPID) && order2.FAUXPROPID != "0")
                        {
                            Level level = dj.SingleOrDefault(p => p.Id == order2.FAUXPROPID);
                            //等级
                            bill_view.Model.SetItemValueByNumber("$$FAUXPROPID2__FF100001", level.FAUXPTYNUMBER, j);
                        }
                        bill_view.Model.SetValue("FINVOICE2", order2.FINVOICE, j);
                        //板号
                        bill_view.Model.SetValue("FBoardNo2", order2.FBoardNo, j);
                        //箱号
                        bill_view.Model.SetValue("FCartonNo2", order2.FCartonNo, j);
                        //库存数量
                        bill_view.Model.SetValue("FQTY2", order2.FQTY, j);
                        //入库日期
                        bill_view.Model.SetValue("FInboundDate2", order2.FInboundDate, j);
                        //下单数量
                        bill_view.Model.SetValue("FOrderQty2", order2.FOrderQty, j);
                        //批号
                        bill_view.Model.SetValue("FLOT2", order2.FLOT, j);
                        //转化pcs数量
                        bill_view.Model.SetValue("FPCSQTY2", order2.FPCSCONVERT, j);
                    }

                    #endregion

                    #region 最左原则
                    int a = 0;
                    foreach (var item in orderPlan3)
                    {
                        if (a == TotalFCartonNo)
                        {
                            break;
                        }
                        else
                        {
                            if (item.FPCSCONVERT == SingleFCartonNo)
                            {
                                bill_view.Model.CreateNewEntryRow("F_PAEZ_Entity3");
                                bill_view.Model.SetValue("FMATERIALID3", item.FMATERIALID, a);
                                //等级
                                //bill_view.Model.SetItemValueByID("FAUXPROPID3", item.FAUXPROPID, a);
                                Level level = dj.SingleOrDefault(p => p.Id == item.FAUXPROPID);
                                if (level != null)
                                {
                                    //等级
                                    bill_view.Model.SetItemValueByNumber("$$FAUXPROPID3__FF100001", level.FAUXPTYNUMBER, a);
                                }
                                bill_view.Model.SetValue("FINVOICE3", item.FINVOICE, a);
                                //板号
                                bill_view.Model.SetValue("FBoardNo3", item.FBoardNo, a);
                                //箱号
                                bill_view.Model.SetValue("FCartonNo3", item.FCartonNo, a);
                                //库存数量
                                bill_view.Model.SetValue("FQTY3", item.FQTY, a);
                                //入库日期
                                bill_view.Model.SetValue("FInboundDate3", item.FInboundDate, a);
                                //下单数量
                                bill_view.Model.SetValue("FOrderQty3", item.FOrderQty, a);
                                //批号
                                bill_view.Model.SetValue("FLOT3", item.FLOT, a);
                                //转化pcs数量
                                bill_view.Model.SetValue("FPCSQTY3", item.FPCSCONVERT, a);
                                a++;
                            }
                        }
                    }
                    //加入剩余数量
                    if (RemainQty != 0)
                    {
                        bill_view.Model.CreateNewEntryRow("F_PAEZ_Entity3");
                        bill_view.Model.SetValue("FMATERIALID3", order3.FMATERIALID, a);
                        //等级
                        if (!string.IsNullOrEmpty(order3.FAUXPROPID) && order3.FAUXPROPID != "0")
                        {
                            Level level = dj.SingleOrDefault(p => p.Id == order3.FAUXPROPID);
                            //等级
                            bill_view.Model.SetItemValueByNumber("$$FAUXPROPID3__FF100001", level.FAUXPTYNUMBER, a);
                        }
                        bill_view.Model.SetValue("FINVOICE3", order3.FINVOICE, a);
                        //板号
                        bill_view.Model.SetValue("FBoardNo3", order3.FBoardNo, a);
                        //箱号
                        bill_view.Model.SetValue("FCartonNo3", order3.FCartonNo, a);
                        //库存数量
                        bill_view.Model.SetValue("FQTY3", order3.FQTY, a);
                        //入库日期
                        bill_view.Model.SetValue("FInboundDate3", order3.FInboundDate, a);
                        //下单数量
                        bill_view.Model.SetValue("FOrderQty3", order3.FOrderQty, a);
                        //批号
                        bill_view.Model.SetValue("FLOT3", order3.FLOT, a);
                        //转化pcs数量
                        bill_view.Model.SetValue("FPCSQTY3", order3.FPCSCONVERT, a);
                    }

                    #endregion
                }
                #endregion
                string result = "";

                IOperationResult save_result = bill_view.Model.Save();
                if (save_result.IsSuccess)
                {
                    string fid = string.Empty;
                    OperateResultCollection Collection = save_result.OperateResult;
                    foreach (var item in Collection)
                    {
                        fid = item.PKValue.ToString();
                    }
                    returnParam.FBUSINESSCODE = fid;
                    returnParam.FBIZFORMID    = "PAEZ_OrderPlan";
                    returnParam.msg           = "方案生成功";
                    returnParam.status        = true;
                    return(returnParam);
                }
                else
                {
                    for (int mf = 0; mf < save_result.ValidationErrors.Count; mf++)
                    {
                        result += "\r\n" + save_result.ValidationErrors[mf].Message;
                    }
                }


                #endregion
            }
            catch (Exception ex)
            {
                returnParam.msg    = ex.ToString();
                returnParam.status = false;
                returnParam.msg    = "方案生成失败";
                return(returnParam);
            }
            return(returnParam);
        }
Esempio n. 24
0
        /// <summary>
        /// 绑定单据后,上传附件
        /// </summary>
        private string BindForm_UploadAttach()
        {
            if (jSONObject != null)
            {
                JSONArray jSONArray = new JSONArray(jSONObject["NewValue"].ToString());
                if (jSONArray.Count > 0)
                {
                    List <DynamicObject> dynList = new List <DynamicObject>();
                    StringBuilder        sb      = new StringBuilder();
                    for (int i = 0; i < jSONArray.Count; i++)
                    {
                        //获取上传的文件名
                        string serverFileName = (jSONArray[i] as Dictionary <string, object>)["ServerFileName"].ToString();
                        string fileName       = (jSONArray[i] as Dictionary <string, object>)["FileName"].ToString();
                        //文件上传到服务端的临时目录
                        string directory = "FileUpLoadServices\\UploadFiles";
                        //文件的完整路径
                        string fileFullPath = PathUtils.GetPhysicalPath(directory, serverFileName);

                        var formMetadata = (FormMetadata)MetaDataServiceHelper.Load(this.Context, FormIdConst.BOS_Attachment);
                        var dataBuff     = System.IO.File.ReadAllBytes(fileFullPath);
                        var dyn          = new DynamicObject(formMetadata.BusinessInfo.GetDynamicObjectType());

                        if (submitType != 0)
                        {
                            // 将数据上传至文件服务器,并返回上传结果
                            var result = this.UploadAttachment(fileName, dataBuff);
                            if (!result.Success)
                            {
                                // 上传失败,收集失败信息
                                sb.AppendLine(string.Format("附件:{0},上传失败:{1}", fileName, result.Message));
                                continue;
                            }

                            // 通过这个FileId就可以从文件服务器下载到对应的附件
                            dyn["FileId"] = result.FileId;
                        }
                        else
                        {
                            // 数据库的方式是直接保存附件数据
                            dyn["Attachment"] = dataBuff;
                        }
                        string _BillType = this.View.BusinessInfo.GetForm().Id;
                        string _BillNo   = this.View.Model.DataObject["BillNo"].ToString(); //原始BOS单据【绑定实体属性】
                        string _InterID  = this.View.Model.DataObject["Id"].ToString();

                        dyn["BillType"] = _BillType;
                        dyn["BillNo"]   = _BillNo;
                        dyn["InterID"]  = _InterID;

                        // 上传文件服务器成功后才加入列表
                        dyn["AttachmentName"] = fileName;
                        dyn["AttachmentSize"] = Math.Round(dataBuff.Length / 1024.0, 2);
                        dyn["EntryInterID"]   = -1;// 参照属性解读

                        dyn["CreateMen_Id"] = Convert.ToInt32(this.Context.UserId);
                        dyn["CreateMen"]    = GetUser(this.Context.UserId.ToString());
                        dyn["ModifyTime"]   = dyn["CreateTime"] = TimeServiceHelper.GetSystemDateTime(this.Context);
                        dyn["ExtName"]      = System.IO.Path.GetExtension(fileName);
                        dyn["FileStorage"]  = submitType.ToString();
                        dyn["EntryKey"]     = " ";

                        dynList.Add(dyn);
                    }
                    if (dynList.Count > 0)
                    {
                        // 所有数据加载完成后再一次性保存全部
                        BusinessDataServiceHelper.Save(this.Context, dynList.ToArray());

                        sb.AppendLine();
                        sb.AppendLine(string.Join(",", dynList.Select(dyn => dyn["AttachmentName"].ToString()).ToArray()) + ",上传成功");
                    }

                    //写入上传日志 增加判定 FLog不存在不写入
                    if (this.Model.BillBusinessInfo.GetElement("FLog") != null)
                    {
                        this.Model.SetValue("FLog", sb.ToString());
                    }
                    return(sb.ToString());
                }
            }
            return("");
        }
Esempio n. 25
0
        public static IOperationResult DoAction(Context context, string[] selPKArray, Enum_OPPAction action)
        {
            IOperationResult            operationResult         = new OperationResult();
            OperateResultCollection     operateResultCollection = new OperateResultCollection();
            Dictionary <string, string> dictionary = new Dictionary <string, string>();
            List <DynamicObject>        list       = new List <DynamicObject>();
            FormMetadata formMetadata = (FormMetadata)MetaDataServiceHelper.Load(context, "CRM_OPP_Opportunity", true);
            BusinessInfo businessInfo = formMetadata.BusinessInfo;

            DynamicObject[] array = BusinessDataServiceHelper.Load(context, selPKArray, businessInfo.GetDynamicObjectType());
            if (array == null || array.Length == 0)
            {
                operateResultCollection.Add(OpportunityCommon.CreateOperateResult(false, ResManager.LoadKDString("未找到对应的数据,可能已被删除!", "006008030001276", SubSystemType.CRM, new object[0])));
                operationResult.OperateResult = operateResultCollection;
                return(operationResult);
            }
            DynamicObject[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                DynamicObject dynamicObject = array2[i];
                string        text          = CheckBeforeAction(dynamicObject, action);
                if (text != "")
                {
                    operateResultCollection.Add(OpportunityCommon.CreateOperateResult(false, text));
                    operationResult.OperateResult = operateResultCollection;
                }
                else
                {
                    if (action == Enum_OPPAction.WIN)
                    {
                        dynamicObject["FDocumentStatus"] = "E";
                    }
                    else
                    {
                        if (action == Enum_OPPAction.LOSE)
                        {
                            dynamicObject["FDocumentStatus"] = "F";
                        }
                        else
                        {
                            if (action == Enum_OPPAction.UNWIN || action == Enum_OPPAction.UNLOSE)
                            {
                                dynamicObject["FDocumentStatus"] = "G";
                            }
                        }
                    }
                    if (action == Enum_OPPAction.WIN || action == Enum_OPPAction.LOSE)
                    {
                        DynamicObjectCollection dynamicObjectCollection = dynamicObject["T_CRM_OppPhase"] as DynamicObjectCollection;
                        foreach (DynamicObject current in dynamicObjectCollection)
                        {
                            if (current["FIsCurrent"].ToString() == "True")
                            {
                                current["FEndtimeReal"] = DateTime.Now;
                                break;
                            }
                        }
                    }
                    dictionary.Add(dynamicObject["Id"].ToString(), dynamicObject["FOPPName"].ToString());
                    list.Add(dynamicObject);
                }
            }
            if (list.Count > 0)
            {
                IOperationResult operationResult2 = BusinessDataServiceHelper.Save(context, businessInfo, list.ToArray(), null, "");
                if (action == Enum_OPPAction.WIN || action == Enum_OPPAction.LOSE)
                {
                    Dictionary <string, string> dictionary2 = new Dictionary <string, string>();
                    string format = ResManager.LoadKDString("赢单商机【{0}】", "006008030001476", SubSystemType.CRM, new object[0]);
                    string text2  = "Win";
                    if (action == Enum_OPPAction.LOSE)
                    {
                        format = ResManager.LoadKDString("输单商机【{0}】", "006008030001477", SubSystemType.CRM, new object[0]);
                        text2  = "Lose";
                    }
                    foreach (OperateResult current2 in operationResult2.OperateResult)
                    {
                        if (current2.SuccessStatus)
                        {
                            dictionary2.Add(current2.PKValue.ToString(), string.Format(format, dictionary[current2.PKValue.ToString()]));
                        }
                    }
                    if (dictionary2.Count > 0)
                    {
                        ILatestInfoService latestInfoService = ServiceFactory.GetLatestInfoService(context);
                        latestInfoService.AddActionInfo(context, "CRM_OPP_Opportunity", text2, dictionary2);
                    }
                }
                if (operationResult.OperateResult.Count > 0)
                {
                    using (IEnumerator <OperateResult> enumerator3 = operationResult2.OperateResult.GetEnumerator())
                    {
                        while (enumerator3.MoveNext())
                        {
                            OperateResult current3 = enumerator3.Current;
                            operationResult.OperateResult.Add(current3);
                        }
                        return(operationResult);
                    }
                }
                operationResult.OperateResult = operationResult2.OperateResult;
            }
            return(operationResult);
        }
        /// <summary>
        /// 附件上传至本地临时目录后的回调函数
        /// PlugIn.Args.MobileUploadEventArgs
        /// Kingdee.BOS.Mobile.PlugIn.Args.MobileUploadEventArgs
        /// </summary>
        /// <param name="e">PlugIn.Args.MobileUploadEventArgs e</param>
        public override void AfterMobileUpload(Kingdee.BOS.Mobile.PlugIn.Args.MobileUploadEventArgs e)
        {
            // 获取服务器临时目录    HttpContext.Current.Request.PhysicalApplicationPath + KeyConst.TEMPFILEPATH;
            string tempDirPath = HttpContext.Current.Request.PhysicalApplicationPath + KeyConst.TEMPFILEPATH;
            // 获取附件表的元数据类
            var formMetadata = (FormMetadata)MetaDataServiceHelper.Load(this.Context, FormIdConst.BOS_Attachment);

            //TY:以下是取值 by 田杨
            //string _BillType = this.View.BillBusinessInfo.GetForm().Id;
            string _BillType = this.View.BillView.BusinessInfo.GetForm().Id;
            string _BillNo   = this.View.BillModel.DataObject["BillNo"].ToString(); //原始BOS单据【绑定实体属性】
            string _InterID  = this.View.BillModel.DataObject["Id"].ToString();

            /*  示例代码 从5.0
             * //_BillType = this.View.BillView.BusinessInfo.GetForm().Id;
             * //_BillNo = this.View.BillModel.DataObject["BillNo"];
             * //dyn["BillStatus"] = this.View.BillModel.DataObject["DocumentStatus"];
             * //_InterID = this.View.BillModel.DataObject["Id"];
             */

            List <DynamicObject> dynList = new List <DynamicObject>();
            StringBuilder        sb      = new StringBuilder();

            foreach (FiledUploadEntity file in e.FileNameArray)
            {
                // 检查文件是否成功上传到临时目录
                if (!file.IsSuccess)
                {
                    continue;
                }

                // 检查文件是否存在于临时目录
                var fileName = System.IO.Path.Combine(tempDirPath, file.FileName);
                if (!System.IO.File.Exists(fileName))
                {
                    continue;
                }

                /**
                 * 此处几个关键属性解读:
                 * 1. BillType  关联的模型的FormId
                 * 2. BillNo    关联的单据编号,用于确定此附件是属于哪张单据
                 * 3. InterID   关联的单据/基础资料ID,附件列表就是根据这个ID进行加载
                 * 4. EntryInterID  关联的单据体ID,这里我们只演示单据头,所以固定设置为-1
                 * 5. AttachmentSize    系统统一按照KB单位进行显示,所以需要除以1024
                 * 6. FileStorage   文件存储类型,0为数据库,1为文件服务,2为亚马逊云,3为金蝶云
                 */
                var dataBuff = System.IO.File.ReadAllBytes(fileName);
                var dyn      = new DynamicObject(formMetadata.BusinessInfo.GetDynamicObjectType());

                if (submitType != 0)
                {
                    // 将数据上传至文件服务器,并返回上传结果
                    var result = this.UploadAttachment(file.FileName, dataBuff);
                    if (!result.Success)
                    {
                        // 上传失败,收集失败信息
                        sb.AppendLine(string.Format("附件:{0},上传失败:{1}", file.FileName, result.Message));
                        continue;
                    }

                    // 通过这个FileId就可以从文件服务器下载到对应的附件
                    dyn["FileId"] = result.FileId;
                }
                else
                {
                    // 数据库的方式是直接保存附件数据
                    dyn["Attachment"] = dataBuff;
                }

                /*  示例代码 从6.1
                 * //// 此处我们不绑定到特定的单据,为了简化示例,只实现单纯的文件上传与下载
                 * //dyn["BillType"] = "Test_MOB_Accessory"; // 虚拟FormId
                 * //dyn["BillNo"] = "A00001"; // 虚拟的单据编号
                 * //dyn["InterID"] = "D00001"; // 虚拟的InterId,这个ID将作为我们下载的识别标识
                 *
                 *  示例代码 从5.0
                 * // 而实际插件开发可以从移动单据中获取到这些数据
                 * //dyn["BillType"] = this.View.BillView.BusinessInfo.GetForm().Id;
                 * //dyn["BillNo"] = this.View.BillModel.DataObject["BillNo"];
                 * ////dyn["BillStatus"] = this.View.BillModel.DataObject["DocumentStatus"];
                 * //dyn["InterID"] = this.View.BillModel.DataObject["Id"];
                 */

                dyn["BillType"] = _BillType;
                dyn["BillNo"]   = _BillNo;
                dyn["InterID"]  = _InterID;

                // 上传文件服务器成功后才加入列表
                dyn["AttachmentName"] = file.OldName;
                dyn["AttachmentSize"] = Math.Round(dataBuff.Length / 1024.0, 2);
                dyn["EntryInterID"]   = -1;// 参照属性解读

                dyn["CreateMen_Id"]    = Convert.ToInt32(this.Context.UserId);
                dyn["CreateMen"]       = GetUser(this.Context.UserId.ToString());
                dyn["ModifyTime"]      = dyn["CreateTime"] = TimeServiceHelper.GetSystemDateTime(this.Context);
                dyn["ExtName"]         = System.IO.Path.GetExtension(file.OldName);
                dyn["FileStorage"]     = submitType.ToString();
                dyn["EntryKey"]        = " ";
                dyn["IsAllowDownLoad"] = 0;//参考PC端,历史原因 0 允许下载,1 不允许下载

                dynList.Add(dyn);
            }

            if (dynList.Count > 0)
            {
                // 所有数据加载完成后再一次性保存全部
                BusinessDataServiceHelper.Save(this.Context, dynList.ToArray());

                sb.AppendLine();
                sb.AppendLine(string.Join(",", dynList.Select(dyn => dyn["AttachmentName"].ToString()).ToArray()) + ",上传成功");
            }

            //写入上传日志 增加判定 FLog不存在不写入
            if (this.Model.BillBusinessInfo.GetElement("FLog") != null)
            {
                this.Model.SetValue("FLog", sb.ToString());
            }

            base.AfterMobileUpload(e);

            this.View.ShowMessage("提交成功,是否退出页面?",
                                  MessageBoxOptions.YesNo,
                                  new Action <MessageBoxResult>((result) =>
            {
                if (result == MessageBoxResult.Yes)
                {
                    //关闭页面
                    //JSONObject arg = new JSONObject();
                    //arg.Put("pageId", this.View.PageId);
                    //this.View.AddAction("closeWebViewWithXT", arg);
                    this.View.Close();
                }
            })
                                  );
        }
        /// <summary>
        /// 输入拣货通知编号,输出拣货通知详情
        /// </summary>
        /// <param name="billno">拣货通知编号</param>
        /// <returns>返回服务结果。</returns>
        public ServiceResult ExecuteService(string whid, string areaid, string ownerid, string billno, string trackno)
        {
            DynamicObjectCollection dataObjectCollection;
            List <JSONObject>       return_data = new List <JSONObject>();
            var result = new ServiceResult <List <JSONObject> >();
            var ctx    = this.KDContext.Session.AppContext;

            // 检查上下文对象
            if (this.IsContextExpired(result))
            {
                return(result);
            }
            // 检查传入参数
            //if (string.IsNullOrWhiteSpace(billno))
            //{
            //    result.Code = (int)ResultCode.Fail;
            //    result.Message = "收货明细编号不能为空!";
            //    return result;
            //}
            //获取相关信息
            try
            {
                //TODO:通过平台动态引擎获取数据
                string sqlSelect1 = string.Format(@"/*dialect*/
                                                    SELECT distinct t0.FID fid, t0.FBILLNO fbillno 
                                                    FROM dbo.BAH_T_WMS_PICKUP T0
                                                    LEFT JOIN dbo.BAH_T_WMS_PICKUPENTRY_B T ON T0.FID = T.FID
                                                    LEFT JOIN dbo.BAH_T_BD_LOCATION_L t1 ON t.FTOLOCID = t1.FID
                                                    LEFT JOIN dbo.BAH_T_WMS_PICKUPENTRY_W T2 ON T.FENTRYID = T2.FENTRYID
                                                    LEFT JOIN dbo.BAH_T_BD_LOCATION t3 ON t.FTOLOCID = t3.FID
                                                    LEFT JOIN dbo.BAH_T_BD_LOCBASE T30 ON T3.FID = T30.FID
                                                    LEFT JOIN dbo.BAH_T_BD_WAREHOUSE t4 on t0.FTOWHID = t4.FID
                                                    INNER JOIN dbo.BAH_T_BD_WAREHOUSE_L t5 on t4.FID = t5.FID
                                                    LEFT JOIN dbo.BAH_V_BD_OWNER t6 ON t0.FTOOWNERID = t6.FID
                                                    INNER JOIN dbo.BAH_V_BD_OWNER_L T7 ON T6.FID = T7.FID
                                                    LEFT JOIN dbo.BAH_V_BD_CONTACT T8 ON T0.FCONTACTID = T8.FID
                                                    INNER JOIN dbo.BAH_V_BD_CONTACT_L T9 ON T8.FID = T9.FID
                                                    LEFT JOIN dbo.BAH_T_WMS_OUTNOTICEENTRY T10 ON T2.FSOURCEID = T10.FENTRYID
                                                    LEFT JOIN dbo.BAH_T_WMS_PICKUPENTRY T100 ON T0.FID=T100.FID
                                                    INNER JOIN dbo.BAH_T_BD_MATWAREHOUSE T11 ON T100.FMATERIALID = T11.FID
                                                    LEFT JOIN dbo.BAH_T_WMS_OUTNOTICEENTRY_W T12 ON T10.FENTRYID = T12.FENTRYID
                                                    WHERE t0.FDOCUMENTSTATUS = 'C' AND t2.FJOINSTATUS = 'A' 
                                                    AND ((T2.FJoinMQty < T.FTOMQTY AND T11.FENABLECAPACITY = 0) OR (T11.FENABLECAPACITY = 1 AND (T2.FJOINCTY < T.FTOCTY OR T2.FJOINCTY = 0))) 


                                                    AND T0.FTOWHID LIKE '%{0}%' AND T0.FTOOWNERID LIKE '%{2}%' AND T30.FAREAID LIKE '%{1}%'  and (t0.FBILLNO = '{3}' or t2.FSOURCEBILLNO  = '{3}' or T.FTOTRACKNO = '{3}' or T12.FSOURCEBILLNO ='{3}' or t3.FNUMBER = '{3}' )
                                                    AND T30.FUSE ='Transition'
                                                                                                            
                 ;", whid, areaid, ownerid, billno, trackno); // or a.num is null
                                                              //库区为零的情况
                string sqlSelect2 = string.Format(@"/*dialect*/
                                                    SELECT distinct t0.FID fid, t0.FBILLNO fbillno 
                                                    FROM dbo.BAH_T_WMS_PICKUP T0
                                                    LEFT JOIN dbo.BAH_T_WMS_PICKUPENTRY_B T ON T0.FID = T.FID
                                                    LEFT JOIN dbo.BAH_T_BD_LOCATION_L t1 ON t.FTOLOCID = t1.FID
                                                    LEFT JOIN dbo.BAH_T_WMS_PICKUPENTRY_W T2 ON T.FENTRYID = T2.FENTRYID
                                                    LEFT JOIN dbo.BAH_T_BD_LOCATION t3 ON t.FTOLOCID = t3.FID
                                                    LEFT JOIN dbo.BAH_T_BD_LOCBASE T30 ON T3.FID = T30.FID
                                                    LEFT JOIN dbo.BAH_T_BD_WAREHOUSE t4 on t0.FTOWHID = t4.FID
                                                    INNER JOIN dbo.BAH_T_BD_WAREHOUSE_L t5 on t4.FID = t5.FID
                                                    LEFT JOIN dbo.BAH_V_BD_OWNER t6 ON t0.FTOOWNERID = t6.FID
                                                    INNER JOIN dbo.BAH_V_BD_OWNER_L T7 ON T6.FID = T7.FID
                                                    LEFT JOIN dbo.BAH_V_BD_CONTACT T8 ON T0.FCONTACTID = T8.FID
                                                    INNER JOIN dbo.BAH_V_BD_CONTACT_L T9 ON T8.FID = T9.FID
                                                    LEFT JOIN dbo.BAH_T_WMS_OUTNOTICEENTRY T10 ON T2.FSOURCEID = T10.FENTRYID
                                                    LEFT JOIN dbo.BAH_T_WMS_PICKUPENTRY T100 ON T0.FID=T100.FID
                                                    INNER JOIN dbo.BAH_T_BD_MATWAREHOUSE T11 ON T100.FMATERIALID = T11.FID
                                                    LEFT JOIN dbo.BAH_T_WMS_OUTNOTICEENTRY_W T12 ON T10.FENTRYID = T12.FENTRYID
                                                    WHERE t0.FDOCUMENTSTATUS = 'C' AND t2.FJOINSTATUS = 'A' 
                                                   
                                                    AND ((T2.FJoinMQty < T.FTOMQTY AND T11.FENABLECAPACITY = 0) OR (T11.FENABLECAPACITY = 1 AND (T2.FJOINCTY < T.FTOCTY OR T2.FJOINCTY = 0))) 


                                                    AND T0.FTOWHID LIKE '%{0}%' AND T0.FTOOWNERID LIKE '%{2}%'  and (t0.FBILLNO = '{3}' or t2.FSOURCEBILLNO  = '{3}' or T.FTOTRACKNO = '{3}' or T12.FSOURCEBILLNO ='{3}' or t3.FNUMBER = '{3}' )
                                                    AND T30.FUSE ='Transition'
                                                                                                           
                 ;", whid, areaid, ownerid, billno, trackno); // or a.num is null
                //TODO:通过平台动态引擎获取数据
                if (areaid == "")
                {
                    dataObjectCollection = DBUtils.ExecuteDynamicObject(ctx, sqlSelect2, null, null);
                }
                else
                {
                    dataObjectCollection = DBUtils.ExecuteDynamicObject(ctx, sqlSelect1, null, null);
                }

                foreach (DynamicObject dataObject in dataObjectCollection)
                {
                    string sqlSelect = string.Format(@"/*dialect*/
               
              SELECT T11.FBILLNO,t.FID,t.FENTRYID, T0.FSEQ, t.FTOLOCID, t6.FNUMBER AS FlocIdNumber, t1.FNAME AS FlocIdName
	            ,t2.FID AS FMaterialFID, t2.FNUMBER AS FMaterialNumber, t3.FNAME AS FMaterialName, t3.FSPECIFICATION, t.FTOPACKAGEID,T7.FNAME AS FPackageName, t.FTOQTY
	            , t.FTOUNITID,  t4.FNAME AS FUnitName,t.FTOMQTY,T.FTOMUNITID,t9.FNAME AS FMUnitName, t0.FLotNo,t.FTOTRACKNO,t0.FPRODUCEDATE,
	            t5.FHasJoinMQty,(t.FTOMQTY - t5.FHasJoinMQty) AS FNeedOUTBOUNDMQTY,
	            CASE T8.FENABLELOT WHEN 1 then 'True' ELSE 'False' END AS FENABLELOT ,
	            CASE T8.FENABLEEXPIRY WHEN 1 then 'True' ELSE 'False' END AS FENABLEEXPIRY,
	            CASE T8.FENABLECAPACITY WHEN 1 then 'True' ELSE 'False' END AS FENABLECAPACITY,
	            t8.FCAPACITYSCALE,t10.FCAPACITYUNIT,
	            t.FTOAVGCTY,t.FTOCTY,
                t5.FHasJoinCty,(t.FTOCTY - t5.FHasJoinCty) AS FNeedCTY,
                t0.FEXPIRYDATE,
                t5.FSOURCEBILLNO,T13.FNAME AS FCONTACTNAME,
                T0.FPHMXWGT
                FROM dbo.BAH_T_WMS_PICKUPENTRY_B t
                LEFT JOIN dbo.BAH_T_WMS_PICKUPENTRY T0 ON T.FENTRYID = T0.FENTRYID
	            LEFT JOIN dbo.BAH_T_BD_LOCATION_L t1 ON t.FTOLOCID = t1.FID
	            LEFT JOIN dbo.BAH_T_BD_MATERIAL t2 ON T0.FMATERIALID = t2.FID
	            LEFT JOIN dbo.BAH_T_BD_MATERIAL_L t3 ON T0.FMATERIALID = t3.FID
	            LEFT JOIN dbo.BAH_V_BD_UNIT_L t4 ON t.FTOUNITID = t4.fid
	            LEFT JOIN dbo.BAH_T_WMS_PICKUPENTRY_W t5 ON t.FENTRYID = t5.FENTRYID
	            LEFT JOIN dbo.BAH_T_BD_LOCATION t6 ON t.FTOLOCID = t6.FID
                LEFT JOIN dbo.BAH_T_BD_PACKAGE_L T7 ON T.FTOPACKAGEID = T7.FID
                LEFT JOIN dbo.BAH_V_BD_UNIT_L t9 ON t.FTOMUNITID = t9.fid
                INNER JOIN dbo.BAH_T_BD_MATWAREHOUSE T8 ON T0.FMATERIALID = T8.FID
                LEFT JOIN dbo.BAH_T_BD_MATWAREHOUSE_L T10 ON T8.FENTRYID = T10.FENTRYID
                INNER JOIN dbo.BAH_T_WMS_PICKUP T11 ON T.FID = T11.FID
                LEFT JOIN dbo.BAH_T_BD_LOCBASE T30 ON T6.FID = T30.FID
                LEFT JOIN dbo.BAH_T_WMS_OUTNOTICE T12 ON T5.FSOURCEBILLNO = T12.FBILLNO
                LEFT JOIN dbo.BAH_V_BD_CONTACT_L T13 ON T12.FCONTACTID = T13.FID 
                WHERE  t5.FJOINSTATUS = 'A'
	            AND t.FID = '{0}'
                AND ((T5.FJoinMQty < T.FTOMQTY AND T8.FENABLECAPACITY = 0) OR (T8.FENABLECAPACITY = 1 AND (T5.FJOINCTY < T.FTOCTY OR T5.FJOINCTY = 0)))
                AND T30.FUSE ='Transition'
                order by t.FTOTRACKNO
                 ;", dataObject["Fid"].ToString());// or a.num is null

                    DynamicObjectCollection mat_objc = DBUtils.ExecuteDynamicObject(ctx, sqlSelect, null, null);


                    //List<JSONObject> detail_list = new List<JSONObject>(); //明细信息
                    foreach (DynamicObject data in mat_objc)
                    {
                        JSONObject      each_detail = new JSONObject();
                        IPackageService pkgService  = null;
                        String          FMQtyForShow;
                        String          FHASMQTYForShow;
                        String          FNeedMQTYForShow;
                        try
                        {
                            FormMetadata          meta       = MetaDataServiceHelper.Load(ctx, "BAH_BD_Package") as FormMetadata;
                            QueryBuilderParemeter queryParam = new QueryBuilderParemeter();
                            queryParam.FormId              = "BAH_BD_Package";
                            queryParam.BusinessInfo        = meta.BusinessInfo;
                            queryParam.FilterClauseWihtKey = " FID ='" + data["FTOPackageId"].ToString() + "' ";
                            var objs = BusinessDataServiceHelper.Load(ctx,
                                                                      meta.BusinessInfo.GetDynamicObjectType(),
                                                                      queryParam).FirstOrDefault();

                            pkgService = PIBDServiceFactory.Instance.GetService <IPackageService>(ctx);
                            var Marray = pkgService.Expand(ctx, objs, decimal.Parse(data["FTOMQty"].ToString()));
                            var Harray = Convert.ToDecimal(data["FHasJoinMQty"]) == 0 ? null : pkgService.Expand(ctx, objs, decimal.Parse(data["FHasJoinMQty"].ToString()));
                            var Narray = pkgService.Expand(ctx, objs, decimal.Parse(data["FNeedOUTBOUNDMQTY"].ToString()));
                            if (Narray.Count() == 1)
                            {
                                each_detail.Add("FNeedQTY", Narray.FirstOrDefault().Qty);
                                each_detail.Add("FNeedUNITID", Narray.FirstOrDefault().Id);
                                each_detail.Add("FNeedName", Narray.FirstOrDefault().Name.Value(2052));
                            }
                            else
                            {
                                each_detail.Add("FNeedQTY", data["FNeedOUTBOUNDMQTY"]);
                                each_detail.Add("FNeedUNITID", data["FTOMUNITID"]);
                                each_detail.Add("FNeedName", data["FMUnitName"]);
                            }
                            FMQtyForShow     = string.Join("", Marray.Select(item => string.Concat(item.Qty.ToTrimEndZeroString(), item.Name.Value(ctx))).ToArray());
                            FHASMQTYForShow  = Convert.ToDecimal(data["FHasJoinMQty"]) == 0 ? "0" + data["FMUnitName"] : string.Join("", Harray.Select(item => string.Concat(item.Qty.ToTrimEndZeroString(), item.Name.Value(ctx))).ToArray());
                            FNeedMQTYForShow = string.Join("", Narray.Select(item => string.Concat(item.Qty.ToTrimEndZeroString(), item.Name.Value(ctx))).ToArray());
                        }
                        finally
                        {
                            PIBDServiceFactory.Instance.CloseService(pkgService);
                        }
                        each_detail.Add("FBILLNO", data["FBILLNO"]);
                        each_detail.Add("FID", data["FID"]);
                        each_detail.Add("FENTRYID", data["FENTRYID"]);
                        each_detail.Add("FSEQ", data["FSEQ"]);
                        each_detail.Add("FLocId", data["FTOLocId"]);
                        each_detail.Add("FlocIdNumber", data["FlocIdNumber"]);
                        each_detail.Add("FlocIdName", data["FlocIdName"]);
                        each_detail.Add("FMaterialFID", data["FMaterialFID"]);
                        each_detail.Add("FMaterialNumber", data["FMaterialNumber"]);
                        each_detail.Add("FMaterialName", data["FMaterialName"]);
                        each_detail.Add("FSPECIFICATION", data["FSPECIFICATION"]);
                        each_detail.Add("FPackageId", data["FTOPackageId"]);
                        each_detail.Add("FPackageName", data["FPackageName"]);
                        each_detail.Add("FQty", data["FTOQty"]);
                        each_detail.Add("FUnitId", data["FTOUnitId"]);
                        each_detail.Add("FUnitName", data["FUnitName"]);
                        each_detail.Add("FMQty", data["FTOMQty"]);
                        each_detail.Add("FMUNITID", data["FTOMUNITID"]);
                        each_detail.Add("FMUnitName", data["FMUnitName"]);
                        each_detail.Add("FMQtyForShow", FMQtyForShow);
                        each_detail.Add("FHASMQTYForShow", FHASMQTYForShow);
                        each_detail.Add("FNeedMQTYForShow", FNeedMQTYForShow);
                        each_detail.Add("FNeedMQTY", data["FNeedOUTBOUNDMQTY"]);
                        each_detail.Add("FLotNo", data["FLotNo"]);
                        each_detail.Add("FTRACKNO", data["FTOTRACKNO"]);
                        if (data["FProduceDate"].ToString() == "0001-01-01 00:00:00")
                        {
                            each_detail.Add("FPRODUCEDATE", "");
                        }
                        else
                        {
                            each_detail.Add("FPRODUCEDATE", Convert.ToDateTime(data["FPRODUCEDATE"].ToString()).ToString("yyyy-MM-dd "));
                        }
                        each_detail.Add("FENABLELOT", data["FENABLELOT"]);
                        each_detail.Add("FENABLEEXPIRY", data["FENABLEEXPIRY"]);
                        each_detail.Add("FENABLECAPACITY", data["FENABLECAPACITY"]);
                        each_detail.Add("FCAPACITYUNIT", data["FCAPACITYUNIT"]);
                        each_detail.Add("FCAPACITYSCALE", data["FCAPACITYSCALE"]);
                        each_detail.Add("FAVGCTY", data["FTOAVGCTY"]);
                        each_detail.Add("FCTY", data["FTOCTY"]);
                        each_detail.Add("FHasJoinCty", data["FHasJoinCty"]);
                        each_detail.Add("FNeedCTY", data["FNeedCTY"]);
                        if (data["FEXPIRYDATE"].ToString() == "0001-01-01 00:00:00")
                        {
                            each_detail.Add("FEXPIRYDATE", "");
                        }
                        else
                        {
                            each_detail.Add("FEXPIRYDATE", Convert.ToDateTime(data["FEXPIRYDATE"].ToString()).ToString("yyyy-MM-dd "));
                        }
                        each_detail.Add("FSOURCEBILLNO", data["FSOURCEBILLNO"]);
                        each_detail.Add("FCONTACTNAME", data["FCONTACTNAME"]);
                        each_detail.Add("FPHMXWGT", data["FPHMXWGT"]);
                        return_data.Add(each_detail);
                    }
                }
                //客户编码和物料编码
                //返回数据
                result.Code    = (int)ResultCode.Success;
                result.Data    = return_data;
                result.Message = "成功返回数据!";
            }
            catch (Exception ex)
            {
                result.Code    = (int)ResultCode.Fail;
                result.Message = ex.Message;
            }
            if (result.Message == "未将对象引用设置到对象的实例。")
            {
                result.Message = "未检索到对应信息!";
            }
            return(result);
        }
        public override void ButtonClick(ButtonClickEventArgs e)
        {
            if (e.Key.EqualsIgnoreCase("F_JD_BTNOK"))
            {
                this.View.GetControl("F_JD_BTNOK").Enabled = false;

                if (FileNameList.Count < 1)
                {
                    this.View.ShowMessage("未检测到需要引入的txt文件!", MessageBoxType.Error);
                }
                else
                {
                    string result = "";
                    for (int f = 0; f < FileNameList.Count; f++)
                    {
                        result += "\r\n《" + _FileList[f] + "》结果:";
                        try
                        {
                            string        CustomKey = this.View.OpenParameter.GetCustomParameter("CustomKey").ToString();//获取父级页面传参的参数
                            List <object> analysis  = new List <object> {
                            };
                            if (CustomKey == "2001")
                            {
                                analysis = GetAnalysisTxt(FileNameList[f]);
                            }
                            else
                            {
                                analysis = GetAnalysisTxt2(FileNameList[f]);
                            }

                            string sql_3 = @"select tt.FID,t1.FENTRYID,t2.FMATERIALID,t2.FNUMBER from t_STK_InStock tt
                            left outer join T_STK_INSTOCKENTRY t1 on tt.FID=t1.FID
                            left outer join T_BD_MATERIAL t2 on t1.FMATERIALID=t2.FMATERIALID
                            where tt.FCancelStatus='A' and tt.FDocumentStatus in('A','B') and tt.F_PAEZ_Text='" + analysis[0].ToString() + "'";


                            DataSet   ds_3    = DBServiceHelper.ExecuteDataSet(this.Context, sql_3);
                            DataTable dt_head = ds_3.Tables[0]; dt_head.PrimaryKey = new DataColumn[] { dt_head.Columns["FENTRYID"] };
                            if (dt_head.Rows.Count < 1)
                            {
                                result += "\r\n 不存在Invoice No:“" + analysis[0].ToString() + "”的单据或已提交或已审核,无法更新单价。\r\n________________________________________________________________________\r\n";
                                continue;
                            }
                            long      BillID   = Convert.ToInt64(dt_head.Rows[0]["FID"]);
                            DataTable dt_entry = (DataTable)analysis[1];

                            #region 修改单据数据

                            FormMetadata  meta        = MetaDataServiceHelper.Load(this.Context, "STK_InStock") as FormMetadata;
                            BusinessInfo  info        = meta.BusinessInfo;
                            DynamicObject toModifyObj = Kingdee.BOS.ServiceHelper.BusinessDataServiceHelper.LoadSingle(this.Context, BillID, info.GetDynamicObjectType());

                            if (toModifyObj != null)
                            {
                                decimal FEXCHANGERATE = 1;
                                DynamicObjectCollection InStockFin = toModifyObj["InStockFin"] as DynamicObjectCollection;
                                foreach (DynamicObject StockFin in InStockFin)
                                {
                                    FEXCHANGERATE = Convert.ToDecimal(info.GetField("FEXCHANGERATE").DynamicProperty.GetValue(StockFin));//汇率
                                }

                                DynamicObjectCollection entryObjs = toModifyObj["InStockEntry"] as DynamicObjectCollection;
                                string  FNUMBER = string.Empty;
                                decimal FTaxPrice = 0; decimal FTAXRATE = 0; decimal FPRICEUNITQTY = 0;
                                string  err_row = "";
                                foreach (DynamicObject entryObj in entryObjs)
                                {
                                    int FENTRYID = Convert.ToInt32(entryObj["Id"]);
                                    FTAXRATE      = Convert.ToDecimal(info.GetField("FTAXRATE").DynamicProperty.GetValue(entryObj)) / 100;
                                    FPRICEUNITQTY = Convert.ToDecimal(info.GetField("FPRICEUNITQTY").DynamicProperty.GetValue(entryObj));
                                    DataRow dr = dt_head.Rows.Find(FENTRYID);
                                    if (dr != null)
                                    {
                                        FNUMBER = dr["FNUMBER"].ToString();
                                        DataRow[] dr_r = dt_entry.Select("FPartID='" + FNUMBER + "'");
                                        if (dr_r.Length > 0)
                                        {
                                            FTaxPrice = Convert.ToDecimal(dr_r[0]["FUnitPrice"]);
                                            decimal FPRICE     = Math.Round((FTaxPrice / (1 + FTAXRATE)), 6, MidpointRounding.AwayFromZero);
                                            decimal FALLAMOUNT = Math.Round((FTaxPrice * FPRICEUNITQTY), 2, MidpointRounding.AwayFromZero);
                                            decimal FAMOUNT    = Math.Round((FTaxPrice / (1 + FTAXRATE) * FPRICEUNITQTY), 2, MidpointRounding.AwayFromZero);

                                            info.GetField("FPRICE").DynamicProperty.SetValue(entryObj, FPRICE);
                                            info.GetField("FTaxPrice").DynamicProperty.SetValue(entryObj, FTaxPrice);
                                            info.GetField("FALLAMOUNT").DynamicProperty.SetValue(entryObj, FALLAMOUNT);
                                            info.GetField("FAMOUNT").DynamicProperty.SetValue(entryObj, FAMOUNT);
                                            info.GetField("FTAXAMOUNT").DynamicProperty.SetValue(entryObj, FALLAMOUNT - FAMOUNT);
                                            info.GetField("FTAXNETPRICE").DynamicProperty.SetValue(entryObj, FTaxPrice);

                                            info.GetField("FTAXAMOUNT_LC").DynamicProperty.SetValue(entryObj, Math.Round((FALLAMOUNT - FAMOUNT) * FEXCHANGERATE, 2, MidpointRounding.AwayFromZero)); //税额(本位币)
                                            info.GetField("FAMOUNT_LC").DynamicProperty.SetValue(entryObj, Math.Round((FAMOUNT * FEXCHANGERATE), 2, MidpointRounding.AwayFromZero));                 //金额(本位币)FAMOUNT_LC
                                            info.GetField("FALLAMOUNT_LC").DynamicProperty.SetValue(entryObj, Math.Round((FALLAMOUNT * FEXCHANGERATE), 2, MidpointRounding.AwayFromZero));           //含税金额(本位币)FAMOUNT_LC
                                        }
                                        else
                                        {
                                            err_row += "物料【" + FNUMBER + "】未检测到导入的数据。\r\n";
                                            continue;
                                        }
                                    }
                                    else
                                    {
                                        err_row += "分录【" + FENTRYID + "】未检测对应物料数据,请检查。\r\n";
                                        continue;
                                    }
                                }
                                if (err_row == "")
                                {
                                    IOperationResult save_result = Kingdee.BOS.ServiceHelper.BusinessDataServiceHelper.Save(this.Context, info, new DynamicObject[] { toModifyObj }, null, "Save");
                                    if (save_result.IsSuccess)
                                    {
                                        Import  = true;
                                        result += "\r\n引入成功!\r\n________________________________________________________________________\r\n";
                                        continue;
                                    }
                                    else
                                    {
                                        for (int mf = 0; mf < save_result.ValidationErrors.Count; mf++)
                                        {
                                            result += "\r\n" + save_result.ValidationErrors[mf].Message;
                                        }
                                        result += "\r\n________________________________________________________________________\r\n";
                                        continue;
                                    }
                                }
                                else
                                {
                                    result += "\r\n" + err_row;
                                    result += "\r\n________________________________________________________________________\r\n";
                                    continue;
                                }
                            }
                            #endregion
                        }
                        catch (Exception ex)
                        {
                            result += "\r\n" + ex.Message.ToString() + "\r\n________________________________________________________________________\r\n";
                            continue;
                        }
                    }

                    this._FileList.Clear();
                    this.FileNameList.Clear();
                    this.View.GetControl("F_JD_FileUpdate").SetValue(DBNull.Value);
                    this.View.Refresh();
                    this.View.ShowMessage("导入完成,以下为具体的引入情况:" + result, MessageBoxType.Advise);
                }
            }
            else if (e.Key.EqualsIgnoreCase("F_JD_BTNCancel"))
            {
                this.View.ReturnToParentWindow(new FormResult(Import));
                this.View.Close();
            }
        }
Esempio n. 29
0
        public override void AfterConvert(Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args.AfterConvertEventArgs e)
        {
            base.AfterConvert(e);
            //获取头数据
            var headEntity = e.Result.FindByEntityKey("FBillHead");

            //获取元数据 用于获取源单需要转化的动态集合
            object[]     pkids    = sourceDataCollection.Select(p => p["FID"]).Distinct().ToArray();
            FormMetadata metadata = MetaDataServiceHelper.Load(this.Context, "PAEZ_ICMO") as FormMetadata;

            DynamicObject[] objs = BusinessDataServiceHelper.Load(this.Context, pkids, metadata.BusinessInfo.GetDynamicObjectType());


            Entity FEntityWorkSeq = e.TargetBusinessInfo.GetEntity("FEntity");
            Entity FentityICMO    = e.TargetBusinessInfo.GetEntity("FEntityICMOIN");
            DynamicObjectCollection sourceProdPlanCollection = null;
            DynamicObjectCollection sourceICMOCollection     = null;

            foreach (var extendDataEntity in headEntity)
            {
                DynamicObjectCollection objectProdPlanCollect      = extendDataEntity["FEntity"] as DynamicObjectCollection;
                DynamicObjectCollection objectMetailICOMCollection = extendDataEntity["PAEZ_SHWorkMaterialIN"] as DynamicObjectCollection;

                for (int i = objectProdPlanCollect.Count - 1; i >= 0; i--)
                {
                    objectProdPlanCollect.RemoveAt(i);
                }

                DynamicObjectCollection objectICMO = null;
                foreach (var sourceItem in objs)
                {
                    sourceProdPlanCollection = sourceItem["PAEZ_ICMO_Entry_ProProcedure"] as DynamicObjectCollection;
                    sourceICMOCollection     = sourceItem["PAEZ_ICMO_Entry_ICItem"] as DynamicObjectCollection;
                }

                foreach (var sourceItem in sourceProdPlanCollection)
                {
                    DynamicObject objectProdPlan = new DynamicObject(FEntityWorkSeq.DynamicObjectType);
                    objectProdPlan["seq"] = sourceItem["seq"];
                    objectProdPlan["F_PAEZ_ProduceID_Id"] = sourceItem["F_PAEZ_ProduceID_Id"];
                    objectProdPlan["F_PAEZ_ProduceID"]    = sourceItem["F_PAEZ_ProduceID"];
                    objectProdPlan["F_PAEZ_Times"]        = sourceItem["F_PAEZ_Times"];
                    objectProdPlan["F_PAEZ_Equipment_Id"] = sourceItem["F_PAEZ_MachineID_Id"];
                    objectProdPlan["F_PAEZ_Equipment"]    = sourceItem["F_PAEZ_MachineID"];
                    objectProdPlan["F_PAEZ_Rolling"]      = sourceItem["F_PAEZ_Rolling"];
                    objectProdPlan["F_PAEZ_Notes"]        = sourceItem["F_PAEZ_Notes"];
                    objectProdPlanCollect.Add(objectProdPlan);
                }

                foreach (var sourceItem in sourceICMOCollection)
                {
                    DynamicObject sourceICMO = new DynamicObject(FentityICMO.DynamicObjectType);
                    sourceICMO["Seq"]                = sourceItem["seq"];
                    sourceICMO["F_PAEZ_Material"]    = sourceItem["F_PAEZ_ICItemID"];                   //原料代码
                    sourceICMO["F_PAEZ_Material_Id"] = sourceItem["F_PAEZ_ICItemID_Id"];                //ID
                    //        sourceICMO["F_PAEZ_BaseProperty"] = sourceItem["F_PAEZ_ICItemName"];                //原料名称
                    //       sourceICMO["F_PAEZ_BaseProperty2_Id"] = sourceItem["F_PAEZ_ICItemMaterial"];           //材质
                    sourceICMO["F_PAEZ_IcItemLevel"]       = sourceItem["F_PAEZ_IcItemLevel"];        //等级
                    sourceICMO["F_PAEZ_Model"]             = sourceItem["F_PAEZ_ICItemModel"];        //规格
                    sourceICMO["F_PAEZ_LotMa"]             = sourceItem["F_PAEZ_Lot"];                //批号
                    sourceICMO["F_PAEZ_ReelItemIN"]        = sourceItem["F_PAEZ_ICItemReelNO"];       //卷号
                    sourceICMO["F_PAEZ_MaWeight"]          = sourceItem["F_PAEZ_ICItemWeight"];       //重量
                    sourceICMO["F_PAEZ_UnitIDMAWeight"]    = sourceItem["F_PAEZ_ICItemWeightUNITID"]; //重量单位
                    sourceICMO["F_PAEZ_QtyMa"]             = sourceItem["F_PAEZ_IcItemQty"];          //数量
                    sourceICMO["F_PAEZ_UnitID1"]           = sourceItem["F_PAEZ_ICItemQtyUnitID"];    //数量单位
                    sourceICMO["F_PAEZ_MaWidth"]           = sourceItem["F_PAEZ_ICItemWidth"];        //宽度
                    sourceICMO["F_PAEZ_MaThickness"]       = sourceItem["F_PAEZ_ICItemThickness"];    //厚度
                    sourceICMO["F_PAEZ_MaLength"]          = sourceItem["F_PAEZ_ICItemLength"];       //长度
                    sourceICMO["F_PAEZ_MaWidthRE"]         = sourceItem["F_PAEZ_ICItemRefWidth"];     //参宽
                    sourceICMO["F_PAEZ_MaThicknessRE"]     = sourceItem["F_PAEZ_ICItemRefThickness"]; //參厚
                    sourceICMO["F_PAEZ_CCONTENTSItemIN"]   = sourceItem["F_PAEZ_ICItemCContents"];    //碳含量
                    sourceICMO["F_PAEZ_CRCONTENTSItemIN"]  = sourceItem["F_PAEZ_ICItemCRContents"];   //铬含量
                    sourceICMO["F_PAEZ_PRODUCTEDGEItemIN"] = sourceItem["F_PAEZ_ICItemEdge"];         //边部状况
                    //   sourceICMO["F_PAEZ_StockLot"] = sourceItem["F_PAEZ_LotStock"];                      //库存批次

                    objectMetailICOMCollection.Add(sourceICMO);
                }
            }
        }
Esempio n. 30
0
        /// <summary>
        /// 目标单单据构建完毕,且已经创建好与源单的关联关系之后,触发此事件
        /// </summary>
        /// <param name="e"></param>
        /// <remarks>
        /// 本事件的时机,刚好能够符合需求,
        /// 而AfterConvert事件,则在执行表单服务策略之后
        /// </remarks>
        public override void OnAfterCreateLink(CreateLinkEventArgs e)
        {
            // 目标单单据体元数据
            Entity entity = e.TargetBusinessInfo.GetEntity("FSaleOrderEntry");

            //源单单单据体元数据
            //Entity es = e.SourceBusinessInfo.GetEntity("FSaleOrderEntry");

            // 读取已经生成的销售订单
            ExtendedDataEntity[] bills = e.TargetExtendedDataEntities.FindByEntityKey("FBillHead");

            // 定义一个集合,存储新拆分出来的单据体行
            List <ExtendedDataEntity> newRows = new List <ExtendedDataEntity>();

            // 对目标单据进行循环
            foreach (var bill in bills)
            {
                // 取单据体集合
                DynamicObjectCollection rowObjs = entity.DynamicProperty.GetValue(bill.DataEntity)
                                                  as DynamicObjectCollection;
                // 对单据体进行循环:从后往前循环,新拆分的行,避开循环
                int rowCount = rowObjs.Count;

                for (int i = rowCount - 1; i >= 0; i--)
                {
                    DynamicObject           rowObj       = rowObjs[i];
                    DynamicObject           FMaterialId  = rowObj["MaterialId"] as DynamicObject;
                    DynamicObjectCollection MaterialBase = FMaterialId["MaterialBase"] as DynamicObjectCollection;
                    DynamicObject           FCategoryID  = MaterialBase[0]["CategoryID"] as DynamicObject;
                    string FCategoryname = Convert.ToString(FCategoryID["Name"]);
                    if (FCategoryname == "产成品")
                    {
                        //获取ID为100440的仓库
                        DynamicObject[] STOCKIDs = BusinessDataServiceHelper.Load(this.Context, new object[] { 100440 }, (MetaDataServiceHelper.Load(this.Context, "BD_STOCK") as FormMetadata).BusinessInfo.GetDynamicObjectType());
                        rowObj["FSTOCKID_MX"] = STOCKIDs[0];
                    }

                    if (FCategoryname == "半成品")
                    {
                        //获取ID为100424的仓库
                        DynamicObject[] STOCKIDs = BusinessDataServiceHelper.Load(this.Context, new object[] { 100424 }, (MetaDataServiceHelper.Load(this.Context, "BD_STOCK") as FormMetadata).BusinessInfo.GetDynamicObjectType());
                        rowObj["FSTOCKID_MX"] = STOCKIDs[0];
                    }
                }
            }
        }