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