forked from ddrilling/AsbCloudServer
Правка по результатам ревью
This commit is contained in:
parent
8c8d868b9f
commit
1f2f3206b1
@ -1,5 +1,5 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Requests;
|
using AsbCloudApp.Services;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@ -10,7 +10,7 @@ namespace AsbCloudApp.Repositories
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Репозиторий работы с данными из таблицы t_data_daub_stat
|
/// Репозиторий работы с данными из таблицы t_data_daub_stat
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IDataSaubStatRepository
|
public interface IDataSaubStatRepository : ITelemetryDataEditorService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение записей по ключу телеметрии
|
/// Получение записей по ключу телеметрии
|
||||||
@ -37,13 +37,5 @@ namespace AsbCloudApp.Repositories
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> InsertRangeAsync(IEnumerable<DataSaubStatDto> dataSaubStats, CancellationToken token);
|
Task<int> InsertRangeAsync(IEnumerable<DataSaubStatDto> dataSaubStats, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление записей по запросу на удаление куска телеметрии
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request"></param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
using System;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Data.DetectedOperation;
|
using AsbCloudApp.Data.DetectedOperation;
|
||||||
using AsbCloudApp.Requests;
|
using AsbCloudApp.Requests;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using AsbCloudApp.Data;
|
using System.Threading.Tasks;
|
||||||
using AsbCloudApp.Data.WellOperation;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Repositories;
|
namespace AsbCloudApp.Repositories;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Таблица автоматически определенных операций
|
/// Таблица автоматически определенных операций
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IDetectedOperationRepository
|
public interface IDetectedOperationRepository : ITelemetryDataEditorService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление нескольких записей
|
/// Добавление нескольких записей
|
||||||
@ -68,12 +68,4 @@ public interface IDetectedOperationRepository
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> DeleteAsync(DetectedOperationByTelemetryRequest request, CancellationToken token);
|
Task<int> DeleteAsync(DetectedOperationByTelemetryRequest request, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Удалить операции по запросу на удаление куска телеметрии
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request">запрос</param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using AsbCloudApp.Data.SAUB;
|
using AsbCloudApp.Data.SAUB;
|
||||||
using AsbCloudApp.Requests;
|
using AsbCloudApp.Requests;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -9,7 +10,7 @@ namespace AsbCloudApp.Repositories
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// репозиторий по работе с данными drill_test
|
/// репозиторий по работе с данными drill_test
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IDrillTestRepository
|
public interface IDrillTestRepository : ITelemetryDataEditorService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить данные drill_test в соответствии с параметрами запроса
|
/// Получить данные drill_test в соответствии с параметрами запроса
|
||||||
@ -37,13 +38,5 @@ namespace AsbCloudApp.Repositories
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> SaveDataAsync(int idTelemetry, IEnumerable<DrillTestBaseDto> dtos, CancellationToken token);
|
Task<int> SaveDataAsync(int idTelemetry, IEnumerable<DrillTestBaseDto> dtos, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление записей drill_test по запросу на удаление куска телеметрии
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request"></param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,14 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AsbCloudApp.Requests;
|
using AsbCloudApp.Requests;
|
||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
|
|
||||||
namespace AsbCloudApp.Repositories
|
namespace AsbCloudApp.Repositories
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// данные ГТИ
|
/// данные ГТИ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IGtrRepository
|
public interface IGtrRepository : ITelemetryDataEditorService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// добавить данные (для панели бурильщика)
|
/// добавить данные (для панели бурильщика)
|
||||||
@ -71,14 +72,5 @@ namespace AsbCloudApp.Repositories
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<DatesRangeDto?> GetRangeAsync(int idWell, DateTimeOffset? geDate, DateTimeOffset? leDate, CancellationToken token);
|
Task<DatesRangeDto?> GetRangeAsync(int idWell, DateTimeOffset? geDate, DateTimeOffset? leDate, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// удаление данных ГТИ по запросу на удаление куска телеметрии
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request">запрос</param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<int> DeleteAsync<TType>(TelemetryPartDeleteRequest request, CancellationToken token)
|
|
||||||
where TType : notnull;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Requests;
|
using AsbCloudApp.Requests;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AsbCloudApp.Repositories
|
namespace AsbCloudApp.Repositories
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Репозиторий по ограничивающим параметрам с фильтрацией
|
/// Репозиторий по ограничивающим параметрам с фильтрацией
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ILimitingParameterRepository
|
public interface ILimitingParameterRepository : ITelemetryDataEditorService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение списка ограничивающих параметров по идентификатору скважины
|
/// Получение списка ограничивающих параметров по идентификатору скважины
|
||||||
@ -30,15 +30,5 @@ namespace AsbCloudApp.Repositories
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<LimitingParameterDataDto>> GetLimitingParametersAsync(LimitingParameterRequest request, int idTelemetry, double timezoneHours, CancellationToken token);
|
Task<IEnumerable<LimitingParameterDataDto>> GetLimitingParametersAsync(LimitingParameterRequest request, int idTelemetry, double timezoneHours, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление ограничивающих параметров по запросу на удаление куска телеметрии
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request"></param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace AsbCloudApp.Requests;
|
namespace AsbCloudApp.Requests;
|
||||||
@ -6,7 +7,7 @@ namespace AsbCloudApp.Requests;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Параметры запроса на удаление куска телеметрии
|
/// Параметры запроса на удаление куска телеметрии
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TelemetryPartDeleteRequest
|
public class TelemetryPartDeleteRequest : IValidatableObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ключ телеметрии
|
/// ключ телеметрии
|
||||||
@ -22,4 +23,17 @@ public class TelemetryPartDeleteRequest
|
|||||||
/// less or equal then Date
|
/// less or equal then Date
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTimeOffset? LeDate { get; set; }
|
public DateTimeOffset? LeDate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Валидация входящих данных
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="validationContext"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||||
|
{
|
||||||
|
if (IdTelemetry == 0)
|
||||||
|
yield return new ValidationResult($"IdTelemetry must be defined");
|
||||||
|
if (!GeDate.HasValue && !LeDate.HasValue)
|
||||||
|
yield return new ValidationResult($"GeDate or LeDate must be defined");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ namespace AsbCloudApp.Services
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сервис сообщений панели оператора
|
/// Сервис сообщений панели оператора
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IMessageService
|
public interface IMessageService : ITelemetryDataEditorService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить сообщения по параметрам
|
/// Получить сообщения по параметрам
|
||||||
@ -29,13 +29,5 @@ namespace AsbCloudApp.Services
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task InsertAsync(string uid, IEnumerable<TelemetryMessageDto> dtos,
|
Task InsertAsync(string uid, IEnumerable<TelemetryMessageDto> dtos,
|
||||||
CancellationToken token);
|
CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление сообщений по запросу на удаление куска телеметрии
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request">запрос</param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,5 +15,5 @@ public interface ITelemetryDataEditorService
|
|||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
|
Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace AsbCloudApp.Services
|
|||||||
/// сервис данных тех. процесса
|
/// сервис данных тех. процесса
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDto"></typeparam>
|
/// <typeparam name="TDto"></typeparam>
|
||||||
public interface ITelemetryDataService<TDto> where TDto : ITelemetryData
|
public interface ITelemetryDataService<TDto> : ITelemetryDataEditorService where TDto : ITelemetryData
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -70,14 +70,5 @@ namespace AsbCloudApp.Services
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> UpdateDataAsync(string uid, IEnumerable<TDto> dtos, CancellationToken token);
|
Task<int> UpdateDataAsync(string uid, IEnumerable<TDto> dtos, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// удалить данные по запросу
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request">запрос</param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ namespace AsbCloudApp.Services
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The wits record repository.
|
/// The wits record repository.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IWitsRecordRepository<TDto>
|
public interface IWitsRecordRepository<TDto> : ITelemetryDataEditorService
|
||||||
where TDto : ITelemetryData
|
where TDto : ITelemetryData
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -46,13 +46,5 @@ namespace AsbCloudApp.Services
|
|||||||
/// <param name="token">The token.</param>
|
/// <param name="token">The token.</param>
|
||||||
/// <returns>A Task.</returns>
|
/// <returns>A Task.</returns>
|
||||||
Task<(DateTime begin, DateTime end, int count)?> GetStatAsync(int idTelemetry, CancellationToken token);
|
Task<(DateTime begin, DateTime end, int count)?> GetStatAsync(int idTelemetry, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Удалить записи по запросу на удаление куска телеметрии
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request"></param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -88,16 +88,16 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
var query = db.Set<DataSaubStat>()
|
var query = db.Set<DataSaubStat>()
|
||||||
.Where(o => o.IdTelemetry == request.IdTelemetry);
|
.Where(o => o.IdTelemetry == request.IdTelemetry);
|
||||||
|
|
||||||
if (request.GeDate is not null)
|
|
||||||
{
|
|
||||||
var geDate = request.GeDate.Value.ToUniversalTime();
|
|
||||||
query = query.Where(o => o.DateStart <= geDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.LeDate is not null)
|
if (request.LeDate is not null)
|
||||||
{
|
{
|
||||||
var leDate = request.LeDate.Value.ToUniversalTime();
|
var leDate = request.LeDate.Value.ToUniversalTime();
|
||||||
query = query.Where(o => o.DateEnd >= leDate);
|
query = query.Where(o => o.DateStart <= leDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.GeDate is not null)
|
||||||
|
{
|
||||||
|
var geDate = request.GeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateEnd >= geDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
|
@ -15,7 +15,8 @@ using AsbCloudApp.Data;
|
|||||||
|
|
||||||
namespace AsbCloudInfrastructure.Repository;
|
namespace AsbCloudInfrastructure.Repository;
|
||||||
|
|
||||||
public class DetectedOperationRepository : CrudRepositoryBase<DetectedOperationDto, DetectedOperation>, IDetectedOperationRepository
|
public class DetectedOperationRepository
|
||||||
|
: CrudRepositoryBase<DetectedOperationDto, DetectedOperation>, IDetectedOperationRepository
|
||||||
{
|
{
|
||||||
private readonly ITelemetryService telemetryService;
|
private readonly ITelemetryService telemetryService;
|
||||||
|
|
||||||
@ -125,16 +126,16 @@ public class DetectedOperationRepository : CrudRepositoryBase<DetectedOperationD
|
|||||||
var query = dbContext.Set<DetectedOperation>()
|
var query = dbContext.Set<DetectedOperation>()
|
||||||
.Where(o => o.IdTelemetry == request.IdTelemetry);
|
.Where(o => o.IdTelemetry == request.IdTelemetry);
|
||||||
|
|
||||||
if (request.GeDate is not null)
|
|
||||||
{
|
|
||||||
var geDate = request.GeDate.Value.ToUniversalTime();
|
|
||||||
query = query.Where(o => o.DateStart <= geDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.LeDate is not null)
|
if (request.LeDate is not null)
|
||||||
{
|
{
|
||||||
var leDate = request.LeDate.Value.ToUniversalTime();
|
var leDate = request.LeDate.Value.ToUniversalTime();
|
||||||
query = query.Where(o => o.DateEnd >= leDate);
|
query = query.Where(o => o.DateStart <= leDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.GeDate is not null)
|
||||||
|
{
|
||||||
|
var geDate = request.GeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateEnd >= geDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
|
@ -85,21 +85,22 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Óíèôèöèðîâàòü ìîäåëè äàííûõ òåëåìåòðèè.×òîáû â áóäóùåì óíèôèöèðîâàòü ðåïîçèòîðèè äàííûõ òåëåìåòðèè.
|
||||||
private IQueryable<DrillTest> BuildQuery(TelemetryPartDeleteRequest request)
|
private IQueryable<DrillTest> BuildQuery(TelemetryPartDeleteRequest request)
|
||||||
{
|
{
|
||||||
var query = db.Set<DrillTest>()
|
var query = db.Set<DrillTest>()
|
||||||
.Where(o => o.IdTelemetry == request.IdTelemetry);
|
.Where(o => o.IdTelemetry == request.IdTelemetry);
|
||||||
|
|
||||||
if (request.GeDate is not null)
|
|
||||||
{
|
|
||||||
var geDate = request.GeDate.Value.ToUniversalTime();
|
|
||||||
query = query.Where(o => o.TimeStampStart <= geDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.LeDate is not null)
|
if (request.LeDate is not null)
|
||||||
{
|
{
|
||||||
var leDate = request.LeDate.Value.ToUniversalTime();
|
var leDate = request.LeDate.Value.ToUniversalTime();
|
||||||
query = query.Where(o => o.TimeStampStart >= leDate);
|
query = query.Where(o => o.TimeStampStart <= leDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.GeDate is not null)
|
||||||
|
{
|
||||||
|
var geDate = request.GeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.TimeStampStart >= geDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
|
@ -446,32 +446,29 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
{
|
{
|
||||||
var query = db.Set<TEntity>().Where(i => i.IdTelemetry == request.IdTelemetry);
|
var query = db.Set<TEntity>().Where(i => i.IdTelemetry == request.IdTelemetry);
|
||||||
|
|
||||||
if (request.GeDate is not null)
|
|
||||||
{
|
|
||||||
var geDate = request.GeDate.Value.ToUniversalTime();
|
|
||||||
query = query.Where(o => o.DateTime <= geDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.LeDate is not null)
|
if (request.LeDate is not null)
|
||||||
{
|
{
|
||||||
var leDate = request.LeDate.Value.ToUniversalTime();
|
var leDate = request.LeDate.Value.ToUniversalTime();
|
||||||
query = query.Where(o => o.DateTime >= leDate);
|
query = query.Where(o => o.DateTime <= leDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.GeDate is not null)
|
||||||
|
{
|
||||||
|
var geDate = request.GeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateTime >= geDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> DeleteAsync<TType>(TelemetryPartDeleteRequest request, CancellationToken token)
|
public async Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token)
|
||||||
where TType : notnull
|
|
||||||
{
|
{
|
||||||
if (typeof(TType) == typeof(float))
|
var result = 0;
|
||||||
return await DeleteAsync<WitsItemFloat, float>(request, token);
|
result += await DeleteAsync<WitsItemFloat, float>(request, token);
|
||||||
if (typeof(TType) == typeof(int))
|
result += await DeleteAsync<WitsItemInt, int>(request, token);
|
||||||
return await DeleteAsync<WitsItemInt, int>(request, token);
|
result += await DeleteAsync<WitsItemString, string>(request, token);
|
||||||
if (typeof(TType) == typeof(string))
|
|
||||||
return await DeleteAsync<WitsItemString, string>(request, token);
|
|
||||||
|
|
||||||
return await Task.FromResult<int>(0);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<int> DeleteAsync<TEntity, TType>(TelemetryPartDeleteRequest request, CancellationToken token)
|
private async Task<int> DeleteAsync<TEntity, TType>(TelemetryPartDeleteRequest request, CancellationToken token)
|
||||||
|
@ -87,16 +87,16 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
var query = context.Set<LimitingParameter>()
|
var query = context.Set<LimitingParameter>()
|
||||||
.Where(o => o.IdTelemetry == request.IdTelemetry);
|
.Where(o => o.IdTelemetry == request.IdTelemetry);
|
||||||
|
|
||||||
if (request.GeDate is not null)
|
|
||||||
{
|
|
||||||
var geDate = request.GeDate.Value.ToUniversalTime();
|
|
||||||
query = query.Where(o => o.DateStart <= geDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.LeDate is not null)
|
if (request.LeDate is not null)
|
||||||
{
|
{
|
||||||
var leDate = request.LeDate.Value.ToUniversalTime();
|
var leDate = request.LeDate.Value.ToUniversalTime();
|
||||||
query = query.Where(o => o.DateEnd >= leDate);
|
query = query.Where(o => o.DateStart <= leDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.GeDate is not null)
|
||||||
|
{
|
||||||
|
var geDate = request.GeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateEnd >= geDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
|
@ -64,16 +64,16 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
var query = db.Set<TEntity>()
|
var query = db.Set<TEntity>()
|
||||||
.Where(o => o.IdTelemetry == request.IdTelemetry);
|
.Where(o => o.IdTelemetry == request.IdTelemetry);
|
||||||
|
|
||||||
if (request.GeDate is not null)
|
|
||||||
{
|
|
||||||
var geDate = request.GeDate.Value.ToUniversalTime();
|
|
||||||
query = query.Where(o => o.DateTime <= geDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.LeDate is not null)
|
if (request.LeDate is not null)
|
||||||
{
|
{
|
||||||
var leDate = request.LeDate.Value.ToUniversalTime();
|
var leDate = request.LeDate.Value.ToUniversalTime();
|
||||||
query = query.Where(o => o.DateTime >= leDate);
|
query = query.Where(o => o.DateTime <= leDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.GeDate is not null)
|
||||||
|
{
|
||||||
|
var geDate = request.GeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateTime >= geDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
|
@ -13,20 +13,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class TelemetryDataEditorService : ITelemetryDataEditorService
|
public class TelemetryDataEditorService : ITelemetryDataEditorService
|
||||||
{
|
{
|
||||||
private readonly ITelemetryDataSaubService dataSaubService;
|
private readonly ITelemetryDataEditorService[] repositories;
|
||||||
private readonly ITelemetryDataService<TelemetryDataSpinDto> dataSpinService;
|
|
||||||
private readonly IDataSaubStatRepository dataSaubStatRepository;
|
|
||||||
private readonly IMessageService messageService;
|
|
||||||
private readonly IDrillTestRepository drillTestRepository;
|
|
||||||
private readonly ILimitingParameterRepository limitingParameterRepository;
|
|
||||||
private readonly IDetectedOperationRepository detectedOperationRepository;
|
|
||||||
private readonly IWitsRecordRepository<Record1Dto> witsRecord1Repository;
|
|
||||||
private readonly IWitsRecordRepository<Record7Dto> witsRecord7Repository;
|
|
||||||
private readonly IWitsRecordRepository<Record8Dto> witsRecord8Repository;
|
|
||||||
private readonly IWitsRecordRepository<Record50Dto> witsRecord50Repository;
|
|
||||||
private readonly IWitsRecordRepository<Record60Dto> witsRecord60Repository;
|
|
||||||
private readonly IWitsRecordRepository<Record61Dto> witsRecord61Repository;
|
|
||||||
private readonly IGtrRepository gtrRepository;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@ -62,40 +49,34 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
|||||||
IGtrRepository gtrRepository
|
IGtrRepository gtrRepository
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.dataSaubService = dataSaubService;
|
repositories =
|
||||||
this.dataSpinService = dataSpinService;
|
[
|
||||||
this.dataSaubStatRepository = dataSaubStatRepository;
|
dataSaubService,
|
||||||
this.messageService = messageService;
|
dataSpinService,
|
||||||
this.drillTestRepository = drillTestRepository;
|
dataSaubStatRepository,
|
||||||
this.limitingParameterRepository = limitingParameterRepository;
|
messageService,
|
||||||
this.detectedOperationRepository = detectedOperationRepository;
|
drillTestRepository,
|
||||||
this.witsRecord1Repository = witsRecord1Repository;
|
limitingParameterRepository,
|
||||||
this.witsRecord7Repository = witsRecord7Repository;
|
detectedOperationRepository,
|
||||||
this.witsRecord8Repository = witsRecord8Repository;
|
witsRecord1Repository,
|
||||||
this.witsRecord50Repository = witsRecord50Repository;
|
witsRecord7Repository,
|
||||||
this.witsRecord60Repository = witsRecord60Repository;
|
witsRecord8Repository,
|
||||||
this.witsRecord61Repository = witsRecord61Repository;
|
witsRecord50Repository,
|
||||||
this.gtrRepository = gtrRepository;
|
witsRecord60Repository,
|
||||||
|
witsRecord61Repository,
|
||||||
|
gtrRepository,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token)
|
public async Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token)
|
||||||
{
|
{
|
||||||
await dataSaubService.DeleteAsync(request, token);
|
int result = 0;
|
||||||
await dataSpinService.DeleteAsync(request, token);
|
foreach (var repository in repositories)
|
||||||
await dataSaubStatRepository.DeleteAsync(request, token);
|
{
|
||||||
await messageService.DeleteAsync(request, token);
|
result += await repository.DeleteAsync(request, token);
|
||||||
await drillTestRepository.DeleteAsync(request, token);
|
}
|
||||||
await limitingParameterRepository.DeleteAsync(request, token);
|
|
||||||
await detectedOperationRepository.DeleteAsync(request, token);
|
return result;
|
||||||
await witsRecord1Repository.DeleteAsync(request, token);
|
|
||||||
await witsRecord7Repository.DeleteAsync(request, token);
|
|
||||||
await witsRecord8Repository.DeleteAsync(request, token);
|
|
||||||
await witsRecord50Repository.DeleteAsync(request, token);
|
|
||||||
await witsRecord60Repository.DeleteAsync(request, token);
|
|
||||||
await witsRecord61Repository.DeleteAsync(request, token);
|
|
||||||
await gtrRepository.DeleteAsync<float>(request, token);
|
|
||||||
await gtrRepository.DeleteAsync<int>(request, token);
|
|
||||||
await gtrRepository.DeleteAsync<string>(request, token);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ using AsbCloudApp.Data;
|
|||||||
using AsbCloudApp.Requests;
|
using AsbCloudApp.Requests;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@ -43,29 +44,20 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление куска телеметрии
|
/// Удаление куска телеметрии по запросу
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="telemetryId">ключ телеметрии</param>
|
/// <param name="request">запрос</param>
|
||||||
/// <param name="gDate">начало интервала удаления</param>
|
|
||||||
/// <param name="lDate">конец интервала удаления</param>
|
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpDelete("/part/{telemetryId}")]
|
[HttpDelete("/part")]
|
||||||
[Permission]
|
[Permission]
|
||||||
public async Task<IActionResult> DeleteAsync(int telemetryId,
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
DateTimeOffset? gDate,
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
DateTimeOffset? lDate,
|
public async Task<IActionResult> DeleteAsync([FromQuery] TelemetryPartDeleteRequest request,CancellationToken token)
|
||||||
CancellationToken token)
|
|
||||||
{
|
{
|
||||||
var request = new TelemetryPartDeleteRequest()
|
var result = await telemetryEditorService.DeleteAsync(request, token);
|
||||||
{
|
|
||||||
IdTelemetry = telemetryId,
|
return Ok(result);
|
||||||
GeDate = gDate,
|
|
||||||
LeDate = lDate
|
|
||||||
};
|
|
||||||
if(gDate.HasValue || lDate.HasValue)
|
|
||||||
await telemetryEditorService.DeleteAsync(request, token);
|
|
||||||
return Ok();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user