Ejemplo n.º 1
0
        /// <summary>
        /// 根据主出库订单ID获取主出库订单及其所有子订单的实例
        /// </summary>
        /// <param name="pOrderId">芒果商城主出库订单ID</param>
        /// <returns>CWmsExWarehouseOrder</returns>
        static public CWmsExWarehouseOrder GetCWmsStockoutOrder(string pOrderId)
        {
            var ret = new ThirdResult <List <object> >(string.Format("根据主出库订单[{0}]获取主出库订单及其所有子订单的实例,开始", pOrderId));

            try
            {
                string errMsg = string.Empty;
                CWmsExWarehouseOrder            outObj  = null;
                List <MangoSubExwarehouseOrder> tmpList = null;

                // get mango order
                MangoExwarehouseOrder mangoOrder = MangoFactory.GetMangoOrder(TCWmsOrderCategory.EExwarehouseOrder, pOrderId) as MangoExwarehouseOrder;
                // create CWmsEntryOrder if successful
                if (null == mangoOrder)
                {
                    ret.Append(string.Format("根据主出库订单[{0}]获取主出库订单及其所有子订单的实例结束, 获取主出库订单失败", pOrderId));
                    ret.End();
                    return(outObj);
                }

                // 获取子出库订单列表
                errMsg = MangoFactory.GetMangoExwarehouseSubOrderList(pOrderId, out tmpList);
                if (!string.IsNullOrEmpty(errMsg) || null == tmpList || 0 >= tmpList.Count)
                {
                    ret.Append(string.Format("根据主出库订单[{0}]获取主出库订单及其所有子订单的实例结束, 获取主出库订单失败。errMsg: {1}", pOrderId, errMsg));
                    ret.End();
                    return(outObj);
                }

                // 创建CWmsExWarehouseOrder实例及其子出库订单实例列表
                outObj = new CWmsExWarehouseOrder();
                (outObj.MangoOrder as MangoExwarehouseOrder).CopyFrom(mangoOrder);

                foreach (var t in tmpList)
                {
                    CWmsExWarehouseSubOrder subOrder = new CWmsExWarehouseSubOrder();
                    (subOrder.MangoOrder as MangoSubExwarehouseOrder).CopyFrom(t);
                    subOrder.Product.MangoProduct.ProductId = t.ProductId;
                    (subOrder.WmsOrderDetail).Owner.CopyFrom(MangoFactory.GetOwner((subOrder.MangoOrder as MangoSubExwarehouseOrder).WarehouseId.ToString())); // 获取货主
                                                                                                                                                               // 设置商品Id
                    subOrder.Product.ItemCode = (string.IsNullOrEmpty(t.ProductGuiGeID.ToString()) || "0".Equals(t.ProductGuiGeID.ToString())) ?
                                                t.ProductId.ToString() : string.Format("{0}-{1}", t.ProductId, t.ProductGuiGeID);

                    outObj.SubOrders.Add((subOrder.MangoOrder as MangoSubExwarehouseOrder).ProductOutputId.ToString(), subOrder);
                }

                ret.Append(string.Format("根据主出库订单[{0}]获取主出库订单及其所有子订单的实例结束, 返回{1}", pOrderId, outObj));
                ret.End();
                return(outObj);
            }
            catch (Exception ex)
            {
                if (null != ex.InnerException)
                {
                    ret.Append(string.Format("InnerException: {0}", ex.InnerException.Message));
                }
                ret.Append(string.Format("发生异常: {0}\r\n调用堆栈:{1}", ex.Message, ex.StackTrace));
                ret.End();
                return(null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取所有符合条件的主出库订单,若执行成功则返回获取的行数,否则返回TError.WCF_RunError和Count=0的主出库订单列表
        /// </summary>
        /// <param name="pFilters"></param>
        /// <param name="pOutList">返回所有符合条件的主出库订单</param>
        /// <param name="pErrMsg"></param>
        /// <returns></returns>
        static public int GetVStockoutOrders(List <CommonFilterModel> pFilters, out List <CWmsExWarehouseOrder> pOutList, out string pErrMsg)
        {
            int    err    = TError.WCF_RunError.Int();
            string errMsg = string.Empty;

            pOutList = new List <CWmsExWarehouseOrder>(1);
            List <MangoExwarehouseOrder> orderList = null;

            try
            {
                if (0 >= (err = MangoFactory.GetVMangoStockoutOrders(pFilters, out orderList, out pErrMsg)) || null == orderList)
                {
                    pErrMsg = string.Format("根据过滤器获取满足条件的全部出库订单失败, err={0}, orderList={2}, errMsg={1}", err, pErrMsg, orderList);
                    Data.Utility.MyLog.Instance.Error(pErrMsg);
                    return(err);
                }
                else
                {
                    foreach (MangoExwarehouseOrder smo in orderList)
                    {
                        #region 获取子出库单
                        List <MangoSubExwarehouseOrder> subList = null;
                        errMsg = MangoFactory.GetMangoExwarehouseSubOrderList(smo.ProductOutputMainId.ToString(), out subList);
                        if (null == subList || 0 == subList.Count)
                        {
                            C_WMS.Data.Utility.MyLog.Instance.Error("在{0}中,获取主出库单({1})的子出库单失败, err={2}, errMsg={3}", System.Reflection.MethodBase.GetCurrentMethod().Name, smo?.ProductOutputMainId, err, errMsg);
                            continue;
                        }
                        #endregion
                        #region 处理子出库单
                        CWmsExWarehouseOrder ceo = new CWmsExWarehouseOrder();
                        foreach (var mso in subList)
                        {
                            if (null == mso)
                            {
                                C_WMS.Data.Utility.MyLog.Instance.Error("在{0}中,主出库单({1})中有空引用的子出库订单实体"
                                                                        , System.Reflection.MethodBase.GetCurrentMethod().Name, smo.ProductOutputMainId);
                                ceo.SubOrders.Clear();
                                break;
                            }
                            CWmsExWarehouseSubOrder cso = new CWmsExWarehouseSubOrder();
                            (cso.MangoOrder as MangoSubExwarehouseOrder).CopyFrom(mso);
                            ceo.SubOrders.Add(mso.ProductOutputId.ToString(), cso);
                        }
                        #endregion
                        if (0 < ceo.SubOrders.Count)
                        {
                            (ceo.MangoOrder as MangoExwarehouseOrder).CopyFrom(smo);
                            pOutList.Add(ceo);
                        }
                        else
                        {
                            C_WMS.Data.Utility.MyLog.Instance.Error("在{0}中,主出库单({1})没有获取到任何子出库订单实体"
                                                                    , System.Reflection.MethodBase.GetCurrentMethod().Name, smo.ProductOutputMainId);
                        }
                    } // foreach (MangoExwarehouseOrder smo in orderList)
                    pErrMsg = string.Empty;
                    return(err);
                }
            }
            catch (Exception ex)
            {
                pErrMsg = ex.Message;
                pOutList.Clear();
                Data.Utility.MyLog.Instance.Error(ex, "根据过滤条件获取主出库订单发生异常");
                return(TError.Post_NoChange.Int());
            }
        }