fix 测试性能
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Linq.Expressions;
|
||||
using System.Diagnostics;
|
||||
using System.Linq.Expressions;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
@@ -15,15 +16,19 @@ namespace Dlhis.ScheduledTask.DeviceUploadLog.Services.Implements;
|
||||
public class DeviceUploadLogService : IDeviceUploadLogService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ILogger<DeviceUploadLogService> _logger;
|
||||
|
||||
public DeviceUploadLogService(IDbContext dbContext)
|
||||
public DeviceUploadLogService(IDbContext dbContext, ILogger<DeviceUploadLogService> logger)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<Pagination<DeviceUploadLogResponse>> GetPageAsync(DeviceUploadLogPageRequest request)
|
||||
{
|
||||
var page = await _dbContext.Queryable<DeviceUploadLogEntity>()
|
||||
var sw = Stopwatch.StartNew();
|
||||
|
||||
var query = _dbContext.Queryable<DeviceUploadLogEntity>()
|
||||
.LeftJoin<DeviceEntity>((deviceUp, device) => deviceUp.DeviceUniqueNo == device.UniqueNo)
|
||||
.LeftJoin<GainfoEntity>((deviceUp, device, ga) => deviceUp.UserUniqueNo == ga.Code)
|
||||
.WhereIF(request.Type.HasValue, (deviceUp, device) => device.Type == request.Type)
|
||||
@@ -47,9 +52,12 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
||||
UserCode = ga.Code,
|
||||
UserName = ga.Name,
|
||||
DeployPlace = device.DeployPlace
|
||||
})
|
||||
.ToPageListAsync(request);
|
||||
});
|
||||
//.ToPageListAsync(request);
|
||||
|
||||
_logger.LogInformation("执行sql:{sql}", query.ToSqlString());
|
||||
var page = await query.ToPageListAsync(request);
|
||||
_logger.LogInformation("执行时间:{ms}", sw.ElapsedMilliseconds);
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user