From 16e52cacf5ff1ec10c20e5e7fb4cce4a6f9a8c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Tue, 27 Jul 2021 14:43:30 +0500 Subject: [PATCH] wellId rename to idWell --- AsbCloudApp/Data/ReportPropertiesDto.cs | 2 +- AsbCloudApp/Services/IAnalyticsService.cs | 10 ++-- AsbCloudApp/Services/IDataService.cs | 4 +- AsbCloudApp/Services/IFileService.cs | 4 +- AsbCloudApp/Services/IMessageService.cs | 4 +- AsbCloudApp/Services/IReportService.cs | 8 +-- AsbCloudApp/Services/ITelemetryService.cs | 4 +- AsbCloudApp/Services/IWellService.cs | 6 +-- AsbCloudDb/Model/AsbCloudDbContext.cs | 10 ++-- AsbCloudDb/Model/IAsbCloudDbContext.cs | 9 ++-- AsbCloudDb/Model/WellOperation.cs | 36 +++++++++++++ .../ReportDataSourcePgCloud.cs | 6 +-- .../Services/AnalyticsService.cs | 20 ++++---- .../Services/DataService.cs | 8 +-- .../Services/FileService.cs | 8 +-- .../Services/MessageService.cs | 8 +-- .../Services/ReportService.cs | 30 +++++------ .../Services/TelemetryService.cs | 6 +-- .../Services/WellService.cs | 23 +++++---- .../Controllers/AnalyticsController.cs | 50 +++++++++---------- AsbCloudWebApi/Controllers/DataController.cs | 16 +++--- AsbCloudWebApi/Controllers/FileController.cs | 34 ++++++------- .../Controllers/MessageController.cs | 16 +++--- .../Controllers/ReportController.cs | 48 +++++++++--------- .../Controllers/TelemetryController.cs | 10 ++-- AsbCloudWebApi/Controllers/WellController.cs | 20 ++++---- .../OpenAPIService/OpenAPI.cs | 36 ++++++------- .../OpenAPIService/OpenAPI.nswag.json | 8 +-- ConsoleApp1/Program.cs | 6 +-- 29 files changed, 245 insertions(+), 205 deletions(-) create mode 100644 AsbCloudDb/Model/WellOperation.cs diff --git a/AsbCloudApp/Data/ReportPropertiesDto.cs b/AsbCloudApp/Data/ReportPropertiesDto.cs index 7526dc68..d025e519 100644 --- a/AsbCloudApp/Data/ReportPropertiesDto.cs +++ b/AsbCloudApp/Data/ReportPropertiesDto.cs @@ -7,7 +7,7 @@ namespace AsbCloudApp.Data public int Id { get; set; } public string Name { get; set; } public string FullName { get; set; } - public int WellId { get; set; } + public int idWell { get; set; } public DateTime Date { get; set; } public DateTimeOffset Begin { get; set; } public DateTimeOffset End { get; set; } diff --git a/AsbCloudApp/Services/IAnalyticsService.cs b/AsbCloudApp/Services/IAnalyticsService.cs index b8efff23..28b83d96 100644 --- a/AsbCloudApp/Services/IAnalyticsService.cs +++ b/AsbCloudApp/Services/IAnalyticsService.cs @@ -7,15 +7,15 @@ namespace AsbCloudApp.Services { public interface IAnalyticsService { - PaginationContainer GetOperationsByWell(int wellId, + PaginationContainer GetOperationsByWell(int idWell, IEnumerable categoryids = default, DateTime begin = default, DateTime end = default, int skip = 0, int take = 32); - IEnumerable GetWellDepthToDay(int wellId); - IEnumerable GetWellDepthToInterval(int wellId, + IEnumerable GetWellDepthToDay(int idWell); + IEnumerable GetWellDepthToInterval(int idWell, int intervalHoursTimestamp, int workBeginTimestamp); - IEnumerable GetOperationsSummary(int wellId, + IEnumerable GetOperationsSummary(int idWell, DateTime begin = default, DateTime end = default); - IEnumerable GetOperationsToInterval(int wellId, + IEnumerable GetOperationsToInterval(int idWell, int intervalHoursTimestamp, int workBeginTimestamp); void SaveAnalytics(DataSaubBase dataSaub); } diff --git a/AsbCloudApp/Services/IDataService.cs b/AsbCloudApp/Services/IDataService.cs index bbc927c4..3f09e7d3 100644 --- a/AsbCloudApp/Services/IDataService.cs +++ b/AsbCloudApp/Services/IDataService.cs @@ -6,9 +6,9 @@ namespace AsbCloudApp.Services { public interface IDataService { - IEnumerable Get(int wellId, DateTime dateBegin = default, double intervalSec = 600d, int approxPointsCount = 1024); + IEnumerable Get(int idWell, DateTime dateBegin = default, double intervalSec = 600d, int approxPointsCount = 1024); void UpdateData(string uid, IEnumerable dtos); - DatesRangeDto GetDataDatesRange(int wellId); + DatesRangeDto GetDataDatesRange(int idWell); } } \ No newline at end of file diff --git a/AsbCloudApp/Services/IFileService.cs b/AsbCloudApp/Services/IFileService.cs index f14b4e6a..d31efd84 100644 --- a/AsbCloudApp/Services/IFileService.cs +++ b/AsbCloudApp/Services/IFileService.cs @@ -7,11 +7,11 @@ namespace AsbCloudApp.Services public interface IFileService { string RootPath { get; } - IDictionary SaveFilesPropertiesToDb(int wellId, + IDictionary SaveFilesPropertiesToDb(int idWell, int idCategory, IEnumerable<(string fileName, int idWell, int idCategory, DateTime date, int idUser)> filesInfo); - PaginationContainer GetFilesInfo(int wellId, + PaginationContainer GetFilesInfo(int idWell, int idCategory, DateTime begin, DateTime end, int skip, int take); diff --git a/AsbCloudApp/Services/IMessageService.cs b/AsbCloudApp/Services/IMessageService.cs index 0ca4b916..9f816c66 100644 --- a/AsbCloudApp/Services/IMessageService.cs +++ b/AsbCloudApp/Services/IMessageService.cs @@ -6,8 +6,8 @@ namespace AsbCloudApp.Services { public interface IMessageService { - PaginationContainer GetMessages(int wellId, IEnumerable categoryids = null, DateTime begin = default, DateTime end = default, int skip = 0, int take = 32); - DatesRangeDto GetMessagesDatesRange(int wellId); + PaginationContainer GetMessages(int idWell, IEnumerable categoryids = null, DateTime begin = default, DateTime end = default, int skip = 0, int take = 32); + DatesRangeDto GetMessagesDatesRange(int idWell); void Insert(string uid, IEnumerable dtos); } } \ No newline at end of file diff --git a/AsbCloudApp/Services/IReportService.cs b/AsbCloudApp/Services/IReportService.cs index 11c7db8e..b15544de 100644 --- a/AsbCloudApp/Services/IReportService.cs +++ b/AsbCloudApp/Services/IReportService.cs @@ -7,10 +7,10 @@ namespace AsbCloudApp.Services public interface IReportService { string RootPath { get; } - int CreateReport(int wellId, int stepSeconds, int format, DateTime begin, DateTime end, + int CreateReport(int idWell, int stepSeconds, int format, DateTime begin, DateTime end, Action handleReportProgress, Action handleReportName); - int GetReportPagesCount(int wellId, DateTime begin, DateTime end, int stepSeconds, int format); - IEnumerable GetSuitableReports(int wellId, DateTime begin, DateTime end, int stepSeconds, int format); - DatesRangeDto GetReportsDatesRange(int wellId); + int GetReportPagesCount(int idWell, DateTime begin, DateTime end, int stepSeconds, int format); + IEnumerable GetSuitableReports(int idWell, DateTime begin, DateTime end, int stepSeconds, int format); + DatesRangeDto GetReportsDatesRange(int idWell); } } diff --git a/AsbCloudApp/Services/ITelemetryService.cs b/AsbCloudApp/Services/ITelemetryService.cs index 192d38d1..4c876077 100644 --- a/AsbCloudApp/Services/ITelemetryService.cs +++ b/AsbCloudApp/Services/ITelemetryService.cs @@ -5,10 +5,10 @@ namespace AsbCloudApp.Services { public interface ITelemetryService { - int? GetWellIdByTelemetryUid(string uid); + int? GetidWellByTelemetryUid(string uid); int GetOrCreateTemetryIdByUid(string uid); double GetTimezoneOffsetByTelemetryId(int idTelemetry); void UpdateInfo(string uid, TelemetryInfoDto info); - Telemetry GetTelemetryByWellId(int wellId); + Telemetry GetTelemetryByidWell(int idWell); } } diff --git a/AsbCloudApp/Services/IWellService.cs b/AsbCloudApp/Services/IWellService.cs index e5c54762..aaf6012f 100644 --- a/AsbCloudApp/Services/IWellService.cs +++ b/AsbCloudApp/Services/IWellService.cs @@ -7,8 +7,8 @@ namespace AsbCloudApp.Services { IEnumerable GetWellsByCompany(int idCompany); IEnumerable GetTransmittingWells(int idCompany); - bool IsCompanyOwnsWell(int idCompany, int wellId); - IEnumerable GetSections(int wellId); - object GetOperations(int wellId); + bool IsCompanyOwnsWell(int idCompany, int idWell); + IEnumerable GetSections(int idWell); + IEnumerable GetOperations(int idWell); } } diff --git a/AsbCloudDb/Model/AsbCloudDbContext.cs b/AsbCloudDb/Model/AsbCloudDbContext.cs index 74485f23..b144da7f 100644 --- a/AsbCloudDb/Model/AsbCloudDbContext.cs +++ b/AsbCloudDb/Model/AsbCloudDbContext.cs @@ -12,24 +12,24 @@ namespace AsbCloudDb.Model //Scaffold-DbContext "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True" Npgsql.EntityFrameworkCore.PostgreSQL -OutputDir Model -DataAnnotations public partial class AsbCloudDbContext : DbContext, IAsbCloudDbContext { - //private readonly string connectionString; public virtual DbSet Clusters { get; set; } public virtual DbSet Companies { get; set; } public virtual DbSet DataSaubBases { get; set; } public virtual DbSet Deposits { get; set; } public virtual DbSet Events { get; set; } public virtual DbSet Messages { get; set; } - public virtual DbSet Telemetries { get; set; } - public virtual DbSet TelemetryUsers { get; set; } public virtual DbSet Users { get; set; } public virtual DbSet UserRoles { get; set; } - public virtual DbSet Wells { get; set; } public virtual DbSet Reports { get; set; } public virtual DbSet Files { get; set; } public virtual DbSet FileCategories { get; set; } + public virtual DbSet Telemetries { get; set; } + public virtual DbSet TelemetryUsers { get; set; } public virtual DbSet Operations { get; set; } public virtual DbSet TelemetryAnalysis { get; set; } - public virtual DbSet SectionAnalysis { get; set; } + public virtual DbSet Wells { get; set; } + public virtual DbSet WellSections { get; set; } + public virtual DbSet WellOperations { get; set; } public virtual DbSet WellTypes { get; set; } //public AsbCloudDbContext(string connectionString = "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True") diff --git a/AsbCloudDb/Model/IAsbCloudDbContext.cs b/AsbCloudDb/Model/IAsbCloudDbContext.cs index bcb1127b..30f306dc 100644 --- a/AsbCloudDb/Model/IAsbCloudDbContext.cs +++ b/AsbCloudDb/Model/IAsbCloudDbContext.cs @@ -15,16 +15,19 @@ namespace AsbCloudDb.Model DbSet Deposits { get; set; } DbSet Events { get; set; } DbSet Messages { get; set; } - DbSet Telemetries { get; set; } - DbSet TelemetryUsers { get; set; } DbSet Users { get; set; } - DbSet Wells { get; set; } DbSet UserRoles { get; set; } DbSet Reports { get; set; } DbSet Files { get; set; } DbSet FileCategories { get; set; } + DbSet Telemetries { get; set; } + DbSet TelemetryUsers { get; set; } DbSet Operations { get; set; } DbSet TelemetryAnalysis { get; set; } + DbSet Wells { get; set; } + DbSet WellSections { get; set; } + DbSet WellOperations { get; set; } + DbSet WellTypes { get; set; } int SaveChanges(); int SaveChanges(bool acceptAllChangesOnSuccess); diff --git a/AsbCloudDb/Model/WellOperation.cs b/AsbCloudDb/Model/WellOperation.cs new file mode 100644 index 00000000..f45eb133 --- /dev/null +++ b/AsbCloudDb/Model/WellOperation.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text.Json.Serialization; + +#nullable disable + +namespace AsbCloudDb.Model +{ + [Table("t_well_operation"), Comment("Операции по скважине")] + public class WellOperation + { + [Key] + [Column("id")] + public int Id { get; set; } + + [Column("id_well")] + public int IdWell { get; set; } + + [Column("caption")] + public string Caption { get; set; } + + [Column("description")] + public string Description { get; set; } + + [Column("casing_section")] + public double CasingSection { get; set; } + + [Column("well_depth")] + public double WellDepth { get; set; } + + [JsonIgnore] + [ForeignKey(nameof(IdWell))] + public virtual Well Well { get; set; } + } +} diff --git a/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs b/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs index ca04d379..82f934c6 100644 --- a/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs +++ b/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs @@ -23,7 +23,7 @@ namespace AsbSaubReport {3, "Информация"}, }; - public ReportDataSourcePgCloud(AsbCloudDbContext context, int wellId) + public ReportDataSourcePgCloud(AsbCloudDbContext context, int idWell) { this.context = context; var well = context.Wells @@ -32,11 +32,11 @@ namespace AsbSaubReport .Include(w => w.RelationCompaniesWells) .ThenInclude(r => r.Company) .Include(w => w.Telemetry) - .FirstOrDefault(w => w.Id == wellId); + .FirstOrDefault(w => w.Id == idWell); idTelemetry = well?.IdTelemetry; if (idTelemetry is null) - throw new ArgumentException($"Well {wellId} doesn't contain telemetry", nameof(wellId)); + throw new ArgumentException($"Well {idWell} doesn't contain telemetry", nameof(idWell)); events = context.Events .Where(e => e.IdTelemetry == idTelemetry) diff --git a/AsbCloudInfrastructure/Services/AnalyticsService.cs b/AsbCloudInfrastructure/Services/AnalyticsService.cs index 2492449e..a18657e5 100644 --- a/AsbCloudInfrastructure/Services/AnalyticsService.cs +++ b/AsbCloudInfrastructure/Services/AnalyticsService.cs @@ -29,9 +29,9 @@ namespace AsbCloudInfrastructure.Services operationDetectorService = new TelemetryOperationDetectorService(operations); } - public IEnumerable GetWellDepthToDay(int wellId) + public IEnumerable GetWellDepthToDay(int idWell) { - var telemetry = telemetryService.GetTelemetryByWellId(wellId); + var telemetry = telemetryService.GetTelemetryByidWell(idWell); if (telemetry is null) return null; @@ -59,12 +59,12 @@ namespace AsbCloudInfrastructure.Services }).ToList(); } - public IEnumerable GetWellDepthToInterval(int wellId, + public IEnumerable GetWellDepthToInterval(int idWell, int intervalSeconds, int workBeginSeconds) { intervalSeconds = intervalSeconds == 0 ? 86400 : intervalSeconds; - var telemetry = telemetryService.GetTelemetryByWellId(wellId); + var telemetry = telemetryService.GetTelemetryByidWell(idWell); if (telemetry is null) return null; @@ -83,11 +83,11 @@ namespace AsbCloudInfrastructure.Services return wellDepthToIntervalData; } - public PaginationContainer GetOperationsByWell(int wellId, + public PaginationContainer GetOperationsByWell(int idWell, IEnumerable categoryIds = default, DateTime begin = default, DateTime end = default, int skip = 0, int take = 32) { - var telemetry = telemetryService.GetTelemetryByWellId(wellId); + var telemetry = telemetryService.GetTelemetryByidWell(idWell); if (telemetry is null) return null; @@ -147,10 +147,10 @@ namespace AsbCloudInfrastructure.Services return result; } - public IEnumerable GetOperationsSummary(int wellId, + public IEnumerable GetOperationsSummary(int idWell, DateTime begin = default, DateTime end = default) { - var telemetry = telemetryService.GetTelemetryByWellId(wellId); + var telemetry = telemetryService.GetTelemetryByidWell(idWell); if (telemetry is null) return null; @@ -173,12 +173,12 @@ namespace AsbCloudInfrastructure.Services return operations; } - public IEnumerable GetOperationsToInterval(int wellId, + public IEnumerable GetOperationsToInterval(int idWell, int intervalSeconds, int workBeginSeconds) { intervalSeconds = intervalSeconds == 0 ? 86400 : intervalSeconds; - var telemetry = telemetryService.GetTelemetryByWellId(wellId); + var telemetry = telemetryService.GetTelemetryByidWell(idWell); if (telemetry is null) return null; diff --git a/AsbCloudInfrastructure/Services/DataService.cs b/AsbCloudInfrastructure/Services/DataService.cs index daedb0b8..bf5f22f1 100644 --- a/AsbCloudInfrastructure/Services/DataService.cs +++ b/AsbCloudInfrastructure/Services/DataService.cs @@ -30,9 +30,9 @@ namespace AsbCloudInfrastructure.Services cacheWells = cacheDb.GetCachedTable((AsbCloudDbContext)db); } - public IEnumerable Get(int wellId, DateTime dateBegin = default, double intervalSec = 600d, int approxPointsCount = 1024) + public IEnumerable Get(int idWell, DateTime dateBegin = default, double intervalSec = 600d, int approxPointsCount = 1024) { - var well = cacheWells.FirstOrDefault(w => w.Id == wellId); + var well = cacheWells.FirstOrDefault(w => w.Id == idWell); if (well is null) return default; @@ -103,9 +103,9 @@ namespace AsbCloudInfrastructure.Services db.SaveChanges(); } - public DatesRangeDto GetDataDatesRange(int wellId) + public DatesRangeDto GetDataDatesRange(int idWell) { - var telemetry = telemetryService.GetTelemetryByWellId(wellId); + var telemetry = telemetryService.GetTelemetryByidWell(idWell); if (telemetry is null) return null; diff --git a/AsbCloudInfrastructure/Services/FileService.cs b/AsbCloudInfrastructure/Services/FileService.cs index f34be6cf..c25d1200 100644 --- a/AsbCloudInfrastructure/Services/FileService.cs +++ b/AsbCloudInfrastructure/Services/FileService.cs @@ -21,7 +21,7 @@ namespace AsbCloudInfrastructure.Services this.telemetryService = telemetryService; } - public IDictionary SaveFilesPropertiesToDb(int wellId, int idCategory, + public IDictionary SaveFilesPropertiesToDb(int idWell, int idCategory, IEnumerable<(string fileName, int idWell, int idCategory, DateTime date, int idUser)> filesInfo) { var fileIdsToNames = new Dictionary(); @@ -45,16 +45,16 @@ namespace AsbCloudInfrastructure.Services return fileIdsToNames; } - public PaginationContainer GetFilesInfo(int wellId, + public PaginationContainer GetFilesInfo(int idWell, int idCategory, DateTime begin = default, DateTime end = default, int skip = 0, int take = 32) { - var telemetry = telemetryService.GetTelemetryByWellId(wellId); + var telemetry = telemetryService.GetTelemetryByidWell(idWell); if (telemetry is null) return null; var filesInfoQuery = db.Files.Include(f => f.User) - .Where(f => f.IdWell == wellId && + .Where(f => f.IdWell == idWell && f.IdCategory == idCategory); if (!filesInfoQuery.Any()) diff --git a/AsbCloudInfrastructure/Services/MessageService.cs b/AsbCloudInfrastructure/Services/MessageService.cs index bf92ae6e..4cd1e12a 100644 --- a/AsbCloudInfrastructure/Services/MessageService.cs +++ b/AsbCloudInfrastructure/Services/MessageService.cs @@ -27,9 +27,9 @@ namespace AsbCloudInfrastructure.Services cacheTUsers = cacheDb.GetCachedTable((AsbCloudDbContext)db); } - public PaginationContainer GetMessages(int wellId, IEnumerable categoryids = default, DateTime begin = default, DateTime end = default, int skip = 0, int take = 32) + public PaginationContainer GetMessages(int idWell, IEnumerable categoryids = default, DateTime begin = default, DateTime end = default, int skip = 0, int take = 32) { - var telemetry = telemetryService.GetTelemetryByWellId(wellId); + var telemetry = telemetryService.GetTelemetryByidWell(idWell); if (telemetry is null) return null; @@ -98,9 +98,9 @@ namespace AsbCloudInfrastructure.Services return result; } - public DatesRangeDto GetMessagesDatesRange(int wellId) + public DatesRangeDto GetMessagesDatesRange(int idWell) { - var telemetry = telemetryService.GetTelemetryByWellId(wellId); + var telemetry = telemetryService.GetTelemetryByidWell(idWell); if (telemetry is null) return null; diff --git a/AsbCloudInfrastructure/Services/ReportService.cs b/AsbCloudInfrastructure/Services/ReportService.cs index d6150f93..f0e880a3 100644 --- a/AsbCloudInfrastructure/Services/ReportService.cs +++ b/AsbCloudInfrastructure/Services/ReportService.cs @@ -30,7 +30,7 @@ namespace AsbCloudInfrastructure.Services public string RootPath { get; private set; } - public int CreateReport(int wellId, int stepSeconds, int format, DateTime begin, + public int CreateReport(int idWell, int stepSeconds, int format, DateTime begin, DateTime end, Action progressHandler, Action reportNameHandler) { var newReportId = queue.EnqueueTask((id) => @@ -40,7 +40,7 @@ namespace AsbCloudInfrastructure.Services using (var context = new AsbCloudDbContext(optionsBuilder.Options)) { - var generator = GetReportGenerator(wellId, begin, end, stepSeconds, format, context); + var generator = GetReportGenerator(idWell, begin, end, stepSeconds, format, context); generator.OnProgress += (s, e) => progressHandler.Invoke(e.progress, e.operation, id); var newReportName = generator.Make(); if (newReportName is not null) @@ -51,7 +51,7 @@ namespace AsbCloudInfrastructure.Services var newReportProperties = new Report { Name = newReportName, - IdWell = wellId, + IdWell = idWell, Date = DateTime.Now, Begin = begin, End = end, @@ -66,23 +66,23 @@ namespace AsbCloudInfrastructure.Services return newReportId; } - public int GetReportPagesCount(int wellId, DateTime begin, DateTime end, int stepSeconds, int format) + public int GetReportPagesCount(int idWell, DateTime begin, DateTime end, int stepSeconds, int format) { - var generator = GetReportGenerator(wellId, begin, end, stepSeconds, format, (AsbCloudDbContext)db); + var generator = GetReportGenerator(idWell, begin, end, stepSeconds, format, (AsbCloudDbContext)db); return generator.GetPagesCount(); } - public IEnumerable GetSuitableReports(int wellId, DateTime begin, DateTime end, int stepSeconds, int format) + public IEnumerable GetSuitableReports(int idWell, DateTime begin, DateTime end, int stepSeconds, int format) { - var suitableReportsFromDb = GetSuitableReportsFromDb(wellId, begin, end, stepSeconds, format); + var suitableReportsFromDb = GetSuitableReportsFromDb(idWell, begin, end, stepSeconds, format); var suitableReportsProperties = suitableReportsFromDb.Select(r => new ReportPropertiesDto { Id = r.Id, Name = Path.GetFileName(r.Name), FullName = r.Name, - WellId = r.IdWell, + idWell = r.IdWell, Date = r.Date, Begin = r.Begin, End = r.End, @@ -93,9 +93,9 @@ namespace AsbCloudInfrastructure.Services return suitableReportsProperties; } - public DatesRangeDto GetReportsDatesRange(int wellId) + public DatesRangeDto GetReportsDatesRange(int idWell) { - var telemetry = telemetryService.GetTelemetryByWellId(wellId); + var telemetry = telemetryService.GetTelemetryByidWell(idWell); if (telemetry is null) return null; @@ -119,10 +119,10 @@ namespace AsbCloudInfrastructure.Services }; } - private IEnumerable GetSuitableReportsFromDb(int wellId, DateTime begin, DateTime end, int stepSeconds, int format) + private IEnumerable GetSuitableReportsFromDb(int idWell, DateTime begin, DateTime end, int stepSeconds, int format) { var suitableReportsNames = (from r in db.Reports - where r.IdWell == wellId + where r.IdWell == idWell && r.Begin >= begin && r.End <= end && r.Step <= stepSeconds @@ -132,9 +132,9 @@ namespace AsbCloudInfrastructure.Services return suitableReportsNames; } - private IReportGenerator GetReportGenerator(int wellId, DateTime begin, DateTime end, int stepSeconds, int format, AsbCloudDbContext context) + private IReportGenerator GetReportGenerator(int idWell, DateTime begin, DateTime end, int stepSeconds, int format, AsbCloudDbContext context) { - var dataSource = new ReportDataSourcePgCloud(context, wellId); + var dataSource = new ReportDataSourcePgCloud(context, idWell); IReportGenerator generator; switch (format) @@ -148,7 +148,7 @@ namespace AsbCloudInfrastructure.Services break; } - generator.ReportDirectory = Path.Combine(RootPath, $"{wellId}"); + generator.ReportDirectory = Path.Combine(RootPath, $"{idWell}"); generator.Begin = begin; generator.End = end; generator.Step = TimeSpan.FromSeconds(stepSeconds); diff --git a/AsbCloudInfrastructure/Services/TelemetryService.cs b/AsbCloudInfrastructure/Services/TelemetryService.cs index 9151987a..1cc6b705 100644 --- a/AsbCloudInfrastructure/Services/TelemetryService.cs +++ b/AsbCloudInfrastructure/Services/TelemetryService.cs @@ -22,7 +22,7 @@ namespace AsbCloudInfrastructure.Services public int GetOrCreateTemetryIdByUid(string uid) => GetOrCreateTelemetryByUid(uid).Id; - public int? GetWellIdByTelemetryUid(string uid) + public int? GetidWellByTelemetryUid(string uid) => GetWellByTelemetryUid(uid)?.Id; public double GetTimezoneOffsetByTelemetryId(int idTelemetry) => @@ -35,9 +35,9 @@ namespace AsbCloudInfrastructure.Services cacheTelemetry.Upsert(telemetry); } - public Telemetry GetTelemetryByWellId(int wellId) + public Telemetry GetTelemetryByidWell(int idWell) { - var well = cacheWells.FirstOrDefault(w => w.Id == wellId); + var well = cacheWells.FirstOrDefault(w => w.Id == idWell); if (well is null) return null; diff --git a/AsbCloudInfrastructure/Services/WellService.cs b/AsbCloudInfrastructure/Services/WellService.cs index 4c1e2c8f..febc51bc 100644 --- a/AsbCloudInfrastructure/Services/WellService.cs +++ b/AsbCloudInfrastructure/Services/WellService.cs @@ -43,6 +43,19 @@ namespace AsbCloudInfrastructure.Services public bool IsCompanyOwnsWell(int idCompany, int idWell) => cacheRelationCompaniesWells.Contains(r => r.IdWell == idWell && r.IdCompany == idCompany); + + public IEnumerable GetSections(int idWell) + { + var query = from s in db.WellSections + where s.IdWell == + return ; + } + + public IEnumerable GetOperations(int idWell) + { + throw new NotImplementedException(); + } + private static WellDto From(Well well) { var wellDto = new WellDto @@ -55,15 +68,5 @@ namespace AsbCloudInfrastructure.Services return wellDto; } - - public IEnumerable GetSections(int wellId) - { - return null; - } - - public object GetOperations(int wellId) - { - throw new NotImplementedException(); - } } } diff --git a/AsbCloudWebApi/Controllers/AnalyticsController.cs b/AsbCloudWebApi/Controllers/AnalyticsController.cs index f580a0ca..063c65f8 100644 --- a/AsbCloudWebApi/Controllers/AnalyticsController.cs +++ b/AsbCloudWebApi/Controllers/AnalyticsController.cs @@ -25,7 +25,7 @@ namespace AsbCloudWebApi.Controllers /// /// Возвращает список операций на скважине за все время /// - /// id скважины + /// id скважины /// список категорий /// дата начала /// окончание @@ -33,17 +33,17 @@ namespace AsbCloudWebApi.Controllers /// для пагинации кол-во записей /// Список операций на скважине за все время [HttpGet] - [Route("{wellId}/operationsByWell")] + [Route("{idWell}/operationsByWell")] [ProducesResponseType(typeof(PaginationContainer), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetOperationsByWell(int wellId, int skip = 0, int take = 32, + public IActionResult GetOperationsByWell(int idWell, int skip = 0, int take = 32, [FromQuery] IEnumerable categoryIds = default, DateTime begin = default, DateTime end = default) { int? idCompany = User.GetCompanyId(); - if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, wellId)) + if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, idWell)) return Forbid(); - var analytics = analyticsService.GetOperationsByWell(wellId, categoryIds, begin, end, skip, take); + var analytics = analyticsService.GetOperationsByWell(idWell, categoryIds, begin, end, skip, take); if (analytics is null || analytics.Count == 0) return NoContent(); @@ -54,19 +54,19 @@ namespace AsbCloudWebApi.Controllers /// /// Возвращает данные по скважине "глубина-день" /// - /// id скважины + /// id скважины /// Коллекцию данных по скважине "глубина-день" [HttpGet] - [Route("{wellId}/wellDepthToDay")] + [Route("{idWell}/wellDepthToDay")] [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetWellDepthToDay(int wellId) + public IActionResult GetWellDepthToDay(int idWell) { int? idCompany = User.GetCompanyId(); - if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, wellId)) + if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, idWell)) return Forbid(); - var wellDepthToDayData = analyticsService.GetWellDepthToDay(wellId); + var wellDepthToDayData = analyticsService.GetWellDepthToDay(idWell); if (wellDepthToDayData is null || !wellDepthToDayData.Any()) return NoContent(); @@ -77,22 +77,22 @@ namespace AsbCloudWebApi.Controllers /// /// Возвращает данные по глубине скважины за период /// - /// id скважины + /// id скважины /// количество секунд в необходимом интервале времени /// количество секунд в времени начала смены /// Коллекцию данных по глубине скважины за период [HttpGet] - [Route("{wellId}/wellDepthToInterval")] + [Route("{idWell}/wellDepthToInterval")] [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetWellDepthToInterval(int wellId, + public IActionResult GetWellDepthToInterval(int idWell, int intervalSeconds, int workBeginSeconds) { int? idCompany = User.GetCompanyId(); - if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, wellId)) + if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, idWell)) return Forbid(); - var wellDepthToIntervalData = analyticsService.GetWellDepthToInterval(wellId, + var wellDepthToIntervalData = analyticsService.GetWellDepthToInterval(idWell, intervalSeconds, workBeginSeconds); if (wellDepthToIntervalData is null || !wellDepthToIntervalData.Any()) @@ -104,21 +104,21 @@ namespace AsbCloudWebApi.Controllers /// /// Возвращает данные по операциям на скважине "операции-время" /// - /// id скважины + /// id скважины /// дата начала интервала /// дата окончания интервала /// Коллекцию операций на скважине [HttpGet] - [Route("{wellId}/operationsSummary")] + [Route("{idWell}/operationsSummary")] [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetOperationsSummary(int wellId, DateTime begin = default, DateTime end = default) + public IActionResult GetOperationsSummary(int idWell, DateTime begin = default, DateTime end = default) { int? idCompany = User.GetCompanyId(); - if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, wellId)) + if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, idWell)) return Forbid(); - var analytics = analyticsService.GetOperationsSummary(wellId, begin, end); + var analytics = analyticsService.GetOperationsSummary(idWell, begin, end); if (analytics is null || !analytics.Any()) return NoContent(); @@ -129,22 +129,22 @@ namespace AsbCloudWebApi.Controllers /// /// Возвращает детальные данные по операциям на скважине за период /// - /// id скважины + /// id скважины /// количество секунд в необходимом интервале времени /// количество секунд в времени начала смены /// Коллекцию операций на скважине [HttpGet] - [Route("{wellId}/operationsToInterval")] + [Route("{idWell}/operationsToInterval")] [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetOperationsToInterval(int wellId, + public IActionResult GetOperationsToInterval(int idWell, int intervalSeconds, int workBeginSeconds) { int? idCompany = User.GetCompanyId(); - if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, wellId)) + if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, idWell)) return Forbid(); - var analytics = analyticsService.GetOperationsToInterval(wellId, intervalSeconds, workBeginSeconds); + var analytics = analyticsService.GetOperationsToInterval(idWell, intervalSeconds, workBeginSeconds); if (analytics is null || !analytics.Any()) return NoContent(); diff --git a/AsbCloudWebApi/Controllers/DataController.cs b/AsbCloudWebApi/Controllers/DataController.cs index b0290766..3ff466b5 100644 --- a/AsbCloudWebApi/Controllers/DataController.cs +++ b/AsbCloudWebApi/Controllers/DataController.cs @@ -29,19 +29,19 @@ namespace AsbCloudWebApi.Controllers /// Возвращает данные САУБ по скважине. /// По умолчанию за последние 10 минут. /// - /// id скважины + /// id скважины /// дата начала выборки. По умолчанию: текущее время - intervalSec /// интервал времени даты начала выборки, секунды /// желаемое количество точек. Если в выборке точек будет больше, то выборка будет прорежена. /// [HttpGet] - [Route("{wellId}/data")] + [Route("{idWell}/data")] [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetData(int wellId, DateTime begin = default, int intervalSec = 600, int approxPointsCount = 1024) + public IActionResult GetData(int idWell, DateTime begin = default, int intervalSec = 600, int approxPointsCount = 1024) { if (begin == default) begin = DateTime.Now.AddSeconds(-intervalSec); - var content = telemetryDataService.Get(wellId, begin, intervalSec, approxPointsCount); + var content = telemetryDataService.Get(idWell, begin, intervalSec, approxPointsCount); if (content is null || !content.Any()) return NoContent(); @@ -50,21 +50,21 @@ namespace AsbCloudWebApi.Controllers } [HttpGet] - [Route("{wellId}/dataDatesRange")] + [Route("{idWell}/dataDatesRange")] [ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetDataDatesRange(int wellId) + public IActionResult GetDataDatesRange(int idWell) { int? idCompany = User.GetCompanyId(); if (idCompany is null) return Forbid(); - bool isCompanyOwnsWell = wellService.IsCompanyOwnsWell((int)idCompany, wellId); + bool isCompanyOwnsWell = wellService.IsCompanyOwnsWell((int)idCompany, idWell); if (!isCompanyOwnsWell) return Forbid(); - DatesRangeDto dataDatesRange = telemetryDataService.GetDataDatesRange(wellId); + DatesRangeDto dataDatesRange = telemetryDataService.GetDataDatesRange(idWell); return Ok(dataDatesRange); } diff --git a/AsbCloudWebApi/Controllers/FileController.cs b/AsbCloudWebApi/Controllers/FileController.cs index 9e10690c..46b82133 100644 --- a/AsbCloudWebApi/Controllers/FileController.cs +++ b/AsbCloudWebApi/Controllers/FileController.cs @@ -26,15 +26,15 @@ namespace AsbCloudWebApi.Controllers /// /// Сохраняет переданные файлы и информацию о них /// - /// id скважины + /// id скважины /// id категории файла /// id отправившего файл пользователя /// Коллекция файлов /// [HttpPost] - [Route("{wellId}/files")] + [Route("{idWell}/files")] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] - public IActionResult SaveFiles(int wellId, int idCategory, int idUser, + public IActionResult SaveFiles(int idWell, int idCategory, int idUser, [FromForm] IFormFileCollection files) { int? idCompany = User.GetCompanyId(); @@ -42,13 +42,13 @@ namespace AsbCloudWebApi.Controllers if (idCompany is null) return Forbid(); - if (!wellService.IsCompanyOwnsWell((int)idCompany, wellId)) + if (!wellService.IsCompanyOwnsWell((int)idCompany, idWell)) return Forbid(); var fileInfoCollection = files.Select(f => - (f.FileName, wellId, idCategory, DateTime.Now, idUser)); + (f.FileName, idWell, idCategory, DateTime.Now, idUser)); - var fileNamesAndIds = fileService.SaveFilesPropertiesToDb(wellId, + var fileNamesAndIds = fileService.SaveFilesPropertiesToDb(idWell, idCategory, fileInfoCollection); foreach (var file in files) @@ -57,7 +57,7 @@ namespace AsbCloudWebApi.Controllers var fileId = fileNamesAndIds[file.FileName]; - var relativePath = Path.Combine(fileService.RootPath, $"{wellId}", + var relativePath = Path.Combine(fileService.RootPath, $"{idWell}", $"{idCategory}", $"{fileId}" + $"{fileExtension}"); Directory.CreateDirectory(Path.GetDirectoryName(relativePath)); @@ -71,7 +71,7 @@ namespace AsbCloudWebApi.Controllers /// /// Возвращает информацию о файлах для скважины в выбраной категории /// - /// id скважины + /// id скважины /// id категории файла /// дата начала /// дата окончания @@ -79,18 +79,18 @@ namespace AsbCloudWebApi.Controllers /// для пагинации кол-во записей взять /// Список информации о файлах в этой категории [HttpGet] - [Route("{wellId}")] + [Route("{idWell}")] [ProducesResponseType(typeof(PaginationContainer), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetFilesInfo([FromRoute] int wellId, + public IActionResult GetFilesInfo([FromRoute] int idWell, int skip = 0, int take = 32, int idCategory = default, DateTime begin = default, DateTime end = default) { int? idCompany = User.GetCompanyId(); - if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, wellId)) + if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, idWell)) return Forbid(); - var filesInfo = fileService.GetFilesInfo(wellId, idCategory, + var filesInfo = fileService.GetFilesInfo(idWell, idCategory, begin, end, skip, take); if (filesInfo is null || !filesInfo.Items.Any()) @@ -102,13 +102,13 @@ namespace AsbCloudWebApi.Controllers /// /// Возвращает файл с диска на сервере /// - /// id скважины + /// id скважины /// id запрашиваемого файла /// Запрашиваемый файл [HttpGet] - [Route("{wellId}/{fileId}")] + [Route("{idWell}/{fileId}")] [ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetFile([FromRoute] int wellId, int fileId) + public IActionResult GetFile([FromRoute] int idWell, int fileId) { try { @@ -117,7 +117,7 @@ namespace AsbCloudWebApi.Controllers if (idCompany is null) return Forbid(); - if (!wellService.IsCompanyOwnsWell((int)idCompany, wellId)) + if (!wellService.IsCompanyOwnsWell((int)idCompany, idWell)) return Forbid(); var fileInfo = fileService.GetFileInfo(fileId); @@ -126,7 +126,7 @@ namespace AsbCloudWebApi.Controllers throw new FileNotFoundException(); // TODO: словарь content typoв - var relativePath = Path.Combine(fileService.RootPath, $"{wellId}", $"{fileInfo.Value.IdCategory}", + var relativePath = Path.Combine(fileService.RootPath, $"{idWell}", $"{fileInfo.Value.IdCategory}", $"{fileInfo.Value.Id}" + Path.GetExtension($"{fileInfo.Value.Name}")); return PhysicalFile(Path.GetFullPath(relativePath), "application/octet-stream", fileInfo.Value.Name); } diff --git a/AsbCloudWebApi/Controllers/MessageController.cs b/AsbCloudWebApi/Controllers/MessageController.cs index a5e14b54..3172afba 100644 --- a/AsbCloudWebApi/Controllers/MessageController.cs +++ b/AsbCloudWebApi/Controllers/MessageController.cs @@ -22,7 +22,7 @@ namespace AsbCloudWebApi.Controllers /// /// Выдает список сообщений по скважине /// - /// id скважины + /// id скважины /// список категорий /// дата начала /// окончание @@ -30,9 +30,9 @@ namespace AsbCloudWebApi.Controllers /// для пагинации кол-во записей /// список сообщений по скважине [HttpGet] - [Route("{wellId}/message")] + [Route("{idWell}/message")] [ProducesResponseType(typeof(PaginationContainer), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetMessage(int wellId, int skip = 0, int take = 32, [FromQuery] IEnumerable categoryids = default, DateTime begin = default, DateTime end = default) + public IActionResult GetMessage(int idWell, int skip = 0, int take = 32, [FromQuery] IEnumerable categoryids = default, DateTime begin = default, DateTime end = default) { if (take > 1024) return BadRequest("limit mast be less then 1024"); @@ -40,7 +40,7 @@ namespace AsbCloudWebApi.Controllers if (begin > DateTime.Now) begin = default; - var result = messageService.GetMessages(wellId, categoryids, begin, end, skip, take); + var result = messageService.GetMessages(idWell, categoryids, begin, end, skip, take); if (result is null || result.Count == 0) return NoContent(); @@ -49,21 +49,21 @@ namespace AsbCloudWebApi.Controllers } [HttpGet] - [Route("{wellId}/messagesDatesRange")] + [Route("{idWell}/messagesDatesRange")] [ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetMessagesDateRange(int wellId) + public IActionResult GetMessagesDateRange(int idWell) { int? idCompany = User.GetCompanyId(); if (idCompany is null) return Forbid(); - bool isCompanyOwnsWell = wellService.IsCompanyOwnsWell((int)idCompany, wellId); + bool isCompanyOwnsWell = wellService.IsCompanyOwnsWell((int)idCompany, idWell); if (!isCompanyOwnsWell) return Forbid(); - DatesRangeDto wellMessagesDatesRange = messageService.GetMessagesDatesRange(wellId); + DatesRangeDto wellMessagesDatesRange = messageService.GetMessagesDatesRange(idWell); return Ok(wellMessagesDatesRange); } diff --git a/AsbCloudWebApi/Controllers/ReportController.cs b/AsbCloudWebApi/Controllers/ReportController.cs index 8b0668e8..eacd06b2 100644 --- a/AsbCloudWebApi/Controllers/ReportController.cs +++ b/AsbCloudWebApi/Controllers/ReportController.cs @@ -51,16 +51,16 @@ namespace AsbCloudWebApi.Controllers /// /// Создает отчет по скважине с указанными параметрами /// - /// id скважины + /// id скважины /// шаг интервала /// формат отчета (0-PDF, 1-LAS) /// дата начала интервала /// дата окончания интервала /// id фоновой задачи формирования отчета [HttpPost] - [Route("{wellId}/report")] + [Route("{idWell}/report")] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] - public IActionResult CreateReport(int wellId, int stepSeconds, int format, + public IActionResult CreateReport(int idWell, int stepSeconds, int format, DateTime begin = default, DateTime end = default) { int? idCompany = User.GetCompanyId(); @@ -68,10 +68,10 @@ namespace AsbCloudWebApi.Controllers if (idCompany is null) return Forbid(); - if (!wellService.IsCompanyOwnsWell((int)idCompany, wellId)) + if (!wellService.IsCompanyOwnsWell((int)idCompany, idWell)) return Forbid(); - var id = reportService.CreateReport(wellId, stepSeconds, format, begin, end, HandleReportProgressAsync, HandleReportNameAsync); + var id = reportService.CreateReport(idWell, stepSeconds, format, begin, end, HandleReportProgressAsync, HandleReportNameAsync); return Ok(id); } @@ -79,13 +79,13 @@ namespace AsbCloudWebApi.Controllers /// /// Возвращает файл-отчет с диска на сервере /// - /// id скважины + /// id скважины /// имя запрашиваемого файла (отчета) /// файл с отчетом [HttpGet] - [Route("{wellId}/{reportName}")] + [Route("{idWell}/{reportName}")] [ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetReport([FromRoute] int wellId, string reportName) + public IActionResult GetReport([FromRoute] int idWell, string reportName) { try { @@ -94,10 +94,10 @@ namespace AsbCloudWebApi.Controllers if (idCompany is null) return Forbid(); - if (!wellService.IsCompanyOwnsWell((int)idCompany, wellId)) + if (!wellService.IsCompanyOwnsWell((int)idCompany, idWell)) return Forbid(); // TODO: словарь content typoв - var relativePath = Path.Combine(reportService.RootPath, $"{wellId}", reportName); + var relativePath = Path.Combine(reportService.RootPath, $"{idWell}", reportName); return PhysicalFile(Path.GetFullPath(relativePath), "application/pdf", reportName); } catch (FileNotFoundException ex) @@ -110,19 +110,19 @@ namespace AsbCloudWebApi.Controllers /// Возвращает имена отчетов, хранящихся на диске, /// которые подходят под указанные параметры /// - /// id скважины + /// id скважины /// шаг интервала /// формат отчета (0-PDF, 1-LAS) /// дата начала интервала /// дата окончания интервала /// Список имен существующих отчетов (отчетов) [HttpGet] - [Route("{wellId}/suitableReports")] + [Route("{idWell}/suitableReports")] [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetSuitableReportsNames(int wellId, int stepSeconds, int format, + public IActionResult GetSuitableReportsNames(int idWell, int stepSeconds, int format, DateTime begin = default, DateTime end = default) { - var suitableReportsNames = reportService.GetSuitableReports(wellId, begin, end, stepSeconds, format); + var suitableReportsNames = reportService.GetSuitableReports(idWell, begin, end, stepSeconds, format); if (suitableReportsNames is null || !suitableReportsNames.Any()) return NoContent(); @@ -133,26 +133,26 @@ namespace AsbCloudWebApi.Controllers /// /// Возвращает прогнозируемое количество страниц будущего отчета /// - /// id скважины + /// id скважины /// дата начала интервала /// дата окончания интервала /// шаг интервала /// формат отчета (0-PDF, 1-LAS) /// прогнозируемое кол-во страниц отчета [HttpGet] - [Route("{wellId}/reportSize")] + [Route("{idWell}/reportSize")] [ProducesResponseType(typeof(string), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetReportSize(int wellId, int stepSeconds, int format, DateTime begin = default, DateTime end = default) + public IActionResult GetReportSize(int idWell, int stepSeconds, int format, DateTime begin = default, DateTime end = default) { int? idCompany = User.GetCompanyId(); if (idCompany is null) return Forbid(); - if (!wellService.IsCompanyOwnsWell((int)idCompany, wellId)) + if (!wellService.IsCompanyOwnsWell((int)idCompany, idWell)) return Forbid(); - int reportSize = reportService.GetReportPagesCount(wellId, begin, end, stepSeconds, format); + int reportSize = reportService.GetReportPagesCount(idWell, begin, end, stepSeconds, format); return Ok(reportSize); } @@ -160,22 +160,22 @@ namespace AsbCloudWebApi.Controllers /// /// Возвращает даты самого старого и самого свежего отчетов в БД /// - /// id скважины + /// id скважины /// Даты самого старого и самого свежего отчетов в БД [HttpGet] - [Route("{wellId}/reportsDatesRange")] + [Route("{idWell}/reportsDatesRange")] [ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetReportsDateRange(int wellId) + public IActionResult GetReportsDateRange(int idWell) { int? idCompany = User.GetCompanyId(); if (idCompany is null) return Forbid(); - if (!wellService.IsCompanyOwnsWell((int)idCompany, wellId)) + if (!wellService.IsCompanyOwnsWell((int)idCompany, idWell)) return Forbid(); - DatesRangeDto wellReportsDatesRange = reportService.GetReportsDatesRange(wellId); + DatesRangeDto wellReportsDatesRange = reportService.GetReportsDatesRange(idWell); return Ok(wellReportsDatesRange); } diff --git a/AsbCloudWebApi/Controllers/TelemetryController.cs b/AsbCloudWebApi/Controllers/TelemetryController.cs index f7534813..e09121fb 100644 --- a/AsbCloudWebApi/Controllers/TelemetryController.cs +++ b/AsbCloudWebApi/Controllers/TelemetryController.cs @@ -67,11 +67,11 @@ namespace AsbCloudWebApi.Controllers [Route("{uid}/data")] public IActionResult PostData(string uid, [FromBody] IEnumerable dtos) { - var wellId = telemetryService.GetWellIdByTelemetryUid(uid); + var idWell = telemetryService.GetidWellByTelemetryUid(uid); DataService.UpdateData(uid, dtos); - if (wellId != null && dtos.Any()) - Task.Run(() => telemetryHubContext.Clients.Group($"well_{wellId}").SendAsync(nameof(ITelemetryHubClient.ReceiveDataSaub), dtos)); + if (idWell != null && dtos.Any()) + Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}").SendAsync(nameof(ITelemetryHubClient.ReceiveDataSaub), dtos)); telemetryTracker.SaveRequestDate(uid); return Ok(); @@ -87,11 +87,11 @@ namespace AsbCloudWebApi.Controllers [Route("{uid}/message")] public IActionResult PostMessages(string uid, [FromBody] IEnumerable dtos) { - var wellId = telemetryService.GetWellIdByTelemetryUid(uid); + var idWell = telemetryService.GetidWellByTelemetryUid(uid); messageService.Insert(uid, dtos); if (dtos.Any()) - Task.Run(() => telemetryHubContext.Clients.Group($"well_{wellId}").SendAsync(nameof(ITelemetryHubClient.ReceiveMessages), dtos)); + Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}").SendAsync(nameof(ITelemetryHubClient.ReceiveMessages), dtos)); telemetryTracker.SaveRequestDate(uid); return Ok(); diff --git a/AsbCloudWebApi/Controllers/WellController.cs b/AsbCloudWebApi/Controllers/WellController.cs index 493b83f8..75ca4011 100644 --- a/AsbCloudWebApi/Controllers/WellController.cs +++ b/AsbCloudWebApi/Controllers/WellController.cs @@ -38,36 +38,36 @@ namespace AsbCloudWebApi.Controllers return Ok(wells); } - [HttpGet("{wellId}/sections")] + [HttpGet("{idWell}/sections")] [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetSections(int wellId) + public IActionResult GetSections(int idWell) { var idCompany = User.GetCompanyId(); if (idCompany is null) return NoContent(); - if (wellService.IsCompanyOwnsWell((int)idCompany, wellId)) + if (wellService.IsCompanyOwnsWell((int)idCompany, idWell)) return Forbid(); - var dto = wellService.GetSections(wellId); + var dto = wellService.GetSections(idWell); return Ok(dto); } - [HttpGet("{wellId}/operations")] - [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] - public IActionResult GetOperations(int wellId) + [HttpGet("{idWell}/operations")] + [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] + public IActionResult GetOperations(int idWell) { var idCompany = User.GetCompanyId(); if (idCompany is null) return NoContent(); - if (wellService.IsCompanyOwnsWell((int)idCompany, wellId)) + if (wellService.IsCompanyOwnsWell((int)idCompany, idWell)) return Forbid(); - var dto = wellService.GetOperations(wellId); + var dto = wellService.GetOperations(idWell); return Ok(dto); } @@ -79,9 +79,7 @@ namespace AsbCloudWebApi.Controllers var idCompany = User.GetCompanyId(); if (idCompany is null) - { return NoContent(); - } var transmittingWells = wellService.GetTransmittingWells((int)idCompany); diff --git a/ConsoleApp1/Connected Services/OpenAPIService/OpenAPI.cs b/ConsoleApp1/Connected Services/OpenAPIService/OpenAPI.cs index b7a17a86..96bd88e8 100644 --- a/ConsoleApp1/Connected Services/OpenAPIService/OpenAPI.cs +++ b/ConsoleApp1/Connected Services/OpenAPIService/OpenAPI.cs @@ -345,34 +345,34 @@ namespace ConsoleApp1.OpenAPIService partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response); /// Возвращает данные САУБ по скважине. /// По умолчанию за последние 10 минут. - /// id скважины + /// id скважины /// дата начала выборки. По умолчанию: текущее время - intervalSec /// интервал времени даты начала выборки, секунды /// желаемое количество точек. Если в выборке точек будет больше, то выборка будет прорежена. /// Success /// A server side error occurred. - public System.Threading.Tasks.Task> DataAsync(int wellId, System.DateTimeOffset? begin, int? intervalSec, int? approxPointsCount) + public System.Threading.Tasks.Task> DataAsync(int idWell, System.DateTimeOffset? begin, int? intervalSec, int? approxPointsCount) { - return DataAsync(wellId, begin, intervalSec, approxPointsCount, System.Threading.CancellationToken.None); + return DataAsync(idWell, begin, intervalSec, approxPointsCount, System.Threading.CancellationToken.None); } /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// Возвращает данные САУБ по скважине. /// По умолчанию за последние 10 минут. - /// id скважины + /// id скважины /// дата начала выборки. По умолчанию: текущее время - intervalSec /// интервал времени даты начала выборки, секунды /// желаемое количество точек. Если в выборке точек будет больше, то выборка будет прорежена. /// Success /// A server side error occurred. - public async System.Threading.Tasks.Task> DataAsync(int wellId, System.DateTimeOffset? begin, int? intervalSec, int? approxPointsCount, System.Threading.CancellationToken cancellationToken) + public async System.Threading.Tasks.Task> DataAsync(int idWell, System.DateTimeOffset? begin, int? intervalSec, int? approxPointsCount, System.Threading.CancellationToken cancellationToken) { - if (wellId == null) - throw new System.ArgumentNullException("wellId"); + if (idWell == null) + throw new System.ArgumentNullException("idWell"); var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/well/{wellId}/data?"); - urlBuilder_.Replace("{wellId}", System.Uri.EscapeDataString(ConvertToString(wellId, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/well/{idWell}/data?"); + urlBuilder_.Replace("{idWell}", System.Uri.EscapeDataString(ConvertToString(idWell, System.Globalization.CultureInfo.InvariantCulture))); if (begin != null) { urlBuilder_.Append(System.Uri.EscapeDataString("begin") + "=").Append(System.Uri.EscapeDataString(begin.Value.ToString("s", System.Globalization.CultureInfo.InvariantCulture))).Append("&"); @@ -447,7 +447,7 @@ namespace ConsoleApp1.OpenAPIService } /// Выдает список сообщений по скважине - /// id скважины + /// id скважины /// для пагинации кол-во записей пропустить /// для пагинации кол-во записей /// список категорий @@ -455,14 +455,14 @@ namespace ConsoleApp1.OpenAPIService /// окончание /// Success /// A server side error occurred. - public System.Threading.Tasks.Task MessageAsync(int wellId, int? skip, int? take, System.Collections.Generic.IEnumerable categoryids, System.DateTimeOffset? begin, System.DateTimeOffset? end) + public System.Threading.Tasks.Task MessageAsync(int idWell, int? skip, int? take, System.Collections.Generic.IEnumerable categoryids, System.DateTimeOffset? begin, System.DateTimeOffset? end) { - return MessageAsync(wellId, skip, take, categoryids, begin, end, System.Threading.CancellationToken.None); + return MessageAsync(idWell, skip, take, categoryids, begin, end, System.Threading.CancellationToken.None); } /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// Выдает список сообщений по скважине - /// id скважины + /// id скважины /// для пагинации кол-во записей пропустить /// для пагинации кол-во записей /// список категорий @@ -470,14 +470,14 @@ namespace ConsoleApp1.OpenAPIService /// окончание /// Success /// A server side error occurred. - public async System.Threading.Tasks.Task MessageAsync(int wellId, int? skip, int? take, System.Collections.Generic.IEnumerable categoryids, System.DateTimeOffset? begin, System.DateTimeOffset? end, System.Threading.CancellationToken cancellationToken) + public async System.Threading.Tasks.Task MessageAsync(int idWell, int? skip, int? take, System.Collections.Generic.IEnumerable categoryids, System.DateTimeOffset? begin, System.DateTimeOffset? end, System.Threading.CancellationToken cancellationToken) { - if (wellId == null) - throw new System.ArgumentNullException("wellId"); + if (idWell == null) + throw new System.ArgumentNullException("idWell"); var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/well/{wellId}/message?"); - urlBuilder_.Replace("{wellId}", System.Uri.EscapeDataString(ConvertToString(wellId, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/well/{idWell}/message?"); + urlBuilder_.Replace("{idWell}", System.Uri.EscapeDataString(ConvertToString(idWell, System.Globalization.CultureInfo.InvariantCulture))); if (skip != null) { urlBuilder_.Append(System.Uri.EscapeDataString("skip") + "=").Append(System.Uri.EscapeDataString(ConvertToString(skip, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); diff --git a/ConsoleApp1/Connected Services/OpenAPIService/OpenAPI.nswag.json b/ConsoleApp1/Connected Services/OpenAPIService/OpenAPI.nswag.json index 77e1a983..802684de 100644 --- a/ConsoleApp1/Connected Services/OpenAPIService/OpenAPI.nswag.json +++ b/ConsoleApp1/Connected Services/OpenAPIService/OpenAPI.nswag.json @@ -73,7 +73,7 @@ } } }, - "/api/well/{wellId}/data": { + "/api/well/{idWell}/data": { "get": { "tags": [ "Data" @@ -82,7 +82,7 @@ "operationId": "GetData", "parameters": [ { - "name": "wellId", + "name": "idWell", "in": "path", "required": true, "description": "id скважины", @@ -154,7 +154,7 @@ } } }, - "/api/well/{wellId}/message": { + "/api/well/{idWell}/message": { "get": { "tags": [ "Message" @@ -163,7 +163,7 @@ "operationId": "GetMessage", "parameters": [ { - "name": "wellId", + "name": "idWell", "in": "path", "required": true, "description": "id скважины", diff --git a/ConsoleApp1/Program.cs b/ConsoleApp1/Program.cs index 073e92e0..48ddd878 100644 --- a/ConsoleApp1/Program.cs +++ b/ConsoleApp1/Program.cs @@ -21,11 +21,11 @@ namespace ConsoleApp1 // .Options; //var context = new AsbCloudDbContext(options); - //var wellId = 1; - //var dataSource = new ReportDataSourcePgCloud(context, wellId); + //var idWell = 1; + //var dataSource = new ReportDataSourcePgCloud(context, idWell); //var generator = new PdfGenerator(dataSource) //{ - // ReportDirectory = $"{wellId}", + // ReportDirectory = $"{idWell}", // Begin = DateTime.Now.AddYears(-30), // End = DateTime.Now.AddYears(30), // Step = TimeSpan.FromDays(1),