效率跟踪

optimize
wanghaomei 1 year ago
parent 6fd0c1630f
commit 7bd7329608

@ -205,6 +205,12 @@ namespace Myshipping.Application
[HttpPost("/BookingOrder/PageData")]
public async Task<dynamic> PageData(BookingOrderInput input)
{
var traceTime = false;
var ticks = DateTime.Now;
if (traceTime)
{
_logger.LogInformation($"PageData Stage 0 ");
}
List<long> userlist = await _right.GetDataScopeList(MenuConst.MenuBookingOrder);
List<long?> pidlist = new List<long?>();
@ -216,6 +222,13 @@ namespace Myshipping.Application
var etoday = DateTime.Now.AddDays(15);
//List<long> userlist = await DataFilterExtensions.GetDataScopeIdList();
if (traceTime)
{
var et = DateTime.Now - ticks;
ticks = DateTime.Now;
_logger.LogInformation($"PageData Stage 1 {et.TotalMilliseconds}");
}
//按部门查询
List<string> saleUserList = null;
List<string> opUserList = null;
@ -231,6 +244,13 @@ namespace Myshipping.Application
opUserList = tmpList.Select(x => x.ToString()).ToList();
}
if (traceTime)
{
var et = DateTime.Now - ticks;
ticks = DateTime.Now;
_logger.LogInformation($"PageData Stage 2 {et.TotalMilliseconds}");
}
#region
var query = _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID)
.WhereIF(!input.ISDel, x => x.IsDeleted == false)
@ -402,7 +422,23 @@ namespace Myshipping.Application
#endregion
var entities = await query.ToPagedListAsync(input.PageNo, input.PageSize);
if (traceTime)
{
var et = DateTime.Now - ticks;
ticks = DateTime.Now;
_logger.LogInformation($"PageData Stage 3 {et.TotalMilliseconds}");
}
var list = entities.Adapt<SqlSugarPagedList<PageBookingOrder>>();
if (traceTime)
{
var et = DateTime.Now - ticks;
ticks = DateTime.Now;
_logger.LogInformation($"PageData Stage 4 {et.TotalMilliseconds}");
}
var bookingidlist = list.Items.Select(x => x.Id).ToList();
var itgoodsStatus = _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(),
(goods, config) => config.Id == goods.ConfigId && bookingidlist.Contains((long)goods.bookingId)).
@ -419,7 +455,7 @@ namespace Myshipping.Application
CreatedUserId = config.CreatedUserId,
Sort = config.Sort
}).ToList();
var configID = itgoodsStatus.Select(x => x.ConfigId).ToList();
var configID = itgoodsStatus.Select(x => x.ConfigId).Distinct().ToList();
var itconfigs = _goodsStatusConfig.AsQueryable().Where(x => configID.Contains(x.Id)).Select(config => new
{
@ -434,12 +470,28 @@ namespace Myshipping.Application
Sort = config.Sort
}).ToList();
if (traceTime)
{
var et = DateTime.Now - ticks;
ticks = DateTime.Now;
_logger.LogInformation($"PageData Stage 5 {et.TotalMilliseconds}");
}
var statusloglist = _repStatuslog.AsQueryable().Filter(null, true).Where(x => bookingidlist.Contains((long)x.BookingId) && (x.Status == "提箱" || x.Status == "返场") && x.IsDeleted == false).ToList();
var statuslogId = statusloglist.Select(x => x.Id).ToList();
var statuslogdetaillist = _statuslogdetail.AsQueryable().Where(x => statuslogId.Contains(x.PId)).ToList();
var BookingStatusList = _repBookingStatus.AsQueryable().Filter(null, true).Where(x => bookingidlist.Contains((long)x.BookingId)).ToList();
var bookingremarkList = _bookingremark.AsQueryable().Filter(null, true).Where(x => bookingidlist.Contains(x.PId)).ToList();
if (traceTime)
{
var et = DateTime.Now - ticks;
ticks = DateTime.Now;
_logger.LogInformation($"PageData Stage 6 {et.TotalMilliseconds}");
}
foreach (var item in list.Items)
{
var sta = BookingStatusList.Where(x => x.BookingId == item.Id).ToList();
@ -586,6 +638,14 @@ namespace Myshipping.Application
item.statuslogs1 = CNTRNODtolist;
}
if (traceTime)
{
var et = DateTime.Now - ticks;
ticks = DateTime.Now;
_logger.LogInformation($"PageData Stage 7 {et.TotalMilliseconds}");
}
return list;
}

Loading…
Cancel
Save