采购入库-变更库存
This commit is contained in:
@@ -2,9 +2,11 @@
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto.BackRecord;
|
||||
using WMS.Web.Core.Dto.Inventory;
|
||||
using WMS.Web.Core.Dto.Login;
|
||||
using WMS.Web.Core.Internal.Results;
|
||||
using WMS.Web.Domain.Entitys;
|
||||
@@ -25,13 +27,16 @@ namespace WMS.Web.Domain.Services
|
||||
public readonly IBasicsRepositories _basicsRepositories;
|
||||
private readonly ISerialNumberService _serialNumberService;
|
||||
private readonly IBackRecordRepositories _backRecordRepositories;
|
||||
private readonly IBoxInventoryService _boxInventoryService;
|
||||
public BackRecordService(IMapper mapper, ILoginService loginService,
|
||||
IBasicsRepositories basicsRepositories,
|
||||
IBoxInventoryService boxInventoryService,
|
||||
ISerialNumberService serialNumberService,
|
||||
IBackRecordRepositories backRecordRepositories)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_loginService = loginService;
|
||||
_boxInventoryService = boxInventoryService;
|
||||
_basicsRepositories = basicsRepositories;
|
||||
_backRecordRepositories = backRecordRepositories;
|
||||
}
|
||||
@@ -66,6 +71,32 @@ namespace WMS.Web.Domain.Services
|
||||
var serialNumber_result = await _serialNumberService.BackRecord(entity, loginInfo, isTransaction);
|
||||
if (!serialNumber_result.IsSuccess)
|
||||
return serialNumber_result;
|
||||
|
||||
//保存成功后:变更库存
|
||||
var boxInventoryBackGenerateDto = dto.Details.GroupBy(x =>new { x.BoxId,x.StockCode,x.SubStockId}).Select(x => new BoxInventoryBackGenerateDto()
|
||||
{
|
||||
BoxId=x.Key.BoxId,
|
||||
StockCode=x.Key.StockCode,
|
||||
SubStockId=x.Key.SubStockId,
|
||||
InventoryInOutType= type== BackRecordType.OutstockOn? (int)InventoryInOutType.In:(int)InventoryInOutType.Out,
|
||||
}).ToList();
|
||||
foreach (var item in dto.Details)
|
||||
{
|
||||
var current= boxInventoryBackGenerateDto.Where(x => x.BoxId == item.BoxId).FirstOrDefault();
|
||||
if (current != null)
|
||||
{
|
||||
var detail = new BoxInventoryBackDetailsGenerateDto();
|
||||
detail.MaterialId = item.MaterialId;
|
||||
detail.Qty = item.Qty;
|
||||
detail.SerialNumbers = item.SerialNumbers;
|
||||
current.Details.Add(detail);
|
||||
}
|
||||
}
|
||||
|
||||
var boxInventoryResult= await _boxInventoryService.GenerateBackBox(boxInventoryBackGenerateDto, isTransaction);
|
||||
if (!boxInventoryResult.IsSuccess)
|
||||
return boxInventoryResult;
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user