forked from ddrilling/AsbCloudServer
Получение drill test с панели
This commit is contained in:
parent
45c32b7f21
commit
2455013f79
41
AsbCloudApp/Data/SAUB/DrillTestDto.cs
Normal file
41
AsbCloudApp/Data/SAUB/DrillTestDto.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace AsbCloudApp.Data.SAUB
|
||||
{
|
||||
/// <summary>
|
||||
/// DTO для описания записи drill_test
|
||||
/// </summary>
|
||||
public class DrillTestDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Идентификатор drill test
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Идентификатор телеметрии drill test
|
||||
/// </summary>
|
||||
public int IdTelemetry { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Время начала drill test
|
||||
/// </summary>
|
||||
public int TimeStampStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Глубина начала drill test
|
||||
/// </summary>
|
||||
public float? DepthStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public virtual TelemetryDto Telemetry { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Параметры теста
|
||||
/// </summary>
|
||||
public IEnumerable<DrillTestParamsDto> Params { get; set; } = Enumerable.Empty<DrillTestParamsDto>();
|
||||
}
|
||||
}
|
53
AsbCloudApp/Data/SAUB/DrillTestParamsDto.cs
Normal file
53
AsbCloudApp/Data/SAUB/DrillTestParamsDto.cs
Normal file
@ -0,0 +1,53 @@
|
||||
namespace AsbCloudApp.Data.SAUB
|
||||
{
|
||||
/// <summary>
|
||||
/// Параметры Drill Test
|
||||
/// </summary>
|
||||
public class DrillTestParamsDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Идентификатор drill test
|
||||
/// </summary>
|
||||
public int IdDrillTest { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Идентификатор телеметрии drill test
|
||||
/// </summary>
|
||||
public int IdTelemetryDrillTest { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Шаг
|
||||
/// </summary>
|
||||
public int Step { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Нагрузка
|
||||
/// </summary>
|
||||
public float? Workload { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Заданная скорость
|
||||
/// </summary>
|
||||
public float? Speed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Скорость проходки
|
||||
/// </summary>
|
||||
public float? DepthSpeed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Время бурения шага
|
||||
/// </summary>
|
||||
public float? TimeDrillStep { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Глубина бурения шага
|
||||
/// </summary>
|
||||
public float? DepthDrillStep { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Drill test
|
||||
/// </summary>
|
||||
public virtual DrillTestDto DrillTest { get; set; } = null!;
|
||||
}
|
||||
}
|
21
AsbCloudApp/Repositories/IDrillTestRepository.cs
Normal file
21
AsbCloudApp/Repositories/IDrillTestRepository.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using AsbCloudApp.Data.SAUB;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudApp.Repositories
|
||||
{
|
||||
/// <summary>
|
||||
/// репозиторий по работе с данными drill_test
|
||||
/// </summary>
|
||||
public interface IDrillTestRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Сохранить данные drill_test
|
||||
/// </summary>
|
||||
/// <param name="idTelemetry">ключ телеметрии</param>
|
||||
/// <param name="dto">запись drill test</param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> SaveDataAsync(int idTelemetry, DrillTestDto dto, CancellationToken token);
|
||||
}
|
||||
}
|
8766
AsbCloudDb/Migrations/20231017055919_Add_Drill_Test.Designer.cs
generated
Normal file
8766
AsbCloudDb/Migrations/20231017055919_Add_Drill_Test.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
72
AsbCloudDb/Migrations/20231017055919_Add_Drill_Test.cs
Normal file
72
AsbCloudDb/Migrations/20231017055919_Add_Drill_Test.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class Add_Drill_Test : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "t_drill_test",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор"),
|
||||
id_telemetry = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор телеметрии"),
|
||||
timestamp_start = table.Column<int>(type: "integer", nullable: false, comment: "Время начала"),
|
||||
depthStart = table.Column<float>(type: "real", nullable: true, comment: "Глубина начала")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_t_drill_test", x => new { x.id, x.id_telemetry });
|
||||
table.ForeignKey(
|
||||
name: "FK_t_drill_test_t_telemetry_id_telemetry",
|
||||
column: x => x.id_telemetry,
|
||||
principalTable: "t_telemetry",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
},
|
||||
comment: "Drill_test");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "t_drill_test_parameter",
|
||||
columns: table => new
|
||||
{
|
||||
id_drill_test = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор drill test"),
|
||||
id_telemetry_drill_test = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор телеметрии drill test"),
|
||||
step = table.Column<int>(type: "integer", nullable: false, comment: "Шаг"),
|
||||
workload = table.Column<float>(type: "real", nullable: true, comment: "Нагрузка"),
|
||||
speed = table.Column<float>(type: "real", nullable: true, comment: "Заданная скорость"),
|
||||
depth_speed = table.Column<float>(type: "real", nullable: true, comment: "Скорость проходки"),
|
||||
time_drill_step = table.Column<float>(type: "real", nullable: true, comment: "Время бурения шага"),
|
||||
depth_drill_step = table.Column<float>(type: "real", nullable: true, comment: "Глубина бурения шага")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_t_drill_test_parameter", x => new { x.id_drill_test, x.id_telemetry_drill_test });
|
||||
table.ForeignKey(
|
||||
name: "FK_t_drill_test_parameter_t_drill_test_id_drill_test_id_teleme~",
|
||||
columns: x => new { x.id_drill_test, x.id_telemetry_drill_test },
|
||||
principalTable: "t_drill_test",
|
||||
principalColumns: new[] { "id", "id_telemetry" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
},
|
||||
comment: "Drill_test_parameter");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_drill_test_id_telemetry",
|
||||
table: "t_drill_test",
|
||||
column: "id_telemetry");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "t_drill_test_parameter");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "t_drill_test");
|
||||
}
|
||||
}
|
||||
}
|
@ -346,6 +346,86 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasComment("части программ бурения");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DrillTest", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasComment("Идентификатор");
|
||||
|
||||
b.Property<int>("IdTelemetry")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_telemetry")
|
||||
.HasComment("Идентификатор телеметрии");
|
||||
|
||||
b.Property<float?>("DepthStart")
|
||||
.HasColumnType("real")
|
||||
.HasColumnName("depthStart")
|
||||
.HasComment("Глубина начала");
|
||||
|
||||
b.Property<int>("TimeStampStart")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("timestamp_start")
|
||||
.HasComment("Время начала");
|
||||
|
||||
b.HasKey("Id", "IdTelemetry");
|
||||
|
||||
b.HasIndex("IdTelemetry");
|
||||
|
||||
b.ToTable("t_drill_test");
|
||||
|
||||
b.HasComment("Drill_test");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DrillTestParameter", b =>
|
||||
{
|
||||
b.Property<int>("IdDrillTest")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_drill_test")
|
||||
.HasComment("Идентификатор drill test");
|
||||
|
||||
b.Property<int>("IdTelemetryDrillTest")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_telemetry_drill_test")
|
||||
.HasComment("Идентификатор телеметрии drill test");
|
||||
|
||||
b.Property<float?>("DepthDrillStep")
|
||||
.HasColumnType("real")
|
||||
.HasColumnName("depth_drill_step")
|
||||
.HasComment("Глубина бурения шага");
|
||||
|
||||
b.Property<float?>("DepthSpeed")
|
||||
.HasColumnType("real")
|
||||
.HasColumnName("depth_speed")
|
||||
.HasComment("Скорость проходки");
|
||||
|
||||
b.Property<float?>("Speed")
|
||||
.HasColumnType("real")
|
||||
.HasColumnName("speed")
|
||||
.HasComment("Заданная скорость");
|
||||
|
||||
b.Property<int>("Step")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("step")
|
||||
.HasComment("Шаг");
|
||||
|
||||
b.Property<float?>("TimeDrillStep")
|
||||
.HasColumnType("real")
|
||||
.HasColumnName("time_drill_step")
|
||||
.HasComment("Время бурения шага");
|
||||
|
||||
b.Property<float?>("Workload")
|
||||
.HasColumnType("real")
|
||||
.HasColumnName("workload")
|
||||
.HasComment("Нагрузка");
|
||||
|
||||
b.HasKey("IdDrillTest", "IdTelemetryDrillTest");
|
||||
|
||||
b.ToTable("t_drill_test_parameter");
|
||||
|
||||
b.HasComment("Drill_test_parameter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Faq", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -7768,6 +7848,28 @@ namespace AsbCloudDb.Migrations
|
||||
b.Navigation("Well");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DrillTest", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
|
||||
.WithMany()
|
||||
.HasForeignKey("IdTelemetry")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Telemetry");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DrillTestParameter", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.DrillTest", "DrillTest")
|
||||
.WithMany("Params")
|
||||
.HasForeignKey("IdDrillTest", "IdTelemetryDrillTest")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("DrillTest");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Faq", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.User", "AuthorAnswer")
|
||||
@ -8563,6 +8665,11 @@ namespace AsbCloudDb.Migrations
|
||||
b.Navigation("RelatedUsers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DrillTest", b =>
|
||||
{
|
||||
b.Navigation("Params");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.FileInfo", b =>
|
||||
{
|
||||
b.Navigation("FileMarks");
|
||||
|
@ -81,8 +81,8 @@ namespace AsbCloudDb.Model
|
||||
public DbSet<NotificationCategory> NotificationCategories => Set<NotificationCategory>();
|
||||
public DbSet<Manual> Manuals => Set<Manual>();
|
||||
public DbSet<ManualDirectory> ManualDirectories => Set<ManualDirectory>();
|
||||
|
||||
|
||||
public DbSet<DrillTest> DrillTests => Set<DrillTest>();
|
||||
public DbSet<DrillTestParameter> DrillTestParameters => Set<DrillTestParameter>();
|
||||
public AsbCloudDbContext() : base()
|
||||
{
|
||||
Interlocked.Increment(ref referenceCount);
|
||||
@ -410,6 +410,19 @@ namespace AsbCloudDb.Model
|
||||
.HasForeignKey(m => m.IdDirectory)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<DrillTest>()
|
||||
.HasKey(m => new { m.Id, m.IdTelemetry });
|
||||
|
||||
modelBuilder.Entity<DrillTestParameter>()
|
||||
.HasKey(m => new { m.IdDrillTest, m.IdTelemetryDrillTest });
|
||||
|
||||
modelBuilder.Entity<DrillTestParameter>()
|
||||
.HasOne(m => m.DrillTest)
|
||||
.WithMany(f => f.Params)
|
||||
.HasForeignKey(x => new { x.IdDrillTest, x.IdTelemetryDrillTest})
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
|
||||
DefaultData.DefaultContextData.Fill(modelBuilder);
|
||||
}
|
||||
|
||||
|
41
AsbCloudDb/Model/DrillTest.cs
Normal file
41
AsbCloudDb/Model/DrillTest.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace AsbCloudDb.Model
|
||||
{
|
||||
[Table("t_drill_test"), Comment("Drill_test")]
|
||||
public class DrillTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Идентификатор drill test
|
||||
/// </summary>
|
||||
[Key, Column("id"), Comment("Идентификатор")]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Идентификатор телеметрии drill test
|
||||
/// </summary>
|
||||
[Key, Column("id_telemetry"), Comment("Идентификатор телеметрии")]
|
||||
public int IdTelemetry { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Время начала drill test
|
||||
/// </summary>
|
||||
[Column("timestamp_start"), Comment("Время начала")]
|
||||
public int TimeStampStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Глубина начала drill test
|
||||
/// </summary>
|
||||
[Column("depthStart"), Comment("Глубина начала")]
|
||||
public float? DepthStart { get; set; }
|
||||
|
||||
[ForeignKey(nameof(IdTelemetry))]
|
||||
public virtual Telemetry Telemetry { get; set; } = null!;
|
||||
|
||||
public virtual ICollection<DrillTestParameter> Params { get; set; } = null!;
|
||||
}
|
||||
}
|
60
AsbCloudDb/Model/DrillTestParameter.cs
Normal file
60
AsbCloudDb/Model/DrillTestParameter.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace AsbCloudDb.Model
|
||||
{
|
||||
[Table("t_drill_test_parameter"), Comment("Drill_test_parameter")]
|
||||
public class DrillTestParameter
|
||||
{
|
||||
/// <summary>
|
||||
/// Идентификатор drill test
|
||||
/// </summary>
|
||||
[Key, Column("id_drill_test"), Comment("Идентификатор drill test")]
|
||||
public int IdDrillTest { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Идентификатор телеметрии drill test
|
||||
/// </summary>
|
||||
[Key, Column("id_telemetry_drill_test"), Comment("Идентификатор телеметрии drill test")]
|
||||
public int IdTelemetryDrillTest { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Шаг
|
||||
/// </summary>
|
||||
[Column("step"), Comment("Шаг")]
|
||||
public int Step { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Нагрузка
|
||||
/// </summary>
|
||||
[Column("workload"), Comment("Нагрузка")]
|
||||
public float? Workload { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Заданная скорость
|
||||
/// </summary>
|
||||
[Column("speed"), Comment("Заданная скорость")]
|
||||
public float? Speed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Скорость проходки
|
||||
/// </summary>
|
||||
[Column("depth_speed"), Comment("Скорость проходки")]
|
||||
public float? DepthSpeed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Время бурения шага
|
||||
/// </summary>
|
||||
[Column("time_drill_step"), Comment("Время бурения шага")]
|
||||
public float? TimeDrillStep { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Глубина бурения шага
|
||||
/// </summary>
|
||||
[Column("depth_drill_step"), Comment("Глубина бурения шага")]
|
||||
public float? DepthDrillStep { get; set; }
|
||||
|
||||
public virtual DrillTest DrillTest { get; set; } = null!;
|
||||
}
|
||||
}
|
@ -74,6 +74,8 @@ namespace AsbCloudDb.Model
|
||||
DbSet<NotificationCategory> NotificationCategories { get; }
|
||||
DbSet<Manual> Manuals { get; }
|
||||
DbSet<ManualDirectory> ManualDirectories { get; }
|
||||
DbSet<DrillTest> DrillTests { get; }
|
||||
DbSet<DrillTestParameter> DrillTestParameters { get; }
|
||||
DatabaseFacade Database { get; }
|
||||
|
||||
Task<int> RefreshMaterializedViewAsync(string mwName, CancellationToken token);
|
||||
|
@ -165,6 +165,7 @@ namespace AsbCloudInfrastructure
|
||||
services.AddTransient<INotificationRepository, NotificationRepository>();
|
||||
services.AddTransient<ICrudRepository<NotificationCategoryDto>, CrudCacheRepositoryBase<NotificationCategoryDto,
|
||||
NotificationCategory>>();
|
||||
services.AddTransient<IDrillTestRepository, DrillTestRepository>();
|
||||
|
||||
// admin crud services:
|
||||
services.AddTransient<ICrudRepository<TelemetryDto>, CrudCacheRepositoryBase<TelemetryDto, Telemetry>>(s =>
|
||||
|
28
AsbCloudInfrastructure/Repository/DrillTestRepository.cs
Normal file
28
AsbCloudInfrastructure/Repository/DrillTestRepository.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using AsbCloudApp.Data.SAUB;
|
||||
using AsbCloudApp.Repositories;
|
||||
using AsbCloudDb.Model;
|
||||
using Mapster;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudInfrastructure.Repository
|
||||
{
|
||||
public class DrillTestRepository : IDrillTestRepository
|
||||
{
|
||||
private readonly IAsbCloudDbContext db;
|
||||
|
||||
public DrillTestRepository(IAsbCloudDbContext db)
|
||||
{
|
||||
this.db = db;
|
||||
}
|
||||
|
||||
public async Task<int> SaveDataAsync(int idTelemetry, DrillTestDto dto, CancellationToken token)
|
||||
{
|
||||
var entity = dto.Adapt<DrillTest>();
|
||||
entity.IdTelemetry = idTelemetry;
|
||||
db.DrillTests.Add(entity);
|
||||
var result = await db.SaveChangesAsync(token);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
73
AsbCloudWebApi/Controllers/SAUB/DrillTestController.cs
Normal file
73
AsbCloudWebApi/Controllers/SAUB/DrillTestController.cs
Normal file
@ -0,0 +1,73 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Data.GTR;
|
||||
using AsbCloudApp.Data.SAUB;
|
||||
using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudInfrastructure.Repository;
|
||||
using AsbCloudWebApi.SignalR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudWebApi.Controllers.SAUB
|
||||
{
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class DrillTestController : ControllerBase
|
||||
|
||||
{
|
||||
protected readonly IWellService wellService;
|
||||
private readonly ITelemetryService telemetryService;
|
||||
private readonly IDrillTestRepository drillTestRepository;
|
||||
private readonly IHubContext<TelemetryHub> telemetryHubContext;
|
||||
|
||||
public string SignalRMethodGetDataName { get; protected set; } = "ReceiveDrilltestData";
|
||||
|
||||
public DrillTestController(
|
||||
ITelemetryService telemetryService,
|
||||
IDrillTestRepository drillTestRepository,
|
||||
IWellService wellService,
|
||||
IHubContext<TelemetryHub> telemetryHubContext)
|
||||
{
|
||||
this.telemetryService = telemetryService;
|
||||
this.drillTestRepository = drillTestRepository;
|
||||
this.wellService = wellService;
|
||||
this.telemetryHubContext = telemetryHubContext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Метод получения данных drill_test и drill_test_params от панели оператора.
|
||||
/// Сохраняет в БД.
|
||||
/// </summary>
|
||||
/// <param name="uid">уникальный идентификатор записи drill_test</param>
|
||||
/// <param name="dto">запись drill test</param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{uid}")]
|
||||
public async Task<IActionResult> PostDataAsync(
|
||||
string uid,
|
||||
[FromBody] DrillTestDto dto,
|
||||
CancellationToken token)
|
||||
{
|
||||
var telemetry = telemetryService.GetOrCreateTelemetryByUid(uid);
|
||||
if(telemetry is null)
|
||||
throw new Exception($"Telemetry with RemoteUid: {uid} does not exist.");
|
||||
|
||||
await drillTestRepository.SaveDataAsync(telemetry.Id, dto, token);
|
||||
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
|
||||
if (idWell is not null)
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
var clients = telemetryHubContext.Clients.Group($"well_{idWell}");
|
||||
await clients.SendAsync(SignalRMethodGetDataName, dto);
|
||||
}, CancellationToken.None);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user