forked from ddrilling/AsbCloudServer
Merge branch 'dev' into Microsoft_MemoryCache
This commit is contained in:
commit
abb6a513fd
@ -91,7 +91,7 @@ namespace System.Collections.Generic
|
||||
get
|
||||
{
|
||||
if (used == 0)
|
||||
return default;
|
||||
throw new IndexOutOfRangeException();
|
||||
|
||||
var i = (current + 1 + index) % used;
|
||||
return array[i];
|
||||
|
@ -10,7 +10,7 @@ namespace AsbCloudApp.Data.Subsystems
|
||||
/// <summary>
|
||||
/// Активная скважина
|
||||
/// </summary>
|
||||
public WellDto Well { get; set; }
|
||||
public WellDto Well { get; set; } = null!;
|
||||
/// <summary>
|
||||
/// Наработки подсистемы АКБ
|
||||
/// </summary>
|
||||
|
@ -51,7 +51,6 @@ namespace AsbCloudApp.Repositories
|
||||
/// <summary>
|
||||
/// Вывод списка всех файлов из базы, для которых нет файла на диске
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="files"></param>
|
||||
/// <returns></returns>
|
||||
IEnumerable<FileInfoDto> GetListFilesNotDisc(IEnumerable<FileInfoDto> files);
|
||||
|
@ -165,15 +165,6 @@ namespace AsbCloudApp.Services
|
||||
public async Task<IEnumerable<FileInfoDto>> GetInfoByIdsAsync(IEnumerable<int> idsFile, CancellationToken token)
|
||||
{
|
||||
var result = await fileRepository.GetInfoByIdsAsync(idsFile, token).ConfigureAwait(false);
|
||||
|
||||
foreach (var entity in result)
|
||||
{
|
||||
|
||||
var ext = Path.GetExtension(entity.Name);
|
||||
var relativePath = GetUrl(entity.IdWell, entity.IdCategory, entity.Id, ext);
|
||||
var fullPath = Path.GetFullPath(relativePath);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudApp.Services
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// Сервис авторизации
|
||||
/// </summary>
|
||||
@ -33,13 +34,14 @@ namespace AsbCloudApp.Services
|
||||
/// <param name="password"></param>
|
||||
/// <param name="token">токен отмены задачи</param>
|
||||
/// <returns></returns>
|
||||
Task<UserTokenDto> LoginAsync(string login,
|
||||
Task<UserTokenDto?> LoginAsync(string login,
|
||||
string password, CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// Обновление токена авторизации
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="identity"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<UserTokenDto?> RefreshAsync(ClaimsPrincipal identity,
|
||||
CancellationToken token);
|
||||
@ -51,4 +53,5 @@ namespace AsbCloudApp.Services
|
||||
/// <returns></returns>
|
||||
int Register(UserRegistrationDto userDto);
|
||||
}
|
||||
#nullable disable
|
||||
}
|
@ -10,6 +10,12 @@ namespace AsbCloudApp.Services
|
||||
/// </summary>
|
||||
public interface IFileCategoryService
|
||||
{
|
||||
/// <summary>
|
||||
/// Получить категории файлов
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<FileCategoryDto> GetOrDefaultAsync(int id, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
|
@ -6,8 +6,19 @@ using System.Threading.Tasks;
|
||||
namespace AsbCloudApp.Services.Subsystems
|
||||
{
|
||||
#nullable enable
|
||||
// TODO: move this to repositories
|
||||
|
||||
/// <summary>
|
||||
/// репозиторий получения подсистем
|
||||
/// </summary>
|
||||
public interface ISubsystemService
|
||||
{
|
||||
/// <summary>
|
||||
/// получение списка подсистем. Если скважина указана, то получим только использованные в скважине подсистемы.
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<SubsystemDto>?> GetSubsystemAsync(int? idWell, CancellationToken token);
|
||||
}
|
||||
#nullable disable
|
||||
|
@ -60,14 +60,6 @@ namespace AsbCloudDb.Model
|
||||
public DbSet<WITS.Record60> Record60 => Set<WITS.Record60>();
|
||||
public DbSet<WITS.Record61> Record61 => Set<WITS.Record61>();
|
||||
|
||||
private System.Text.Json.JsonSerializerOptions jsonSerializerOptions = new()
|
||||
{
|
||||
AllowTrailingCommas = true,
|
||||
WriteIndented = true,
|
||||
NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString |
|
||||
System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals,
|
||||
};
|
||||
|
||||
public AsbCloudDbContext() : base()
|
||||
{
|
||||
}
|
||||
@ -368,10 +360,5 @@ namespace AsbCloudDb.Model
|
||||
var sql = $"REFRESH MATERIALIZED VIEW {materializedViewName};";
|
||||
return Database.ExecuteSqlRawAsync(sql, token);
|
||||
}
|
||||
|
||||
public Task<int> RefreshMaterializedViewAsync<TEntity>(string? mwName = null, CancellationToken token = default) where TEntity : class
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,58 +5,57 @@
|
||||
/// <summary>
|
||||
/// КНБК описание
|
||||
/// </summary>
|
||||
public string BHADescription { get; set; }
|
||||
public string BHADescription { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Бурение с наращиваниями в инт. 2195-2763м. Время начала
|
||||
/// </summary>
|
||||
public string ExtensionDrillingOneBegin { get; set; }
|
||||
public string ExtensionDrillingOneBegin { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Бурение с наращиваниями в инт. 2195-2763м. Время окончания
|
||||
/// </summary>
|
||||
public string ExtensionDrillingOneFinish { get; set; }
|
||||
public string ExtensionDrillingOneFinish { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Промывка. Время начала
|
||||
/// </summary>
|
||||
public string SluiceBegin { get; set; }
|
||||
public string SluiceBegin { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Промывка. Время окончания
|
||||
/// </summary>
|
||||
public string SluiceFinish { get; set; }
|
||||
public string SluiceFinish { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Подьем КНБК. Время начала
|
||||
/// </summary>
|
||||
public string ClimbBegin { get; set; }
|
||||
public string ClimbBegin { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Подьем КНБК. Время окончания
|
||||
/// </summary>
|
||||
public string ClimbFinish { get; set; }
|
||||
public string ClimbFinish { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Спуск КНБК. Время начала
|
||||
/// </summary>
|
||||
public string DescentBegin { get; set; }
|
||||
public string DescentBegin { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Спуск КНБК. Время окончания
|
||||
/// </summary>
|
||||
public string DescentFinish { get; set; }
|
||||
public string DescentFinish { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Бурение с наращиваниями в инт. 2763-2850м. Время начала
|
||||
/// </summary>
|
||||
public string ExtensionDrillingTwoBegin { get; set; }
|
||||
public string ExtensionDrillingTwoBegin { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Бурение с наращиваниями в инт. 2763-2850м. Время окончания
|
||||
/// </summary>
|
||||
public string ExtensionDrillingTwoFinish { get; set; }
|
||||
public string ExtensionDrillingTwoFinish { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,22 +6,22 @@ namespace AsbCloudDb.Model.DailyReport
|
||||
/// <summary>
|
||||
/// название скважины
|
||||
/// </summary>
|
||||
public string WellName { get; set; }
|
||||
public string WellName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// название куста
|
||||
/// </summary>
|
||||
public string ClusterName { get; set; }
|
||||
public string ClusterName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// заказчик
|
||||
/// </summary>
|
||||
public string Customer { get; set; }
|
||||
public string Customer { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// подрядчик
|
||||
/// </summary>
|
||||
public string Contractor { get; set; }
|
||||
public string Contractor { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// дата рапорта
|
||||
@ -61,12 +61,12 @@ namespace AsbCloudDb.Model.DailyReport
|
||||
/// <summary>
|
||||
/// ФИО бурильщиков
|
||||
/// </summary>
|
||||
public string FirstDriller { get; set; }
|
||||
public string FirstDriller { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// ФИО бурильщиков
|
||||
/// </summary>
|
||||
public string SecondDriller { get; set; }
|
||||
public string SecondDriller { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Время работы АПД
|
||||
|
@ -72,32 +72,32 @@ namespace AsbCloudDb.Model.DailyReport
|
||||
/// <summary>
|
||||
/// указываются все причины, которые влияют на снижение МСП.
|
||||
/// </summary>
|
||||
public string DeclinesReasonsROP { get; set; }
|
||||
public string DeclinesReasonsROP { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Увеличение мех скорости за секцию %
|
||||
/// </summary>
|
||||
public string IncreaseSpeedSection { get; set; }
|
||||
public string IncreaseSpeedSection { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Увеличение мех скорости за сутки %
|
||||
/// </summary>
|
||||
public string IncreaseSpeedDay { get; set; }
|
||||
public string IncreaseSpeedDay { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Сокращение времени бурения за секцию, ч
|
||||
/// </summary>
|
||||
public string ReductionTimeDrilling { get; set; }
|
||||
public string ReductionTimeDrilling { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Ротор/Слайд %
|
||||
/// </summary>
|
||||
public string RotorSlidePercent { get; set; }
|
||||
public string RotorSlidePercent { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// МСП
|
||||
/// </summary>
|
||||
public string MspSection { get; set; }
|
||||
public string MspSection { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,12 @@
|
||||
/// <summary>
|
||||
/// ФИО Мастера буровой
|
||||
/// </summary>
|
||||
public string DrillingMaster { get; set; }
|
||||
public string DrillingMaster { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// ФИО супервайзера
|
||||
/// </summary>
|
||||
public string Supervisor { get; set; }
|
||||
public string Supervisor { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,92 +5,92 @@
|
||||
/// <summary>
|
||||
/// Бурение
|
||||
/// </summary>
|
||||
public string Drilling { get; set; }
|
||||
public string Drilling { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Промывка
|
||||
/// </summary>
|
||||
public string Flushing { get; set; }
|
||||
public string Flushing { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Наращивание
|
||||
/// </summary>
|
||||
public string Building { get; set; }
|
||||
public string Building { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Проработка
|
||||
/// </summary>
|
||||
public string Elaboration { get; set; }
|
||||
public string Elaboration { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Расширка
|
||||
/// </summary>
|
||||
public string Extension { get; set; }
|
||||
public string Extension { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Ремонт
|
||||
/// </summary>
|
||||
public string Repair { get; set; }
|
||||
public string Repair { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// КНБК
|
||||
/// </summary>
|
||||
public string Knbk { get; set; }
|
||||
public string Knbk { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// СПО
|
||||
/// </summary>
|
||||
public string Spo { get; set; }
|
||||
public string Spo { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// ПЗР
|
||||
/// </summary>
|
||||
public string Pzr { get; set; }
|
||||
public string Pzr { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// ПВО
|
||||
/// </summary>
|
||||
public string Pvo { get; set; }
|
||||
public string Pvo { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// ПГР
|
||||
/// </summary>
|
||||
public string Pgr { get; set; }
|
||||
public string Pgr { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// ГИС
|
||||
/// </summary>
|
||||
public string Gis { get; set; }
|
||||
public string Gis { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// ОЗЦ
|
||||
/// </summary>
|
||||
public string Ozc { get; set; }
|
||||
public string Ozc { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Тех. работы
|
||||
/// </summary>
|
||||
public string EngineeringWorks { get; set; }
|
||||
public string EngineeringWorks { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Снятие замера
|
||||
/// </summary>
|
||||
public string TakingMeasure { get; set; }
|
||||
public string TakingMeasure { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Цементирование
|
||||
/// </summary>
|
||||
public string Cementing { get; set; }
|
||||
public string Cementing { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Простой
|
||||
/// </summary>
|
||||
public string Simple { get; set; }
|
||||
public string Simple { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// НПВ
|
||||
/// </summary>
|
||||
public string Npv { get; set; }
|
||||
public string Npv { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,8 @@ namespace AsbCloudInfrastructure
|
||||
services.AddDbContext<AsbCloudDbContext>(options =>
|
||||
options.UseNpgsql(configuration.GetConnectionString(connectionStringName)));
|
||||
|
||||
services.AddFluentValidation();
|
||||
// TODO: переместить FluentValidation в описание моделей
|
||||
services.AddFluentValidationClientsideAdapters();
|
||||
|
||||
services.AddMemoryCache();
|
||||
services.AddScoped<IAsbCloudDbContext>(provider => provider.GetService<AsbCloudDbContext>());
|
||||
|
@ -12,6 +12,7 @@ using AsbCloudApp.Data.DailyReport;
|
||||
using AsbCloudApp.Requests;
|
||||
using AsbCloudInfrastructure.Services.DetectOperations;
|
||||
using AsbCloudApp.Data.DetectedOperation;
|
||||
using AsbCloudApp.Exceptions;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services.DailyReport
|
||||
{
|
||||
@ -34,7 +35,8 @@ namespace AsbCloudInfrastructure.Services.DailyReport
|
||||
{
|
||||
var well = wellService.GetOrDefault(idWell);
|
||||
if (well is null || well.Timezone is null)
|
||||
return null;
|
||||
throw new ArgumentInvalidException("idWell doesn`t exist", nameof(idWell));
|
||||
|
||||
var query = db.DailyReports.Where(r => r.IdWell == idWell);
|
||||
|
||||
DateTimeOffset ExtractDate(DateTime dateTime)
|
||||
@ -65,9 +67,8 @@ namespace AsbCloudInfrastructure.Services.DailyReport
|
||||
public async Task<DailyReportDto> GetOrGenerateAsync(int idWell, DateTime date, CancellationToken token)
|
||||
{
|
||||
var dateOnly = DateTime.SpecifyKind(date.Date, DateTimeKind.Utc);
|
||||
var dailyReportDto = await GetAsync(idWell, dateOnly, token);
|
||||
if (dailyReportDto is null)
|
||||
dailyReportDto = await MakeDefaultDailyReportAsync(idWell, dateOnly, token);
|
||||
var dailyReportDto = await GetOrDefaultAsync(idWell, dateOnly, token);
|
||||
dailyReportDto ??= await MakeDefaultDailyReportAsync(idWell, dateOnly, token);
|
||||
return dailyReportDto;
|
||||
}
|
||||
|
||||
@ -105,7 +106,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport
|
||||
|
||||
public async Task<Stream?> MakeReportAsync(int idWell, DateTime date, CancellationToken token = default)
|
||||
{
|
||||
var dailyReportDto = await GetAsync(idWell, date, token);
|
||||
var dailyReportDto = await GetOrDefaultAsync(idWell, date, token);
|
||||
if (dailyReportDto is null)
|
||||
return null;
|
||||
|
||||
@ -113,7 +114,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport
|
||||
return memoryStream;
|
||||
}
|
||||
|
||||
private async Task<DailyReportDto?> GetAsync(int idWell, DateTime date, CancellationToken token)
|
||||
private async Task<DailyReportDto?> GetOrDefaultAsync(int idWell, DateTime date, CancellationToken token)
|
||||
{
|
||||
var dateOffset = date.Date;
|
||||
var entity = await db.DailyReports
|
||||
|
@ -37,7 +37,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// <param name="idWell">id скважины</param>
|
||||
/// <param name="idCategory">id категории файла</param>
|
||||
/// <param name="files">Коллекция файлов</param>
|
||||
/// <param name="userService">dependency</param>
|
||||
/// <param name="userRepository">dependency</param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
@ -100,7 +100,6 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// <summary>
|
||||
/// Возвращает файл с диска на сервере
|
||||
/// </summary>
|
||||
/// <param name="idWell">id скважины</param>
|
||||
/// <param name="idFile">id запрашиваемого файла</param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns>Запрашиваемый файл</returns>
|
||||
@ -108,7 +107,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
[Route("{idFile}")]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetFileAsync([FromRoute] int idWell,
|
||||
public async Task<IActionResult> GetFileAsync(
|
||||
int idFile, CancellationToken token = default)
|
||||
{
|
||||
int? idCompany = User.GetCompanyId();
|
||||
@ -135,7 +134,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// </summary>
|
||||
/// <param name="idWell">id скважины</param>
|
||||
/// <param name="idFile">id запрашиваемого файла</param>
|
||||
/// <param name="userService">dependency</param>
|
||||
/// <param name="userRepository">dependency</param>
|
||||
/// <param name="token">Токен отмены задачи </param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{idFile}")]
|
||||
|
Loading…
Reference in New Issue
Block a user