Добавлены модели БД ,модели ДТО, интерфейсы, сервисы

This commit is contained in:
eugeniy_ivanov 2022-07-14 03:47:11 +05:00
parent 2b633c8425
commit 7f4b434a8c
16 changed files with 437 additions and 0 deletions

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsbCloudApp.Data.Subsystems
{
/// <summary>
/// Описание параметров подсистемы
/// </summary>
public class SubsystemDto : IId
{
/// <summary>
/// Идентификатор подсистемы
/// </summary>
public int Id { get; set; }
/// <summary>
/// Наименование подсистемы
/// </summary>
public string Name { get; set; }
/// <summary>
/// Детальное описание подсистемы
/// </summary>
public string Description { get; set; }
}
}

View File

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsbCloudApp.Data.Subsystems
{
/// <summary>
/// Модель информации о работе подсистемы
/// </summary>
public class SubsystemOperationTimeDto:IId
{
/// <summary>
/// Идентификатор
/// </summary>
public int Id { get; set; }
/// <summary>
/// ИД телеметрии по которой выдается информация
/// </summary>
public int IdTelemetry { get; set; }
public TelemetryBaseDto Telemetry { get; set; }
/// <summary>
/// идентификатор подсистемы
/// </summary>
public int IdSubsystem { get; set; }
public SubsystemDto Subsystem { get; set; }
/// <summary>
/// дата/время включения подсистемы
/// </summary>
public DateTime DateStart { get; set; }
/// <summary>
/// дата/время выключения подсистемы
/// </summary>
public DateTime DateEnd { get; set; }
/// <summary>
/// глубина забоя на момент включения подсистемы
/// </summary>
public double DepthStart { get; set; }
/// <summary>
/// глубина забоя на момент выключения подсистемы
/// </summary>
public double DepthEnd { get; set; }
}
}

View File

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsbCloudApp.Data.Subsystems
{
/// <summary>
/// Статистика подсистемы
/// </summary>
public class SubsystemStatisticsDto
{
/// <summary>
/// Идентификатор подсистемы
/// </summary>
public int IdSubsystem { get; set; }
/// <summary>
/// Название подсистемы
/// </summary>
public string Subsystem { get; set; }
/// <summary>
/// наработка подсистемы
/// </summary>
public DateTime UsedTime { get; set; }
/// <summary>
/// коэффициент использования
/// </summary>
public TimeSpan KUsage { get; set; }
/// <summary>
/// коэффициент применения
/// </summary>
public TimeSpan K2 { get; set; }
}
}

View File

@ -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
{
}
}

View File

@ -0,0 +1,6 @@
namespace AsbCloudApp.Services.Subsystems
{
internal interface ISubsystemService
{
}
}

View File

@ -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<IEnumerable<SubsystemStatisticsDto>> GetStatisticsAsync(CancellationToken token);
Task<IEnumerable<SubsystemStatisticsDto>> GetPeriodStatisticsAsync(DateTime periodBegin,
DateTime periodEnd,
CancellationToken token = default);
}
}

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -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<ICrudService<SubsystemDto>, CrudCacheServiceBase<SubsystemDto, Subsystem>>();
services.AddTransient<ICrudService<PermissionDto>, CrudCacheServiceBase<PermissionDto, Permission>>();

View File

@ -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();
}
}
}

View File

@ -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
{
}
}

View File

@ -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<SubsystemDto, Subsystem>
{
public SubsystemService(IAsbCloudDbContext dbContext) : base(dbContext)
{
}
}
}

View File

@ -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<IEnumerable<SubsystemStatisticsDto>> GetPeriodStatisticsAsync(DateTime periodBegin, DateTime periodEnd, CancellationToken token = default)
{
throw new NotImplementedException();
}
public Task<IEnumerable<SubsystemStatisticsDto>> GetStatisticsAsync(CancellationToken token)
{
throw new NotImplementedException();
}
}
}

View File

@ -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
{
/// <summary>
/// Редактор подсистем для админки
/// </summary>
[Route("api/admin/subsystem")]
[ApiController]
[Authorize]
public class AdminSubsystemController : CrudController<SubsystemDto, ICrudService<SubsystemDto>>
{
public AdminSubsystemController(ICrudService<SubsystemDto> service)
: base(service)
{
}
}
}

View File

@ -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
{
/// <summary>
/// Наработка подсистем
/// </summary>
[Route("api/[OperatingTimeSubsystem]")]
[ApiController]
[Authorize]
public class OperatingTimeSubsystemController : ControllerBase
{
}
}

View File

@ -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
{
/// <summary>
/// Статистика наработки подсистем
/// </summary>
[Route("api/statisticsSubsystem")]
[ApiController]
[Authorize]
public class StatisticSubsystemsController : ControllerBase
{
/// <summary>
/// получить без временного периода в запросе.
/// </summary>
[HttpGet]
[ProducesResponseType(typeof(IEnumerable<SubsystemStatisticsDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetStatisticsAsync(CancellationToken token = default)
{
var subsystemResult = new List<SubsystemStatisticsDto>()
{
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<SubsystemStatisticsDto>), (int)System.Net.HttpStatusCode.OK)]
//public async Task<IActionResult> GetStatisticsPeriodAsync(CancellationToken token = default, DateTime dateBegin , DateTime dateEnd)
//{
// var subsystemResult = new List<SubsystemStatisticsDto>()
// {
// 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);
//}
}
}