盘点支持更换仓位
This commit is contained in:
@@ -6,6 +6,7 @@ using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto;
|
||||
@@ -39,6 +40,7 @@ namespace WMS.Web.Domain.Services
|
||||
private readonly IErpService _erpService;
|
||||
private readonly ILogger<TakeStockService> _logger;
|
||||
private readonly IBoxInventoryService _boxInventoryService;
|
||||
private readonly IBoxInventoryRepositories _boxInventoryRepositories;
|
||||
private readonly IErpBasicDataExtendService _erpBasicDataExtendService;
|
||||
private readonly ISerialNumberService _serialNumberService;
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
@@ -50,7 +52,8 @@ namespace WMS.Web.Domain.Services
|
||||
ISingleDataService singleDataService, IErpService erpService, ILogger<TakeStockService> logger,
|
||||
IBoxInventoryService boxInventoryService, IErpBasicDataExtendService erpBasicDataExtendService,
|
||||
ISerialNumberService serialNumberService, IServiceScopeFactory serviceScopeFactory,
|
||||
ISerialNumbersRepositories serialNumberRepositories, IBoxRepositories boxRepositories)
|
||||
ISerialNumbersRepositories serialNumberRepositories, IBoxRepositories boxRepositories,
|
||||
IBoxInventoryRepositories boxInventoryRepositories)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_loginService = loginService;
|
||||
@@ -66,6 +69,7 @@ namespace WMS.Web.Domain.Services
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
_serialNumberRepositories = serialNumberRepositories;
|
||||
_boxRepositories = boxRepositories;
|
||||
_boxInventoryRepositories = boxInventoryRepositories;
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存
|
||||
@@ -80,8 +84,15 @@ namespace WMS.Web.Domain.Services
|
||||
if (dto.Count() == 0) return Result.ReSuccess();
|
||||
if (dto.GroupBy(g => g.BoxId).Count() > 1)
|
||||
return Result.ReFailure(ResultCodes.TakeStockBoxError);
|
||||
//v1.0.6 如果箱子不存在则添加箱信息
|
||||
//v1.0.6 如果箱子不存在则添加箱信息 和 可以更换仓位
|
||||
var dto_f = dto.First();
|
||||
bool isUpdateSubStock = false;
|
||||
BoxInventory boxInventory = null;
|
||||
if (isUpdateSubStock)
|
||||
{
|
||||
boxInventory = await _boxInventoryRepositories.Get(dto_f.BoxId);
|
||||
if (boxInventory == null) return Result.ReFailure(ResultCodes.BoxInventoryNoDataError);
|
||||
}
|
||||
if (dto_f.BoxId == 0)
|
||||
{
|
||||
var dBox = await _boxRepositories.GetByNo(dto_f.BoxBillNo);
|
||||
@@ -95,7 +106,7 @@ namespace WMS.Web.Domain.Services
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
dBox = await _boxRepositories.Add(dBox);
|
||||
if(dBox==null)return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
if (dBox == null) return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
dto.ForEach(f => f.BoxId = dBox.Id);
|
||||
}
|
||||
|
||||
@@ -163,7 +174,13 @@ namespace WMS.Web.Domain.Services
|
||||
}
|
||||
if (res_Rollback.IsSuccess)
|
||||
{
|
||||
var res_Inventory = await _boxInventoryService.GenerateTakeBox(list, serialNumbersBoxInventoryList, false);
|
||||
List<TakeStock> takes = list;
|
||||
if (isUpdateSubStock)
|
||||
{
|
||||
takes = new List<TakeStock>();
|
||||
takes = GetUpdateSubStockTakeStock(dto, loginInfo, boxInventory);
|
||||
}
|
||||
var res_Inventory = await _boxInventoryService.GenerateTakeBox(list, serialNumbersBoxInventoryList, isUpdateSubStock, false);
|
||||
if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory;
|
||||
}
|
||||
|
||||
@@ -386,5 +403,50 @@ namespace WMS.Web.Domain.Services
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/// <summary>
|
||||
/// 盘点更换仓位组装盘点单结构,用来调用即时库存
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
private List<TakeStock> GetUpdateSubStockTakeStock(List<SaveTakeStockRequest> dto, LoginInDto loginInfo, BoxInventory boxInventory)
|
||||
{
|
||||
List<TakeStock> list = new List<TakeStock>();
|
||||
var fist = dto.First();
|
||||
|
||||
//先用箱库存 组装盘亏单 把数据都盘出去
|
||||
TakeStock loss = new TakeStock();
|
||||
loss.Create(loginInfo.UserInfo.StaffId, TakeStockType.Loss);
|
||||
foreach (var d in boxInventory.Details)
|
||||
{
|
||||
loss.Details.Add(new TakeStockDetails()
|
||||
{
|
||||
BoxId = fist.BoxId,
|
||||
MaterialNumber = d.MaterialNumber,
|
||||
OrgCode = boxInventory.OrgCode,
|
||||
StockCode = boxInventory.StockCode,
|
||||
SubStockCode = boxInventory.SubStockCode,
|
||||
Old_SubStockCode = boxInventory.SubStockCode,
|
||||
AfterQty = 0,
|
||||
BeforeQty = d.Qty,
|
||||
SerialNumbers = d.SerialNumbers,
|
||||
FinalQty = d.Qty
|
||||
});
|
||||
}
|
||||
list.Add(loss);
|
||||
|
||||
//组装盘盈单
|
||||
TakeStock profit = new TakeStock();
|
||||
profit.Create(loginInfo.UserInfo.StaffId, TakeStockType.Profit);
|
||||
profit.Details = _mapper.Map<List<TakeStockDetails>>(dto.Where(w => w.AfterQty > 0));
|
||||
foreach (var d in profit.Details)
|
||||
{
|
||||
d.OrgCode = boxInventory.OrgCode;
|
||||
d.BeforeQty = 0;
|
||||
d.FinalQty = d.AfterQty;
|
||||
}
|
||||
list.Add(profit);
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user