盘点及时库存调整
This commit is contained in:
@@ -71,41 +71,20 @@ namespace WMS.Web.Domain.Services
|
||||
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();
|
||||
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)
|
||||
{
|
||||
isSuccess = await _takeStockRepositories.AddRange(list, false);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user