出库箱拣货

This commit is contained in:
18942506660
2023-11-23 15:22:16 +08:00
parent 8cf8dab210
commit 2bb740f15e
3 changed files with 30 additions and 2 deletions

View File

@@ -33,6 +33,8 @@ namespace WMS.Web.Domain.Mappers
.ForMember(x => x.DetailId, ops => ops.Ignore()) .ForMember(x => x.DetailId, ops => ops.Ignore())
.ForMember(x => x.Qty, ops => ops.Ignore()); .ForMember(x => x.Qty, ops => ops.Ignore());
CreateMap<SaveOutStockDetailsRequest, OutStockBoxsDetails>(); CreateMap<SaveOutStockDetailsRequest, OutStockBoxsDetails>();
CreateMap<BoxInventoryDetails, SaveOutStockDetailsRequest>();
CreateMap<OutStockTask, GetOutStockTaskByNoResponse>(); CreateMap<OutStockTask, GetOutStockTaskByNoResponse>();

View File

@@ -37,11 +37,13 @@ namespace WMS.Web.Domain.Services
private readonly ISerialNumberService _serialNumberService; private readonly ISerialNumberService _serialNumberService;
private readonly IBoxInventoryService _boxInventoryService; private readonly IBoxInventoryService _boxInventoryService;
private readonly IInventoryInOutDetailsService _inventoryInOutDetailsService; private readonly IInventoryInOutDetailsService _inventoryInOutDetailsService;
private readonly IBoxInventoryRepositories _boxInventoryRepositories;
public OutStockService(IMapper mapper, ILoginService loginService, public OutStockService(IMapper mapper, ILoginService loginService,
IBasicsRepositories transactionRepositories, IBasicsRepositories transactionRepositories,
IOutStockRepositories outStockRepositories, IOutStockTaskRepositories outStockTaskRepositories, IOutStockRepositories outStockRepositories, IOutStockTaskRepositories outStockTaskRepositories,
IOutStockTaskService outStockTaskService, IErpService erpService, ISerialNumberService serialNumberService, IOutStockTaskService outStockTaskService, IErpService erpService, ISerialNumberService serialNumberService,
IBoxInventoryService boxInventoryService, IInventoryInOutDetailsService inventoryInOutDetailsService) IBoxInventoryService boxInventoryService, IInventoryInOutDetailsService inventoryInOutDetailsService,
IBoxInventoryRepositories boxInventoryRepositories)
{ {
_mapper = mapper; _mapper = mapper;
_loginService = loginService; _loginService = loginService;
@@ -53,6 +55,7 @@ namespace WMS.Web.Domain.Services
_serialNumberService = serialNumberService; _serialNumberService = serialNumberService;
_boxInventoryService = boxInventoryService; _boxInventoryService = boxInventoryService;
_inventoryInOutDetailsService = inventoryInOutDetailsService; _inventoryInOutDetailsService = inventoryInOutDetailsService;
_boxInventoryRepositories = boxInventoryRepositories;
} }
/// <summary> /// <summary>
/// 出库单 /// 出库单
@@ -73,9 +76,30 @@ namespace WMS.Web.Domain.Services
return Result.ReFailure(ResultCodes.OutStockMaterialError); return Result.ReFailure(ResultCodes.OutStockMaterialError);
//1.需要验证物料对应箱和序列号是否存在库存 //1.需要验证物料对应箱和序列号是否存在库存
//如果是按箱出库从库存拿取数据 //如果是按箱出库从库存拿取数据
if(dto.Method==1) if (dto.Method == 1)
{ {
//获取箱子对应的所有库存
var boxInventoryList = await _boxInventoryRepositories.GetList(dto.Details.Select(s => s.BoxId).ToList());
//过滤掉不同仓库和不同组织的
boxInventoryList = boxInventoryList.Where(w => w.StockCode == outStockTask.StockCode && w.OrgCode == outStockTask.OrgCode).ToList();
//组装dto
var boxInventoryDetails = boxInventoryList.SelectMany(s => s.Details).ToList();
foreach (var b in boxInventoryDetails)
{
var num = boxInventoryDetails.Where(w => w.MaterialId == b.MaterialId).Sum(s => s.Qty);
var taskDetail = outStockTask.Details.FirstOrDefault(f => f.MaterialId == b.MaterialId);
if (taskDetail == null) return Result.ReFailure(ResultCodes.BoxOutStockTaskMaterialError);
//箱子里该物料的总数量大于出库单(应出库数量-已出库数量) 不能出库
if (num > (taskDetail.AccruedQty - taskDetail.RealityQty))
return Result.ReFailure(ResultCodes.BoxNumberError);
var box = boxInventoryList.FirstOrDefault(f => f.Id == b.Fid);
if (box == null) return Result.ReFailure(ResultCodes.BoxNoData);
var dtod = _mapper.Map<SaveOutStockDetailsRequest>(b);
dtod.BoxId = box.BoxId;
dtod.SubStockId = box.SubStockId;
dto.Details.Add(dtod);
}
} }
var mIds = dto.Details.GroupBy(g => g.MaterialId).Select(s => s.Key).ToList(); var mIds = dto.Details.GroupBy(g => g.MaterialId).Select(s => s.Key).ToList();

View File

@@ -31,6 +31,8 @@ namespace WMS.Web.Domain.Values
public static ValueTuple<int, string> OutStockTaskAlready = (70004, "任务单已全部出库"); public static ValueTuple<int, string> OutStockTaskAlready = (70004, "任务单已全部出库");
public static ValueTuple<int, string> OutStockTaskRepeal = (70005, "任务单已作废"); public static ValueTuple<int, string> OutStockTaskRepeal = (70005, "任务单已作废");
public static ValueTuple<int, string> MergeNumberError = (70006, "必须选择两个及以上的单合并"); public static ValueTuple<int, string> MergeNumberError = (70006, "必须选择两个及以上的单合并");
public static ValueTuple<int, string> BoxNumberError= (70007, "该批箱数量不符,不能出库");
public static ValueTuple<int, string> BoxOutStockTaskMaterialError = (70008, "该批箱物料和出库单中不存在,不能出库");
public static ValueTuple<int, string> BoxIsTrueShelf = (80000, "该箱已上架,请选择其它箱进行上架!"); public static ValueTuple<int, string> BoxIsTrueShelf = (80000, "该箱已上架,请选择其它箱进行上架!");
public static ValueTuple<int, string> BoxNoData = (80000, "箱信息不存在"); public static ValueTuple<int, string> BoxNoData = (80000, "箱信息不存在");