forked from ddrilling/AsbCloudServer
LimitingParameterDataDto fix. DateTimeOffset -> DateTime
This commit is contained in:
parent
7e5979c48a
commit
8fd3f3c290
@ -21,12 +21,12 @@ namespace AsbCloudApp.Data
|
||||
/// <summary>
|
||||
/// Дата начала ограничения
|
||||
/// </summary>
|
||||
public DateTimeOffset DateStart { get; set; }
|
||||
public DateTime DateStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата окончания ограничения
|
||||
/// </summary>
|
||||
public DateTimeOffset DateEnd { get; set; }
|
||||
public DateTime DateEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Глубина начала ограничения
|
||||
|
@ -20,6 +20,7 @@ namespace AsbCloudApp.Repositories
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<LimitingParameterDataDto>> GetLimitingParametersAsync(LimitingParameterRequest request, WellDto wellDto, CancellationToken token);
|
||||
Task<IEnumerable<LimitingParameterDataDto>> GetLimitingParametersAsync(LimitingParameterRequest request, int idTelemetry, double timezoneHours, CancellationToken token);
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Requests;
|
||||
using AsbCloudDb.Model;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@ -19,41 +20,49 @@ namespace AsbCloudInfrastructure.Repository
|
||||
{
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<LimitingParameterDataDto>> GetLimitingParametersAsync(LimitingParameterRequest request, WellDto wellDto, CancellationToken token)
|
||||
{
|
||||
var query = BuildQuery(request, wellDto);
|
||||
var timezoneOffset = wellDto.Timezone.Hours;
|
||||
var IdTelemetry = wellDto.IdTelemetry!.Value;
|
||||
return await GetLimitingParametersAsync(request, IdTelemetry, timezoneOffset, token);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<LimitingParameterDataDto>> GetLimitingParametersAsync(LimitingParameterRequest request, int idTelemetry, double timezoneHours, CancellationToken token)
|
||||
{
|
||||
var timezoneSpan = TimeSpan.FromHours(timezoneHours);
|
||||
var query = BuildQuery(request, idTelemetry, timezoneHours);
|
||||
|
||||
var data = (await query.ToListAsync(token))
|
||||
.Select(x => new LimitingParameterDataDto
|
||||
{
|
||||
IdWell = wellDto.Id,
|
||||
IdWell = request.IdWell,
|
||||
IdTelemetry = x.IdTelemetry,
|
||||
IdFeedRegulator = x.IdFeedRegulator,
|
||||
DateStart = x.DateStart,
|
||||
DateEnd = x.DateEnd,
|
||||
DateStart = DateTime.SpecifyKind(x.DateStart.UtcDateTime + timezoneSpan, DateTimeKind.Unspecified),
|
||||
DateEnd = DateTime.SpecifyKind(x.DateEnd.UtcDateTime + timezoneSpan, DateTimeKind.Unspecified),
|
||||
DepthStart = x.DepthStart,
|
||||
DepthEnd = x.DepthEnd
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private IQueryable<LimitingParameter> BuildQuery(LimitingParameterRequest request, WellDto wellDto)
|
||||
private IQueryable<LimitingParameter> BuildQuery(LimitingParameterRequest request, int idTelemetry, double timezoneHours)
|
||||
{
|
||||
var query = context.LimitingParameter
|
||||
.OrderBy(x => x.Id)
|
||||
.Where(x => x.IdTelemetry == wellDto.IdTelemetry)
|
||||
.Where(x => x.IdTelemetry == idTelemetry)
|
||||
.AsNoTracking();
|
||||
|
||||
if (request.GtDate.HasValue)
|
||||
{
|
||||
var gtDate = request.GtDate.Value.ToUtcDateTimeOffset(wellDto.Timezone.Hours);
|
||||
var gtDate = request.GtDate.Value.ToUtcDateTimeOffset(timezoneHours);
|
||||
query = query.Where(x => x.DateEnd >= gtDate);
|
||||
}
|
||||
|
||||
if (request.LtDate.HasValue)
|
||||
{
|
||||
var ltDate = request.LtDate.Value.ToUtcDateTimeOffset(wellDto.Timezone.Hours);
|
||||
var ltDate = request.LtDate.Value.ToUtcDateTimeOffset(timezoneHours);
|
||||
query = query.Where(x => x.DateStart <= ltDate);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,6 @@ namespace AsbCloudInfrastructure.Services
|
||||
var data = (await limitingParameterRepository.GetLimitingParametersAsync(request, well, token))
|
||||
.GroupBy(x => x.IdFeedRegulator);
|
||||
|
||||
|
||||
List<LimitingParameterDto> result = new List<LimitingParameterDto>(data.Count());
|
||||
foreach (var item in data)
|
||||
{
|
||||
@ -107,7 +106,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
return (float)result;
|
||||
}
|
||||
|
||||
private DateTimeOffset GetDate(double depth, LimitingParameterDataDto dto)
|
||||
private DateTime GetDate(double depth, LimitingParameterDataDto dto)
|
||||
{
|
||||
var a = depth - dto.DepthStart;
|
||||
var b = dto.DepthEnd - dto.DepthStart;
|
||||
|
Loading…
Reference in New Issue
Block a user