箱库存

This commit is contained in:
tongfei
2023-11-23 17:52:02 +08:00
parent 4572cbd3a6
commit 2840590e16
2 changed files with 26 additions and 56 deletions

View File

@@ -20,7 +20,7 @@ namespace WMS.Web.Domain.Services
/// <summary>
/// 出入库回退上下架:服务接口
/// </summary>
public class BackRecordService: IBackRecordService
public class BackRecordService : IBackRecordService
{
private readonly IMapper _mapper;
private readonly ILoginService _loginService;
@@ -60,13 +60,10 @@ namespace WMS.Web.Domain.Services
entity.Create(loginInfo.UserInfo.StaffId);
entity = await _backRecordRepositories.Add(entity, isTransaction);
//提交事务
var isSuccess = _basicsRepositories.CommitTransaction(isRollback, _transaction);
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
if (entity != null)
{
if (entity == null)
return Result.ReFailure(ResultCodes.DateWriteError);
//保存成功后:序列号跟踪流程添加
var serialNumber_result = await _serialNumberService.BackRecord(entity, loginInfo, isTransaction);
if (!serialNumber_result.IsSuccess)
@@ -75,14 +72,16 @@ namespace WMS.Web.Domain.Services
//保存成功后:变更库存
var entitys = new List<BackRecord>();
entitys.Add(entity);
var boxInventoryResult= await _boxInventoryService.GenerateBackBox(entitys, isTransaction);
var boxInventoryResult = await _boxInventoryService.GenerateBackBox(entitys, isTransaction);
if (!boxInventoryResult.IsSuccess)
return boxInventoryResult;
return Result.ReSuccess();
}
else
//提交事务
var isSuccess = _basicsRepositories.CommitTransaction(isRollback, _transaction);
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
return Result.ReSuccess();
}
}
}

View File

@@ -229,29 +229,10 @@ namespace WMS.Web.Domain.Services
if (!serialNumber_result.IsSuccess)
return serialNumber_result;
//保存成功后:变更箱库存
var boxInventoryGenerateDto = dto.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);
//箱库存变动
var dtoDatas = new List<InStock>();
dtoDatas.Add(entity);
var boxInventoryResult = await _boxInventoryService.GenerateInStockBox(dtoDatas, isTransaction);
if (!boxInventoryResult.IsSuccess)
return boxInventoryResult;
@@ -335,20 +316,10 @@ namespace WMS.Web.Domain.Services
if (!serialNumber_result.IsSuccess)
return serialNumber_result;
//7.箱库存的变更
//7.1组装头部和明细
var boxInventoryGenerateDto = dto.Boxs.Select(item => new BoxInventoryGenerateDto()
{
InventoryInOutMethod = dto.ShelfMethod == (int)ShelfMethod.Product ? (int)InventoryInOutMethod.Box : (int)InventoryInOutMethod.Product,
InventoryInOutType = (int)InventoryInOutType.In,
BoxId = item.BoxId,
StockCode = dto.StockCode,
SubStockId = dto.SubStockId,
Details = _mapper.Map<List<BoxInventoryGenerateDetailsDto>>(item.Details)
}).ToList();
//7.2执行处理箱库存
var boxInventoryResult = await _boxInventoryService.HandlBoxInventory(boxInventoryGenerateDto, isTransaction);
//箱库存变动
var dtoDatas = new List<InStock>();
dtoDatas.Add(entity);
var boxInventoryResult = await _boxInventoryService.GenerateInStockBox(dtoDatas, isTransaction);
if (!boxInventoryResult.IsSuccess)
return boxInventoryResult;