/// <summary> /// 根据主入库订单ID获取主入库订单及其所有子订单的实例 /// </summary> /// <param name="pOrderId">芒果商城主入库单ID</param> /// <returns>CWmsEntryOrder对象</returns> static public CWmsEntryOrder GetCWmsEntryOrder(string pOrderId) { try { CWmsEntryOrder outObj = null; List <MangoSubEntryOrder> tmpList = null; string errMsg = string.Empty; // get mango order MangoEntryOrder mangoOrder = MangoFactory.GetMangoOrder(TCWmsOrderCategory.EEntryOrder, pOrderId) as MangoEntryOrder; // get sub orders errMsg = MangoFactory.GetVMangoSubEntryOrders(pOrderId, out tmpList); // create CWmsEntryOrder if successful if (null != mangoOrder && string.IsNullOrEmpty(errMsg) && 0 < tmpList?.Count) { outObj = new CWmsEntryOrder(); (outObj.MangoOrder as MangoEntryOrder).CopyFrom(mangoOrder); outObj.WmsOrder.SetWmsOrderType(TWmsOrderType.CGRK);// 默认采购入库 foreach (var s in tmpList) { int tmpPlanQty = -1; CWmsSubEntryOder cso = new CWmsSubEntryOder(); (cso.MangoOrder as MangoSubEntryOrder).CopyFrom(s); #region // 获取应收数量 if (0 >= s.ProductBuyId.Int()) { // 无采购入库Id,判断为芒果网络商品入库(补),实收数量即为应收数量 (cso.WmsOrderDetail as Wms.Data.WmsEntryOrderDetail).planQty = CWmsUtility.Decimal2Int(s.ProductInputCount.Decimal()); } else { // 有采购入库Id,取采购入库单中的应收数量 (cso.WmsOrderDetail as Wms.Data.WmsEntryOrderDetail).planQty = (TError.RunGood.Int() == MangoFactory.GetPlanQuantityByPid(s.ProductBuyId.ToString(), out tmpPlanQty)) ? tmpPlanQty : -1; } #endregion // 设置商品Id cso.Product.ItemCode = (string.IsNullOrEmpty(s.ProductGuiGeID.ToString()) || "0".Equals(s.ProductGuiGeID.ToString())) ? s.ProductId.ToString() : string.Format("{0}-{1}", s.ProductId, s.ProductGuiGeID); outObj.SubOrders.Add(s.ProductInputId.ToString(), cso); } // TODO: other operations } else { C_WMS.Data.Utility.MyLog.Instance.Error("根据主入库订单ID({0})获取主入库订单及其所有子订单的实例失败, mangoOrder=(1}, 子单据数量={2}", pOrderId, mangoOrder, tmpList?.Count); } return(outObj); } catch (Exception ex) { C_WMS.Data.Utility.MyLog.Instance.Error(ex, "根据主入库订单ID({0})获取主入库订单及其所有子订单的实例异常", pOrderId); return(null); } }
/// <summary> /// 根据过滤器获取满足条件的全部入库订单。若执行成功则返回获取的行数,否则返回小于或等于0 /// static public int GetVEntryOrders(List[CommonFilterModel], out List[CWmsEntryOrder], out string) /// </summary> /// <param name="pFilters">过滤器</param> /// <param name="pOutList">返回满足条件的全部入库订单,若执行失败则返回数量为0的列表实体</param> /// <param name="pErrMsg"></param> /// <returns></returns> static public int GetV_EntryOrders(List <CommonFilterModel> pFilters, out IEnumerable <CWmsEntryOrder> pOutList, out string pErrMsg) { int err = TError.WCF_RunError.Int(); List <MangoEntryOrder> orderList = null; try { if (0 >= (err = MangoFactory.GetVMangoEntryOrders(pFilters, out orderList, out pErrMsg)) || null == orderList) { pOutList = null; pErrMsg = string.Format("根据过滤器获取入库订单失败, err={0}, orderList={2}, errMsg={1}", err, pErrMsg, orderList); C_WMS.Data.Utility.MyLog.Instance.Warning(pErrMsg); return(err); } else { foreach (MangoEntryOrder smo in orderList) { #region 获取子入库单 List <MangoSubEntryOrder> subList = null; errMsg = MangoFactory.GetVMangoSubEntryOrders(smo?.ProductInputMainId.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?.ProductInputMainId, err, errMsg); continue; } #endregion #region 处理子入库单 CWmsEntryOrder ceo = new CWmsEntryOrder(); foreach (var mso in subList) { if (null == mso) { C_WMS.Data.Utility.MyLog.Instance.Error("在{0}中,主入库单({1})中有空引用的子入库订单实体", System.Reflection.MethodBase.GetCurrentMethod().Name, smo?.ProductInputMainId); ceo.SubOrders.Clear(); break; } CWmsSubEntryOder cso = new CWmsSubEntryOder(); (cso.MangoOrder as MangoSubEntryOrder).CopyFrom(mso); ceo.SubOrders.Add(mso.ProductInputId.ToString(), cso); } #endregion if (0 < ceo.SubOrders.Count) { (ceo.MangoOrder as MangoEntryOrder).CopyFrom(smo); pOutList.Add(ceo); } else { C_WMS.Data.Utility.MyLog.Instance.Error("在{0}中,主入库单({1})没有获取到任何子入库订单实体", System.Reflection.MethodBase.GetCurrentMethod().Name, smo?.ProductInputMainId); } } // foreach (MangoEntryOrder smo in orderList) err = Enumerable.Count(pOutList); pErrMsg = (0 < err) ? string.Empty : string.Format(""); return(err); } } catch (Exception ex) { pOutList = null; pErrMsg = ex.Message; Data.Utility.MyLog.Instance.Error(ex, "根据过滤条件获取主入库订单发生异常"); return(TError.Post_NoChange.Int()); } }