diff --git a/src/WMS.Web.Repositories/OutStockRepositories.cs b/src/WMS.Web.Repositories/OutStockRepositories.cs index 0f40f96f..1c9f301b 100644 --- a/src/WMS.Web.Repositories/OutStockRepositories.cs +++ b/src/WMS.Web.Repositories/OutStockRepositories.cs @@ -82,10 +82,6 @@ namespace WMS.Web.Repositories /// public async Task<(List list, int total)> GetListAsync(OutStockQueryRequest dto) { - List detailIds = new List(); - if (!string.IsNullOrEmpty(dto.SourceBillNo)) - detailIds = await _context.OutStockTaskDetails.FromSqlRaw($"SELECT Id FROM t_wms_outstock_details WHERE SourceBillNo like '%{dto.SourceBillNo}%'").Select(s => s.Id).ToListAsync(); - List ids = new List(); if (!string.IsNullOrEmpty(dto.Creator)) { @@ -138,8 +134,8 @@ namespace WMS.Web.Repositories query = query.Where(w => mIds.Contains(w.detail.MaterialId)); if (ids.Count() > 0) query = query.Where(w => ids.Contains(w.order.CreatorId)); - if (detailIds.Count()!=0) - query = query.Where(w => detailIds.Contains(w.detail.Id)); + if (!string.IsNullOrEmpty(dto.SourceBillNo)) + query = query.Where(w => w.detail.ErpDetails.Where(wd => EF.Functions.Like(wd.SourceBillNo, "%" + dto.SourceBillNo + "%")).Select(s => s.DetailId).Contains(w.detail.Id)); if (dto.Type != null) query = query.Where(w => w.order.Type == (OutStockType)dto.Type); if (dto.SuccessSync != null)