非采购上架-箱库存变更

This commit is contained in:
tongfei
2023-11-17 09:38:42 +08:00
parent 6cc4cdf6a4
commit c771127508
3 changed files with 41 additions and 23 deletions

View File

@@ -207,7 +207,7 @@ namespace WMS.Web.Domain.Services
return serialNumber_result;
//保存成功后:变更箱库存
var boxInventoryGenerateDto = entity.Details.GroupBy(x => new { x.BoxId, x.StockCode, x.SubStockId }).Select(x => new BoxInventoryGenerateDto()
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,
@@ -246,12 +246,10 @@ namespace WMS.Web.Domain.Services
/// <returns></returns>
private async Task<Result> ShelfNoPurchaseSave(NoPurchaseShelfRequest dto, LoginInDto loginInfo, bool isTransaction = true)
{
//1.修改-入库任务单的信息
var updateInStockTaskRequest = new UpdateInStockTaskRequest();
updateInStockTaskRequest.Id = dto.TaskId;
updateInStockTaskRequest.Boxs = dto.Boxs;
updateInStockTaskRequest.Details =new List<UpdateInStockTaskDetailsRequest>();
updateInStockTaskRequest.Details = new List<UpdateInStockTaskDetailsRequest>();
foreach (var item in dto.Details)
{
var updateInStockTaskDetailsRequest = new UpdateInStockTaskDetailsRequest();
@@ -259,7 +257,17 @@ namespace WMS.Web.Domain.Services
updateInStockTaskDetailsRequest.ReceiveQty = item.Qty;
updateInStockTaskRequest.Details.Add(updateInStockTaskDetailsRequest);
}
//1.1.先找到箱IDs获取箱基本信息
var boxIds = dto.Details.GroupBy(x => x.BoxId).Select(x => x.Key).ToList();
var boxInfos= await _boxRepositories.GetEntityList(boxIds);
foreach (var item in boxInfos)
{
var task_box = new UpdateInStockTaskBoxRequest();
task_box.BoxId = item.Id;
task_box.BoxBillNo = item.BoxBillNo;
updateInStockTaskRequest.Boxs.Add(task_box);
}
//2.修改后返回当前实体
var update_result = await this.Update(updateInStockTaskRequest, loginInfo.UserInfo.StaffId, null, isTransaction, true);
if (!update_result.IsSuccess)
@@ -271,10 +279,6 @@ namespace WMS.Web.Domain.Services
entity.Details = _mapper.Map<List<InStockDetails>>(dto.Details);
entity.Create(loginInfo.UserInfo.StaffId);
//需要填写序列号
//需要修改库存
//需要同步金蝶
//添加入库单信息
entity = await _inStockRepositories.Add(entity, isTransaction);
if(entity==null)
@@ -284,7 +288,7 @@ namespace WMS.Web.Domain.Services
if (dto.ShelfMethod == (int)ShelfMethod.Product)
{
var changeBox = new SaveChangeBoxRecordRequest();
changeBox.DestBoxId = dto.Boxs.FirstOrDefault().BoxId;
changeBox.DestBoxId = boxIds.FirstOrDefault();
foreach (var item in dto.Details)
{
var changeBoxRD = new SaveChangeBoxRecordDetailsRequest();
@@ -302,6 +306,33 @@ namespace WMS.Web.Domain.Services
var serialNumber_result = await _serialNumberService.InStock(entity, loginInfo, isTransaction);
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 = dto.ShelfMethod == (int)ShelfMethod.Product?(int)InventoryInOutMethod.Box: (int)InventoryInOutMethod.Product,
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);
if (!boxInventoryResult.IsSuccess)
return boxInventoryResult;
return Result.ReSuccess();
}
@@ -370,10 +401,7 @@ namespace WMS.Web.Domain.Services
}
var isSuccess = await _inStockTaskRepositories.UpdateRange(entitys, isTransaction);
if (isSuccess)
{
return Result.ReSuccess();
}
else
return Result.ReFailure(ResultCodes.DateWriteError);
}