采购入库-变更库存

This commit is contained in:
tongfei
2023-11-16 17:37:19 +08:00
parent ec486c1dbd
commit 815b2f6b21
8 changed files with 99 additions and 22 deletions

View File

@@ -10,6 +10,7 @@ using WMS.Web.Core.Dto.ChangeBoxRecord;
using WMS.Web.Core.Dto.Erp;
using WMS.Web.Core.Dto.InStock;
using WMS.Web.Core.Dto.InStockTask;
using WMS.Web.Core.Dto.Inventory;
using WMS.Web.Core.Dto.Login;
using WMS.Web.Core.Internal.Results;
using WMS.Web.Domain.Entitys;
@@ -32,17 +33,19 @@ namespace WMS.Web.Domain.Services
private readonly ISerialNumberService _serialNumberService;
private readonly IChangeMoveBoxService _changeMoveBoxService;
private readonly IBoxRepositories _boxRepositories;
private readonly IBoxInventoryService _boxInventoryService;
private readonly IBasicsRepositories _basicsRepositories;
private readonly IInStockRepositories _inStockRepositories;
private readonly IInStockTaskRepositories _inStockTaskRepositories;
private readonly IErpBasicDataExtendService _erpBasicDataExtendService;
public InStockService(IMapper mapper, IErpService erpService, ISerialNumberService serialNumberService, ILoginService loginService, IBoxRepositories boxRepositories,
public InStockService(IMapper mapper, IErpService erpService, IBoxInventoryService boxInventoryService,ISerialNumberService serialNumberService, ILoginService loginService, IBoxRepositories boxRepositories,
IBasicsRepositories basicsRepositories, IErpBasicDataExtendService erpBasicDataExtendService, IChangeMoveBoxService changeMoveBoxService,
IInStockRepositories inStockRepositories, IInStockTaskRepositories inStockTaskRepositories)
{
_mapper = mapper;
_erpService = erpService;
_loginService = loginService;
_boxInventoryService = boxInventoryService;
_serialNumberService = serialNumberService;
_boxRepositories = boxRepositories;
_changeMoveBoxService = changeMoveBoxService;
@@ -202,6 +205,33 @@ namespace WMS.Web.Domain.Services
var serialNumber_result= await _serialNumberService.InStock(entity, loginInfo, isTransaction);
if (!serialNumber_result.IsSuccess)
return serialNumber_result;
//保存成功后:变更箱库存
var boxInventoryGenerateDto = entity.Details.GroupBy(x => new { x.BoxId, x.StockCode, x.SubStockId }).Select(x => new BoxInventoryGenerateDto()
{
InventoryInOutMethod= (int)InventoryInOutMethod.Box,
InventoryInOutType=(int)InventoryInOutType.In,
BoxId=x.Key.BoxId,
StockCode=x.Key.StockCode,
SubStockId=x.Key.SubStockId
}).ToList();
foreach (var item in dto.Details)
{
var current = boxInventoryGenerateDto.Where(x => x.BoxId == item.BoxId).FirstOrDefault();
if (current != null)
{
var detail = new BoxInventoryGenerateDetailsDto();
detail.MaterialId = item.MaterialId;
detail.Qty = item.Qty;
detail.SerialNumbers = item.SerialNumbers;
current.Details.Add(detail);
}
}
var boxInventoryResult = await _boxInventoryService.HandlBoxInventory(boxInventoryGenerateDto, isTransaction);
if (!boxInventoryResult.IsSuccess)
return boxInventoryResult;
return Result.ReSuccess();
}
else
@@ -340,7 +370,10 @@ namespace WMS.Web.Domain.Services
}
var isSuccess = await _inStockTaskRepositories.UpdateRange(entitys, isTransaction);
if (isSuccess)
{
return Result.ReSuccess();
}
else
return Result.ReFailure(ResultCodes.DateWriteError);
}