盘点及时库存调整

This commit is contained in:
18942506660
2023-11-23 15:27:05 +08:00
parent eb73e30fc6
commit 48950fb957

View File

@@ -71,41 +71,20 @@ namespace WMS.Web.Domain.Services
entity.StockCode = subStock?.StockCode; entity.StockCode = subStock?.StockCode;
} }
#region dto
List<BoxInventoryGenerateDto> inventoryList = new List<BoxInventoryGenerateDto>();
foreach (var entity in list)
{
var inventoryDetail = new List<BoxInventoryGenerateDetailsDto>()
{
new BoxInventoryGenerateDetailsDto()
{
MaterialId=entity.MaterialId,
Qty=entity.FinalQty
}
};
BoxInventoryGenerateDto inventory = new BoxInventoryGenerateDto()
{
BoxId = entity.BoxId,
InventoryInOutMethod = 2,//盘点单按产品修改库存
InventoryInOutType = entity.ResultType == TakeStockType.Profit ? 1 : 2,
StockCode = entity.StockCode,
SubStockId = entity.SubStockId,
Details = inventoryDetail
};
inventoryList.Add(inventory);
}
#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)
{ {
isSuccess = await _takeStockRepositories.AddRange(list, false); isSuccess = await _takeStockRepositories.AddRange(list, false);
if (!isSuccess) res_Rollback = Result.ReFailure(ResultCodes.DateWriteError); if (!isSuccess) res_Rollback = Result.ReFailure(ResultCodes.DateWriteError);
} }
if(res_Rollback.IsSuccess)
{
var res_Inventory = await _boxInventoryService.GenerateTakeBox(list, false);
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);