入库单创建人条件查询优化
This commit is contained in:
@@ -27,7 +27,7 @@ namespace WMS.Web.Repositories
|
||||
/// <summary>
|
||||
/// wms入库单-仓储
|
||||
/// </summary>
|
||||
public class InStockRepositories: IAllFielRepositories<InStockQueryRequest>, IInStockRepositories
|
||||
public class InStockRepositories : IAllFielRepositories<InStockQueryRequest>, IInStockRepositories
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
@@ -36,25 +36,28 @@ namespace WMS.Web.Repositories
|
||||
private readonly ISingleDataService _singleDataService;
|
||||
private readonly IErpService _erpService;
|
||||
private readonly IErpBasicDataExtendService _erpBasicDataExtendService;
|
||||
private readonly IBasicsRepositories _basicsRepositories;
|
||||
|
||||
|
||||
public InStockRepositories(RepositoryDbContext context,
|
||||
public InStockRepositories(RepositoryDbContext context,
|
||||
IMapper mapper,
|
||||
IErpService erpService,
|
||||
ILoginRepositories loginRepositories,
|
||||
IServiceProvider serviceProvider,
|
||||
ISingleDataService singleDataService,
|
||||
IErpBasicDataExtendService erpBasicDataExtendService)
|
||||
IBasicsRepositories basicsRepositories,
|
||||
IErpBasicDataExtendService erpBasicDataExtendService)
|
||||
{
|
||||
_context = context;
|
||||
_mapper = mapper;
|
||||
_erpService = erpService;
|
||||
_basicsRepositories = basicsRepositories;
|
||||
_serviceProvider = serviceProvider;
|
||||
_loginRepositories = loginRepositories;
|
||||
_singleDataService = singleDataService;
|
||||
_erpBasicDataExtendService = erpBasicDataExtendService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 箱是否存在于入库单明细中;(箱是否被上架了)
|
||||
@@ -176,7 +179,7 @@ namespace WMS.Web.Repositories
|
||||
{
|
||||
var model = await _context.Instock
|
||||
.Include(s => s.Details)
|
||||
.Include(s=>s.ErpDetails)
|
||||
.Include(s => s.ErpDetails)
|
||||
.FirstOrDefaultAsync(f => f.Id == entity.Id);
|
||||
if (model == null)
|
||||
return null;
|
||||
@@ -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);
|
||||
|
||||
@@ -351,8 +367,8 @@ namespace WMS.Web.Repositories
|
||||
Qty = s.detail.Qty,
|
||||
Creator = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, s.order.CreatorId),
|
||||
CreateTime = s.order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
SuccessSync = s.order.Type!= InstockType.Purchase?"--":(s.order.SuccessSync == SyncStatus.Success ? "成功" : (s.order.SuccessSync == SyncStatus.SyncIng ? "同步中" : "失败")),
|
||||
Remark=s.order.Remark
|
||||
SuccessSync = s.order.Type != InstockType.Purchase ? "--" : (s.order.SuccessSync == SyncStatus.Success ? "成功" : (s.order.SuccessSync == SyncStatus.SyncIng ? "同步中" : "失败")),
|
||||
Remark = s.order.Remark
|
||||
}).OrderByDescending(x => x.Id).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync();
|
||||
|
||||
return (list, total);
|
||||
|
||||
Reference in New Issue
Block a user