forked from ddrilling/AsbCloudServer
Merge pull request '#7963103 Отображение общей наработки тальканата по всем объектам' (#17) from TelemetryWireline into dev
Reviewed-on: http://test.digitaldrilling.ru:8080/DDrilling/AsbCloudServer/pulls/17
This commit is contained in:
commit
5c9e656b01
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace AsbCloudApp.Data.SAUB
|
namespace AsbCloudApp.Data.SAUB
|
||||||
{
|
{
|
||||||
|
#nullable enable
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// DTO телеметрии наработки талевого каната
|
/// DTO телеметрии наработки талевого каната
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -32,5 +33,10 @@ namespace AsbCloudApp.Data.SAUB
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float ReplaceWarnSp { get; set; }
|
public float ReplaceWarnSp { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Информация по скважине
|
||||||
|
/// </summary>
|
||||||
|
public WellInfoDto WellInfo { get; set; } = null!;
|
||||||
}
|
}
|
||||||
|
#nullable disable
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Data.SAUB;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Repositories
|
||||||
|
{
|
||||||
|
#nullable enable
|
||||||
|
/// <summary>
|
||||||
|
/// Наработка талевого каната
|
||||||
|
/// </summary>
|
||||||
|
public interface ITelemetryWirelineRunOutRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Принимает данные от панели
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uid"></param>
|
||||||
|
/// <param name="dto"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<int> AddOrUpdateAsync(string uid, TelemetryWirelineRunOutDto dto, CancellationToken token);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Выдает данные по скважине
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <param name="wellInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<TelemetryWirelineRunOutDto?> GetOrDefaultAsync(int idWell, CancellationToken token);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Возвращает данные по всем скважинам
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idCompany"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<TelemetryWirelineRunOutDto>> GetAllAsync(int idCompany, CancellationToken token);
|
||||||
|
}
|
||||||
|
#nullable disable
|
||||||
|
}
|
6782
AsbCloudDb/Migrations/20230110035135_AddTable_t_telemetry_wireline_run_out.Designer.cs
generated
Normal file
6782
AsbCloudDb/Migrations/20230110035135_AddTable_t_telemetry_wireline_run_out.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Migrations
|
||||||
|
{
|
||||||
|
public partial class AddTable_t_telemetry_wireline_run_out : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "t_telemetry_wireline_run_out",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
id_well = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
id_telemetry = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
date_time = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||||
|
hauling = table.Column<float>(type: "real", nullable: false),
|
||||||
|
hauling_warn_sp = table.Column<float>(type: "real", nullable: false),
|
||||||
|
replace = table.Column<float>(type: "real", nullable: false),
|
||||||
|
replace_warn_sp = table.Column<float>(type: "real", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_t_telemetry_wireline_run_out", x => x.id);
|
||||||
|
},
|
||||||
|
comment: "Наработка талевого каната");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "t_telemetry_wireline_run_out");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
6778
AsbCloudDb/Migrations/20230110043915_UpdateTable_t_telemetry_wireline_run_out.Designer.cs
generated
Normal file
6778
AsbCloudDb/Migrations/20230110043915_UpdateTable_t_telemetry_wireline_run_out.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,26 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Migrations
|
||||||
|
{
|
||||||
|
public partial class UpdateTable_t_telemetry_wireline_run_out : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "id_well",
|
||||||
|
table: "t_telemetry_wireline_run_out");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "id_well",
|
||||||
|
table: "t_telemetry_wireline_run_out",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
6780
AsbCloudDb/Migrations/20230111043034_UpdateTable_t_telemetry_wireline_run_out_comment.Designer.cs
generated
Normal file
6780
AsbCloudDb/Migrations/20230111043034_UpdateTable_t_telemetry_wireline_run_out_comment.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,157 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Migrations
|
||||||
|
{
|
||||||
|
public partial class UpdateTable_t_telemetry_wireline_run_out_comment : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropPrimaryKey(
|
||||||
|
name: "PK_t_telemetry_wireline_run_out",
|
||||||
|
table: "t_telemetry_wireline_run_out");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "id",
|
||||||
|
table: "t_telemetry_wireline_run_out");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<float>(
|
||||||
|
name: "replace_warn_sp",
|
||||||
|
table: "t_telemetry_wireline_run_out",
|
||||||
|
type: "real",
|
||||||
|
nullable: false,
|
||||||
|
comment: "Наработка талевого каната до сигнализации о необходимости замены, т*км",
|
||||||
|
oldClrType: typeof(float),
|
||||||
|
oldType: "real");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<float>(
|
||||||
|
name: "replace",
|
||||||
|
table: "t_telemetry_wireline_run_out",
|
||||||
|
type: "real",
|
||||||
|
nullable: false,
|
||||||
|
comment: "Наработка талевого каната с момента замены каната, т*км",
|
||||||
|
oldClrType: typeof(float),
|
||||||
|
oldType: "real");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<int>(
|
||||||
|
name: "id_telemetry",
|
||||||
|
table: "t_telemetry_wireline_run_out",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
comment: "Идентификатор телеметрии",
|
||||||
|
oldClrType: typeof(int),
|
||||||
|
oldType: "integer")
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<float>(
|
||||||
|
name: "hauling_warn_sp",
|
||||||
|
table: "t_telemetry_wireline_run_out",
|
||||||
|
type: "real",
|
||||||
|
nullable: false,
|
||||||
|
comment: "Наработка талевого каната до сигнализации о необходимости перетяжки, т*км",
|
||||||
|
oldClrType: typeof(float),
|
||||||
|
oldType: "real");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<float>(
|
||||||
|
name: "hauling",
|
||||||
|
table: "t_telemetry_wireline_run_out",
|
||||||
|
type: "real",
|
||||||
|
nullable: false,
|
||||||
|
comment: "Наработка талевого каната с момента перетяжки каната, т*км",
|
||||||
|
oldClrType: typeof(float),
|
||||||
|
oldType: "real");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<DateTimeOffset>(
|
||||||
|
name: "date_time",
|
||||||
|
table: "t_telemetry_wireline_run_out",
|
||||||
|
type: "timestamp with time zone",
|
||||||
|
nullable: false,
|
||||||
|
comment: "Отметка времени",
|
||||||
|
oldClrType: typeof(DateTimeOffset),
|
||||||
|
oldType: "timestamp with time zone");
|
||||||
|
|
||||||
|
migrationBuilder.AddPrimaryKey(
|
||||||
|
name: "PK_t_telemetry_wireline_run_out",
|
||||||
|
table: "t_telemetry_wireline_run_out",
|
||||||
|
column: "id_telemetry");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropPrimaryKey(
|
||||||
|
name: "PK_t_telemetry_wireline_run_out",
|
||||||
|
table: "t_telemetry_wireline_run_out");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<float>(
|
||||||
|
name: "replace_warn_sp",
|
||||||
|
table: "t_telemetry_wireline_run_out",
|
||||||
|
type: "real",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(float),
|
||||||
|
oldType: "real",
|
||||||
|
oldComment: "Наработка талевого каната до сигнализации о необходимости замены, т*км");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<float>(
|
||||||
|
name: "replace",
|
||||||
|
table: "t_telemetry_wireline_run_out",
|
||||||
|
type: "real",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(float),
|
||||||
|
oldType: "real",
|
||||||
|
oldComment: "Наработка талевого каната с момента замены каната, т*км");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<float>(
|
||||||
|
name: "hauling_warn_sp",
|
||||||
|
table: "t_telemetry_wireline_run_out",
|
||||||
|
type: "real",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(float),
|
||||||
|
oldType: "real",
|
||||||
|
oldComment: "Наработка талевого каната до сигнализации о необходимости перетяжки, т*км");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<float>(
|
||||||
|
name: "hauling",
|
||||||
|
table: "t_telemetry_wireline_run_out",
|
||||||
|
type: "real",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(float),
|
||||||
|
oldType: "real",
|
||||||
|
oldComment: "Наработка талевого каната с момента перетяжки каната, т*км");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<DateTimeOffset>(
|
||||||
|
name: "date_time",
|
||||||
|
table: "t_telemetry_wireline_run_out",
|
||||||
|
type: "timestamp with time zone",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(DateTimeOffset),
|
||||||
|
oldType: "timestamp with time zone",
|
||||||
|
oldComment: "Отметка времени");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<int>(
|
||||||
|
name: "id_telemetry",
|
||||||
|
table: "t_telemetry_wireline_run_out",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(int),
|
||||||
|
oldType: "integer",
|
||||||
|
oldComment: "Идентификатор телеметрии")
|
||||||
|
.OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "id",
|
||||||
|
table: "t_telemetry_wireline_run_out",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
migrationBuilder.AddPrimaryKey(
|
||||||
|
name: "PK_t_telemetry_wireline_run_out",
|
||||||
|
table: "t_telemetry_wireline_run_out",
|
||||||
|
column: "id");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3550,6 +3550,48 @@ namespace AsbCloudDb.Migrations
|
|||||||
b.HasComment("Пользователи панели САУБ. Для сообщений.");
|
b.HasComment("Пользователи панели САУБ. Для сообщений.");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("AsbCloudDb.Model.TelemetryWirelineRunOut", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("IdTelemetry")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id_telemetry")
|
||||||
|
.HasComment("Идентификатор телеметрии");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("IdTelemetry"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateTime")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("date_time")
|
||||||
|
.HasComment("Отметка времени");
|
||||||
|
|
||||||
|
b.Property<float>("Hauling")
|
||||||
|
.HasColumnType("real")
|
||||||
|
.HasColumnName("hauling")
|
||||||
|
.HasComment("Наработка талевого каната с момента перетяжки каната, т*км");
|
||||||
|
|
||||||
|
b.Property<float>("HaulingWarnSp")
|
||||||
|
.HasColumnType("real")
|
||||||
|
.HasColumnName("hauling_warn_sp")
|
||||||
|
.HasComment("Наработка талевого каната до сигнализации о необходимости перетяжки, т*км");
|
||||||
|
|
||||||
|
b.Property<float>("Replace")
|
||||||
|
.HasColumnType("real")
|
||||||
|
.HasColumnName("replace")
|
||||||
|
.HasComment("Наработка талевого каната с момента замены каната, т*км");
|
||||||
|
|
||||||
|
b.Property<float>("ReplaceWarnSp")
|
||||||
|
.HasColumnType("real")
|
||||||
|
.HasColumnName("replace_warn_sp")
|
||||||
|
.HasComment("Наработка талевого каната до сигнализации о необходимости замены, т*км");
|
||||||
|
|
||||||
|
b.HasKey("IdTelemetry");
|
||||||
|
|
||||||
|
b.ToTable("t_telemetry_wireline_run_out");
|
||||||
|
|
||||||
|
b.HasComment("Наработка талевого каната");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AsbCloudDb.Model.User", b =>
|
modelBuilder.Entity("AsbCloudDb.Model.User", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
|
@ -52,6 +52,8 @@ namespace AsbCloudDb.Model
|
|||||||
public virtual DbSet<WellFinalDocument> WellFinalDocuments => Set<WellFinalDocument>();
|
public virtual DbSet<WellFinalDocument> WellFinalDocuments => Set<WellFinalDocument>();
|
||||||
public virtual DbSet<LimitingParameter> LimitingParameter => Set<LimitingParameter>();
|
public virtual DbSet<LimitingParameter> LimitingParameter => Set<LimitingParameter>();
|
||||||
|
|
||||||
|
public virtual DbSet<TelemetryWirelineRunOut> TelemetryWirelineRunOut => Set<TelemetryWirelineRunOut>();
|
||||||
|
|
||||||
// WITS
|
// WITS
|
||||||
public DbSet<WITS.Record1> Record1 => Set<WITS.Record1>();
|
public DbSet<WITS.Record1> Record1 => Set<WITS.Record1>();
|
||||||
public DbSet<WITS.Record7> Record7 => Set<WITS.Record7>();
|
public DbSet<WITS.Record7> Record7 => Set<WITS.Record7>();
|
||||||
|
@ -51,6 +51,7 @@ namespace AsbCloudDb.Model
|
|||||||
DbSet<OperationValue> OperationValues { get; }
|
DbSet<OperationValue> OperationValues { get; }
|
||||||
DbSet<WellFinalDocument> WellFinalDocuments { get; }
|
DbSet<WellFinalDocument> WellFinalDocuments { get; }
|
||||||
DbSet<LimitingParameter> LimitingParameter { get; }
|
DbSet<LimitingParameter> LimitingParameter { get; }
|
||||||
|
DbSet<TelemetryWirelineRunOut> TelemetryWirelineRunOut { get; }
|
||||||
|
|
||||||
DbSet<Record1> Record1 { get; }
|
DbSet<Record1> Record1 { get; }
|
||||||
DbSet<Record7> Record7 { get; }
|
DbSet<Record7> Record7 { get; }
|
||||||
|
30
AsbCloudDb/Model/TelemetryWirelineRunOut.cs
Normal file
30
AsbCloudDb/Model/TelemetryWirelineRunOut.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Model
|
||||||
|
{
|
||||||
|
[Table("t_telemetry_wireline_run_out"), Comment("Наработка талевого каната")]
|
||||||
|
public class TelemetryWirelineRunOut
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[Column("id_telemetry"), Comment("Идентификатор телеметрии")]
|
||||||
|
public int IdTelemetry { get; set; }
|
||||||
|
|
||||||
|
[Column("date_time"), Comment("Отметка времени")]
|
||||||
|
public DateTimeOffset DateTime { get; set; }
|
||||||
|
|
||||||
|
[Column("hauling"), Comment("Наработка талевого каната с момента перетяжки каната, т*км")]
|
||||||
|
public float Hauling { get; set; }
|
||||||
|
|
||||||
|
[Column("hauling_warn_sp"), Comment("Наработка талевого каната до сигнализации о необходимости перетяжки, т*км")]
|
||||||
|
public float HaulingWarnSp { get; set; }
|
||||||
|
|
||||||
|
[Column("replace"), Comment("Наработка талевого каната с момента замены каната, т*км")]
|
||||||
|
public float Replace { get; set; }
|
||||||
|
|
||||||
|
[Column("replace_warn_sp"), Comment("Наработка талевого каната до сигнализации о необходимости замены, т*км")]
|
||||||
|
public float ReplaceWarnSp { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,12 @@ namespace AsbCloudInfrastructure
|
|||||||
{
|
{
|
||||||
public static class DateTimeExtentions
|
public static class DateTimeExtentions
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Приветсти к UTC из времени куста
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="date"></param>
|
||||||
|
/// <param name="remoteTimezoneOffsetHours"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static DateTimeOffset ToUtcDateTimeOffset(this DateTime date, double remoteTimezoneOffsetHours)
|
public static DateTimeOffset ToUtcDateTimeOffset(this DateTime date, double remoteTimezoneOffsetHours)
|
||||||
{
|
{
|
||||||
if (date == default)
|
if (date == default)
|
||||||
@ -18,6 +24,12 @@ namespace AsbCloudInfrastructure
|
|||||||
return new DateTimeOffset(dateUtc);
|
return new DateTimeOffset(dateUtc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Привести ко времени куста из utc
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="date"></param>
|
||||||
|
/// <param name="remoteTimezoneOffsetHours"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static DateTime ToRemoteDateTime(this DateTimeOffset date, double remoteTimezoneOffsetHours)
|
public static DateTime ToRemoteDateTime(this DateTimeOffset date, double remoteTimezoneOffsetHours)
|
||||||
{
|
{
|
||||||
if (date == default)
|
if (date == default)
|
||||||
|
@ -169,6 +169,8 @@ namespace AsbCloudInfrastructure
|
|||||||
services.AddTransient<IUserRoleRepository, UserRoleRepository>();
|
services.AddTransient<IUserRoleRepository, UserRoleRepository>();
|
||||||
services.AddTransient<IUserRepository, UserRepository>();
|
services.AddTransient<IUserRepository, UserRepository>();
|
||||||
services.AddTransient<ILimitingParameterRepository, LimitingParameterRepository>();
|
services.AddTransient<ILimitingParameterRepository, LimitingParameterRepository>();
|
||||||
|
services.AddTransient<ITelemetryWirelineRunOutRepository, TelemetryWirelineRunOutRepository>();
|
||||||
|
|
||||||
// Subsystem service
|
// Subsystem service
|
||||||
services.AddTransient<ICrudRepository<SubsystemDto>, CrudCacheRepositoryBase<SubsystemDto, Subsystem>>();
|
services.AddTransient<ICrudRepository<SubsystemDto>, CrudCacheRepositoryBase<SubsystemDto, Subsystem>>();
|
||||||
services.AddTransient<ISubsystemService, SubsystemService>();
|
services.AddTransient<ISubsystemService, SubsystemService>();
|
||||||
|
@ -0,0 +1,115 @@
|
|||||||
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Data.SAUB;
|
||||||
|
using AsbCloudApp.Repositories;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
|
using AsbCloudDb;
|
||||||
|
using AsbCloudDb.Model;
|
||||||
|
using AsbCloudInfrastructure.Services.SAUB;
|
||||||
|
using Mapster;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudInfrastructure.Repository
|
||||||
|
{
|
||||||
|
#nullable enable
|
||||||
|
public class TelemetryWirelineRunOutRepository : ITelemetryWirelineRunOutRepository
|
||||||
|
{
|
||||||
|
private readonly IAsbCloudDbContext context;
|
||||||
|
private readonly ITelemetryService telemetryService;
|
||||||
|
private readonly IWellService wellService;
|
||||||
|
|
||||||
|
public TelemetryWirelineRunOutRepository(IAsbCloudDbContext context,
|
||||||
|
ITelemetryService telemetryService,
|
||||||
|
IWellService wellService)
|
||||||
|
{
|
||||||
|
this.context = context;
|
||||||
|
this.telemetryService = telemetryService;
|
||||||
|
this.wellService = wellService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public async Task<int> AddOrUpdateAsync(string uid, TelemetryWirelineRunOutDto dto, CancellationToken token)
|
||||||
|
{
|
||||||
|
var idTelemetry = telemetryService.GetOrCreateTelemetryIdByUid(uid);
|
||||||
|
var timezoneOffset = telemetryService.GetTimezone(idTelemetry).Hours;
|
||||||
|
var entity = Convert(idTelemetry, dto, timezoneOffset);
|
||||||
|
|
||||||
|
var updatingItem = context.TelemetryWirelineRunOut
|
||||||
|
.Where(x => x.IdTelemetry == idTelemetry)
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
|
if (updatingItem is null)
|
||||||
|
context.TelemetryWirelineRunOut.Add(entity);
|
||||||
|
else
|
||||||
|
context.TelemetryWirelineRunOut.Update(entity);
|
||||||
|
|
||||||
|
return await context.SaveChangesAsync(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public async Task<TelemetryWirelineRunOutDto?> GetOrDefaultAsync(int idWell, CancellationToken token)
|
||||||
|
{
|
||||||
|
var well = await wellService.GetOrDefaultAsync(idWell, token).ConfigureAwait(false);
|
||||||
|
if (well is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return await GetOrDefaultAsync(well, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<TelemetryWirelineRunOutDto?> GetOrDefaultAsync(WellDto well, CancellationToken token)
|
||||||
|
{
|
||||||
|
var idTelemetry = telemetryService.GetOrDefaultIdTelemetryByIdWell(well.Id);
|
||||||
|
if (idTelemetry is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var entity = await context.TelemetryWirelineRunOut
|
||||||
|
.Where(x => x.IdTelemetry == idTelemetry)
|
||||||
|
.AsNoTracking()
|
||||||
|
.FirstOrDefaultAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (entity is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var timezoneHours = well.Timezone.Hours;
|
||||||
|
return Convert(entity, well, timezoneHours);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public async Task<IEnumerable<TelemetryWirelineRunOutDto>> GetAllAsync(int idCompany, CancellationToken token)
|
||||||
|
{
|
||||||
|
var wells = await wellService.GetWellsByCompanyAsync(idCompany, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
var result = new List<TelemetryWirelineRunOutDto>(wells.Count());
|
||||||
|
foreach (var well in wells)
|
||||||
|
{
|
||||||
|
var dto = await GetOrDefaultAsync(well, token);
|
||||||
|
if (dto is not null)
|
||||||
|
result.Add(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TelemetryWirelineRunOut Convert(int idTelemetry, TelemetryWirelineRunOutDto dto, double timezoneOffset)
|
||||||
|
{
|
||||||
|
var entity = dto.Adapt<TelemetryWirelineRunOut>();
|
||||||
|
entity.IdTelemetry = idTelemetry;
|
||||||
|
entity.DateTime = dto.DateTime.ToUtcDateTimeOffset(timezoneOffset);
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TelemetryWirelineRunOutDto Convert(TelemetryWirelineRunOut entity, WellDto well, double timezoneOffset)
|
||||||
|
{
|
||||||
|
var dto = entity.Adapt<TelemetryWirelineRunOutDto>();
|
||||||
|
dto.DateTime = entity.DateTime.ToRemoteDateTime(timezoneOffset);
|
||||||
|
dto.WellInfo = well;
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#nullable disable
|
||||||
|
}
|
@ -1,107 +0,0 @@
|
|||||||
using AsbCloudApp.Services;
|
|
||||||
using AsbCloudWebApi.SignalR;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
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 abstract class TelemetryInstantDataController<TDto> : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly ITelemetryService telemetryService;
|
|
||||||
private readonly IWellService wellService;
|
|
||||||
private readonly IHubContext<TelemetryHub> telemetryHubContext;
|
|
||||||
private readonly InstantDataRepository repository;
|
|
||||||
|
|
||||||
protected abstract string SirnalRMethodGetDataName { get; }
|
|
||||||
|
|
||||||
public TelemetryInstantDataController(
|
|
||||||
ITelemetryService telemetryService,
|
|
||||||
IWellService wellService,
|
|
||||||
IHubContext<TelemetryHub> telemetryHubContext,
|
|
||||||
InstantDataRepository repository)
|
|
||||||
{
|
|
||||||
this.telemetryService = telemetryService;
|
|
||||||
this.wellService = wellService;
|
|
||||||
this.telemetryHubContext = telemetryHubContext;
|
|
||||||
this.repository = repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Принимает данные от панели
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uid"></param>
|
|
||||||
/// <param name="dto"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost]
|
|
||||||
[Route("{uid}")]
|
|
||||||
[AllowAnonymous]
|
|
||||||
public virtual IActionResult PostData(
|
|
||||||
string uid,
|
|
||||||
[FromBody] TDto dto)
|
|
||||||
{
|
|
||||||
if (dto is null)
|
|
||||||
return BadRequest("Dto shouldn't be null");
|
|
||||||
|
|
||||||
var idTelemetry = telemetryService.GetOrCreateTelemetryIdByUid(uid);
|
|
||||||
|
|
||||||
var typedStore = repository.GetOrAdd(idTelemetry, (id) => new System.Collections.Concurrent.ConcurrentDictionary<Type, object>());
|
|
||||||
var typeDto = typeof(TDto);
|
|
||||||
typedStore.AddOrUpdate(typeDto, dto, (_, _) => dto);
|
|
||||||
|
|
||||||
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
|
|
||||||
if (idWell is not null)
|
|
||||||
_ = Task.Run(async () =>
|
|
||||||
{
|
|
||||||
var clients = telemetryHubContext.Clients.Group($"well_{idWell}");
|
|
||||||
await clients.SendAsync(SirnalRMethodGetDataName, dto);
|
|
||||||
}, CancellationToken.None);
|
|
||||||
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Выдает данные по скважине
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="idWell"></param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{idWell}")]
|
|
||||||
//[Permission]
|
|
||||||
public virtual async Task<ActionResult<TDto>> GetDataAsync(
|
|
||||||
int idWell,
|
|
||||||
CancellationToken token = default)
|
|
||||||
{
|
|
||||||
int? idCompany = User.GetCompanyId();
|
|
||||||
|
|
||||||
if (idCompany is null)
|
|
||||||
return Forbid();
|
|
||||||
|
|
||||||
bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
|
||||||
idWell, token).ConfigureAwait(false);
|
|
||||||
|
|
||||||
if (!isCompanyOwnsWell)
|
|
||||||
return Forbid();
|
|
||||||
|
|
||||||
int? idTelemetry = telemetryService.GetOrDefaultIdTelemetryByIdWell(idWell);
|
|
||||||
if (idTelemetry is null)
|
|
||||||
return NoContent();
|
|
||||||
|
|
||||||
var typedStore = repository.GetValueOrDefault((int)idTelemetry, null);
|
|
||||||
|
|
||||||
if (typedStore is null)
|
|
||||||
return NoContent();
|
|
||||||
|
|
||||||
var typeDto = typeof(TDto);
|
|
||||||
var dto = typedStore.GetValueOrDefault(typeDto);
|
|
||||||
|
|
||||||
return Ok(dto);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,26 +4,107 @@ using AsbCloudWebApi.SignalR;
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Threading;
|
||||||
|
using AsbCloudApp.Repositories;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers.SAUB
|
namespace AsbCloudWebApi.Controllers.SAUB
|
||||||
{
|
{
|
||||||
|
#nullable enable
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Наработка талевого каната
|
/// Наработка талевого каната
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
public class TelemetryWirelineRunOutController : TelemetryInstantDataController<TelemetryWirelineRunOutDto>
|
public class TelemetryWirelineRunOutController : ControllerBase
|
||||||
{
|
{
|
||||||
protected override string SirnalRMethodGetDataName => "ReceiveWirelineRunOut";
|
private readonly ITelemetryService telemetryService;
|
||||||
|
private readonly IWellService wellService;
|
||||||
|
private readonly IHubContext<TelemetryHub> telemetryHubContext;
|
||||||
|
private readonly ITelemetryWirelineRunOutRepository repository;
|
||||||
|
private string SirnalRMethodGetDataName => "ReceiveWirelineRunOut";
|
||||||
|
|
||||||
public TelemetryWirelineRunOutController(
|
public TelemetryWirelineRunOutController(
|
||||||
ITelemetryService telemetryService,
|
ITelemetryService telemetryService,
|
||||||
IWellService wellService,
|
IWellService wellService,
|
||||||
IHubContext<TelemetryHub> telemetryHubContext,
|
IHubContext<TelemetryHub> telemetryHubContext,
|
||||||
InstantDataRepository repository)
|
ITelemetryWirelineRunOutRepository repository)
|
||||||
: base(telemetryService, wellService, telemetryHubContext, repository)
|
|
||||||
{
|
{
|
||||||
|
this.telemetryService = telemetryService;
|
||||||
|
this.wellService = wellService;
|
||||||
|
this.telemetryHubContext = telemetryHubContext;
|
||||||
|
this.repository = repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Принимает данные от панели
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uid"></param>
|
||||||
|
/// <param name="dto"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("{uid}")]
|
||||||
|
[AllowAnonymous]
|
||||||
|
public IActionResult PostData(string uid, [FromBody] TelemetryWirelineRunOutDto dto, CancellationToken token)
|
||||||
|
{
|
||||||
|
if (dto is null)
|
||||||
|
return BadRequest("Dto shouldn't be null");
|
||||||
|
|
||||||
|
var data = repository.AddOrUpdateAsync(uid, 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(SirnalRMethodGetDataName, dto);
|
||||||
|
}, CancellationToken.None);
|
||||||
|
|
||||||
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Выдает данные по скважине
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("{idWell}")]
|
||||||
|
[Permission]
|
||||||
|
public async Task<ActionResult<TelemetryWirelineRunOutDto>> GetDataAsync(int idWell, CancellationToken token)
|
||||||
|
{
|
||||||
|
int? idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
|
if (idCompany is null)
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
|
bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
|
idWell, token).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (!isCompanyOwnsWell)
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
|
var dto = await repository.GetOrDefaultAsync(idWell, token);
|
||||||
|
|
||||||
|
if (dto is null)
|
||||||
|
return NoContent();
|
||||||
|
return Ok(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<IEnumerable<TelemetryWirelineRunOutDto>>> GetAllAsync(CancellationToken token)
|
||||||
|
{
|
||||||
|
int? idCompany = User.GetCompanyId();
|
||||||
|
if (idCompany is null)
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
|
var dtos = await repository.GetAllAsync((int)idCompany, token);
|
||||||
|
return Ok(dtos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user