优化接口
This commit is contained in:
@@ -31,13 +31,16 @@ namespace WMS.Web.Api.Controllers
|
||||
private readonly IInStockService _inStockService;
|
||||
private readonly IInStockRepositories _inStockRepositories;
|
||||
private readonly IExportExcelService _exportExcelService;
|
||||
private readonly IRedisConcurrentProcessService _redisConcurrentProcessService;
|
||||
public InStockController(IOptions<QiniuOptions> option,
|
||||
ILoginService loginService,
|
||||
IInStockRepositories inStockRepositories,
|
||||
IInStockService inStockService,
|
||||
IExportExcelService exportExcelService)
|
||||
IExportExcelService exportExcelService,
|
||||
IRedisConcurrentProcessService redisConcurrentProcessService)
|
||||
{
|
||||
_option = option?.Value;
|
||||
this._redisConcurrentProcessService = redisConcurrentProcessService;
|
||||
this._loginService = loginService;
|
||||
this._inStockService = inStockService;
|
||||
this._exportExcelService = exportExcelService;
|
||||
|
||||
@@ -755,16 +755,17 @@ namespace WMS.Web.Repositories
|
||||
}
|
||||
}
|
||||
|
||||
var taskIds = new List<int>();
|
||||
List<int> taskIds = null;
|
||||
if (dto.BoxBillNos != null && dto.BoxBillNos.Count != 0)
|
||||
{
|
||||
taskIds = new List<int>();
|
||||
var tids = await _context.InstockTaskBox.Where(x => dto.BoxBillNos.Contains(x.BoxBillNo)).GroupBy(x => x.TaskId).Select(x => x.Key).ToListAsync();
|
||||
taskIds.AddRange(tids);
|
||||
}
|
||||
if (dto.SerialNumbers != null && dto.SerialNumbers.Count != 0)
|
||||
{
|
||||
//这个也可以查询到:条件是数据集合,实体对象的属性是数据集合的情况下;只是AsEnumerable有点性能不好!仅此而已
|
||||
//var tids_objs = _context.InStockDetails.AsEnumerable().Where(x => dto.SerialNumbers.All(sn => x.SerialNumbers.Contains(sn))).ToList();
|
||||
var tids_objs = _context.InStockDetails.AsEnumerable().Where(x => dto.SerialNumbers.All(sn => x.SerialNumbers.Contains(sn))).ToList();
|
||||
|
||||
string str = $"select * from t_wms_instock_details where ";
|
||||
for (int i = 0; i < dto.SerialNumbers.Count(); i++)
|
||||
@@ -777,8 +778,15 @@ namespace WMS.Web.Repositories
|
||||
var fs = FormattableStringFactory.Create(str);
|
||||
var InStockDetails = _context.Set<InStockDetails>().FromSqlInterpolated(fs).ToList();
|
||||
var tids = InStockDetails.GroupBy(x => x.TaskId).Select(x => x.Key).ToList();
|
||||
|
||||
if (taskIds == null)
|
||||
{
|
||||
taskIds = new List<int>();
|
||||
taskIds.AddRange(tids);
|
||||
}
|
||||
else
|
||||
taskIds = tids.Intersect(taskIds).ToList();
|
||||
}
|
||||
|
||||
var query = _context.InStockTaskDetails
|
||||
.GroupJoin(_context.InStockTask, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
|
||||
@@ -794,7 +802,7 @@ namespace WMS.Web.Repositories
|
||||
query = query.Where(w => materialNumbs.Contains(w.detail.MaterialNumber));
|
||||
}
|
||||
|
||||
if (taskIds.Count != 0)
|
||||
if (taskIds != null)
|
||||
{
|
||||
query = query.Where(w => taskIds.Contains(w.order.Id));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user