接口优化
This commit is contained in:
@@ -101,39 +101,23 @@ namespace WMS.Web.Repositories
|
||||
/// </summary>
|
||||
/// <param name="boxBillNo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<BoxInventoryDetailsResponse>> GetListDetailsBy(string boxBillNo)
|
||||
public async Task<BoxInventoryResponse> GetInfoBy(string boxBillNo)
|
||||
{
|
||||
//1.获取物料集合和组织集合
|
||||
var materials_result = await _erpService.BillQueryForMaterial();
|
||||
if (!materials_result.IsSuccess)
|
||||
return new List<BoxInventoryDetailsResponse>();
|
||||
var materials = materials_result.Data.ToList();
|
||||
////1.获取物料集合和组织集合
|
||||
//var materials_result = await _erpService.BillQueryForMaterial();
|
||||
//if (!materials_result.IsSuccess)
|
||||
// return new List<BoxInventoryDetailsResponse>();
|
||||
//var materials = materials_result.Data.ToList();
|
||||
|
||||
var query=_context.BoxInventoryDetails
|
||||
.GroupJoin(_context.BoxInventory, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
|
||||
.SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
|
||||
.GroupJoin(_context.Box, p => p.order.BoxId, t => t.Id, (p, ts) => new { p.detail, p.order, ts })
|
||||
.SelectMany(x => x.ts.DefaultIfEmpty(), (p, box) => new { p.detail, p.order, box })
|
||||
.Where(x => 1 == 1 && x.box.BoxBillNo==boxBillNo);
|
||||
var entity=await _context.BoxInventory.Include(x=>x.Details)
|
||||
.GroupJoin(_context.Box, t => t.BoxId, box => box.Id, (boxinvent, ts) => new { boxinvent, ts })
|
||||
.SelectMany(x => x.ts.DefaultIfEmpty(), (p, box) => new { p.boxinvent, box })
|
||||
.Where(x => 1 == 1 && x.box.BoxBillNo==boxBillNo).Select(x=>x.boxinvent).FirstOrDefaultAsync();
|
||||
|
||||
var list = await query.Select(x => new BoxInventoryDetailsResponse()
|
||||
{
|
||||
MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, x.detail.MaterialId),
|
||||
MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, x.detail.MaterialId),
|
||||
Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, x.detail.MaterialId),
|
||||
StockCode =x.order.StockCode,
|
||||
Stock = _singleDataService.GetSingleData(SingleAction.Stocks, _loginRepositories.CompanyId, x.order.StockCode),
|
||||
SubStockId=x.order.SubStockId,
|
||||
SubStock= _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, x.order.SubStockId),
|
||||
DetailsId =x.detail.Id,
|
||||
BoxId=x.box.Id,
|
||||
BoxInventoryId=x.order.Id,
|
||||
MaterialId=x.detail.MaterialId,
|
||||
Qty=x.detail.Qty,
|
||||
SerialNumbers=x.detail.SerialNumbers
|
||||
}).ToListAsync();
|
||||
|
||||
return list;
|
||||
var response = _mapper.Map<BoxInventoryResponse>(entity);
|
||||
response.Details = _mapper.Map<List<BoxInventoryDetailsResponse>>(entity.Details);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user