forked from ddrilling/AsbCloudServer
#7987467 fix
This commit is contained in:
parent
9c9d01d24a
commit
102288f9e5
@ -1,7 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System;
|
||||
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
|
@ -67,11 +67,11 @@ namespace AsbCloudDb.Model
|
||||
|
||||
[JsonIgnore]
|
||||
[ForeignKey(nameof(IdWell))]
|
||||
public virtual Well? Well { get; set; } = null!;
|
||||
public virtual Well Well { get; set; } = null!;
|
||||
|
||||
[JsonIgnore]
|
||||
[ForeignKey(nameof(IdWellSectionType))]
|
||||
public virtual WellSectionType? WellSectionType { get; set; } = null!;
|
||||
public virtual WellSectionType WellSectionType { get; set; } = null!;
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -26,29 +26,20 @@ namespace AsbCloudInfrastructure.Repository
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ProcessMapDto>> GetAllAsync(int idWell,
|
||||
DateTime? updateFrom, CancellationToken token = default)
|
||||
DateTime? updateFrom, CancellationToken token)
|
||||
{
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
var updateFromUtc = updateFrom?.ToUtcDateTimeOffset(timezone.Hours);
|
||||
var entities = await GetQuery()
|
||||
.Where(e => e.IdWell == idWell)
|
||||
.Where(e => e.LastUpdate >= updateFromUtc)
|
||||
var entities = await BuildQuery(idWell, updateFrom)
|
||||
.OrderBy(e => e.DepthStart)
|
||||
.ThenBy(e => e.Id)
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var dtos = entities.Select(entity =>
|
||||
{
|
||||
var dto = entity.Adapt<ProcessMapDto>();
|
||||
dto.LastUpdate = entity.LastUpdate.ToRemoteDateTime(timezone.Hours);
|
||||
return dto;
|
||||
});
|
||||
var dtos = entities.Select(Convert);
|
||||
return dtos;
|
||||
}
|
||||
|
||||
public override async Task<int> InsertAsync(ProcessMapDto dto,
|
||||
CancellationToken token = default)
|
||||
CancellationToken token)
|
||||
{
|
||||
dto.LastUpdate = DateTime.UtcNow;
|
||||
var result = await base.InsertAsync(dto, token);
|
||||
@ -56,13 +47,27 @@ namespace AsbCloudInfrastructure.Repository
|
||||
}
|
||||
|
||||
public override async Task<int> UpdateAsync(ProcessMapDto dto,
|
||||
CancellationToken token = default)
|
||||
CancellationToken token)
|
||||
{
|
||||
dto.LastUpdate = DateTime.UtcNow;
|
||||
var result = await base.UpdateAsync(dto, token);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private IQueryable<ProcessMap> BuildQuery(int idWell, DateTime? updateFrom)
|
||||
{
|
||||
var query = GetQuery().Where(e => e.IdWell == idWell);
|
||||
|
||||
if (updateFrom is not null)
|
||||
{
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
var updateFromUtc = updateFrom?.ToUtcDateTimeOffset(timezone.Hours);
|
||||
query.Where(e => e.LastUpdate >= updateFromUtc);
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
protected override ProcessMapDto Convert(ProcessMap entity)
|
||||
{
|
||||
var dto = entity.Adapt<ProcessMapDto>();
|
||||
|
@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// РТК
|
||||
/// </summary>
|
||||
@ -37,7 +38,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
[Route("/api/telemetry/{uid}/drillFlowChart")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(IEnumerable<ProcessMapDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetByTelemetryAsync(string uid, DateTime updateFrom = default, CancellationToken token = default)
|
||||
public async Task<IActionResult> GetByTelemetryAsync(string uid, DateTime updateFrom, CancellationToken token)
|
||||
{
|
||||
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
|
||||
if (idWell is null)
|
||||
@ -88,4 +89,5 @@ namespace AsbCloudWebApi.Controllers
|
||||
return await base.InsertAsync(value, token);
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
}
|
Loading…
Reference in New Issue
Block a user