列表查询条件添加
This commit is contained in:
@@ -24,16 +24,17 @@ namespace WMS.Web.Repositories
|
||||
private readonly RepositoryDbContext _context;
|
||||
private readonly ISingleDataService _singleDataService;
|
||||
private readonly ILoginRepositories _loginRepositories;
|
||||
|
||||
private readonly IBasicsRepositories _basicsRepositories;
|
||||
|
||||
public ChangeBoxRecordRepositories(RepositoryDbContext context, IMapper mapper, IServiceProvider serviceProvider,
|
||||
ISingleDataService singleDataService, ILoginRepositories loginRepositories)
|
||||
ISingleDataService singleDataService, ILoginRepositories loginRepositories, IBasicsRepositories basicsRepositories)
|
||||
{
|
||||
_context = context;
|
||||
_mapper = mapper;
|
||||
_serviceProvider = serviceProvider;
|
||||
_singleDataService = singleDataService;
|
||||
_loginRepositories = loginRepositories;
|
||||
_basicsRepositories = basicsRepositories;
|
||||
}
|
||||
/// <summary>
|
||||
/// 新增
|
||||
@@ -76,14 +77,33 @@ namespace WMS.Web.Repositories
|
||||
/// <returns></returns>
|
||||
public async Task<(List<ChangeBoxRecordQueryInfoResponse> list, int total)> GetListAsync(ChangeBoxRecordQueryRequest dto)
|
||||
{
|
||||
List<int> ids = new List<int>();
|
||||
if (!string.IsNullOrEmpty(dto.Creator))
|
||||
{
|
||||
var staffList = await _basicsRepositories.GetStaffListAsync(_loginRepositories.CompanyId);
|
||||
ids = staffList.Where(w => EF.Functions.Like(w.Name, "%" + dto.Creator + "%")).Select(s => s.Id).ToList();
|
||||
}
|
||||
|
||||
var query = _context.ChangeBoxRecord
|
||||
.GroupJoin(_context.Box, changeBox => changeBox.SrcBoxId, srcBox => srcBox.Id, (changeBox, srcBox) => new { changeBox, srcBox })
|
||||
.SelectMany(x => x.srcBox.DefaultIfEmpty(), (d, srcBox) => new { d.changeBox, srcBox })
|
||||
.GroupJoin(_context.Box, d => d.changeBox.DestBoxId, destBox => destBox.Id, (d, destBox) => new { d.changeBox, d.srcBox, destBox })
|
||||
.SelectMany(x => x.destBox.DefaultIfEmpty(), (d, destBox) => new { d.changeBox,d.srcBox, destBox })
|
||||
.SelectMany(x => x.destBox.DefaultIfEmpty(), (d, destBox) => new { d.changeBox, d.srcBox, destBox })
|
||||
.OrderByDescending(o => o.changeBox.Id)
|
||||
.Where(adv => 1 == 1);
|
||||
|
||||
if (ids.Count() > 0)
|
||||
query = query.Where(w => ids.Contains(w.changeBox.CreatorId));
|
||||
if (!string.IsNullOrEmpty(dto.SrcBox))
|
||||
query = query.Where(w => EF.Functions.Like(w.srcBox.BoxBillNo, "%" + dto.SrcBox + "%"));
|
||||
if (!string.IsNullOrEmpty(dto.DestBox))
|
||||
query = query.Where(w => EF.Functions.Like(w.destBox.BoxBillNo, "%" + dto.DestBox + "%"));
|
||||
if (dto.StockId != null)
|
||||
query = query.Where(w => w.changeBox.StockId == dto.StockId);
|
||||
if (dto.SrcSubStockId != null)
|
||||
query = query.Where(w => w.changeBox.SrcSubStockId == dto.SrcSubStockId);
|
||||
if (dto.DestSubStockId != null)
|
||||
query = query.Where(w => w.changeBox.DestSubStockId == dto.DestSubStockId);
|
||||
if (dto.CreateBeginDate != null)
|
||||
query = query.Where(w => w.changeBox.CreateTime >= dto.CreateBeginDate);
|
||||
if (dto.CreateEndDate != null)
|
||||
@@ -103,7 +123,7 @@ namespace WMS.Web.Repositories
|
||||
SrcSubStock = _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, s.changeBox.SrcSubStockId),
|
||||
DestSubStock = _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, s.changeBox.DestSubStockId),
|
||||
Creator = _singleDataService.GetSingleData(SingleAction.Staffs, _loginRepositories.CompanyId, s.changeBox.CreatorId),
|
||||
CreateTime =s.changeBox.CreateTime.DateToStringSeconds()
|
||||
CreateTime = s.changeBox.CreateTime.DateToStringSeconds()
|
||||
#endregion
|
||||
|
||||
}).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync();
|
||||
|
||||
Reference in New Issue
Block a user