列表物料填充

This commit is contained in:
18942506660
2023-11-08 11:26:38 +08:00
parent 3be6fcde9a
commit bb70df7871
3 changed files with 51 additions and 16 deletions

View File

@@ -26,16 +26,18 @@ namespace WMS.Web.Repositories
private readonly RepositoryDbContext _context;
private readonly ISingleDataService _singleDataService;
private readonly ILoginRepositories _loginRepositories;
private readonly IErpService _erpService;
public OutStockTaskRepositories(RepositoryDbContext context, IMapper mapper, IServiceProvider serviceProvider,
ISingleDataService singleDataService, ILoginRepositories loginRepositories)
ISingleDataService singleDataService, ILoginRepositories loginRepositories, IErpService erpService)
{
_context = context;
_mapper = mapper;
_serviceProvider = serviceProvider;
_singleDataService = singleDataService;
_loginRepositories = loginRepositories;
_erpService = erpService;
}
/// <summary>
/// 新增
@@ -212,6 +214,16 @@ namespace WMS.Web.Repositories
/// <returns></returns>
public async Task<(List<OutStockTaskQueryInfoResponse> list, int total)> GetListAsync(OutStockTaskQueryRequest dto)
{
//1.获取物料集合
var materials_result = await _erpService.BillQueryForMaterial();
if (!materials_result.IsSuccess)
return (new List<OutStockTaskQueryInfoResponse>(), 0);
var materials = materials_result.Data.ToList();
List<int> mIds = new List<int>();
//物料集合;模糊查询后的物料集合
if (!string.IsNullOrEmpty(dto.MaterialNumber))
mIds = materials.Where(w => EF.Functions.Like(w.MaterialNumber, "%" + dto.MaterialNumber + "%")).Select(s=>s.MaterialId).ToList();
var query = _context.OutStockTaskDetails
.GroupJoin(_context.OutStockTask, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
.SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
@@ -219,7 +231,8 @@ namespace WMS.Web.Repositories
.Where(adv => 1 == 1);
//if (!string.IsNullOrEmpty(dto.ReceiptCustomer))
//if (!string.IsNullOrEmpty(dto.MaterialNumber))
if (mIds.Count()!=0)
query = query.Where(w => mIds.Contains(w.detail.MaterialId));
if (dto.Ids.Count() > 0)
query = query.Where(w => dto.Ids.Contains(w.detail.Id));
if (!string.IsNullOrEmpty(dto.SourceBillNo))
@@ -254,10 +267,10 @@ namespace WMS.Web.Repositories
SaleBillNo = s.detail.SaleBillNo,
DeliveryOrg = "",
ReceiptCustomer = "",
MaterialName = "",
MaterialNumber = "",
Specifications = "",
Unit="",
MaterialName = materials.FirstOrDefault(f => f.MaterialId == s.detail.MaterialId).MaterialName ?? "",
MaterialNumber = materials.FirstOrDefault(f => f.MaterialId == s.detail.MaterialId).MaterialNumber ?? "",
Specifications = materials.FirstOrDefault(f => f.MaterialId == s.detail.MaterialId).Specifications ?? "",
Unit= materials.FirstOrDefault(f => f.MaterialId == s.detail.MaterialId).BaseUnitName ?? "",
#endregion
}).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync();