物料搜索
This commit is contained in:
@@ -23,7 +23,7 @@ namespace WMS.Web.Repositories
|
||||
/// <summary>
|
||||
/// 箱库存-仓储
|
||||
/// </summary>
|
||||
public class BoxInventoryRepositories: IAllFielRepositories<BoxInventoryQueryRequest>, IBoxInventoryRepositories
|
||||
public class BoxInventoryRepositories : IAllFielRepositories<BoxInventoryQueryRequest>, IBoxInventoryRepositories
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
@@ -60,7 +60,7 @@ namespace WMS.Web.Repositories
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<(List<BoxInventoryQueryResponse> list, int total)> GetPagedList(BoxInventoryQueryRequest dto, int companyId)
|
||||
public async Task<(List<BoxInventoryQueryResponse> list, int total)> GetPagedList(BoxInventoryQueryRequest dto, int companyId)
|
||||
{
|
||||
//1.获取物料集合和组织集合
|
||||
var materials = new List<ErpMaterialDto>();
|
||||
@@ -68,15 +68,16 @@ namespace WMS.Web.Repositories
|
||||
if (materials_result.IsSuccess)
|
||||
materials = materials_result.Data.ToList();
|
||||
|
||||
List<string> materialNumbs = new List<string>();
|
||||
//物料集合;模糊查询后的物料集合
|
||||
if (!string.IsNullOrEmpty(dto.MaterialNumber))
|
||||
{
|
||||
if (materials.Count != 0)
|
||||
{
|
||||
materials = materials.Where(w => w.MaterialNumber.Contains(dto.MaterialNumber)
|
||||
materialNumbs = materials.Where(w => w.MaterialNumber.Contains(dto.MaterialNumber)
|
||||
|| w.MaterialName.Contains(dto.MaterialNumber)
|
||||
|| w.Specifications.Contains(dto.MaterialNumber)
|
||||
).ToList();
|
||||
).Select(x => x.MaterialNumber).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,16 +90,16 @@ namespace WMS.Web.Repositories
|
||||
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 })
|
||||
.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(adv => 1 == 1 && adv.detail.Qty!=0 );
|
||||
.Where(adv => 1 == 1 && adv.detail.Qty != 0);
|
||||
|
||||
if (!string.IsNullOrEmpty(dto.BoxBillNo))
|
||||
query = query.Where(w => EF.Functions.Like(w.box.BoxBillNo, "%" + dto.BoxBillNo + "%"));
|
||||
|
||||
if (!string.IsNullOrEmpty(dto.StockCode))
|
||||
{
|
||||
var splitStrs= dto.StockCode.Split("_$");
|
||||
var splitStrs = dto.StockCode.Split("_$");
|
||||
query = query.Where(w => w.order.StockCode == splitStrs[0] && w.order.OrgCode == splitStrs[1]);
|
||||
}
|
||||
|
||||
@@ -108,14 +109,8 @@ namespace WMS.Web.Repositories
|
||||
//物料ID在模糊后的物料
|
||||
if (!string.IsNullOrEmpty(dto.MaterialNumber))
|
||||
{
|
||||
if (materials != null && materials.Count != 0)
|
||||
{
|
||||
var mids = materials.Select(x => x.MaterialNumber).ToList();
|
||||
query = query.Where(w => mids.Contains(w.detail.MaterialNumber));
|
||||
}
|
||||
query = query.Where(w => materialNumbs.Contains(w.detail.MaterialNumber));
|
||||
}
|
||||
var tt = _singleDataService.GetSingleData(SingleAction.SubStocksJoinOrgCode, companyId, "wmsCK0213" + "CK001" + "101");
|
||||
_logger.LogInformation("箱库存列表:"+tt+"公司ID:"+companyId);
|
||||
|
||||
int total = await query.CountAsync();
|
||||
var list = await query.Select(s => new BoxInventoryQueryResponse()
|
||||
@@ -126,14 +121,14 @@ namespace WMS.Web.Repositories
|
||||
MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.detail.MaterialNumber),
|
||||
MaterialNumber = s.detail.MaterialNumber,
|
||||
Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.detail.MaterialNumber),
|
||||
Stock = _singleDataService.GetSingleData(SingleAction.StocksJoinOrgCode, companyId, s.order.StockCode+s.order.OrgCode),
|
||||
Stock = _singleDataService.GetSingleData(SingleAction.StocksJoinOrgCode, companyId, s.order.StockCode + s.order.OrgCode),
|
||||
SubStock = _singleDataService.GetSingleData(SingleAction.SubStocksJoinOrgCode, companyId, s.order.SubStockCode + s.order.StockCode + s.order.OrgCode),
|
||||
SerialNumbers =(string.Join(",",s.detail.SerialNumbers)).TrimEnd(','),
|
||||
SerialNumbers = (string.Join(",", s.detail.SerialNumbers)).TrimEnd(','),
|
||||
Org = _erpBasicDataExtendService.GetOrgName(orgs, s.order.OrgCode),
|
||||
Qty = s.detail.Qty,
|
||||
}).OrderByDescending(x => x.Id).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync();
|
||||
|
||||
return (list,total);
|
||||
|
||||
return (list, total);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -150,26 +145,26 @@ namespace WMS.Web.Repositories
|
||||
materials = materials_result.Data.ToList();
|
||||
|
||||
|
||||
var entity =await _context.BoxInventory.Include(x=>x.Details)
|
||||
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();
|
||||
.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 response = _mapper.Map<BoxInventoryResponse>(entity);
|
||||
if (response != null)
|
||||
{
|
||||
response.Stock = _singleDataService.GetSingleData(SingleAction.StocksJoinOrgCode, _loginRepositories.CompanyId, response.StockCode + response.OrgCode);
|
||||
response.SubStock = _singleDataService.GetSingleData(SingleAction.SubStocksJoinOrgCode, _loginRepositories.CompanyId, response.SubStockCode+ response.StockCode + response.OrgCode);
|
||||
response.SubStock = _singleDataService.GetSingleData(SingleAction.SubStocksJoinOrgCode, _loginRepositories.CompanyId, response.SubStockCode + response.StockCode + response.OrgCode);
|
||||
response.Details = _mapper.Map<List<BoxInventoryDetailsResponse>>(entity.Details);
|
||||
response.Details.ForEach(x =>
|
||||
{
|
||||
x.MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, x.MaterialNumber);
|
||||
x.MaterialNumber = x.MaterialNumber;
|
||||
x.MaterialNumber = x.MaterialNumber;
|
||||
x.Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, x.MaterialNumber);
|
||||
});
|
||||
response.TotalQty = response.Details.Sum(x=>x.Qty);
|
||||
response.TotalQty = response.Details.Sum(x => x.Qty);
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -196,7 +191,7 @@ namespace WMS.Web.Repositories
|
||||
/// <returns></returns>
|
||||
public async Task<BoxInventory> Get(int id)
|
||||
{
|
||||
return await _context.BoxInventory.Include(x => x.Details).Where(x => x.BoxId== id).FirstOrDefaultAsync();
|
||||
return await _context.BoxInventory.Include(x => x.Details).Where(x => x.BoxId == id).FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -245,7 +240,7 @@ namespace WMS.Web.Repositories
|
||||
List<int> list = entitys.Select(s => s.Id).ToList();
|
||||
var res = await _context.BoxInventory.Include(x => x.Details).Where(f => list.Contains(f.Id)).ToListAsync();
|
||||
_mapper.Map(entitys, res);
|
||||
var tt= await _context.SaveChangesAsync();
|
||||
var tt = await _context.SaveChangesAsync();
|
||||
if (_transaction != null)
|
||||
_transaction.Commit();
|
||||
}
|
||||
@@ -296,7 +291,7 @@ namespace WMS.Web.Repositories
|
||||
/// <returns></returns>
|
||||
public async Task<(object obj, int total)> GetListField(BoxInventoryQueryRequest dto, int companyId)
|
||||
{
|
||||
return await GetPagedList(dto,companyId);
|
||||
return await GetPagedList(dto, companyId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user