对接及时库存

This commit is contained in:
18942506660
2023-11-23 17:30:28 +08:00
parent 0410e84e13
commit 4572cbd3a6

View File

@@ -135,48 +135,11 @@ namespace WMS.Web.Domain.Services
} }
entity.Create(loginInfo.UserInfo.StaffId, outStockTask, dto.Method); entity.Create(loginInfo.UserInfo.StaffId, outStockTask, dto.Method);
#region dto
List<BoxInventoryGenerateDto> inventoryList = new List<BoxInventoryGenerateDto>();
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<InventoryInOutDetailsGenerateDto> 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
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
Result res_Rollback = Result.ReSuccess(); Result res_Rollback = Result.ReSuccess();
bool isSuccess = true; bool isSuccess = true;
//修改库存 //修改库存
//var res_Inventory = await _boxInventoryService.HandlBoxInventory(inventoryList, false);
//if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory;
if (res_Rollback.IsSuccess) if (res_Rollback.IsSuccess)
{ {
entity = await _outStockRepositories.Add(entity, false); entity = await _outStockRepositories.Add(entity, false);
@@ -192,11 +155,11 @@ namespace WMS.Web.Domain.Services
var res_change = await _serialNumberService.OutStock(entity, loginInfo, false); var res_change = await _serialNumberService.OutStock(entity, loginInfo, false);
if (!res_change.IsSuccess) res_Rollback = res_change; if (!res_change.IsSuccess) res_Rollback = res_change;
} }
//if (res_Rollback.IsSuccess) if (res_Rollback.IsSuccess)
//{ {
// res_Inventory = await _inventoryInOutDetailsService.GenerateInOrOutDetails(generateList, false); var res_Inventory = await _boxInventoryService.GenerateOutStockBox(entity, false);
// if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory; if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory;
//} }
//提交事务 //提交事务
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback.IsSuccess ? false : true, _transaction); isSuccess = _transactionRepositories.CommitTransaction(res_Rollback.IsSuccess ? false : true, _transaction);
if (!res_Rollback.IsSuccess) return res_Rollback; if (!res_Rollback.IsSuccess) return res_Rollback;