/// <summary> /// 借货单归还调整 Allocated 的方法 /// </summary> /// <param name="model">传入的批次信息</param> /// <param name="InUser">操作人</param> /// <param name="DocumentNumber">操作的单据号</param> /// <param name="Type">操作的单据类型</param> /// <param name="Action">操作的单据的动作</param> /// <param name="result">操作是否成功</param> /// <param name="OriginalInventoryBatchDetailsInfolist">ST表对应的原由单据信息</param> /// <returns>返回值</returns> private void InnerReturndMethod(List <InventoryBatchDetailsInfo> model, int inputDocumentNumber, string inputType, string inputAction) { string inputInUser = ServiceContext.Current.UserDisplayName; #region 将原由的数据作废 //将原有的单据 占用的库存调回去( 只调整损单占用的库存就可以了 因为 益单是不占用库存的) if (model != null && model.Count > 0) { #region 拼接 损单调整占用库存的XML 消息 List <ItemBatchInfo> itemBatchInfoList = new List <ItemBatchInfo>(); foreach (var item in model) { ItemBatchInfo itemBatchInfo = new ItemBatchInfo(); itemBatchInfo.BatchNumber = item.BatchNumber; itemBatchInfo.ProductNumber = item.ProductSysNo.ToString(); Stock stock = new Stock(); stock.Quantity = item.ReturnQty.ToString(); //归还调整 批次商品 的库存 stock.WarehouseNumber = item.StockSysNo.ToString(); List <Stock> StockList = new List <Stock>(); StockList.Add(stock); Stocks stocks = new Stocks(); stocks.Stock = StockList; itemBatchInfo.Stocks = stocks; itemBatchInfoList.Add(itemBatchInfo); } BatchXMLMessage batchXMLMessage = new BatchXMLMessage() { Header = new InventoryHeader { NameSpace = "http://soa.newegg.com/InventoryProfile", Action = inputAction, Version = "V10", Type = "Lend", CompanyCode = "8601", Tag = inputType + "" + inputAction, Language = "zh-CN", From = "IPP", GlobalBusinessType = "Listing", StoreCompanyCode = "8601", TransactionCode = inputDocumentNumber.ToString() }, Body = new InventoryBody { InUser = inputInUser, Number = inputDocumentNumber.ToString(), ItemBatchInfo = itemBatchInfoList } }; string paramXml = SerializationUtility.XmlSerialize(batchXMLMessage); XmlDocument xmlD = new XmlDocument(); xmlD.LoadXml(paramXml); paramXml = "<" + xmlD.DocumentElement.Name + ">" + xmlD.DocumentElement.InnerXml + "</" + xmlD.DocumentElement.Name + ">"; #endregion ObjectFactory <IInventoryAdjustDA> .Instance.AdjustBatchNumberInventory(paramXml);//调整批次库存表 占用数量 } #endregion }
/// <summary> /// 更新批次商品状态 /// </summary> private static void UpdateProductBatchStatus() { List <ProductBatchInfo> lstProductBatchInfo = ProductRingDA.QueryProductBatchModified(); //需要修改批次状态的数据 var productBatchInfoGroup = lstProductBatchInfo.GroupBy(p => new { p.ProductSysNo }); List <ProductBatchInfo> lstProductBatchGroup; List <ItemBatchInfo> itemBatchInfoList; ItemBatchInfo itemBatchInfo; foreach (var itemGroup in productBatchInfoGroup) { lstProductBatchGroup = itemGroup.ToList(); itemBatchInfoList = new List <ItemBatchInfo>(); foreach (ProductBatchInfo item in lstProductBatchGroup) { itemBatchInfo = new ItemBatchInfo(); itemBatchInfo.BatchNumber = item.BatchNumber; itemBatchInfo.ProductNumber = item.ProductSysNo.ToString(); itemBatchInfo.Status = item.NewStatus; itemBatchInfoList.Add(itemBatchInfo); } BatchXMLMessage batchXMLMessage = new BatchXMLMessage() { Header = new InventoryHeader() { NameSpace = "http://soa.newegg.com/InventoryProfile", Action = "Status", Version = "V10", Type = "Update", CompanyCode = "8601", Tag = "UpdateStatus", Language = "zh-CN", From = "Job", GlobalBusinessType = "Listing", StoreCompanyCode = "8601", TransactionCode = "" }, Body = new InventoryBody() { Number = "", InUser = "******", ItemBatchInfo = itemBatchInfoList } }; string paramXml = SerializationUtility.XmlSerialize(batchXMLMessage); XmlDocument xmlD = new XmlDocument(); xmlD.LoadXml(paramXml); paramXml = "<" + xmlD.DocumentElement.Name + ">" + xmlD.DocumentElement.InnerXml + "</" + xmlD.DocumentElement.Name + ">"; //给仓库发消息,调整批次信息 ProductRingDA.UpdateBatchInfo(paramXml); } }
/// <summary> /// 修改批次信息状态 /// </summary> /// <param name="productBatchInfo"></param> public virtual void UpdateProductBatchStatus(InventoryBatchDetailsInfo productBatchInfo) { List <ItemBatchInfo> itemBatchInfoList = new List <ItemBatchInfo>(); ItemBatchInfo itemBatchInfo = new ItemBatchInfo(); itemBatchInfo.BatchNumber = productBatchInfo.BatchNumber; itemBatchInfo.ProductNumber = productBatchInfo.ProductSysNo.ToString(); itemBatchInfo.Status = productBatchInfo.Status; itemBatchInfoList.Add(itemBatchInfo); BatchXMLMessage batchXMLMessage = new BatchXMLMessage() { Header = new InventoryHeader() { NameSpace = "http://soa.newegg.com/InventoryProfile", Action = "Status", Version = "V10", Type = "Update", CompanyCode = "8601", Tag = "UpdateStatus", Language = "zh-CN", From = "IPP", GlobalBusinessType = "Listing", StoreCompanyCode = "8601", TransactionCode = "" }, Body = new InventoryBody() { Number = "", InUser = ServiceContext.Current.UserDisplayName, ItemBatchInfo = itemBatchInfoList } }; string paramXml = SerializationUtility.XmlSerialize(batchXMLMessage); XmlDocument xmlD = new XmlDocument(); xmlD.LoadXml(paramXml); paramXml = "<" + xmlD.DocumentElement.Name + ">" + xmlD.DocumentElement.InnerXml + "</" + xmlD.DocumentElement.Name + ">"; //给仓库发消息,调整批次信息 InventoryAdjustDA.AdjustBatchNumberInventory(paramXml); //SendSSBToWMS(query, InUser); }
/// <summary> /// 损益单出库 (确认成功): /// </summary> /// <param name="adjustRequestSysNo">原始损益单编号</param> /// <param name="productSysNo">损益商品编号</param> /// <param name="realAdjustQty">该商品的实际损益数量</param> /// <returns></returns> public static AdjustRequestInfo AdjustOutStock(int adjustRequestSysNo, int?productSysNo, int?realAdjustQty, int sellerSysNo) { var adjustRequestInfo = GetAdjustRequestInfoBySysNo(adjustRequestSysNo); #region Check操作 : if (null == adjustRequestInfo || adjustRequestInfo.SysNo <= 0) { throw new BusinessException(string.Format("找不到编号为{0}的损益单据信息!", adjustRequestSysNo)); } if (productSysNo.HasValue && realAdjustQty.HasValue) { var productItemInfo = adjustRequestInfo.AdjustItemInfoList.FirstOrDefault(x => x.ProductSysNo == productSysNo); if (productItemInfo == null) { throw new BusinessException(string.Format("编号为{0}的商品不存在于该损益单中!损益单编号 :{1}", productSysNo, adjustRequestSysNo)); } if (realAdjustQty >= 0) { if (realAdjustQty > productItemInfo.AdjustQuantity) { throw new BusinessException(string.Format("编号为{0}的商品实际损益的数量大于预损益的数量!损益单编号 :{1}", productSysNo, adjustRequestSysNo)); } } else { if (realAdjustQty < productItemInfo.AdjustQuantity) { throw new BusinessException(string.Format("编号为{0}的商品实际损益的数量大于预损益的数量!损益单编号 :{1}", productSysNo, adjustRequestSysNo)); } } } var stockInfo = StockService.LoadStock(adjustRequestInfo.Stock.SysNo); if (null == stockInfo) { throw new BusinessException("损益单据关联的仓库编号无效!"); } if (stockInfo.MerchantSysNo != sellerSysNo) { throw new BusinessException("此商家无权操作此单据!"); } //增加损益单状态Check (已申报状态): if (adjustRequestInfo.RequestStatus != AdjustRequestStatus.Reported) { throw new BusinessException(string.Format("损益单编号 :{1},当前单据的状态不是'已申报'状态,不能进行损益单确认操作", productSysNo, adjustRequestSysNo)); } #endregion bool isConsign = false; adjustRequestInfo.OutStockDate = DateTime.Now; adjustRequestInfo.RequestStatus = Enums.AdjustRequestStatus.OutStock; isConsign = (adjustRequestInfo.ConsignFlag == RequestConsignFlag.Consign || adjustRequestInfo.ConsignFlag == RequestConsignFlag.GatherPay); var inventoryAdjustContract = new InventoryAdjustContractInfo { SourceBizFunctionName = InventoryAdjustSourceBizFunction.Inventory_AdjustRequest, SourceActionName = InventoryAdjustSourceAction.OutStock, ReferenceSysNo = adjustRequestInfo.SysNo.ToString(), AdjustItemList = new List <InventoryAdjustItemInfo>() }; using (TransactionScope scope = new TransactionScope()) { if (adjustRequestInfo.AdjustItemInfoList != null && adjustRequestInfo.AdjustItemInfoList.Count > 0) { adjustRequestInfo.AdjustItemInfoList.ForEach(adjustItem => { //if (adjustItem.AdjustProduct.ProductPriceInfo == null) //{ // BizExceptionHelper.Throw("Common_CannotFindPriceInformation"); // throw new BusinessException("损益数量只能为非0的整数!"); //} if (adjustItem.AdjustQuantity == 0) { throw new BusinessException("损益数量只能为非0的整数!"); } var cost = InventoryDA.GetItemCost(adjustItem.ProductSysNo.Value); inventoryAdjustContract.AdjustItemList.Add(new InventoryAdjustItemInfo { AdjustQuantity = adjustItem.AdjustQuantity.Value, ProductSysNo = adjustItem.ProductSysNo.Value, StockSysNo = (int)adjustRequestInfo.Stock.SysNo, AdjustUnitCost = cost, }); //update flash item unit cost if (adjustItem.AdjustCost != cost) { adjustItem.AdjustCost = cost; InventoryDA.UpdateAdjustItemCost(adjustItem); } }); } InventoryDA.UpdateAdjustRequestStatus(adjustRequestInfo); if (inventoryAdjustContract.AdjustItemList.Count > 0) { //string adjustResult = ObjectFactory<InventoryAdjustContractProcessor>.Instance.ProcessAdjustContract(inventoryAdjustContract); //if (!string.IsNullOrEmpty(adjustResult)) //{ // throw new BizException("库存调整失败: " + adjustResult); //} #region 调整库存: foreach (InventoryAdjustItemInfo adjustItem in inventoryAdjustContract.AdjustItemList) { ProductQueryInfo productInfo = ProductService.GetProductBySysNo(adjustItem.ProductSysNo); if (productInfo == null || productInfo.SysNo <= 0) { throw new BusinessException(string.Format("欲调库存的商品不存在,商品编号:{0}", adjustItem.ProductSysNo)); } InventoryDA.InitProductInventoryInfo(adjustItem.ProductSysNo, adjustItem.StockSysNo); var inventoryType = InventoryDA.GetProductInventroyType(adjustItem.ProductSysNo); ECommerce.Entity.Inventory.ProductInventoryInfo stockInventoryCurrentInfo = InventoryDA.GetProductInventoryInfoByStock(adjustItem.ProductSysNo, adjustItem.StockSysNo); ECommerce.Entity.Inventory.ProductInventoryInfo totalInventoryCurrentInfo = InventoryDA.GetProductTotalInventoryInfo(adjustItem.ProductSysNo); ECommerce.Entity.Inventory.ProductInventoryInfo stockInventoryAdjustInfo = new Entity.Inventory.ProductInventoryInfo() { ProductSysNo = adjustItem.ProductSysNo, StockSysNo = adjustItem.StockSysNo }; ECommerce.Entity.Inventory.ProductInventoryInfo totalInventoryAdjustInfo = new ECommerce.Entity.Inventory.ProductInventoryInfo() { ProductSysNo = adjustItem.ProductSysNo }; if (adjustItem.AdjustQuantity < 0) { //损单出库 if (adjustRequestInfo.ConsignFlag == RequestConsignFlag.Consign || adjustRequestInfo.ConsignFlag == RequestConsignFlag.GatherPay) { //代销商品, 恢复可用库存, 减少已分配库存/代销库存 stockInventoryAdjustInfo.AvailableQty = -adjustItem.AdjustQuantity; totalInventoryAdjustInfo.AvailableQty = -adjustItem.AdjustQuantity; if (adjustItem.AdjustQuantity < 0) { //AllocatedQty(-,->0),小于0则自动调为0。 if (stockInventoryCurrentInfo.AllocatedQty + adjustItem.AdjustQuantity < 0) { stockInventoryAdjustInfo.AllocatedQty = -stockInventoryCurrentInfo.AllocatedQty; } else { stockInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity; } if (totalInventoryCurrentInfo.AllocatedQty + adjustItem.AdjustQuantity < 0) { totalInventoryAdjustInfo.AllocatedQty = -totalInventoryCurrentInfo.AllocatedQty; } else { totalInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity; } } else { stockInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity; totalInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity; } stockInventoryAdjustInfo.ConsignQty = adjustItem.AdjustQuantity; totalInventoryAdjustInfo.ConsignQty = adjustItem.AdjustQuantity; } else { //非代销商品, 减少财务库存/已分配库存 stockInventoryAdjustInfo.AccountQty = adjustItem.AdjustQuantity; totalInventoryAdjustInfo.AccountQty = adjustItem.AdjustQuantity; if (adjustItem.AdjustQuantity < 0) { //AllocatedQty(-,->0),小于0则自动调为0。 if (stockInventoryCurrentInfo.AllocatedQty + adjustItem.AdjustQuantity < 0) { stockInventoryAdjustInfo.AllocatedQty = -stockInventoryCurrentInfo.AllocatedQty; } else { stockInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity; } if (totalInventoryCurrentInfo.AllocatedQty + adjustItem.AdjustQuantity < 0) { totalInventoryAdjustInfo.AllocatedQty = -totalInventoryCurrentInfo.AllocatedQty; } else { totalInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity; } } else { stockInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity; totalInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity; } } } else { //溢单出库 if (adjustRequestInfo.ConsignFlag == RequestConsignFlag.Consign || adjustRequestInfo.ConsignFlag == RequestConsignFlag.GatherPay) { //代销商品, 增加代销库存 (损/溢单都增加代销库存?) stockInventoryAdjustInfo.ConsignQty = adjustItem.AdjustQuantity; totalInventoryAdjustInfo.ConsignQty = adjustItem.AdjustQuantity; } else { //非代销商品, 增加财务库存/可用库存 stockInventoryAdjustInfo.AccountQty = adjustItem.AdjustQuantity; totalInventoryAdjustInfo.AccountQty = adjustItem.AdjustQuantity; stockInventoryAdjustInfo.AvailableQty = adjustItem.AdjustQuantity; totalInventoryAdjustInfo.AvailableQty = adjustItem.AdjustQuantity; } } //预检调整后的商品库存是否合法 Entity.Inventory.ProductInventoryInfo stockInventoryAdjustAfterAdjust = InventoryService.PreCalculateInventoryAfterAdjust(stockInventoryCurrentInfo, stockInventoryAdjustInfo); Entity.Inventory.ProductInventoryInfo totalInventoryAdjustAfterAdjust = InventoryService.PreCalculateInventoryAfterAdjust(totalInventoryCurrentInfo, totalInventoryAdjustInfo); bool isNeedCompareAvailableQtyAndAccountQty = true; InventoryService.PreCheckGeneralRules(stockInventoryAdjustAfterAdjust, ref isNeedCompareAvailableQtyAndAccountQty); InventoryService.PreCheckGeneralRules(totalInventoryAdjustAfterAdjust, ref isNeedCompareAvailableQtyAndAccountQty); //调整商品库存: InventoryDA.AdjustProductStockInventoryInfo(stockInventoryAdjustInfo); InventoryDA.AdjustProductTotalInventoryInfo(totalInventoryAdjustInfo); } #endregion #region 损益单为代销类型,出库时需要写入代销转财务日志 if (isConsign) { List <ConsignToAcctLogInfo> acctLogInfoList = new List <ConsignToAcctLogInfo>(); adjustRequestInfo.AdjustItemInfoList.ForEach(x => { ConsignToAcctLogInfo acctLog = new ConsignToAcctLogInfo(); acctLog.ProductSysNo = x.ProductSysNo; acctLog.StockSysNo = adjustRequestInfo.Stock.SysNo; acctLog.VendorSysNo = InventoryDA.GetProductBelongVendorSysNo(x.ProductSysNo.Value); acctLog.ProductQuantity = -x.AdjustQuantity; acctLog.OutStockTime = adjustRequestInfo.OutStockDate; acctLog.CreateCost = x.AdjustCost; acctLog.OrderSysNo = adjustRequestInfo.SysNo; acctLog.CompanyCode = adjustRequestInfo.CompanyCode; acctLog.StoreCompanyCode = adjustRequestInfo.CompanyCode; acctLog.IsConsign = (int)adjustRequestInfo.ConsignFlag; acctLogInfoList.Add(acctLog); }); if (acctLogInfoList.Count > 0) { foreach (var item in acctLogInfoList) { InventoryDA.CreatePOConsignToAccLogForInventory(item); } } } #endregion #region string InUser = "******"; List <InventoryBatchDetailsInfo> batchDetailsInfoEntitylist = InventoryDA.GetBatchDetailsInfoEntityListByNumber(adjustRequestInfo.SysNo.Value); if (batchDetailsInfoEntitylist != null && batchDetailsInfoEntitylist.Count > 0) { #region 构建损益单 出库调整批次库存表的SSB消息 调整库存 List <ItemBatchInfo> itemBatchInfoList = new List <ItemBatchInfo>(); foreach (var item in batchDetailsInfoEntitylist) { ItemBatchInfo itemBatchInfo = new ItemBatchInfo(); itemBatchInfo.BatchNumber = item.BatchNumber; itemBatchInfo.ProductNumber = item.ProductSysNo.ToString(); Stock stock = new Stock(); AdjustRequestItemInfo aEntity = new AdjustRequestItemInfo(); aEntity = adjustRequestInfo.AdjustItemInfoList.Find(x => { return(x.ProductSysNo == item.ProductSysNo); }); if (aEntity != null && aEntity.AdjustQuantity > 0) { stock.Quantity = item.Quantity.ToString(); //单据出库两个数量都要调整 stock.AllocatedQty = string.Empty; //益单不调 占用库存 作废 取消作废 单据 只调整 占用库存 } else { stock.Quantity = item.Quantity.ToString(); //单据出库两个数量都要调整 stock.AllocatedQty = item.Quantity.ToString(); //损单 需要调整 占用库存 作废 取消作废 单据 只调整 占用库存 } stock.WarehouseNumber = item.StockSysNo.ToString(); List <Stock> StockList = new List <Stock>(); StockList.Add(stock); Stocks stocks = new Stocks(); stocks.Stock = StockList; itemBatchInfo.Stocks = stocks; itemBatchInfoList.Add(itemBatchInfo); } BatchXMLMessage batchXMLMessage = new BatchXMLMessage() { Header = new InventoryHeader { NameSpace = "http://soa.ECommerce.com/InventoryProfile", Action = "OutStock", Version = "V10", Type = "Adjust", CompanyCode = "8601", Tag = "AdjustOutStock", Language = "zh-CN", From = "IPP", GlobalBusinessType = "Listing", StoreCompanyCode = "8601", TransactionCode = adjustRequestInfo.SysNo.ToString() }, Body = new InventoryBody { InUser = InUser, Number = adjustRequestInfo.SysNo.ToString(), ItemBatchInfo = itemBatchInfoList } }; string paramXml = SerializationUtility.XmlSerialize(batchXMLMessage); XmlDocument xmlD = new XmlDocument(); xmlD.LoadXml(paramXml); paramXml = "<" + xmlD.DocumentElement.Name + ">" + xmlD.DocumentElement.InnerXml + "</" + xmlD.DocumentElement.Name + ">"; InventoryDA.AdjustBatchNumberInventory(paramXml);//调整批次库存表 占用数量 #endregion } List <InventoryAdjustItemInfo> adjustCaseEntityList = new List <InventoryAdjustItemInfo>(); foreach (var item in inventoryAdjustContract.AdjustItemList) { if (!InventoryDA.CheckISBatchNumberProduct(item.ProductSysNo)) { item.AdjustQuantity = item.AdjustQuantity; adjustCaseEntityList.Add(item); } } AdjustSendSSBToWMS(adjustRequestInfo.SysNo.Value, adjustRequestInfo.Stock.SysNo.ToString(), batchDetailsInfoEntitylist, adjustCaseEntityList);//损益单出库向仓库发送SSB消息 #endregion } scope.Complete(); } return(adjustRequestInfo); }
/// <summary> /// 作废原来单据 /// </summary> /// <param name="inputInUser"></param> /// <param name="inputDocumentNumber"></param> /// <param name="deleteItemSysNoList"></param> /// <param name="inputType"></param> /// <param name="inputAction"></param> /// <returns></returns> private void AbandonSTBInfo(int inputDocumentNumber, string inputType, string inputAction) { string inputInUser = ServiceContext.Current.UserDisplayName; //获取数据库重更新前的数量 List <InventoryBatchDetailsInfo> OriginalInventoryBatchDetailsInfolist = ObjectFactory <IInventoryAdjustDA> .Instance.GetBatchDetailsInfoEntityListByNumber(Convert.ToInt32(inputDocumentNumber)); if (OriginalInventoryBatchDetailsInfolist != null && OriginalInventoryBatchDetailsInfolist.Count > 0) { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(0, 5, 0))) { //损益单 调整需要 特殊处理 if (inputType.Equals("Adjust") && inputAction.Equals("Create"))//损益单创建 输入正值 不调占用库存 { #region 将原由的数据作废 List <InventoryBatchDetailsInfo> OriginalYiDanList = new List <InventoryBatchDetailsInfo>(); List <InventoryBatchDetailsInfo> OriginalSunDanList = new List <InventoryBatchDetailsInfo>(); OriginalYiDanList = OriginalInventoryBatchDetailsInfolist.FindAll(x => { return(x.Quantity >= 0); }); OriginalSunDanList = OriginalInventoryBatchDetailsInfolist.FindAll(x => { return(x.Quantity < 0); }); //将原有的单据 占用的库存调回去( 只调整损单占用的库存就可以了 因为 益单是不占用库存的) if (OriginalSunDanList != null && OriginalSunDanList.Count > 0) { #region 拼接 损单调整占用库存的XML 消息 List <ItemBatchInfo> itemBatchInfoList = new List <ItemBatchInfo>(); foreach (var item in OriginalSunDanList) { ItemBatchInfo itemBatchInfo = new ItemBatchInfo(); itemBatchInfo.BatchNumber = item.BatchNumber; itemBatchInfo.ProductNumber = item.ProductSysNo.ToString(); Stock stock = new Stock(); stock.AllocatedQty = item.Quantity.ToString(); // 损单作废 将占用库存 调回去 stock.WarehouseNumber = item.StockSysNo.ToString(); List <Stock> StockList = new List <Stock>(); StockList.Add(stock); Stocks stocks = new Stocks(); stocks.Stock = StockList; itemBatchInfo.Stocks = stocks; itemBatchInfoList.Add(itemBatchInfo); } BatchXMLMessage batchXMLMessage = new BatchXMLMessage() { Header = new InventoryHeader { NameSpace = "http://soa.newegg.com/InventoryProfile", Action = inputAction, Version = "V10", Type = "Adjust", CompanyCode = "8601", Tag = inputType + "" + inputAction, Language = "zh-CN", From = "IPP", GlobalBusinessType = "Listing", StoreCompanyCode = "8601", TransactionCode = inputDocumentNumber.ToString() }, Body = new InventoryBody { InUser = inputInUser, Number = inputDocumentNumber.ToString(), ItemBatchInfo = itemBatchInfoList } }; string paramXml = SerializationUtility.XmlSerialize(batchXMLMessage); XmlDocument xmlD = new XmlDocument(); xmlD.LoadXml(paramXml); paramXml = "<" + xmlD.DocumentElement.Name + ">" + xmlD.DocumentElement.InnerXml + "</" + xmlD.DocumentElement.Name + ">"; #endregion ObjectFactory <IInventoryAdjustDA> .Instance.AdjustBatchNumberInventory(paramXml);//调整批次库存表 占用数量 } ObjectFactory <IInventoryAdjustDA> .Instance.DeleteAllBatchItem(inputDocumentNumber, ""); #endregion } else if (inputType.Equals("Lend") && inputAction.Equals("Create"))//借货单创建 更新 { #region 将原由的数据作废 //将原有的单据 占用的库存调回去( 只调整损单占用的库存就可以了 因为 益单是不占用库存的) if (OriginalInventoryBatchDetailsInfolist != null && OriginalInventoryBatchDetailsInfolist.Count > 0) { #region 拼接 损单调整占用库存的XML 消息 List <ItemBatchInfo> itemBatchInfoList = new List <ItemBatchInfo>(); foreach (var item in OriginalInventoryBatchDetailsInfolist) { ItemBatchInfo itemBatchInfo = new ItemBatchInfo(); itemBatchInfo.BatchNumber = item.BatchNumber; itemBatchInfo.ProductNumber = item.ProductSysNo.ToString(); Stock stock = new Stock(); stock.AllocatedQty = (-item.Quantity).ToString(); // 原由借货单作废 将占用库存 调回去 stock.WarehouseNumber = item.StockSysNo.ToString(); List <Stock> StockList = new List <Stock>(); StockList.Add(stock); Stocks stocks = new Stocks(); stocks.Stock = StockList; itemBatchInfo.Stocks = stocks; itemBatchInfoList.Add(itemBatchInfo); } BatchXMLMessage batchXMLMessage = new BatchXMLMessage() { Header = new InventoryHeader { NameSpace = "http://soa.newegg.com/InventoryProfile", Action = inputAction, Version = "V10", Type = "Lend", CompanyCode = "8601", Tag = inputType + "" + inputAction, Language = "zh-CN", From = "IPP", GlobalBusinessType = "Listing", StoreCompanyCode = "8601", TransactionCode = inputDocumentNumber.ToString() }, Body = new InventoryBody() { InUser = inputInUser, Number = inputDocumentNumber.ToString(), ItemBatchInfo = itemBatchInfoList } }; string paramXml = SerializationUtility.XmlSerialize(batchXMLMessage); XmlDocument xmlD = new XmlDocument(); xmlD.LoadXml(paramXml); paramXml = "<" + xmlD.DocumentElement.Name + ">" + xmlD.DocumentElement.InnerXml + "</" + xmlD.DocumentElement.Name + ">"; #endregion ObjectFactory <IInventoryAdjustDA> .Instance.AdjustBatchNumberInventory(paramXml);//调整批次库存表 占用数量 } ObjectFactory <IInventoryAdjustDA> .Instance.DeleteAllBatchItem(inputDocumentNumber, ""); #endregion } else if (inputType.Equals("Convert") && inputAction.Equals("DeleteAllSourceBatchItem"))//转换单创建 目标商品不调占用库存 { List <InventoryBatchDetailsInfo> OriginalSourceInventoryBatchDetailsInfolist = OriginalInventoryBatchDetailsInfolist.FindAll(x => { return(x.ReturnQty == 0); }); if (OriginalSourceInventoryBatchDetailsInfolist != null && OriginalSourceInventoryBatchDetailsInfolist.Count > 0) { #region 拼接 损单调整占用库存的XML 消息 List <ItemBatchInfo> itemBatchInfoList = new List <ItemBatchInfo>(); foreach (var item in OriginalSourceInventoryBatchDetailsInfolist) { ItemBatchInfo itemBatchInfo = new ItemBatchInfo(); itemBatchInfo.BatchNumber = item.BatchNumber; itemBatchInfo.ProductNumber = item.ProductSysNo.ToString(); Stock stock = new Stock(); stock.AllocatedQty = (-item.Quantity).ToString(); // 原由借货单作废 将占用库存 调回去 stock.WarehouseNumber = item.StockSysNo.ToString(); List <Stock> StockList = new List <Stock>(); StockList.Add(stock); Stocks stocks = new Stocks(); stocks.Stock = StockList; itemBatchInfo.Stocks = stocks; itemBatchInfoList.Add(itemBatchInfo); } BatchXMLMessage batchXMLMessage = new BatchXMLMessage() { Header = new InventoryHeader { NameSpace = "http://soa.newegg.com/InventoryProfile", Action = "Create", Version = "V10", Type = "Convert", CompanyCode = "8601", Tag = inputType + "" + "Create", Language = "zh-CN", From = "IPP", GlobalBusinessType = "Listing", StoreCompanyCode = "8601", TransactionCode = inputDocumentNumber.ToString() }, Body = new InventoryBody { InUser = inputInUser, Number = inputDocumentNumber.ToString(), ItemBatchInfo = itemBatchInfoList } }; string paramXml = SerializationUtility.XmlSerialize(batchXMLMessage); XmlDocument xmlD = new XmlDocument(); xmlD.LoadXml(paramXml); paramXml = "<" + xmlD.DocumentElement.Name + ">" + xmlD.DocumentElement.InnerXml + "</" + xmlD.DocumentElement.Name + ">"; #endregion ObjectFactory <IInventoryAdjustDA> .Instance.AdjustBatchNumberInventory(paramXml);//调整批次库存表 占用数量 } ObjectFactory <IInventoryAdjustDA> .Instance.DeleteAllBatchItem(inputDocumentNumber, "DeleteAllSourceBatchItem"); } else if (inputType.Equals("Convert") && inputAction.Equals("DeleteAllTargetBatchItem"))//转换单创建 目标商品不调占用库存 { ObjectFactory <IInventoryAdjustDA> .Instance.DeleteAllBatchItem(inputDocumentNumber, "DeleteAllTargetBatchItem"); } scope.Complete(); } } }
/// <summary> /// 转换单 创建更新 调整 Allocated 的方法 /// </summary> /// <param name="model">传入的批次信息</param> /// <param name="InUser">操作人</param> /// <param name="DocumentNumber">操作的单据号</param> /// <param name="Type">操作的单据类型</param> /// <param name="Action">操作的单据的动作</param> /// <param name="result">操作是否成功</param> /// <param name="OriginalInventoryBatchDetailsInfolist">ST表对应的原由单据信息</param> /// <returns>返回值</returns> private void InnerConvertMethod(List <InventoryBatchDetailsInfo> model, int inputDocumentNumber, List <int> deleteItemSysNoList, string inputType, string inputAction, List <InventoryBatchDetailsInfo> OriginalSourceInventoryBatchDetailsInfolist) { #region 将原由的数据作废 //将原有的单据 占用的库存调回去( 只调整损单占用的库存就可以了 因为 益单是不占用库存的) if (OriginalSourceInventoryBatchDetailsInfolist != null && OriginalSourceInventoryBatchDetailsInfolist.Count > 0) { #region 拼接 损单调整占用库存的XML 消息 List <ItemBatchInfo> itemBatchInfoList = new List <ItemBatchInfo>(); foreach (var item in OriginalSourceInventoryBatchDetailsInfolist) { ItemBatchInfo itemBatchInfo = new ItemBatchInfo(); itemBatchInfo.BatchNumber = item.BatchNumber; itemBatchInfo.ProductNumber = item.ProductSysNo.ToString(); Stock stock = new Stock(); stock.AllocatedQty = (-item.Quantity).ToString(); // 原由借货单作废 将占用库存 调回去 stock.WarehouseNumber = item.StockSysNo.ToString(); List <Stock> StockList = new List <Stock>(); StockList.Add(stock); Stocks stocks = new Stocks(); stocks.Stock = StockList; itemBatchInfo.Stocks = stocks; itemBatchInfoList.Add(itemBatchInfo); } BatchXMLMessage batchXMLMessage = new BatchXMLMessage() { Header = new InventoryHeader { NameSpace = "http://soa.newegg.com/InventoryProfile", Action = inputAction, Version = "V10", Type = "Convert", CompanyCode = "8601", Tag = inputType + "" + inputAction, Language = "zh-CN", From = "IPP", GlobalBusinessType = "Listing", StoreCompanyCode = "8601", TransactionCode = inputDocumentNumber.ToString() }, Body = new InventoryBody { InUser = ServiceContext.Current.UserDisplayName, Number = inputDocumentNumber.ToString(), ItemBatchInfo = itemBatchInfoList } }; string paramXml = SerializationUtility.XmlSerialize(batchXMLMessage); XmlDocument xmlD = new XmlDocument(); xmlD.LoadXml(paramXml); paramXml = "<" + xmlD.DocumentElement.Name + ">" + xmlD.DocumentElement.InnerXml + "</" + xmlD.DocumentElement.Name + ">"; #endregion ObjectFactory <IInventoryAdjustDA> .Instance.AdjustBatchNumberInventory(paramXml);//调整批次库存表 占用数量 } #endregion #region 作废后 就相当于创建新单据了 if (deleteItemSysNoList != null) { foreach (var item in deleteItemSysNoList) { ObjectFactory <IInventoryAdjustDA> .Instance.DeleteBatchItemOfSTB(item, inputDocumentNumber); } } ObjectFactory <IInventoryAdjustDA> .Instance.SourceUpdateSTBInfo(model, inputDocumentNumber, inputType);//调整批次库存表 占用数量。 if (model != null && model.Count > 0) { #region 源商品转换单调整 占用库存 XML List <ItemBatchInfo> itemBatchInfoList = new List <ItemBatchInfo>(); foreach (var item in model) { ItemBatchInfo itemBatchInfo = new ItemBatchInfo(); itemBatchInfo.BatchNumber = item.BatchNumber; itemBatchInfo.ProductNumber = item.ProductSysNo.ToString(); Stock stock = new Stock(); stock.AllocatedQty = item.Quantity.ToString(); //创建单据 只调整 占用库存 stock.WarehouseNumber = item.StockSysNo.ToString(); List <Stock> StockList = new List <Stock>(); StockList.Add(stock); Stocks stocks = new Stocks(); stocks.Stock = StockList; itemBatchInfo.Stocks = stocks; itemBatchInfoList.Add(itemBatchInfo); } BatchXMLMessage batchXMLMessage = new BatchXMLMessage() { Header = new InventoryHeader { NameSpace = "http://soa.newegg.com/InventoryProfile", Action = inputAction, Version = "V10", Type = "Convert", CompanyCode = "8601", Tag = inputType + "" + inputAction, Language = "zh-CN", From = "IPP", GlobalBusinessType = "Listing", StoreCompanyCode = "8601", TransactionCode = inputDocumentNumber.ToString() }, Body = new InventoryBody { InUser = ServiceContext.Current.UserDisplayName, Number = inputDocumentNumber.ToString(), ItemBatchInfo = itemBatchInfoList } }; string paramXml = SerializationUtility.XmlSerialize(batchXMLMessage); XmlDocument xmlD = new XmlDocument(); xmlD.LoadXml(paramXml); paramXml = "<" + xmlD.DocumentElement.Name + ">" + xmlD.DocumentElement.InnerXml + "</" + xmlD.DocumentElement.Name + ">"; #endregion ObjectFactory <IInventoryAdjustDA> .Instance.AdjustBatchNumberInventory(paramXml);//调整批次库存表 占用数量 } #endregion }