库存仓储优化
This commit is contained in:
@@ -477,6 +477,62 @@ namespace WMS.Web.Domain.Services
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 入库回退上下架-箱库存的变更
|
||||
/// </summary>
|
||||
/// <param name="dtoDatas"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> GenerateBackBox(List<BackRecord> dtoDatas, bool isTransaction)
|
||||
{
|
||||
//1.判断来源数据是否存在
|
||||
if (dtoDatas == null || dtoDatas.Count == 0)
|
||||
return Result.ReFailure(ResultCodes.InventoryNoSourceError);
|
||||
|
||||
//2.获取“箱库存集合”
|
||||
var boxIds = dtoDatas.SelectMany(x=>x.Details).GroupBy(x => x.BoxId).Select(x => x.Key).ToList();
|
||||
var boxInventorys = await _boxInventoryRepositories.GetList(boxIds);
|
||||
var boxs = await _boxRepositories.GetEntityList(boxIds);
|
||||
var serialNumbers = await _serialNumbersRepositories.GetEntityListByBoxIds(boxIds);
|
||||
|
||||
//
|
||||
var dtoDetails_in = dtoDatas.Where(x => x.Type == BackRecordType.OutstockOn).SelectMany(x => x.Details).ToList();
|
||||
|
||||
//2.1组织:头部
|
||||
var generateDtoList = dtoDatas.SelectMany(x => x.Details).GroupBy(x => new { x.BoxId, x.OrgCode, x.StockCode, x.SubStockId })
|
||||
.Select(x=>new BoxInventoryBackGenerateDto()
|
||||
{
|
||||
BoxId=x.Key.BoxId,
|
||||
OrgCode=x.Key.OrgCode,
|
||||
StockCode=x.Key.StockCode,
|
||||
SubStockId=x.Key.SubStockId
|
||||
}).ToList();
|
||||
|
||||
|
||||
//3.遍历:组装明细
|
||||
generateDtoList.ForEach(x =>
|
||||
{
|
||||
foreach (var detItem in dtoDatas.SelectMany(x=>x.Details).ToList())
|
||||
{
|
||||
//3.1箱是当前的
|
||||
if (detItem.BoxId == x.BoxId)
|
||||
{
|
||||
var dtoCurrent = dtoDatas.Where(x => x.Id == detItem.Fid).FirstOrDefault();
|
||||
if (dtoCurrent != null)
|
||||
x.InventoryInOutType = dtoCurrent.Type == BackRecordType.InstockOff ? (int)InventoryInOutType.Out : (int)InventoryInOutType.In;
|
||||
//3.2组装明细
|
||||
var det = new BoxInventoryBackDetailsGenerateDto();
|
||||
det.MaterialId = detItem.MaterialId;
|
||||
det.Qty = detItem.Qty;
|
||||
det.SerialNumbers = detItem.SerialNumbers;
|
||||
x.Details.Add(det);
|
||||
}
|
||||
}
|
||||
});
|
||||
//4.提交处理
|
||||
return await this.GenerateBackBox(generateDtoList, isTransaction);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 处理箱库存变更:出入库
|
||||
|
||||
Reference in New Issue
Block a user