盘点修改库存
This commit is contained in:
@@ -10,6 +10,7 @@ using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto;
|
||||
using WMS.Web.Core.Dto.Erp;
|
||||
using WMS.Web.Core.Dto.Erp.TakeStock;
|
||||
using WMS.Web.Core.Dto.Inventory;
|
||||
using WMS.Web.Core.Dto.Login;
|
||||
using WMS.Web.Core.Dto.TakeStock;
|
||||
using WMS.Web.Core.Internal.Results;
|
||||
@@ -36,10 +37,12 @@ namespace WMS.Web.Domain.Services
|
||||
private readonly ISingleDataService _singleDataService;
|
||||
private readonly IErpService _erpService;
|
||||
private readonly ILogger<TakeStockService> _logger;
|
||||
private readonly IBoxInventoryService _boxInventoryService;
|
||||
public TakeStockService(IMapper mapper, ILoginService loginService,
|
||||
IBasicsRepositories transactionRepositories,
|
||||
ITakeStockRepositories takeStockRepositories, ILoginRepositories loginRepositories,
|
||||
ISingleDataService singleDataService, IErpService erpService, ILogger<TakeStockService> logger)
|
||||
ISingleDataService singleDataService, IErpService erpService, ILogger<TakeStockService> logger,
|
||||
IBoxInventoryService boxInventoryService)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_loginService = loginService;
|
||||
@@ -49,6 +52,7 @@ namespace WMS.Web.Domain.Services
|
||||
_singleDataService = singleDataService;
|
||||
_erpService = erpService;
|
||||
_logger = logger;
|
||||
_boxInventoryService = boxInventoryService;
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存
|
||||
@@ -62,17 +66,45 @@ namespace WMS.Web.Domain.Services
|
||||
foreach (var entity in list)
|
||||
entity.Create(loginInfo.UserInfo.StaffId);
|
||||
|
||||
//需要填写序列号
|
||||
//需要修改库存
|
||||
#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();
|
||||
bool isRollback = false;
|
||||
Result res_Rollback = Result.ReSuccess();
|
||||
bool isSuccess = true;
|
||||
isSuccess = await _takeStockRepositories.AddRange(list, false);
|
||||
if (!isSuccess) isRollback = 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);
|
||||
}
|
||||
|
||||
//提交事务
|
||||
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
|
||||
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback.IsSuccess ? false : true, _transaction);
|
||||
if (!res_Rollback.IsSuccess) return res_Rollback;
|
||||
if (!isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user