fix 优化查询
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Dlhis.Basic.WorkGrids.Request;
|
||||
using Dlhis.Basic.WorkGrids.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Jip.Api;
|
||||
using Dlhis.Jip.Api.Requests;
|
||||
@@ -17,7 +18,7 @@ public class WorkGridScheduleService : IWorkGridScheduleService
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly IJinkoJipApi _jinkoJipApi;
|
||||
|
||||
public WorkGridScheduleService(IDbContext dbContext ,IJinkoJipApi jinkoJipApi)
|
||||
public WorkGridScheduleService(IDbContext dbContext, IJinkoJipApi jinkoJipApi)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_jinkoJipApi = jinkoJipApi;
|
||||
@@ -53,15 +54,18 @@ public class WorkGridScheduleService : IWorkGridScheduleService
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<WorkGridScheduleResponse>> GetListAsync(Guid workGridCode, DateOnly date)
|
||||
public async Task<List<WorkGridScheduleResponse>> GetListAsync(Guid workGridCode, DateOnly date, WorkGridTimePeriodEnumType? periodType)
|
||||
{
|
||||
return await _dbContext.Queryable<WorkGridScheduleEntity>()
|
||||
.LeftJoin<GainfoEntity>((x, ga) => x.UserCode == ga.Code)
|
||||
.Where(x => x.WorkGridCode == workGridCode && x.Date == date)
|
||||
.Select(x => new WorkGridScheduleResponse
|
||||
.WhereIF(periodType.HasValue, x => x.PeriodType == periodType)
|
||||
.Select((x, ga) => new WorkGridScheduleResponse
|
||||
{
|
||||
Date = x.Date,
|
||||
PeriodType = x.PeriodType,
|
||||
UserCode = x.UserCode
|
||||
UserCode = x.UserCode,
|
||||
UserName = ga.Name
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
@@ -72,7 +76,7 @@ public class WorkGridScheduleService : IWorkGridScheduleService
|
||||
var workGridSchedules = await _dbContext.Queryable<WorkGridScheduleEntity>()
|
||||
.Where(x => x.WorkGridCode == workGridCode && x.Date >= start && x.Date <= end)
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
return workGridSchedules.GroupBy(x => x.Date).Select(x =>
|
||||
{
|
||||
return new WorkGridScheduleSummaryResponse
|
||||
@@ -90,9 +94,9 @@ public class WorkGridScheduleService : IWorkGridScheduleService
|
||||
/// <inheritdoc />
|
||||
public async Task<Pagination<WorkGridScheduleAttendancePageResponse>> GetAttendancePageAsync(WorkGridScheduleAttendancePageRequest request)
|
||||
{
|
||||
return await _dbContext.Queryable<DeviceUploadLogEntity>()
|
||||
return await _dbContext.Queryable<DeviceUploadLogEntity>()
|
||||
.LeftJoin<DeviceEntity>((log, d) => log.DeviceUniqueNo == d.UniqueNo)
|
||||
.Where(log => log.UserUniqueNo == request.UserCode )
|
||||
.Where(log => log.UserUniqueNo == request.UserCode)
|
||||
.WhereIF(request.DateTimePeriod.HasValue(), log => log.RaiseDateTime >= request.DateTimePeriod.Start
|
||||
&& log.RaiseDateTime <= request.DateTimePeriod.End)
|
||||
.OrderBy(log => log.RaiseDateTime)
|
||||
|
||||
Reference in New Issue
Block a user