生成-物料收发明细
This commit is contained in:
@@ -31,6 +31,16 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// </summary>
|
||||
public string StockCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 仓位ID
|
||||
/// </summary>
|
||||
public int SubStockId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 箱ID
|
||||
/// </summary>
|
||||
public int BoxId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单据类型
|
||||
/// </summary>
|
||||
|
||||
23
src/WMS.Web.Domain/IService/IInventoryInOutDetailsService.cs
Normal file
23
src/WMS.Web.Domain/IService/IInventoryInOutDetailsService.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto.Inventory;
|
||||
using WMS.Web.Core.Internal.Results;
|
||||
|
||||
namespace WMS.Web.Domain.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料收发明细:服务接口
|
||||
/// </summary>
|
||||
public interface IInventoryInOutDetailsService
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成:物料收发明细
|
||||
/// </summary>
|
||||
/// <param name="dtos"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result> GenerateInOrOutDetails(List<InventoryInOutDetailsGenerateDto> dtos, bool isTransaction);
|
||||
}
|
||||
}
|
||||
@@ -35,5 +35,14 @@ namespace WMS.Web.Domain.Infrastructure
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> UpdateRange(List<InventoryDetails> entitys, bool isTransaction = true);
|
||||
|
||||
/// <summary>
|
||||
/// 列表-根据物料和仓库和仓位
|
||||
/// </summary>
|
||||
/// <param name="materialIds"></param>
|
||||
/// <param name="stockCodes"></param>
|
||||
/// <param name="subStockIds"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<InventoryDetails>> GetListBy(List<int> materialIds, List<string> stockCodes, List<int> subStockIds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,14 @@ namespace WMS.Web.Domain.Mappers
|
||||
//箱库存映射
|
||||
CreateMap<BoxInventoryGenerateDto, BoxInventory>();
|
||||
CreateMap<BoxInventoryGenerateDetailsDto, BoxInventoryDetails>();
|
||||
|
||||
//物料收发明细-映射
|
||||
CreateMap<InventoryInOutDetailsGenerateDto, InventoryInOutDetails>()
|
||||
.ForMember(x => x.OrderType, ops => ops.MapFrom(x => x.OrderType))
|
||||
.ForMember(x => x.Type, ops => ops.MapFrom(x => x.InventoryInOutType));
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
78
src/WMS.Web.Domain/Services/InventoryInOutDetailsService.cs
Normal file
78
src/WMS.Web.Domain/Services/InventoryInOutDetailsService.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto.Inventory;
|
||||
using WMS.Web.Core.Internal.Results;
|
||||
using WMS.Web.Domain.Entitys;
|
||||
using WMS.Web.Domain.Infrastructure;
|
||||
using WMS.Web.Domain.IService;
|
||||
using WMS.Web.Domain.Values;
|
||||
|
||||
namespace WMS.Web.Domain.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料收发明细:服务
|
||||
/// </summary>
|
||||
public class InventoryInOutDetailsService: IInventoryInOutDetailsService
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IBoxRepositories _boxRepositories;
|
||||
private readonly ISerialNumbersRepositories _serialNumbersRepositories;
|
||||
private readonly IInventoryDetailsRepositories _inventoryDetailsRepositories;
|
||||
private readonly IInventoryInOutDetailsRepositories _inventoryInOutDetailsRepositories;
|
||||
public InventoryInOutDetailsService(IMapper mapper, IBoxRepositories boxRepositories,
|
||||
ISerialNumbersRepositories serialNumbersRepositories,
|
||||
IInventoryDetailsRepositories inventoryDetailsRepositories,
|
||||
IInventoryInOutDetailsRepositories inventoryInOutDetailsRepositories)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_boxRepositories = boxRepositories;
|
||||
_inventoryDetailsRepositories = inventoryDetailsRepositories;
|
||||
_serialNumbersRepositories = serialNumbersRepositories;
|
||||
_inventoryInOutDetailsRepositories = inventoryInOutDetailsRepositories;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成:物料收发明细
|
||||
/// </summary>
|
||||
/// <param name="dtos"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> GenerateInOrOutDetails(List<InventoryInOutDetailsGenerateDto> dtos,bool isTransaction)
|
||||
{
|
||||
//找到物料对应的即时库存明细
|
||||
var materialIds = dtos.Select(x => x.MaterialId).ToList();
|
||||
var stockCodes = dtos.GroupBy(x => x.StockCode).Select(x => x.Key).ToList();
|
||||
var subStockIds = dtos.GroupBy(x => x.SubStockId).Select(x => x.Key).ToList();
|
||||
var inventoryDetails=await _inventoryDetailsRepositories.GetListBy(materialIds, stockCodes, subStockIds);
|
||||
|
||||
//1.创建要新增的对象
|
||||
var add_entitys = new List<InventoryInOutDetails>();
|
||||
|
||||
//2.遍历:box库存来源数据明细
|
||||
foreach (var dto in dtos)
|
||||
{
|
||||
//2.1当前的即时库存明细
|
||||
var currentDetail= inventoryDetails.Where(x => x.MaterialId == dto.MaterialId && x.StockCode == dto.StockCode && x.SubStockId == dto.SubStockId).FirstOrDefault();
|
||||
|
||||
//2.2组装物料收发明细实体
|
||||
var entity = _mapper.Map<InventoryInOutDetails>(dto);
|
||||
entity.SurplusQty = currentDetail == null ? 0 : currentDetail.Qty;
|
||||
add_entitys.Add(entity);
|
||||
}
|
||||
|
||||
var isSuccess = true;
|
||||
if (add_entitys.Count != 0)
|
||||
{
|
||||
isSuccess = await _inventoryInOutDetailsRepositories.AddRange(add_entitys, isTransaction);
|
||||
if(!isSuccess)
|
||||
return Result.ReFailure(ResultCodes.InventoryInOutDetailsWriteError);
|
||||
}
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,7 @@ namespace WMS.Web.Domain.Values
|
||||
public static ValueTuple<int, string> BoxInventoryMaterialNoDataError = (800041, "箱物料库存数据不存在,请稍候再试!");
|
||||
public static ValueTuple<int, string> BoxInventoryNoInventoryError = (800012, "箱库存物料数量不足,请核对后再试!");
|
||||
public static ValueTuple<int, string> BoxInventoryHaveInventoryError = (800013, "该箱库存已经存在,请核对后再试!");
|
||||
public static ValueTuple<int, string> InventoryInOutDetailsWriteError = (800014, "写入物料收发明细失败!");
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user