From 7f4b434a8ca124b20f5f1eded77c3d9cd4f3fb59 Mon Sep 17 00:00:00 2001 From: eugeniy_ivanov Date: Thu, 14 Jul 2022 03:47:11 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D0=B8=20=D0=91?= =?UTF-8?q?=D0=94=20,=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D0=B8=20=D0=94=D0=A2?= =?UTF-8?q?=D0=9E,=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5=D0=B9?= =?UTF-8?q?=D1=81=D1=8B,=20=D1=81=D0=B5=D1=80=D0=B2=D0=B8=D1=81=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudApp/Data/Subsystems/SubsystemDto.cs | 27 ++++++ .../Subsystems/SubsystemOperationTimeDto.cs | 48 ++++++++++ .../Data/Subsystems/SubsystemStatisticsDto.cs | 38 ++++++++ .../ISubsystemOperationTimeService.cs | 12 +++ .../Services/Subsystems/ISubsystemService.cs | 6 ++ .../Subsystems/ISubsystemStatisticsService.cs | 16 ++++ AsbCloudDb/Model/Subsystems/Subsystem.cs | 26 +++++ .../Subsystems/SubsystemOperationTime.cs | 39 ++++++++ AsbCloudInfrastructure/DependencyInjection.cs | 4 + ...SubsystemOperationTimeBackgroundService.cs | 24 +++++ .../SubsystemOperationTimeService.cs | 14 +++ .../Services/Subsystems/SubsystemService.cs | 14 +++ .../Subsystems/SubsystemStatisticService.cs | 30 ++++++ .../Subsystems/AdminSubsystemController.cs | 23 +++++ .../OperatingTimeSubsystemController.cs | 22 +++++ .../StatisticSubsystemsController.cs | 94 +++++++++++++++++++ 16 files changed, 437 insertions(+) create mode 100644 AsbCloudApp/Data/Subsystems/SubsystemDto.cs create mode 100644 AsbCloudApp/Data/Subsystems/SubsystemOperationTimeDto.cs create mode 100644 AsbCloudApp/Data/Subsystems/SubsystemStatisticsDto.cs create mode 100644 AsbCloudApp/Services/Subsystems/ISubsystemOperationTimeService.cs create mode 100644 AsbCloudApp/Services/Subsystems/ISubsystemService.cs create mode 100644 AsbCloudApp/Services/Subsystems/ISubsystemStatisticsService.cs create mode 100644 AsbCloudDb/Model/Subsystems/Subsystem.cs create mode 100644 AsbCloudDb/Model/Subsystems/SubsystemOperationTime.cs create mode 100644 AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeBackgroundService.cs create mode 100644 AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeService.cs create mode 100644 AsbCloudInfrastructure/Services/Subsystems/SubsystemService.cs create mode 100644 AsbCloudInfrastructure/Services/Subsystems/SubsystemStatisticService.cs create mode 100644 AsbCloudWebApi/Controllers/Subsystems/AdminSubsystemController.cs create mode 100644 AsbCloudWebApi/Controllers/Subsystems/OperatingTimeSubsystemController.cs create mode 100644 AsbCloudWebApi/Controllers/Subsystems/StatisticSubsystemsController.cs diff --git a/AsbCloudApp/Data/Subsystems/SubsystemDto.cs b/AsbCloudApp/Data/Subsystems/SubsystemDto.cs new file mode 100644 index 00000000..7bf2c0b6 --- /dev/null +++ b/AsbCloudApp/Data/Subsystems/SubsystemDto.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AsbCloudApp.Data.Subsystems +{ + /// + /// Описание параметров подсистемы + /// + public class SubsystemDto : IId + { + /// + /// Идентификатор подсистемы + /// + public int Id { get; set; } + /// + /// Наименование подсистемы + /// + public string Name { get; set; } + /// + /// Детальное описание подсистемы + /// + public string Description { get; set; } + } +} diff --git a/AsbCloudApp/Data/Subsystems/SubsystemOperationTimeDto.cs b/AsbCloudApp/Data/Subsystems/SubsystemOperationTimeDto.cs new file mode 100644 index 00000000..ccb923d7 --- /dev/null +++ b/AsbCloudApp/Data/Subsystems/SubsystemOperationTimeDto.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AsbCloudApp.Data.Subsystems +{ + /// + /// Модель информации о работе подсистемы + /// + public class SubsystemOperationTimeDto:IId + { + /// + /// Идентификатор + /// + public int Id { get; set; } + /// + /// ИД телеметрии по которой выдается информация + /// + public int IdTelemetry { get; set; } + public TelemetryBaseDto Telemetry { get; set; } + + /// + /// идентификатор подсистемы + /// + public int IdSubsystem { get; set; } + public SubsystemDto Subsystem { get; set; } + /// + /// дата/время включения подсистемы + /// + public DateTime DateStart { get; set; } + /// + /// дата/время выключения подсистемы + /// + public DateTime DateEnd { get; set; } + /// + /// глубина забоя на момент включения подсистемы + /// + public double DepthStart { get; set; } + /// + /// глубина забоя на момент выключения подсистемы + /// + public double DepthEnd { get; set; } + + + } +} diff --git a/AsbCloudApp/Data/Subsystems/SubsystemStatisticsDto.cs b/AsbCloudApp/Data/Subsystems/SubsystemStatisticsDto.cs new file mode 100644 index 00000000..6363bf2c --- /dev/null +++ b/AsbCloudApp/Data/Subsystems/SubsystemStatisticsDto.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AsbCloudApp.Data.Subsystems +{ + /// + /// Статистика подсистемы + /// + public class SubsystemStatisticsDto + { + + /// + /// Идентификатор подсистемы + /// + public int IdSubsystem { get; set; } + /// + /// Название подсистемы + /// + public string Subsystem { get; set; } + /// + /// наработка подсистемы + /// + public DateTime UsedTime { get; set; } + /// + /// коэффициент использования + /// + public TimeSpan KUsage { get; set; } + /// + /// коэффициент применения + /// + public TimeSpan K2 { get; set; } + + + } +} diff --git a/AsbCloudApp/Services/Subsystems/ISubsystemOperationTimeService.cs b/AsbCloudApp/Services/Subsystems/ISubsystemOperationTimeService.cs new file mode 100644 index 00000000..44e0b2d4 --- /dev/null +++ b/AsbCloudApp/Services/Subsystems/ISubsystemOperationTimeService.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AsbCloudApp.Services.Subsystems +{ + public interface ISubsystemOperationTimeService + { + } +} diff --git a/AsbCloudApp/Services/Subsystems/ISubsystemService.cs b/AsbCloudApp/Services/Subsystems/ISubsystemService.cs new file mode 100644 index 00000000..c9a51954 --- /dev/null +++ b/AsbCloudApp/Services/Subsystems/ISubsystemService.cs @@ -0,0 +1,6 @@ +namespace AsbCloudApp.Services.Subsystems +{ + internal interface ISubsystemService + { + } +} diff --git a/AsbCloudApp/Services/Subsystems/ISubsystemStatisticsService.cs b/AsbCloudApp/Services/Subsystems/ISubsystemStatisticsService.cs new file mode 100644 index 00000000..411baa9e --- /dev/null +++ b/AsbCloudApp/Services/Subsystems/ISubsystemStatisticsService.cs @@ -0,0 +1,16 @@ +using AsbCloudApp.Data.Subsystems; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace AsbCloudApp.Services.Subsystems +{ + public interface ISubsystemStatisticsService + { + Task> GetStatisticsAsync(CancellationToken token); + Task> GetPeriodStatisticsAsync(DateTime periodBegin, + DateTime periodEnd, + CancellationToken token = default); + } +} diff --git a/AsbCloudDb/Model/Subsystems/Subsystem.cs b/AsbCloudDb/Model/Subsystems/Subsystem.cs new file mode 100644 index 00000000..b781d4cb --- /dev/null +++ b/AsbCloudDb/Model/Subsystems/Subsystem.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations.Schema; + +namespace AsbCloudDb.Model.Subsystems +{ + [Table("t_subsystem"), Comment("Описание подсистем")] + public class Subsystem : IId + { + [Key] + [Column("id")] + public int Id { get; set; } + + [Column("name")] + [StringLength(255)] + public string? Name { get; set; } + + [Column("description")] + [StringLength(255)] + public string? Description { get; set; } + } + +} diff --git a/AsbCloudDb/Model/Subsystems/SubsystemOperationTime.cs b/AsbCloudDb/Model/Subsystems/SubsystemOperationTime.cs new file mode 100644 index 00000000..3e86ca6d --- /dev/null +++ b/AsbCloudDb/Model/Subsystems/SubsystemOperationTime.cs @@ -0,0 +1,39 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace AsbCloudDb.Model.Subsystems +{ + [Table("t_subsystem_operation_time"), Comment("наработки подсистем")] + public partial class SubsystemOperationTime : IId + { + [Key] + [Column("id")] + public int Id { get; set; } + + [Column("id_telemetry"), Comment("ИД телеметрии по которой выдается информация")] + public int IdTelemetry { get; set; } + + [Column("id_subsystem")] + public int IdSubsystem { get; set; } + + [Column("date_end"), Comment("дата/время включения подсистемы")] + public DateTime DateStart { get; set; } + [Column("date_end"), Comment("дата/время выключения подсистемы")] + public DateTime DateEnd { get; set; } + [Column("depth_start"), Comment("глубина забоя на момент включения подсистемы")] + public double DepthStart { get; set; } + [Column("depth_end"), Comment("глубина забоя на момент выключения подсистемы")] + public double DepthEnd { get; set; } + + [ForeignKey(nameof(IdSubsystem))] + public virtual Subsystem Subsystem { get; set; } + + [ForeignKey(nameof(IdTelemetry))] + public virtual Telemetry Telemetry { get; set; } + + + + } +} diff --git a/AsbCloudInfrastructure/DependencyInjection.cs b/AsbCloudInfrastructure/DependencyInjection.cs index c4cab363..de9a1889 100644 --- a/AsbCloudInfrastructure/DependencyInjection.cs +++ b/AsbCloudInfrastructure/DependencyInjection.cs @@ -1,7 +1,9 @@ using AsbCloudApp.Data; using AsbCloudApp.Data.SAUB; +using AsbCloudApp.Data.Subsystems; using AsbCloudApp.Services; using AsbCloudDb.Model; +using AsbCloudDb.Model.Subsystems; using AsbCloudInfrastructure.Repository; using AsbCloudInfrastructure.Services; using AsbCloudInfrastructure.Services.Cache; @@ -141,6 +143,8 @@ namespace AsbCloudInfrastructure dbSet => dbSet .Include(c => c.Wells) .Include(c => c.Deposit))); // может быть включен в сервис ClusterService + // Subsystem service + services.AddTransient, CrudCacheServiceBase>(); services.AddTransient, CrudCacheServiceBase>(); diff --git a/AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeBackgroundService.cs b/AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeBackgroundService.cs new file mode 100644 index 00000000..e4538522 --- /dev/null +++ b/AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeBackgroundService.cs @@ -0,0 +1,24 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace AsbCloudInfrastructure.Services.Subsystems +{ + internal class SubsystemOperationTimeBackgroundService : BackgroundService + { + private readonly string connectionString; + public SubsystemOperationTimeBackgroundService(IConfiguration configuration) + { + connectionString = configuration.GetConnectionString("DefaultConnection"); + } + protected override Task ExecuteAsync(CancellationToken token) + { + throw new NotImplementedException(); + } + } +} diff --git a/AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeService.cs b/AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeService.cs new file mode 100644 index 00000000..d756aec6 --- /dev/null +++ b/AsbCloudInfrastructure/Services/Subsystems/SubsystemOperationTimeService.cs @@ -0,0 +1,14 @@ +using AsbCloudApp.Services.Subsystems; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AsbCloudInfrastructure.Services.Subsystems +{ + internal class SubsystemOperationTimeService: ISubsystemOperationTimeService + { + + } +} diff --git a/AsbCloudInfrastructure/Services/Subsystems/SubsystemService.cs b/AsbCloudInfrastructure/Services/Subsystems/SubsystemService.cs new file mode 100644 index 00000000..f740c5fa --- /dev/null +++ b/AsbCloudInfrastructure/Services/Subsystems/SubsystemService.cs @@ -0,0 +1,14 @@ +using AsbCloudApp.Data.Subsystems; +using AsbCloudDb.Model; +using AsbCloudDb.Model.Subsystems; +using AsbCloudInfrastructure.Repository; + +namespace AsbCloudInfrastructure.Services.Subsystems +{ + internal class SubsystemService : CrudCacheServiceBase + { + public SubsystemService(IAsbCloudDbContext dbContext) : base(dbContext) + { + } + } +} diff --git a/AsbCloudInfrastructure/Services/Subsystems/SubsystemStatisticService.cs b/AsbCloudInfrastructure/Services/Subsystems/SubsystemStatisticService.cs new file mode 100644 index 00000000..d083bf8b --- /dev/null +++ b/AsbCloudInfrastructure/Services/Subsystems/SubsystemStatisticService.cs @@ -0,0 +1,30 @@ +using AsbCloudApp.Data.Subsystems; +using AsbCloudApp.Services.Subsystems; +using AsbCloudDb.Model; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace AsbCloudInfrastructure.Services.Subsystems +{ + internal class SubsystemStatisticService : ISubsystemStatisticsService + { + + private readonly IAsbCloudDbContext db; + + public SubsystemStatisticService(IAsbCloudDbContext db) + { + this.db = db; + } + public Task> GetPeriodStatisticsAsync(DateTime periodBegin, DateTime periodEnd, CancellationToken token = default) + { + throw new NotImplementedException(); + } + + public Task> GetStatisticsAsync(CancellationToken token) + { + throw new NotImplementedException(); + } + } +} diff --git a/AsbCloudWebApi/Controllers/Subsystems/AdminSubsystemController.cs b/AsbCloudWebApi/Controllers/Subsystems/AdminSubsystemController.cs new file mode 100644 index 00000000..3663f5df --- /dev/null +++ b/AsbCloudWebApi/Controllers/Subsystems/AdminSubsystemController.cs @@ -0,0 +1,23 @@ +using AsbCloudApp.Data.Subsystems; +using AsbCloudApp.Services; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace AsbCloudWebApi.Controllers.Subsystems +{ + /// + /// Редактор подсистем для админки + /// + [Route("api/admin/subsystem")] + [ApiController] + [Authorize] + public class AdminSubsystemController : CrudController> + { + public AdminSubsystemController(ICrudService service) + : base(service) + { + } + } + } + diff --git a/AsbCloudWebApi/Controllers/Subsystems/OperatingTimeSubsystemController.cs b/AsbCloudWebApi/Controllers/Subsystems/OperatingTimeSubsystemController.cs new file mode 100644 index 00000000..1e6d9451 --- /dev/null +++ b/AsbCloudWebApi/Controllers/Subsystems/OperatingTimeSubsystemController.cs @@ -0,0 +1,22 @@ +using AsbCloudApp.Data.Subsystems; +using AsbCloudApp.Services; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace AsbCloudWebApi.Controllers.Subsystems +{ + /// + /// Наработка подсистем + /// + [Route("api/[OperatingTimeSubsystem]")] + [ApiController] + [Authorize] + + public class OperatingTimeSubsystemController : ControllerBase + { + } + } diff --git a/AsbCloudWebApi/Controllers/Subsystems/StatisticSubsystemsController.cs b/AsbCloudWebApi/Controllers/Subsystems/StatisticSubsystemsController.cs new file mode 100644 index 00000000..1fafe82b --- /dev/null +++ b/AsbCloudWebApi/Controllers/Subsystems/StatisticSubsystemsController.cs @@ -0,0 +1,94 @@ +using AsbCloudApp.Data.Subsystems; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace AsbCloudWebApi.Controllers.Subsystems +{ + /// + /// Статистика наработки подсистем + /// + [Route("api/statisticsSubsystem")] + [ApiController] + [Authorize] + public class StatisticSubsystemsController : ControllerBase + { + + /// + /// получить без временного периода в запросе. + /// + [HttpGet] + [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] + public async Task GetStatisticsAsync(CancellationToken token = default) + { + var subsystemResult = new List() + { + new SubsystemStatisticsDto(){ + IdSubsystem = 1, + Subsystem = "test1", + UsedTime = System.DateTime.Now, + K2 = System.TimeSpan.MinValue, + KUsage = System.TimeSpan.MinValue + + }, + new SubsystemStatisticsDto(){ + IdSubsystem = 2, + Subsystem = "test2", + UsedTime = System.DateTime.Now, + K2 = System.TimeSpan.Zero, + KUsage = System.TimeSpan.Zero + }, + new SubsystemStatisticsDto(){ + IdSubsystem = 3, + Subsystem = "test3", + UsedTime = System.DateTime.Now, + K2 = System.TimeSpan.MaxValue, + KUsage = System.TimeSpan.MaxValue + } + }; + + return Ok(subsystemResult); + } + + + + //[HttpGet] + //[ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] + //public async Task GetStatisticsPeriodAsync(CancellationToken token = default, DateTime dateBegin , DateTime dateEnd) + //{ + // var subsystemResult = new List() + // { + // new SubsystemStatisticsDto(){ + // IdSubsystem = 1, + // Subsystem = "test1", + // UsedTime = System.DateTime.Now, + // K2 = System.TimeSpan.MinValue, + // KUsage = System.TimeSpan.MinValue + + // }, + // new SubsystemStatisticsDto(){ + // IdSubsystem = 2, + // Subsystem = "test2", + // UsedTime = System.DateTime.Now, + // K2 = System.TimeSpan.Zero, + // KUsage = System.TimeSpan.Zero + // }, + // new SubsystemStatisticsDto(){ + // IdSubsystem = 3, + // Subsystem = "test3", + // UsedTime = System.DateTime.Now, + // K2 = System.TimeSpan.MaxValue, + // KUsage = System.TimeSpan.MaxValue + // } + // }; + + // return Ok(subsystemResult); + //} + + + } +}