forked from ddrilling/AsbCloudServer
Merge branch 'dev' into well_statistic
This commit is contained in:
commit
9ad290550c
30
AsbCloudApp/Data/GTR/WitsItemRecordDto.cs
Normal file
30
AsbCloudApp/Data/GTR/WitsItemRecordDto.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Data.GTR
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Запись WITS
|
||||||
|
/// </summary>
|
||||||
|
public class WitsItemRecordDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Record Id
|
||||||
|
/// </summary>
|
||||||
|
public int IdRecord { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Item Id
|
||||||
|
/// </summary>
|
||||||
|
public int IdItem { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Дата создания записи
|
||||||
|
/// </summary>
|
||||||
|
public DateTime Date { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Значение
|
||||||
|
/// </summary>
|
||||||
|
public JsonValue Value { get; set; } = default!;
|
||||||
|
}
|
||||||
|
}
|
@ -23,5 +23,5 @@ namespace AsbCloudApp.Data
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<WellFinalDocumentDto> WellFinalDocuments { get; set; } = Enumerable.Empty<WellFinalDocumentDto>();
|
public IEnumerable<WellFinalDocumentDto> WellFinalDocuments { get; set; } = Enumerable.Empty<WellFinalDocumentDto>();
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -58,4 +58,3 @@ public class WellGroupOpertionDto
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<WellGroupOpertionDto>? Items { get; set; }
|
public IEnumerable<WellGroupOpertionDto>? Items { get; set; }
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
@ -22,5 +22,5 @@ namespace AsbCloudApp.Data
|
|||||||
public DateTime? DateLastAssosiatedPlanOperation { get; set; }
|
public DateTime? DateLastAssosiatedPlanOperation { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,8 @@ using System.Collections.Generic;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Repositories
|
namespace AsbCloudApp.Repositories
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// данные ГТИ
|
/// данные ГТИ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -34,6 +32,14 @@ namespace AsbCloudApp.Repositories
|
|||||||
Task<IEnumerable<WitsRecordDto>> GetAsync(int idWell,
|
Task<IEnumerable<WitsRecordDto>> GetAsync(int idWell,
|
||||||
DateTime? dateBegin, double intervalSec = 600d,
|
DateTime? dateBegin, double intervalSec = 600d,
|
||||||
int approxPointsCount = 1024, CancellationToken token = default);
|
int approxPointsCount = 1024, CancellationToken token = default);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// получение последних данных ГТИ по record id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell"></param>
|
||||||
|
/// <param name="idRecord"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<WitsItemRecordDto>> GetLastDataByRecordIdAsync(int idWell, int idRecord, CancellationToken token = default);
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ using AsbCloudApp.Repositories;
|
|||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudDb.Model.GTR;
|
using AsbCloudDb.Model.GTR;
|
||||||
using Mapster;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -13,7 +12,6 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudInfrastructure.Repository
|
namespace AsbCloudInfrastructure.Repository
|
||||||
{
|
{
|
||||||
|
|
||||||
public class GtrWitsRepository : IGtrRepository
|
public class GtrWitsRepository : IGtrRepository
|
||||||
{
|
{
|
||||||
private readonly IAsbCloudDbContext db;
|
private readonly IAsbCloudDbContext db;
|
||||||
@ -39,9 +37,18 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
DateTimeOffset? dateBeginUtc = dateBegin?.ToUtcDateTimeOffset(timezone.Hours);
|
DateTimeOffset? dateBeginUtc = dateBegin?.ToUtcDateTimeOffset(timezone.Hours);
|
||||||
var dateEnd = dateBeginUtc?.AddSeconds(intervalSec);
|
var dateEnd = dateBeginUtc?.AddSeconds(intervalSec);
|
||||||
|
|
||||||
var recordAllInt = await GetItemsOrDefaultAsync<WitsItemInt, int>(telemetry.Id, dateBeginUtc, dateEnd, approxPointsCount, timezone.Hours, token);
|
var witsRequest = new WitsRequest()
|
||||||
var recordAllFloat = await GetItemsOrDefaultAsync<WitsItemFloat, float>(telemetry.Id, dateBeginUtc, dateEnd, approxPointsCount,timezone.Hours, token);
|
{
|
||||||
var recordAllString = await GetItemsOrDefaultAsync<WitsItemString, string>(telemetry.Id, dateBeginUtc, dateEnd, approxPointsCount, timezone.Hours, token);
|
IdTelemetry = telemetry.Id,
|
||||||
|
DateBeginUtc = dateBeginUtc,
|
||||||
|
DateEnd = dateEnd,
|
||||||
|
ApproxPointsCount = approxPointsCount,
|
||||||
|
TimezoneHours = timezone.Hours
|
||||||
|
};
|
||||||
|
|
||||||
|
var recordAllInt = await GetItemsOrDefaultAsync<WitsItemInt, int>(witsRequest, token);
|
||||||
|
var recordAllFloat = await GetItemsOrDefaultAsync<WitsItemFloat, float>(witsRequest, token);
|
||||||
|
var recordAllString = await GetItemsOrDefaultAsync<WitsItemString, string>(witsRequest, token);
|
||||||
|
|
||||||
var dtos = (recordAllFloat.Union(recordAllInt)).Union(recordAllString)
|
var dtos = (recordAllFloat.Union(recordAllInt)).Union(recordAllString)
|
||||||
.GroupBy(g => new
|
.GroupBy(g => new
|
||||||
@ -53,43 +60,88 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
{
|
{
|
||||||
Id = g.Key.IdRecord,
|
Id = g.Key.IdRecord,
|
||||||
Date = g.Key.Date,
|
Date = g.Key.Date,
|
||||||
Items = g.Select(r => new {
|
Items = g.Select(r => new
|
||||||
|
{
|
||||||
Key = r.IdItem,
|
Key = r.IdItem,
|
||||||
Value = r.Item
|
r.Value
|
||||||
}).ToDictionary(x => x.Key, x => x.Value)
|
}).ToDictionary(x => x.Key, x => x.Value)
|
||||||
});
|
});
|
||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<IEnumerable<ItemRecord>> GetItemsOrDefaultAsync<TEntity, TValue>(
|
public async Task<IEnumerable<WitsItemRecordDto>> GetLastDataByRecordIdAsync(int idWell, int idRecord, CancellationToken token = default)
|
||||||
int idTelemetry,
|
{
|
||||||
DateTimeOffset? dateBegin,
|
var telemetry = telemetryService.GetOrDefaultTelemetryByIdWell(idWell);
|
||||||
DateTimeOffset? dateEnd,
|
if (telemetry is null)
|
||||||
int approxPointsCount,
|
return Enumerable.Empty<WitsItemRecordDto>();
|
||||||
double timezoneHours,
|
|
||||||
|
var timezone = telemetryService.GetTimezone(telemetry.Id);
|
||||||
|
|
||||||
|
var witsRequest = new WitsRequest()
|
||||||
|
{
|
||||||
|
IdTelemetry = telemetry.Id,
|
||||||
|
TimezoneHours = timezone.Hours,
|
||||||
|
IdRecord = idRecord,
|
||||||
|
};
|
||||||
|
|
||||||
|
var recordAllInt = await GetGroupedItemsOrDefaultAsync<WitsItemInt, int>(witsRequest, token);
|
||||||
|
var recordAllFloat = await GetGroupedItemsOrDefaultAsync<WitsItemFloat, float>(witsRequest, token);
|
||||||
|
var recordAllString = await GetGroupedItemsOrDefaultAsync<WitsItemString, string>(witsRequest, token);
|
||||||
|
|
||||||
|
var dtos = recordAllFloat.Union(recordAllInt).Union(recordAllString);
|
||||||
|
return dtos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<IEnumerable<WitsItemRecordDto>> GetGroupedItemsOrDefaultAsync<TEntity, TValue>(WitsRequest request, CancellationToken token)
|
||||||
|
where TEntity : WitsItemBase<TValue>
|
||||||
|
where TValue : notnull
|
||||||
|
{
|
||||||
|
var query = BuildQuery<TEntity, TValue>(request);
|
||||||
|
var groupedQuery = query.GroupBy(g => new
|
||||||
|
{
|
||||||
|
g.IdRecord,
|
||||||
|
g.IdTelemetry,
|
||||||
|
g.IdItem
|
||||||
|
})
|
||||||
|
.Select(g => new
|
||||||
|
{
|
||||||
|
g.Key.IdRecord,
|
||||||
|
g.Key.IdItem,
|
||||||
|
Data = g.OrderByDescending(i => i.DateTime)
|
||||||
|
.FirstOrDefault()
|
||||||
|
});
|
||||||
|
|
||||||
|
var groupedEntities = await groupedQuery
|
||||||
|
.ToArrayAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
var dtos = groupedEntities
|
||||||
|
.Select(e => new WitsItemRecordDto()
|
||||||
|
{
|
||||||
|
IdRecord = e.IdRecord,
|
||||||
|
IdItem = e.IdItem,
|
||||||
|
Date = e.Data!.DateTime.ToRemoteDateTime(request.TimezoneHours),
|
||||||
|
Value = new JsonValue(e.Data!.Value)
|
||||||
|
});
|
||||||
|
|
||||||
|
return dtos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<IEnumerable<WitsItemRecordDto>> GetItemsOrDefaultAsync<TEntity, TValue>(
|
||||||
|
WitsRequest request,
|
||||||
CancellationToken token)
|
CancellationToken token)
|
||||||
where TEntity : WitsItemBase<TValue>
|
where TEntity : WitsItemBase<TValue>
|
||||||
where TValue : notnull
|
where TValue : notnull
|
||||||
{
|
{
|
||||||
var query = db.Set<TEntity>()
|
var query = BuildQuery<TEntity, TValue>(request);
|
||||||
.Where(i => i.IdTelemetry == idTelemetry);
|
|
||||||
|
|
||||||
if (dateBegin is not null)
|
|
||||||
query = query
|
|
||||||
.Where(d => d.DateTime >= dateBegin);
|
|
||||||
|
|
||||||
if (dateEnd is not null)
|
|
||||||
query = query
|
|
||||||
.Where(d => d.DateTime <= dateEnd);
|
|
||||||
|
|
||||||
var fullDataCount = await query.CountAsync(token);
|
var fullDataCount = await query.CountAsync(token);
|
||||||
|
|
||||||
if (fullDataCount == 0)
|
if (fullDataCount == 0)
|
||||||
return Enumerable.Empty<ItemRecord>();
|
return Enumerable.Empty<WitsItemRecordDto>();
|
||||||
|
|
||||||
if (fullDataCount > 1.75 * approxPointsCount)
|
if (request.ApproxPointsCount is not null && fullDataCount > 1.75 * request.ApproxPointsCount)
|
||||||
{
|
{
|
||||||
var m = (int)Math.Round(1d * fullDataCount / approxPointsCount);
|
var m = (int)Math.Round(1d * fullDataCount / request.ApproxPointsCount!.Value);
|
||||||
if (m > 1)
|
if (m > 1)
|
||||||
query = query.Where((d) => (((d.DateTime.DayOfYear * 24 + d.DateTime.Hour) * 60 + d.DateTime.Minute) * 60 + d.DateTime.Second) % m == 0);
|
query = query.Where((d) => (((d.DateTime.DayOfYear * 24 + d.DateTime.Hour) * 60 + d.DateTime.Minute) * 60 + d.DateTime.Second) % m == 0);
|
||||||
}
|
}
|
||||||
@ -100,17 +152,37 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
.ToListAsync(token)
|
.ToListAsync(token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
var items = entities.Select(e => new ItemRecord
|
var items = entities.Select(e => new WitsItemRecordDto
|
||||||
{
|
{
|
||||||
IdRecord = e.IdRecord,
|
IdRecord = e.IdRecord,
|
||||||
IdTelemetry = e.IdTelemetry,
|
Date = e.DateTime.ToRemoteDateTime(request.TimezoneHours),
|
||||||
Date = e.DateTime.ToRemoteDateTime(timezoneHours),
|
|
||||||
IdItem = e.IdItem,
|
IdItem = e.IdItem,
|
||||||
Item = new JsonValue(e.Value)
|
Value = new JsonValue(e.Value)
|
||||||
});
|
});
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IQueryable<TEntity> BuildQuery<TEntity, TValue>(WitsRequest request)
|
||||||
|
where TEntity : WitsItemBase<TValue>
|
||||||
|
where TValue : notnull
|
||||||
|
{
|
||||||
|
var query = db.Set<TEntity>().Where(i => i.IdTelemetry == request.IdTelemetry);
|
||||||
|
|
||||||
|
if (request.IdRecord is not null)
|
||||||
|
query = query
|
||||||
|
.Where(d => d.IdRecord == request.IdRecord);
|
||||||
|
|
||||||
|
if (request.DateBeginUtc is not null)
|
||||||
|
query = query
|
||||||
|
.Where(d => d.DateTime >= request.DateBeginUtc);
|
||||||
|
|
||||||
|
if (request.DateEnd is not null)
|
||||||
|
query = query
|
||||||
|
.Where(d => d.DateTime <= request.DateEnd);
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task SaveDataAsync(int idTelemetry, WitsRecordDto dto, CancellationToken token)
|
public async Task SaveDataAsync(int idTelemetry, WitsRecordDto dto, CancellationToken token)
|
||||||
{
|
{
|
||||||
var timezoneHours = telemetryService.GetTimezone(idTelemetry).Hours;
|
var timezoneHours = telemetryService.GetTimezone(idTelemetry).Hours;
|
||||||
@ -139,7 +211,8 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
private static TEntity MakeEntity<TEntity, TValue>(int idRecord, int idItem, int idTelemetry, DateTimeOffset dateTime, TValue value)
|
private static TEntity MakeEntity<TEntity, TValue>(int idRecord, int idItem, int idTelemetry, DateTimeOffset dateTime, TValue value)
|
||||||
where TEntity : WitsItemBase<TValue>, new()
|
where TEntity : WitsItemBase<TValue>, new()
|
||||||
where TValue : notnull
|
where TValue : notnull
|
||||||
=> new TEntity() {
|
=> new TEntity()
|
||||||
|
{
|
||||||
IdRecord = idRecord,
|
IdRecord = idRecord,
|
||||||
IdItem = idItem,
|
IdItem = idItem,
|
||||||
IdTelemetry = idTelemetry,
|
IdTelemetry = idTelemetry,
|
||||||
@ -147,14 +220,14 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
Value = value,
|
Value = value,
|
||||||
};
|
};
|
||||||
|
|
||||||
internal class ItemRecord
|
private class WitsRequest
|
||||||
{
|
{
|
||||||
public int IdRecord { get; set; }
|
|
||||||
public int IdTelemetry { get; set; }
|
public int IdTelemetry { get; set; }
|
||||||
public DateTime Date { get; set; }
|
public DateTimeOffset? DateBeginUtc { get; set; }
|
||||||
public int IdItem { get; set; }
|
public DateTimeOffset? DateEnd { get; set; }
|
||||||
public JsonValue Item { get; set; } = default!;
|
public int? ApproxPointsCount { get; set; }
|
||||||
|
public double TimezoneHours { get; set; }
|
||||||
|
public int? IdRecord { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ using System.Threading.Tasks;
|
|||||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// CRUD контроллер для админки.
|
/// CRUD контроллер для админки.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -140,5 +140,5 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
|||||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// CRUD контроллер dto связных со скважиной для админки.
|
/// CRUD контроллер dto связных со скважиной для админки.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -161,5 +161,5 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Суточный рапорт
|
/// Суточный рапорт
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -194,5 +194,5 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ using AsbCloudApp.Repositories;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Хранение файлов
|
/// Хранение файлов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -244,5 +244,5 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Статистика по операциям (заведенным вручную) на скважине
|
/// Статистика по операциям (заведенным вручную) на скважине
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -166,5 +166,5 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
idWell, token).ConfigureAwait(false);
|
idWell, token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Плановая траектория (загрузка и хранение)
|
/// Плановая траектория (загрузка и хранение)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -249,5 +249,5 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
idWell, token).ConfigureAwait(false);
|
idWell, token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// РТК
|
/// РТК
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -152,5 +152,5 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return await base.UpdateAsync(value, token);
|
return await base.UpdateAsync(value, token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Мониторинг запросов, ошибок, пользователей
|
/// Мониторинг запросов, ошибок, пользователей
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -88,5 +88,5 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers.SAUB
|
namespace AsbCloudWebApi.Controllers.SAUB
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class GtrWitsController : ControllerBase
|
public class GtrWitsController : ControllerBase
|
||||||
@ -68,6 +68,33 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
|||||||
return Ok(content);
|
return Ok(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// получение последних данных ГТИ по ключу record
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell">id скважины</param>
|
||||||
|
/// <param name="idRecord">id record</param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("{idWell}/{idRecord}")]
|
||||||
|
[Permission]
|
||||||
|
public async Task<ActionResult<IEnumerable<WitsItemRecordDto>>> GetLastDataByRecordIdAsync(int idWell, int idRecord, CancellationToken token = default)
|
||||||
|
{
|
||||||
|
int? idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
|
if (idCompany is null)
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
|
bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
|
idWell, token).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (!isCompanyOwnsWell)
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
|
var content = await gtrRepository.GetLastDataByRecordIdAsync(idWell, idRecord, token).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return Ok(content);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Метод для получения WITS записи от панели оператора.
|
/// Метод для получения WITS записи от панели оператора.
|
||||||
/// Сохраняет в БД.
|
/// Сохраняет в БД.
|
||||||
@ -91,5 +118,5 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
|||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ using AsbCloudApp.Repositories;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers.SAUB
|
namespace AsbCloudWebApi.Controllers.SAUB
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Наработка талевого каната
|
/// Наработка талевого каната
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -112,5 +112,5 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Расписание бурильщиков
|
/// Расписание бурильщиков
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Композитная скважина
|
/// Композитная скважина
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -90,5 +90,5 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
idWell, token).ConfigureAwait(false);
|
idWell, token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ using AsbCloudApp.Repositories;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дело скважины
|
/// Дело скважины
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -175,5 +175,5 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
idWell, token).ConfigureAwait(false);
|
idWell, token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Буровые операции (вводимые вручную)
|
/// Буровые операции (вводимые вручную)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -393,5 +393,5 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
idWell, token).ConfigureAwait(false);
|
idWell, token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Converters
|
namespace AsbCloudWebApi.Converters
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
public class DateOnlyJsonConverter : JsonConverter<DateOnly>
|
public class DateOnlyJsonConverter : JsonConverter<DateOnly>
|
||||||
{
|
{
|
||||||
public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||||
@ -18,5 +18,5 @@ namespace AsbCloudWebApi.Converters
|
|||||||
writer.WriteStringValue(isoDate);
|
writer.WriteStringValue(isoDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Converters
|
namespace AsbCloudWebApi.Converters
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
public class DateOnlyTypeConverter : TypeConverter
|
public class DateOnlyTypeConverter : TypeConverter
|
||||||
{
|
{
|
||||||
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
|
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
|
||||||
@ -44,5 +44,5 @@ namespace AsbCloudWebApi.Converters
|
|||||||
return base.ConvertTo(context, culture, value, destinationType);
|
return base.ConvertTo(context, culture, value, destinationType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ using System.Globalization;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Converters
|
namespace AsbCloudWebApi.Converters
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
public class TimeOnlyTypeConverter : TypeConverter
|
public class TimeOnlyTypeConverter : TypeConverter
|
||||||
{
|
{
|
||||||
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
|
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
|
||||||
@ -42,5 +42,5 @@ namespace AsbCloudWebApi.Converters
|
|||||||
return base.ConvertTo(context, culture, value, destinationType);
|
return base.ConvertTo(context, culture, value, destinationType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Middlewares
|
namespace AsbCloudWebApi.Middlewares
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
public class PermissionsMiddlware
|
public class PermissionsMiddlware
|
||||||
{
|
{
|
||||||
private readonly RequestDelegate next;
|
private readonly RequestDelegate next;
|
||||||
@ -80,5 +80,5 @@ namespace AsbCloudWebApi.Middlewares
|
|||||||
await context.ForbidAsync();
|
await context.ForbidAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Middlewares
|
namespace AsbCloudWebApi.Middlewares
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
public class RequerstTrackerMiddleware
|
public class RequerstTrackerMiddleware
|
||||||
{
|
{
|
||||||
private readonly RequestDelegate next;
|
private readonly RequestDelegate next;
|
||||||
@ -49,5 +49,5 @@ namespace AsbCloudWebApi.Middlewares
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Middlewares
|
namespace AsbCloudWebApi.Middlewares
|
||||||
{
|
{
|
||||||
#nullable enable
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is not real middleware it`s part of PermissionsMiddlware.
|
/// This is not real middleware it`s part of PermissionsMiddlware.
|
||||||
/// DO NOT register it in setup.cs as middleware.
|
/// DO NOT register it in setup.cs as middleware.
|
||||||
@ -69,5 +69,5 @@ namespace AsbCloudWebApi.Middlewares
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user