Замена типа дат в WellOperationRequestBase с DateTime на DateTimeOffset

This commit is contained in:
Olga Nemt 2024-03-18 10:05:20 +05:00
parent 271b9d363d
commit 9723ee3b9e
3 changed files with 19 additions and 19 deletions

View File

@ -11,12 +11,12 @@ namespace AsbCloudApp.Requests
/// <summary> /// <summary>
/// фильтр по дате начала операции /// фильтр по дате начала операции
/// </summary> /// </summary>
public DateTime? GeDate { get; set; } public DateTimeOffset? GeDate { get; set; }
/// <summary> /// <summary>
/// фильтр по дате окончания операции /// фильтр по дате окончания операции
/// </summary> /// </summary>
public DateTime? LtDate { get; set; } public DateTimeOffset? LeDate { get; set; }
/// <summary> /// <summary>
/// фильтр. Больше или равно глубины скважины на начало операции. /// фильтр. Больше или равно глубины скважины на начало операции.
@ -60,7 +60,7 @@ namespace AsbCloudApp.Requests
GeDepth = request.GeDepth; GeDepth = request.GeDepth;
LeDepth = request.LeDepth; LeDepth = request.LeDepth;
GeDate = request.GeDate; GeDate = request.GeDate;
LtDate = request.LtDate; LeDate = request.LeDate;
OperationCategoryIds = request.OperationCategoryIds; OperationCategoryIds = request.OperationCategoryIds;
OperationType = request.OperationType; OperationType = request.OperationType;

View File

@ -57,7 +57,7 @@ public class WellOperationRepository : IWellOperationRepository
.ToArrayAsync(token); .ToArrayAsync(token);
var dateLastAssosiatedPlanOperation = await GetDateLastAssosiatedPlanOperationAsync(idWell, currentDate, timezone.Hours, token); var dateLastAssosiatedPlanOperation = await GetDateLastAssosiatedPlanOperationAsync(idWell, currentDate, timezone.Hours, token);
var result = new WellOperationPlanDto() var result = new WellOperationPlanDto()
{ {
WellOperationsPlan = dtos.Select(Convert), WellOperationsPlan = dtos.Select(Convert),
@ -199,9 +199,9 @@ public class WellOperationRepository : IWellOperationRepository
{ {
var query = BuildQuery(request) var query = BuildQuery(request)
.AsNoTracking(); .AsNoTracking();
var dtos = await query.ToArrayAsync(token); var dtos = await query.ToArrayAsync(token);
return dtos.Select(Convert); return dtos.Select(Convert);
} }
@ -222,7 +222,7 @@ public class WellOperationRepository : IWellOperationRepository
CancellationToken token) CancellationToken token)
{ {
var query = BuildQuery(request); var query = BuildQuery(request);
var result = new PaginationContainer<WellOperationDto> var result = new PaginationContainer<WellOperationDto>
{ {
Skip = request.Skip ?? 0, Skip = request.Skip ?? 0,
@ -390,7 +390,7 @@ public class WellOperationRepository : IWellOperationRepository
{ {
var timezone = wellService.GetTimezone(request.IdWell); var timezone = wellService.GetTimezone(request.IdWell);
var timeZoneOffset = timezone.Hours; var timeZoneOffset = timezone.Hours;
var query = db.WellOperations var query = db.WellOperations
.Include(s => s.WellSectionType) .Include(s => s.WellSectionType)
.Include(s => s.OperationCategory) .Include(s => s.OperationCategory)
@ -413,14 +413,14 @@ public class WellOperationRepository : IWellOperationRepository
if (request.GeDate.HasValue) if (request.GeDate.HasValue)
{ {
var geDateOffset = request.GeDate.Value.ToUtcDateTimeOffset(timeZoneOffset); //var geDateOffset = request.GeDate.Value.ToUtcDateTimeOffset(timeZoneOffset);
query = query.Where(e => e.DateStart >= geDateOffset); query = query.Where(e => e.DateStart >= request.GeDate);
} }
if (request.LtDate.HasValue) if (request.LeDate.HasValue)
{ {
var ltDateOffset = request.LtDate.Value.ToUtcDateTimeOffset(timeZoneOffset); //var leDateOffset = request.LeDate.Value.ToUtcDateTimeOffset(timeZoneOffset);
query = query.Where(e => e.DateStart < ltDateOffset); query = query.Where(e => e.DateStart <= request.LeDate);
} }
var currentWellOperations = db.WellOperations var currentWellOperations = db.WellOperations
@ -468,7 +468,7 @@ public class WellOperationRepository : IWellOperationRepository
{ {
dtos = dtos.SortBy(request.SortFields); dtos = dtos.SortBy(request.SortFields);
} }
dtos = dtos dtos = dtos
.OrderBy(e => e.DateStart) .OrderBy(e => e.DateStart)
.ThenBy(e => e.DepthEnd) .ThenBy(e => e.DepthEnd)
@ -533,7 +533,7 @@ public class WellOperationRepository : IWellOperationRepository
var timezoneOffset = TimeSpan.FromHours(timezone.Hours); var timezoneOffset = TimeSpan.FromHours(timezone.Hours);
var dtoWithRemoteDateTime = dto.Adapt<WellOperationDto>(); var dtoWithRemoteDateTime = dto.Adapt<WellOperationDto>();
dtoWithRemoteDateTime.DateStart = dto.DateStart.ToOffset(TimeSpan.FromHours(timezoneOffset.Hours)); dtoWithRemoteDateTime.DateStart = dto.DateStart.ToOffset(TimeSpan.FromHours(timezoneOffset.Hours));
dtoWithRemoteDateTime.LastUpdateDate = dto.LastUpdateDate?.ToOffset(TimeSpan.FromHours(timezoneOffset.Hours)); dtoWithRemoteDateTime.LastUpdateDate = dto.LastUpdateDate?.ToOffset(TimeSpan.FromHours(timezoneOffset.Hours));
@ -605,11 +605,11 @@ public class WellOperationRepository : IWellOperationRepository
var geDateUtc = geDate.Value.ToUniversalTime(); var geDateUtc = geDate.Value.ToUniversalTime();
query = query.Where(e => e.DateStart >= geDateUtc); query = query.Where(e => e.DateStart >= geDateUtc);
} }
var groups = await query var groups = await query
.GroupBy(o => new { o.IdWell, o.IdType }) .GroupBy(o => new { o.IdWell, o.IdType })
.Select(g => new{ .Select(g => new{
MaxDate = g.Max(o => o.DateStart), MaxDate = g.Max(o => o.DateStart),
g.Key.IdWell, g.Key.IdWell,
g.Key.IdType, g.Key.IdType,
}) })

View File

@ -114,7 +114,7 @@ public class DailyReportService : IDailyReportService
IdWell = idWell, IdWell = idWell,
OperationType = WellOperation.IdOperationTypeFact, OperationType = WellOperation.IdOperationTypeFact,
GeDate = geDate, GeDate = geDate,
LtDate = ltDate LeDate = ltDate
}; };
var factWellOperations = (await wellOperationRepository.GetAsync(factOperationRequest, cancellationToken)) var factWellOperations = (await wellOperationRepository.GetAsync(factOperationRequest, cancellationToken))
@ -191,7 +191,7 @@ public class DailyReportService : IDailyReportService
IdWell = idWell, IdWell = idWell,
OperationType = WellOperation.IdOperationTypeFact, OperationType = WellOperation.IdOperationTypeFact,
GeDate = geDateFactWellOperation, GeDate = geDateFactWellOperation,
LtDate = ltDateFactWellOperation LeDate = ltDateFactWellOperation
}; };
var factWellOperations = await wellOperationRepository.GetAsync(factWellOperationRequest, cancellationToken); var factWellOperations = await wellOperationRepository.GetAsync(factWellOperationRequest, cancellationToken);