修复bug

This commit is contained in:
18942506660
2023-12-07 13:47:37 +08:00
parent 11455a0e54
commit 5d4137b61c

View File

@@ -41,12 +41,13 @@ namespace WMS.Web.Domain.Services
private readonly IInventoryInOutDetailsService _inventoryInOutDetailsService;
private readonly IBoxInventoryRepositories _boxInventoryRepositories;
private readonly ILogger<OutStockService> _logger;
private readonly IBoxRepositories _boxRepositories;
public OutStockService(IMapper mapper, ILoginService loginService,
IBasicsRepositories transactionRepositories,
IOutStockRepositories outStockRepositories, IOutStockTaskRepositories outStockTaskRepositories,
IOutStockTaskService outStockTaskService, IErpService erpService, ISerialNumberService serialNumberService,
IBoxInventoryService boxInventoryService, IInventoryInOutDetailsService inventoryInOutDetailsService,
IBoxInventoryRepositories boxInventoryRepositories, ILogger<OutStockService> logger)
IBoxInventoryRepositories boxInventoryRepositories, ILogger<OutStockService> logger, IBoxRepositories boxRepositories)
{
_mapper = mapper;
_loginService = loginService;
@@ -60,6 +61,7 @@ namespace WMS.Web.Domain.Services
_inventoryInOutDetailsService = inventoryInOutDetailsService;
_boxInventoryRepositories = boxInventoryRepositories;
_logger = logger;
_boxRepositories = boxRepositories;
}
/// <summary>
/// 出库单
@@ -79,14 +81,24 @@ namespace WMS.Web.Domain.Services
var ex = dto.Details.Select(s => s.MaterialId).Except(outStockTask.Details.Select(s => s.MaterialId)).ToList();
if (ex.Count() > 0 && dto.Method == 2)
return Result.ReFailure(ResultCodes.OutStockMaterialError);
var boxIds = dto.Details.Select(s => s.BoxId).ToList();
var boxInventoryList = await _boxInventoryRepositories.GetList(boxIds);
foreach (var boxid in boxIds)
{
var inventory = boxInventoryList.FirstOrDefault(f => f.BoxId == boxid);
if (inventory == null)
{
var box = await _boxRepositories.Get(boxid);
return Result.ReFailure($"箱号:{box?.BoxBillNo} 不存在库存", 70008);
}
}
//1.需要验证物料对应箱和序列号是否存在库存
//如果是按箱出库从库存拿取数据
if (dto.Method == 1)
{
var boxs = dto.Details.Select(s => s.BoxId).ToList();
dto.Details.Clear();
//获取箱子对应的所有库存
var boxInventoryList = await _boxInventoryRepositories.GetList(boxs);
//过滤掉不同仓库和不同组织的
boxInventoryList = boxInventoryList.Where(w => w.StockCode == outStockTask.StockCode && w.OrgCode == outStockTask.OrgCode).ToList();
//组装dto