物料收发明细
This commit is contained in:
@@ -21,10 +21,12 @@ namespace WMS.Web.Domain.Services
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IBoxRepositories _boxRepositories;
|
||||
private readonly IInventoryDetailsService _inventoryDetailsService;
|
||||
private readonly IInventoryInOutDetailsService _inventoryInOutDetailsService;
|
||||
private readonly ISerialNumbersRepositories _serialNumbersRepositories;
|
||||
private readonly IBoxInventoryRepositories _boxInventoryRepositories;
|
||||
public BoxInventoryService(IMapper mapper, IBoxRepositories boxRepositories,
|
||||
IInventoryDetailsService inventoryDetailsService,
|
||||
IInventoryInOutDetailsService inventoryInOutDetailsService,
|
||||
ISerialNumbersRepositories serialNumbersRepositories,
|
||||
IBoxInventoryRepositories boxInventoryRepositories)
|
||||
{
|
||||
@@ -33,6 +35,7 @@ namespace WMS.Web.Domain.Services
|
||||
_inventoryDetailsService = inventoryDetailsService;
|
||||
_serialNumbersRepositories = serialNumbersRepositories;
|
||||
_boxInventoryRepositories = boxInventoryRepositories;
|
||||
_inventoryInOutDetailsService = inventoryInOutDetailsService;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +89,49 @@ namespace WMS.Web.Domain.Services
|
||||
}
|
||||
});
|
||||
//4.开始处理
|
||||
return await this.ExeChangeBox(generateDtos, isTransaction);
|
||||
var result= await this.ExeChangeBox(generateDtos, sourceBoxInventorys, targetBoxInventorys, isTransaction);
|
||||
if (!result.IsSuccess)
|
||||
return result;
|
||||
|
||||
//5.物料收发明细dtos
|
||||
var InventoryInOutDetailsGenerateDtoList = new List<InventoryInOutDetailsGenerateDto>();
|
||||
|
||||
//5.1遍历
|
||||
foreach (var item in dtoDatas)
|
||||
{
|
||||
//5.2组装:原箱物料收发明细;有箱库存就需要创建物料收发明细;
|
||||
var sour = sourceBoxInventorys.Where(x => x.BoxId == item.SrcBoxId).FirstOrDefault();
|
||||
if (sour != null)
|
||||
{
|
||||
var inventoryInOutDet = _inventoryInOutDetailsService.GenerateDto(
|
||||
item.SrcBoxId, item.MaterialId,
|
||||
sour.OrgCode, sour.StockCode,
|
||||
sour.SubStockId, OrderType.ChangeBox,
|
||||
item.BillNo, item.Qty, InventoryInOutType.Out);
|
||||
InventoryInOutDetailsGenerateDtoList.Add(inventoryInOutDet);
|
||||
}
|
||||
//5.3组装:目标箱物料收发明细;有箱库存就需要创建物料收发明细;
|
||||
var tagBox = targetBoxInventorys.Where(x => x.BoxId == item.DestBoxId).FirstOrDefault();
|
||||
if (tagBox != null)
|
||||
{
|
||||
var inventoryInOutDet=_inventoryInOutDetailsService.GenerateDto(
|
||||
item.DestBoxId, item.MaterialId,
|
||||
item.DestBoxOrgCode, item.DestStockCode,
|
||||
item.DestSubStockId, OrderType.ChangeBox,
|
||||
item.BillNo, item.Qty, InventoryInOutType.In);
|
||||
InventoryInOutDetailsGenerateDtoList.Add(inventoryInOutDet);
|
||||
}
|
||||
}
|
||||
|
||||
//5.提交物料收发明细:新增
|
||||
if (InventoryInOutDetailsGenerateDtoList.Count != 0)
|
||||
{
|
||||
var inout_result = await _inventoryInOutDetailsService.GenerateInOrOutDetails(InventoryInOutDetailsGenerateDtoList,isTransaction);
|
||||
if (!inout_result.IsSuccess)
|
||||
return inout_result;
|
||||
}
|
||||
return Result.ReSuccess();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -101,6 +146,9 @@ namespace WMS.Web.Domain.Services
|
||||
if (dtoDatas == null || dtoDatas.Count == 0)
|
||||
return Result.ReFailure(ResultCodes.InventoryNoSourceError);
|
||||
|
||||
//物料收发明细dtos
|
||||
var InventoryInOutDetailsGenerateDtoList = new List<InventoryInOutDetailsGenerateDto>();
|
||||
|
||||
//2.箱库存集合
|
||||
var boxIds = dtoDatas.Where(x => x.BoxId != 0 && x.Type == MoveBoxType.Down).GroupBy(x => x.BoxId).Select(x => x.Key).ToList();
|
||||
var boxInventorys = await _boxInventoryRepositories.GetList(boxIds);
|
||||
@@ -112,6 +160,7 @@ namespace WMS.Web.Domain.Services
|
||||
var generateDtoList = new List<BoxInventoryMoveGenerateDto>();
|
||||
foreach (var item in dtoDatas)
|
||||
{
|
||||
//2.2.1箱库存dto-组装
|
||||
var generateDto = new BoxInventoryMoveGenerateDto();
|
||||
generateDto.BoxId = item.BoxId;
|
||||
generateDto.OrgCode = item.OrgCode;
|
||||
@@ -120,9 +169,43 @@ namespace WMS.Web.Domain.Services
|
||||
generateDto.InventoryInOutType = item.Type == MoveBoxType.Down ? (int)InventoryInOutType.Out : (int)InventoryInOutType.In;
|
||||
generateDtoList.Add(generateDto);
|
||||
|
||||
//2.2.2物料收发明dto-组装
|
||||
var SubStockId = item.Type == MoveBoxType.Up ? item.DestSubStockId : item.SrcSubStockId;
|
||||
InventoryInOutType InOutType = item.Type == MoveBoxType.Down ? InventoryInOutType.Out : InventoryInOutType.In;
|
||||
var ishave = boxInventorys.Where(x => x.BoxId == item.BoxId).Any();
|
||||
//上架-箱是不存在库存的情况下,生成物料收发明细
|
||||
//或者
|
||||
//下架-箱库存是存在的情况下,生成物料收发明细
|
||||
if ((!ishave && item.Type == MoveBoxType.Up) || (ishave && item.Type == MoveBoxType.Down))
|
||||
{
|
||||
//5.1.1取箱信息
|
||||
var box = boxs.Where(x => x.Id == item.BoxId).FirstOrDefault();
|
||||
foreach (var boxDet in box.Details)
|
||||
{
|
||||
var inventoryInOutDet = _inventoryInOutDetailsService.GenerateDto(
|
||||
item.BoxId, boxDet.MaterialId,
|
||||
item.OrgCode, item.StockCode,
|
||||
SubStockId, OrderType.MoveBox,
|
||||
item.BillNo, item.Qty, InOutType);
|
||||
InventoryInOutDetailsGenerateDtoList.Add(inventoryInOutDet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//4.开始处理
|
||||
return await this.ExeMoveBox(generateDtoList, isTransaction);
|
||||
var result= await this.ExeMoveBox(generateDtoList, boxInventorys, boxs, isTransaction);
|
||||
if (!result.IsSuccess)
|
||||
return result;
|
||||
|
||||
//5.提交物料收发明细:新增
|
||||
if (InventoryInOutDetailsGenerateDtoList.Count != 0)
|
||||
{
|
||||
var inout_result = await _inventoryInOutDetailsService.GenerateInOrOutDetails(InventoryInOutDetailsGenerateDtoList, isTransaction);
|
||||
if (!inout_result.IsSuccess)
|
||||
return inout_result;
|
||||
}
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -425,13 +508,16 @@ namespace WMS.Web.Domain.Services
|
||||
//提交处理
|
||||
return await this.ExeOutStockBox(generateDtoList, isTransaction);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 改箱-箱库存的变更
|
||||
/// </summary>
|
||||
/// <param name="dtoDatas"></param>
|
||||
/// <param name="sourceBoxInventorys"></param>
|
||||
/// <param name="targetBoxInventorys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<Result> ExeChangeBox(List<BoxInventoryChangeGenerateDto> dtoDatas, bool isTransaction)
|
||||
private async Task<Result> ExeChangeBox(List<BoxInventoryChangeGenerateDto> dtoDatas,List<BoxInventory> sourceBoxInventorys, List<BoxInventory> targetBoxInventorys, bool isTransaction)
|
||||
{
|
||||
//1.判断来源数据是否存在
|
||||
if (dtoDatas == null || dtoDatas.Count == 0)
|
||||
@@ -441,16 +527,6 @@ namespace WMS.Web.Domain.Services
|
||||
var add_entitys = new List<BoxInventory>();
|
||||
var InventoryDetailsGenerateDto = new List<InventoryDetailsGenerateDto>();
|
||||
|
||||
var boxIds = dtoDatas.GroupBy(x => x.BoxId).Select(x => x.Key).ToList();
|
||||
var targetBoxIds = dtoDatas.GroupBy(x => x.TargetBoxId).Select(x => x.Key).ToList();
|
||||
|
||||
//2.原来箱库存集合
|
||||
var sourceBoxInventorys = await _boxInventoryRepositories.GetList(boxIds);
|
||||
|
||||
//2.1目标箱库存集合
|
||||
var targetBoxInventorys = await _boxInventoryRepositories.GetList(targetBoxIds);
|
||||
|
||||
|
||||
foreach (var dto in dtoDatas)
|
||||
{
|
||||
#region 原箱库存-库存处理
|
||||
@@ -487,7 +563,6 @@ namespace WMS.Web.Domain.Services
|
||||
inventoryDet.InventoryInOutType = (int)InventoryInOutType.Out;
|
||||
//2.2.2即时库存:修改箱库存的集合
|
||||
InventoryDetailsGenerateDto.Add(inventoryDet);
|
||||
|
||||
}
|
||||
//2.2.1箱库存:修改箱库存的集合
|
||||
update_entitys.Add(sour_update_entity);
|
||||
@@ -573,9 +648,11 @@ namespace WMS.Web.Domain.Services
|
||||
/// 移箱-箱库存的变更
|
||||
/// </summary>
|
||||
/// <param name="dtoDatas"></param>
|
||||
/// <param name="boxInventorys"></param>
|
||||
/// <param name="boxs"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<Result> ExeMoveBox(List<BoxInventoryMoveGenerateDto> dtoDatas, bool isTransaction)
|
||||
private async Task<Result> ExeMoveBox(List<BoxInventoryMoveGenerateDto> dtoDatas, List<BoxInventory> boxInventorys,List<Box> boxs, bool isTransaction)
|
||||
{
|
||||
//1.判断来源数据是否存在
|
||||
if (dtoDatas == null || dtoDatas.Count == 0)
|
||||
@@ -587,8 +664,6 @@ namespace WMS.Web.Domain.Services
|
||||
|
||||
//2.获取“箱库存集合”和“箱基本信息集合”
|
||||
var boxIds = dtoDatas.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);
|
||||
|
||||
//3.遍历:dto
|
||||
|
||||
Reference in New Issue
Block a user