public void DoOrderReceipt(OrderReceiptRecordInfo model) { DateTime currTime = DateTime.Now; OrderReceipt orbBll = new OrderReceipt(); var orbModel = orbBll.GetModel(model.OrderId); OrderReceiptProduct orpBll = new OrderReceiptProduct(); var orpModel = orpBll.GetModel(model.OrderId, model.ProductId); orpModel.ReceiptQty += model.Qty; orpBll.UpdateQty(model.OrderId, model.ProductId, orpModel.ReceiptQty); StockProduct spBll = new StockProduct(); StockProductInfo spModel = null; spModel = spBll.GetModel(Guid.Empty, model.ProductId); if (spModel == null) { var stepCode = (int)EnumData.EnumStep.收货; var stepName = EnumData.EnumStep.收货.ToString(); spModel = new StockProductInfo(Guid.Empty, model.ProductId, model.Qty, orpModel.ReceiptQty, 0, stepCode.ToString(), stepName, EnumData.EnumIsDisable.启用.ToString(), "", "", currTime); spBll.Insert(spModel); } else { spModel.UnQty += model.Qty; spModel.LastUpdatedDate = currTime; spBll.Update(spModel); } }
public void DoProduct(Guid productId, Guid customerId, int stepCode, bool isIncrease, double qty, double unQty, double freezeQty) { var spBll = new StockProduct(); var slpBll = new StockLocationProduct(); var spInfo = spBll.GetModel(productId, customerId); if (spInfo == null) { return; } var pslList = JsonConvert.DeserializeObject <List <ProductStockLocationAttrInfo> >(spInfo.StockLocations); if ((int)EnumData.EnumStep.发货 == stepCode) { if (!isIncrease) { var qpslInfo = pslList.FirstOrDefault(m => m.FreezeQty >= freezeQty); if (qpslInfo == null) { throw new ArgumentException(MC.M_QtyInvalidError); } qpslInfo.FreezeQty -= freezeQty; spInfo.FreezeQty -= freezeQty; qpslInfo.Qty += freezeQty; spInfo.Qty += freezeQty; if (qpslInfo.Qty == 0 && qpslInfo.FreezeQty == 0) { pslList.Remove(qpslInfo); } var slpInfo = slpBll.GetModel(qpslInfo.StockLocationId); var slpList = JsonConvert.DeserializeObject <List <StockLocationProductAttrInfo> >(slpInfo.ProductAttr); var slpItem = slpList.First(m => m.ProductId.Equals(productId)); slpItem.FreezeQty -= freezeQty; if (slpItem.FreezeQty < 0) { slpItem.FreezeQty = 0; } if (slpItem.Qty == 0 && slpItem.FreezeQty == 0) { slpList.Remove(slpItem); } slpInfo.ProductAttr = JsonConvert.SerializeObject(slpList); slpInfo.MaxVolume -= freezeQty; slpBll.Update(slpInfo); } } spInfo.StockLocations = JsonConvert.SerializeObject(pslList); spBll.Update(spInfo); }
private void DoShelfMissionProduct(BarcodeTypeInfo model) { try { ShelfMissionProductQueueInfo item = JsonConvert.DeserializeObject <ShelfMissionProductQueueInfo>(model.TypeBody); var spBll = new StockProduct(); var spInfo = spBll.GetModel(Guid.Empty, item.ProductId); if (spInfo == null) { throw new ArgumentException(string.Format("货品({0})未入库!", item.ProductId)); } var stepList = spInfo.StepCode.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); var currStepCode = ((int)EnumData.EnumStep.架).ToString(); var currStepName = EnumData.EnumStep.架.ToString(); if (!stepList.Contains(currStepCode)) { stepList.Add(currStepCode); } spInfo.UnQty -= item.Qty; if (spInfo.UnQty < 0) { throw new ArgumentException(string.Format("货品({0})上架数量({1})超出范围!", item.ProductId, item.Qty)); } spInfo.Qty += item.Qty; spInfo.StepCode = string.Join(",", stepList); spInfo.LastStepName = currStepName; spInfo.LastUpdatedDate = DateTime.Now; spInfo.StockLocations = JsonConvert.SerializeObject(item.StockLocationList); spBll.Update(spInfo); } catch (Exception ex) { new CustomException(ex.Message, ex); } }
public void DoProduct(Guid productId, Guid customerId, Guid slId, int stepCode, double qty, double unQty, double freezeQty) { var spBll = new StockProduct(); var spInfo = spBll.GetModel(productId, customerId); if (spInfo == null) { throw new ArgumentException(MC.M_StockProductInvalidError); } var pslaList = JsonConvert.DeserializeObject <List <ProductStockLocationAttrInfo> >(spInfo.StockLocations); var currTime = DateTime.Now; if (stepCode == (int)EnumData.EnumStep.发货) { #region 发货 var pslItem = pslaList.FirstOrDefault(m => m.StockLocationId.Equals(slId)); if (pslItem == null) { throw new ArgumentException(MC.GetString(MC.Params_Data_NotExist, "库位ID为“" + slId + "”")); } pslItem.FreezeQty += freezeQty; pslItem.Qty -= freezeQty; if (pslItem.Qty == 0 && pslItem.FreezeQty == 0) { pslaList.Remove(pslItem); } spInfo.Qty -= freezeQty; spInfo.FreezeQty += freezeQty; #endregion } else if (stepCode == (int)EnumData.EnumStep.架) { #region 架 var pslItem = pslaList.FirstOrDefault(m => m.StockLocationId.Equals(slId)); if (pslItem == null) { var slBll = new StockLocation(); var slInfo = slBll.GetModel(slId); if (slInfo == null) { throw new ArgumentException(MC.GetString(MC.Params_Data_NotExist, "库位ID为“" + slId + "”")); } pslaList.Add(new ProductStockLocationAttrInfo(slId, slInfo.Code, slInfo.Named, qty, 0, currTime)); } else { pslItem.Qty += qty; if (pslItem.Qty == 0 && pslItem.FreezeQty == 0) { pslaList.Remove(pslItem); } } spInfo.Qty += qty; spInfo.UnQty -= qty; if (spInfo.UnQty < 0) { throw new ArgumentException(MC.GetString(MC.Request_InvalidQty, qty.ToString())); } #endregion } spInfo.StockLocations = JsonConvert.SerializeObject(pslaList); spBll.Update(spInfo); }
public void DoProduct(Guid productId, Guid customerId, int stepCode, bool isIncrease, Dictionary <Guid, float> dicSl) { var spBll = new StockProduct(); var spInfo = spBll.GetModel(productId, customerId); if (spInfo == null) { throw new ArgumentException(MC.M_StockProductInvalidError); } var pslList = JsonConvert.DeserializeObject <List <ProductStockLocationAttrInfo> >(spInfo.StockLocations); var slpBll = new StockLocationProduct(); if ((int)EnumData.EnumStep.拣货 == stepCode) { if (!isIncrease) { foreach (KeyValuePair <Guid, float> kvp in dicSl) { var pslItem = pslList.FirstOrDefault(m => m.StockLocationId.Equals(kvp.Key)); if (pslItem == null) { throw new ArgumentException(MC.M_StockProductInvalidError); } pslItem.FreezeQty -= kvp.Value; if (pslItem.FreezeQty < 0) { pslItem.FreezeQty = 0; } if (pslItem.Qty == 0 && pslItem.FreezeQty == 0) { pslList.Remove(pslItem); } spInfo.FreezeQty -= kvp.Value; var slpInfo = slpBll.GetModel(kvp.Key); var slpList = JsonConvert.DeserializeObject <List <StockLocationProductAttrInfo> >(slpInfo.ProductAttr); var slpItem = slpList.FirstOrDefault(m => m.ProductId.Equals(productId)); if (slpItem == null) { throw new ArgumentException(MC.M_StockProductInvalidError); } slpItem.FreezeQty -= kvp.Value; if (slpItem.FreezeQty < 0) { slpItem.FreezeQty = 0; } slpItem.Qty -= kvp.Value; if (slpItem.Qty < 0) { slpItem.Qty = 0; } if (slpItem.Qty == 0 && slpItem.FreezeQty == 0) { slpList.Remove(slpItem); } slpInfo.MaxVolume += kvp.Value; slpInfo.ProductAttr = JsonConvert.SerializeObject(slpList); slpBll.Update(slpInfo); } } } spInfo.StepCode = Common.GetStepCode(spInfo.StepCode, stepCode.ToString(), false); spInfo.LastStepName = Enum.GetName(typeof(EnumData.EnumStep), stepCode); spInfo.StockLocations = JsonConvert.SerializeObject(pslList); spBll.Update(spInfo); }
public void DoShelfMissionProduct(string itemAppend) { var items = itemAppend.Split(new char[] { '$' }, StringSplitOptions.RemoveEmptyEntries); var shelfMissionId = Guid.Parse(items[0]); var orderId = Guid.Parse(items[1]); var productId = Guid.Parse(items[2]); var smBll = new ShelfMission(); var smInfo = smBll.GetModel(shelfMissionId); if (smInfo == null) { throw new ArgumentException(MC.GetString(MC.Params_Data_NotExist, shelfMissionId.ToString())); } var oBll = new OrderReceipt(); var orderInfo = oBll.GetModel(orderId); if (orderInfo == null) { throw new ArgumentException(MC.GetString(MC.Params_Data_NotExist, orderId.ToString())); } var pBll = new Product(); var productInfo = pBll.GetModel(productId); var minVolume = productInfo.OutPackVolume == 0 ? 1 : productInfo.OutPackVolume; var slItems = items[3].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); var slBll = new StockLocation(); var pslaList = new List <ProductStockLocationAttrInfo>(); var dicSl = new Dictionary <Guid, float>(); var totalQty = 0f; var currTime = DateTime.Now; foreach (var item in slItems) { var subItems = item.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var slId = Guid.Parse(subItems[0]); var qty = float.Parse(subItems[1]); var slInfo = slBll.GetModel(slId); if (slInfo == null) { throw new ArgumentException(MC.GetString(MC.Params_Data_NotExist, "库位ID为" + slId + "")); } pslaList.Add(new ProductStockLocationAttrInfo(slId, slInfo.Code, slInfo.Named, qty, 0, currTime)); dicSl.Add(slId, qty); totalQty += qty; } var smpBll = new ShelfMissionProduct(); var smpInfo = smpBll.GetModel(shelfMissionId, orderId, productId); if (smpInfo == null) { throw new ArgumentException(MC.Data_NotExist); } smpInfo.Qty += totalQty; smpInfo.StockLocations = JsonConvert.SerializeObject(pslaList); smpInfo.LastUpdatedDate = currTime; smpBll.Update(smpInfo); smBll.SetTotalProduct(shelfMissionId.ToString()); #region 库存库位货品 var spBll = new StockProduct(); spBll.DoProduct(productId, orderInfo.CustomerId, (int)EnumData.EnumStep.架, dicSl); #endregion }