入库单创建人条件查询优化
This commit is contained in:
@@ -36,6 +36,7 @@ namespace WMS.Web.Repositories
|
||||
private readonly ISingleDataService _singleDataService;
|
||||
private readonly IErpService _erpService;
|
||||
private readonly IErpBasicDataExtendService _erpBasicDataExtendService;
|
||||
private readonly IBasicsRepositories _basicsRepositories;
|
||||
|
||||
|
||||
public InStockRepositories(RepositoryDbContext context,
|
||||
@@ -44,11 +45,13 @@ namespace WMS.Web.Repositories
|
||||
ILoginRepositories loginRepositories,
|
||||
IServiceProvider serviceProvider,
|
||||
ISingleDataService singleDataService,
|
||||
IBasicsRepositories basicsRepositories,
|
||||
IErpBasicDataExtendService erpBasicDataExtendService)
|
||||
{
|
||||
_context = context;
|
||||
_mapper = mapper;
|
||||
_erpService = erpService;
|
||||
_basicsRepositories = basicsRepositories;
|
||||
_serviceProvider = serviceProvider;
|
||||
_loginRepositories = loginRepositories;
|
||||
_singleDataService = singleDataService;
|
||||
@@ -282,6 +285,16 @@ namespace WMS.Web.Repositories
|
||||
if (!string.IsNullOrEmpty(dto.MaterialNumber))
|
||||
materials = materials.Where(w => w.MaterialNumber.Contains(dto.MaterialNumber)).ToList();
|
||||
|
||||
if (companyId == 0)
|
||||
companyId = _loginRepositories.CompanyId;
|
||||
List<int> cr_ids = new List<int>();
|
||||
if (!string.IsNullOrEmpty(dto.Creator))
|
||||
{
|
||||
var staffList = await _basicsRepositories.GetStaffListAsync(companyId);
|
||||
if (staffList != null)
|
||||
cr_ids = staffList.Where(w => w.Name.Contains(dto.Creator)).Select(s => s.Id).ToList();
|
||||
}
|
||||
|
||||
var query = _context.InStockTotalDetails
|
||||
.GroupJoin(_context.Instock, detail => detail.InStockId, order => order.Id, (detail, orders) => new { detail, orders })
|
||||
.SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
|
||||
@@ -302,6 +315,9 @@ namespace WMS.Web.Repositories
|
||||
query = query.Where(w => w.detail.MaterialId == 0);
|
||||
}
|
||||
|
||||
if (cr_ids.Count!=0)
|
||||
query = query.Where(w => cr_ids.Contains(w.order.CreatorId));
|
||||
|
||||
if (dto.SupplierId.HasValue)
|
||||
query = query.Where(w => w.detail.SupplierId == dto.SupplierId.Value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user