金蝶物料数据-开始使用
This commit is contained in:
@@ -27,19 +27,25 @@ namespace WMS.Web.Repositories
|
||||
private readonly ILoginRepositories _loginRepositories;
|
||||
private readonly RepositoryDbContext _context;
|
||||
private readonly ISingleDataService _singleDataService;
|
||||
private readonly IErpService _erpService;
|
||||
private readonly IErpBasicDataExtendService _erpBasicDataExtendService;
|
||||
|
||||
|
||||
public InStockRepositories(RepositoryDbContext context,
|
||||
IMapper mapper,
|
||||
IErpService erpService,
|
||||
ILoginRepositories loginRepositories,
|
||||
IServiceProvider serviceProvider,
|
||||
ISingleDataService singleDataService)
|
||||
ISingleDataService singleDataService,
|
||||
IErpBasicDataExtendService erpBasicDataExtendService)
|
||||
{
|
||||
_context = context;
|
||||
_mapper = mapper;
|
||||
_erpService = erpService;
|
||||
_serviceProvider = serviceProvider;
|
||||
_loginRepositories = loginRepositories;
|
||||
_singleDataService = singleDataService;
|
||||
_erpBasicDataExtendService = erpBasicDataExtendService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -49,6 +55,16 @@ namespace WMS.Web.Repositories
|
||||
/// <returns></returns>
|
||||
public async Task<ResultPagedList<InStockQueryResponse>> GetPagedList(InStockQueryRequest dto)
|
||||
{
|
||||
//1.获取物料集合
|
||||
var materials_result = await _erpService.BillQueryForMaterial();
|
||||
if (!materials_result.IsSuccess)
|
||||
return ResultPagedList<InStockQueryResponse>.ReFailure(materials_result);
|
||||
var materials = materials_result.Data.ToList();
|
||||
|
||||
//物料集合;模糊查询后的物料集合
|
||||
if (!string.IsNullOrEmpty(dto.MaterialNumber))
|
||||
materials = materials.Where(w => EF.Functions.Like(w.MaterialNumber, "%" + dto.MaterialNumber + "%")).ToList();
|
||||
|
||||
var query=_context.InStockDetails
|
||||
.GroupJoin(_context.Instock, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
|
||||
.SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
|
||||
@@ -57,10 +73,14 @@ namespace WMS.Web.Repositories
|
||||
if (!string.IsNullOrEmpty(dto.SourceBillNo))
|
||||
query = query.Where(w => EF.Functions.Like(w.detail.SourceBillNo, "%" + dto.SourceBillNo + "%"));
|
||||
|
||||
//if (!string.IsNullOrEmpty(dto.MaterialNumber))
|
||||
// query = query.Where(w => EF.Functions.Like(w.detail.BillNo, "%" + dto.BillNo + "%"));
|
||||
//物料ID在模糊后的物料
|
||||
if (materials != null && materials.Count != 0 && !string.IsNullOrEmpty(dto.MaterialNumber))
|
||||
{
|
||||
var mids = materials.Select(x => x.MaterialId).ToList();
|
||||
query = query.Where(w => mids.Contains(w.detail.MaterialId));
|
||||
}
|
||||
|
||||
if(dto.SupplierId.HasValue)
|
||||
if (dto.SupplierId.HasValue)
|
||||
query = query.Where(w => w.detail.SupplierId == dto.SupplierId.Value);
|
||||
|
||||
if (dto.OrgId.HasValue)
|
||||
@@ -90,10 +110,10 @@ namespace WMS.Web.Repositories
|
||||
SourceBillNo=s.detail.SourceBillNo,
|
||||
Supplier="",
|
||||
Org="",
|
||||
MaterialName="",
|
||||
MaterialNumber="",
|
||||
Specifications="",
|
||||
Stock= _singleDataService.GetSingleData(SingleAction.Stocks, _loginRepositories.CompanyId, s.detail.StockId),
|
||||
MaterialName= _erpBasicDataExtendService.GetMaterialName(materials, s.detail.MaterialId),
|
||||
MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, s.detail.MaterialId),
|
||||
Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.detail.MaterialId),
|
||||
Stock = _singleDataService.GetSingleData(SingleAction.Stocks, _loginRepositories.CompanyId, s.detail.StockId),
|
||||
Qty =s.detail.Qty,
|
||||
Creator = _singleDataService.GetSingleData(SingleAction.Staffs, _loginRepositories.CompanyId, s.order.CreatorId),
|
||||
CreateTime =s.order.CreateTime,
|
||||
|
||||
Reference in New Issue
Block a user