diff --git a/src/WMS.Web.Domain/Services/OutStockService.cs b/src/WMS.Web.Domain/Services/OutStockService.cs index 64142994..88ec8a95 100644 --- a/src/WMS.Web.Domain/Services/OutStockService.cs +++ b/src/WMS.Web.Domain/Services/OutStockService.cs @@ -133,50 +133,13 @@ namespace WMS.Web.Domain.Services outd.SerialNumbers.AddRange(dtoDetails.SelectMany(s => s.SerialNumbers)); entity.Details.Add(outd); } - entity.Create(loginInfo.UserInfo.StaffId, outStockTask,dto.Method); - - #region 组装库存dto - List inventoryList = new List(); - var boxIds = dto.Details.GroupBy(g => g.BoxId).Select(s => s.Key).ToList(); - foreach (var boxId in boxIds) - { - var inventoryDetail = dto.Details.Where(w => w.BoxId == boxId).Select(s => new BoxInventoryGenerateDetailsDto() - { - MaterialId = s.MaterialId, - Qty = s.Qty, - SerialNumbers = s.SerialNumbers - }).ToList(); - BoxInventoryGenerateDto inventory = new BoxInventoryGenerateDto() - { - BoxId = boxId, - InventoryInOutMethod = dto.Method, - StockCode = outStockTask.StockCode, - SubStockId = dto.Details.FirstOrDefault(f => f.BoxId == boxId)?.SubStockId ?? 0,// outStockTask.Details.First().SubStockId, - Details = inventoryDetail - }; - inventoryList.Add(inventory); - } - - List generateList = dto.Details.Select(s => new InventoryInOutDetailsGenerateDto() - { - BoxId = s.BoxId, - InventoryInOutType = 2, - OrderBillNo = outStockTask.BillNo, - Qty = s.Qty, - StockCode = outStockTask.StockCode, - MaterialId = s.MaterialId, - SubStockId = s.SubStockId, - OrgCode = outStockTask.OrgCode, - OrderType = 1, - }).ToList(); - #endregion + entity.Create(loginInfo.UserInfo.StaffId, outStockTask, dto.Method); IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); Result res_Rollback = Result.ReSuccess(); bool isSuccess = true; //修改库存 - //var res_Inventory = await _boxInventoryService.HandlBoxInventory(inventoryList, false); - //if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory; + if (res_Rollback.IsSuccess) { entity = await _outStockRepositories.Add(entity, false); @@ -192,11 +155,11 @@ namespace WMS.Web.Domain.Services var res_change = await _serialNumberService.OutStock(entity, loginInfo, false); if (!res_change.IsSuccess) res_Rollback = res_change; } - //if (res_Rollback.IsSuccess) - //{ - // res_Inventory = await _inventoryInOutDetailsService.GenerateInOrOutDetails(generateList, false); - // if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory; - //} + if (res_Rollback.IsSuccess) + { + var res_Inventory = await _boxInventoryService.GenerateOutStockBox(entity, false); + if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory; + } //提交事务 isSuccess = _transactionRepositories.CommitTransaction(res_Rollback.IsSuccess ? false : true, _transaction); if (!res_Rollback.IsSuccess) return res_Rollback;