diff --git a/src/WMS.Web.Repositories/InventoryInOutDetailsRepositories.cs b/src/WMS.Web.Repositories/InventoryInOutDetailsRepositories.cs index cc6d8727..24c4ccdd 100644 --- a/src/WMS.Web.Repositories/InventoryInOutDetailsRepositories.cs +++ b/src/WMS.Web.Repositories/InventoryInOutDetailsRepositories.cs @@ -26,19 +26,24 @@ namespace WMS.Web.Repositories private readonly ILoginRepositories _loginRepositories; private readonly RepositoryDbContext _context; private readonly ISingleDataService _singleDataService; - + private readonly IErpService _erpService; + private readonly IErpBasicDataExtendService _erpBasicDataExtendService; public InventoryInOutDetailsRepositories(RepositoryDbContext context, IMapper mapper, + IErpService erpService, ILoginRepositories loginRepositories, IServiceProvider serviceProvider, - ISingleDataService singleDataService) + ISingleDataService singleDataService, + IErpBasicDataExtendService erpBasicDataExtendService) { _context = context; _mapper = mapper; + _erpService = erpService; _serviceProvider = serviceProvider; _loginRepositories = loginRepositories; _singleDataService = singleDataService; + _erpBasicDataExtendService = erpBasicDataExtendService; } /// @@ -48,11 +53,25 @@ namespace WMS.Web.Repositories /// public async Task> GetPagedList(InventoryInOutDetailsQueryRequest dto) { + //1.获取物料集合和组织集合 + var materials_result = await _erpService.BillQueryForMaterial(); + if (!materials_result.IsSuccess) + return ResultPagedList.ReFailure(materials_result); + var materials = materials_result.Data.ToList(); + + //物料集合;模糊查询后的物料集合 + if (!string.IsNullOrEmpty(dto.MaterialNumber)) + materials = materials.Where(w => EF.Functions.Like(w.MaterialNumber, "%" + dto.MaterialNumber + "%")).ToList(); + var query = _context.InventoryInOutDetails .Where(adv => 1 == 1); - //if (!string.IsNullOrEmpty(dto.MaterialNumber)) - // query = query.Where(w => EF.Functions.Like(w.detail.BillNo, "%" + dto.BillNo + "%")); + //物料ID在模糊后的物料 + if (materials != null && materials.Count != 0 && !string.IsNullOrEmpty(dto.MaterialNumber)) + { + var mids = materials.Select(x => x.MaterialId).ToList(); + query = query.Where(w => mids.Contains(w.MaterialId)); + } if (dto.StockId.HasValue) query = query.Where(w => w.StockId == dto.StockId.Value); @@ -72,10 +91,10 @@ namespace WMS.Web.Repositories var list = await query.Select(s => new InventoryInOutDetailsQueryResponse() { Id = s.Id, - MaterialName = "", - MaterialNumber = "", - Specifications = "", - Type=s.Type.GetRemark(), + MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.MaterialId), + MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, s.MaterialId), + Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.MaterialId), + Type =s.Type.GetRemark(), OrderType=s.OrderType.GetRemark(), OrderBillNo=s.OrderBillNo, Stock = "",