forked from ddrilling/AsbCloudServer
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
bf7c0895b3
11
AsbCloudApp/Data/WellCompositeDto.cs
Normal file
11
AsbCloudApp/Data/WellCompositeDto.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace AsbCloudApp.Data
|
||||||
|
{
|
||||||
|
public class WellCompositeDto
|
||||||
|
{
|
||||||
|
public int IdWell { get; set; }
|
||||||
|
|
||||||
|
public int IdWellSrc { get; set; }
|
||||||
|
|
||||||
|
public int IdWellSectionType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -10,7 +10,6 @@ namespace AsbCloudApp.Services
|
|||||||
Task<Dictionary<int, string>> GetCategoriesAsync(CancellationToken token);
|
Task<Dictionary<int, string>> GetCategoriesAsync(CancellationToken token);
|
||||||
Task<MeasureDto> GetLastAsync(int idWell, int idCategory, CancellationToken token);
|
Task<MeasureDto> GetLastAsync(int idWell, int idCategory, CancellationToken token);
|
||||||
Task<IEnumerable<MeasureDto>> GetHisoryAsync(int idWell, CancellationToken token);
|
Task<IEnumerable<MeasureDto>> GetHisoryAsync(int idWell, CancellationToken token);
|
||||||
Task<IEnumerable<MeasureDto>> GetAllLastAsync(int idWell, CancellationToken token);
|
|
||||||
Task<int> InsertAsync(int idWell, MeasureDto data, CancellationToken token);
|
Task<int> InsertAsync(int idWell, MeasureDto data, CancellationToken token);
|
||||||
Task<int> UpdateAsync(int idWell, MeasureDto data, CancellationToken token);
|
Task<int> UpdateAsync(int idWell, MeasureDto data, CancellationToken token);
|
||||||
Task<int> MarkAsDeleteAsync(int idWell, int idData, CancellationToken token);
|
Task<int> MarkAsDeleteAsync(int idWell, int idData, CancellationToken token);
|
||||||
|
@ -10,7 +10,6 @@ namespace AsbCloudApp.Services
|
|||||||
Task<IEnumerable<WellDto>> GetWellsByCompanyAsync(int idCompany, CancellationToken token);
|
Task<IEnumerable<WellDto>> GetWellsByCompanyAsync(int idCompany, CancellationToken token);
|
||||||
Task<IEnumerable<WellDto>> GetTransmittingWellsAsync(int idCompany, CancellationToken token);
|
Task<IEnumerable<WellDto>> GetTransmittingWellsAsync(int idCompany, CancellationToken token);
|
||||||
Task<bool> IsCompanyInvolvedInWellAsync(int idCompany, int idWell, CancellationToken token);
|
Task<bool> IsCompanyInvolvedInWellAsync(int idCompany, int idWell, CancellationToken token);
|
||||||
Task<IEnumerable<WellOperationDto>> GetOperationsAsync(int idWell, CancellationToken token);
|
|
||||||
Task<string> GetWellCaptionByIdAsync(int idWell, CancellationToken token);
|
Task<string> GetWellCaptionByIdAsync(int idWell, CancellationToken token);
|
||||||
Task<IEnumerable<CompanyDto>> GetCompaniesAsync(int idWell, CancellationToken token);
|
Task<IEnumerable<CompanyDto>> GetCompaniesAsync(int idWell, CancellationToken token);
|
||||||
Task<WellDto> GetAsync(int idWell, CancellationToken token);
|
Task<WellDto> GetAsync(int idWell, CancellationToken token);
|
||||||
|
2585
AsbCloudDb/Migrations/20211012043133_Add_CompositeWell.Designer.cs
generated
Normal file
2585
AsbCloudDb/Migrations/20211012043133_Add_CompositeWell.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
54
AsbCloudDb/Migrations/20211012043133_Add_CompositeWell.cs
Normal file
54
AsbCloudDb/Migrations/20211012043133_Add_CompositeWell.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Migrations
|
||||||
|
{
|
||||||
|
public partial class Add_CompositeWell : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "t_сomposite_well",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id_well = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины получателя"),
|
||||||
|
id_well_src = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины композита"),
|
||||||
|
id_well_section_type = table.Column<int>(type: "integer", nullable: false, comment: "Id тип секции композита"),
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_t_сomposite_well", x => new { x.id_well, x.id_well_src, x.id_well_section_type });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "t_сomposite_well_src_t_well_id_fk",
|
||||||
|
column: x => x.id_well_src,
|
||||||
|
principalTable: "t_well",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "t_сomposite_well_t_well_id_fk",
|
||||||
|
column: x => x.id_well,
|
||||||
|
principalTable: "t_well",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "t_сomposite_well_t_well_section_type_id_fk",
|
||||||
|
column: x => x.id_well_src,
|
||||||
|
principalTable: "t_well_section_type",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
},
|
||||||
|
comment: "Композитная скважина");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_t_сomposite_well_id_well_src",
|
||||||
|
table: "t_сomposite_well",
|
||||||
|
column: "id_well_src");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "t_сomposite_well");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2582
AsbCloudDb/Migrations/20211012044236_Remove_CompositeWell_id.Designer.cs
generated
Normal file
2582
AsbCloudDb/Migrations/20211012044236_Remove_CompositeWell_id.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Migrations
|
||||||
|
{
|
||||||
|
public partial class Remove_CompositeWell_id : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Id",
|
||||||
|
table: "t_сomposite_well");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "Id",
|
||||||
|
table: "t_сomposite_well",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2582
AsbCloudDb/Migrations/20211012053725_Rename_CompositeWell_to_WellComposite.Designer.cs
generated
Normal file
2582
AsbCloudDb/Migrations/20211012053725_Rename_CompositeWell_to_WellComposite.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,93 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Migrations
|
||||||
|
{
|
||||||
|
public partial class Rename_CompositeWell_to_WellComposite : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "t_сomposite_well");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "t_well_сomposite",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id_well = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины получателя"),
|
||||||
|
id_well_src = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины композита"),
|
||||||
|
id_well_section_type = table.Column<int>(type: "integer", nullable: false, comment: "Id тип секции композита")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_t_well_сomposite", x => new { x.id_well, x.id_well_src, x.id_well_section_type });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "t_well_сomposite_src_t_well_id_fk",
|
||||||
|
column: x => x.id_well_src,
|
||||||
|
principalTable: "t_well",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "t_well_сomposite_t_well_id_fk",
|
||||||
|
column: x => x.id_well,
|
||||||
|
principalTable: "t_well",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "t_well_сomposite_t_well_section_type_id_fk",
|
||||||
|
column: x => x.id_well_src,
|
||||||
|
principalTable: "t_well_section_type",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
},
|
||||||
|
comment: "Композитная скважина");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_t_well_сomposite_id_well_src",
|
||||||
|
table: "t_well_сomposite",
|
||||||
|
column: "id_well_src");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "t_well_сomposite");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "t_сomposite_well",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id_well = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины получателя"),
|
||||||
|
id_well_src = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины композита"),
|
||||||
|
id_well_section_type = table.Column<int>(type: "integer", nullable: false, comment: "Id тип секции композита")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_t_сomposite_well", x => new { x.id_well, x.id_well_src, x.id_well_section_type });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "t_сomposite_well_src_t_well_id_fk",
|
||||||
|
column: x => x.id_well_src,
|
||||||
|
principalTable: "t_well",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "t_сomposite_well_t_well_id_fk",
|
||||||
|
column: x => x.id_well,
|
||||||
|
principalTable: "t_well",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "t_сomposite_well_t_well_section_type_id_fk",
|
||||||
|
column: x => x.id_well_src,
|
||||||
|
principalTable: "t_well_section_type",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
},
|
||||||
|
comment: "Композитная скважина");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_t_сomposite_well_id_well_src",
|
||||||
|
table: "t_сomposite_well",
|
||||||
|
column: "id_well_src");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1572,6 +1572,33 @@ namespace AsbCloudDb.Migrations
|
|||||||
.HasComment("скважины");
|
.HasComment("скважины");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("AsbCloudDb.Model.WellComposite", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("IdWell")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id_well")
|
||||||
|
.HasComment("Id скважины получателя");
|
||||||
|
|
||||||
|
b.Property<int>("IdWellSrc")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id_well_src")
|
||||||
|
.HasComment("Id скважины композита");
|
||||||
|
|
||||||
|
b.Property<int>("IdWellSectionType")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id_well_section_type")
|
||||||
|
.HasComment("Id тип секции композита");
|
||||||
|
|
||||||
|
b.HasKey("IdWell", "IdWellSrc", "IdWellSectionType");
|
||||||
|
|
||||||
|
b.HasIndex("IdWellSrc");
|
||||||
|
|
||||||
|
b.ToTable("t_well_сomposite");
|
||||||
|
|
||||||
|
b
|
||||||
|
.HasComment("Композитная скважина");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AsbCloudDb.Model.WellOperation", b =>
|
modelBuilder.Entity("AsbCloudDb.Model.WellOperation", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@ -2407,6 +2434,36 @@ namespace AsbCloudDb.Migrations
|
|||||||
b.Navigation("WellType");
|
b.Navigation("WellType");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("AsbCloudDb.Model.WellComposite", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("AsbCloudDb.Model.Well", "Well")
|
||||||
|
.WithMany("WellComposites")
|
||||||
|
.HasForeignKey("IdWell")
|
||||||
|
.HasConstraintName("t_well_сomposite_t_well_id_fk")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("AsbCloudDb.Model.Well", "WellSrc")
|
||||||
|
.WithMany("WellCompositeSrcs")
|
||||||
|
.HasForeignKey("IdWellSrc")
|
||||||
|
.HasConstraintName("t_well_сomposite_src_t_well_id_fk")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("AsbCloudDb.Model.WellSectionType", "WellSectionType")
|
||||||
|
.WithMany("WellComposites")
|
||||||
|
.HasForeignKey("IdWellSrc")
|
||||||
|
.HasConstraintName("t_well_сomposite_t_well_section_type_id_fk")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Well");
|
||||||
|
|
||||||
|
b.Navigation("WellSectionType");
|
||||||
|
|
||||||
|
b.Navigation("WellSrc");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AsbCloudDb.Model.WellOperation", b =>
|
modelBuilder.Entity("AsbCloudDb.Model.WellOperation", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("AsbCloudDb.Model.WellOperationCategory", "OperationCategory")
|
b.HasOne("AsbCloudDb.Model.WellOperationCategory", "OperationCategory")
|
||||||
@ -2492,6 +2549,10 @@ namespace AsbCloudDb.Migrations
|
|||||||
{
|
{
|
||||||
b.Navigation("RelationCompaniesWells");
|
b.Navigation("RelationCompaniesWells");
|
||||||
|
|
||||||
|
b.Navigation("WellComposites");
|
||||||
|
|
||||||
|
b.Navigation("WellCompositeSrcs");
|
||||||
|
|
||||||
b.Navigation("WellOperations");
|
b.Navigation("WellOperations");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2504,6 +2565,8 @@ namespace AsbCloudDb.Migrations
|
|||||||
{
|
{
|
||||||
b.Navigation("DrillParamsCollection");
|
b.Navigation("DrillParamsCollection");
|
||||||
|
|
||||||
|
b.Navigation("WellComposites");
|
||||||
|
|
||||||
b.Navigation("WellOperations");
|
b.Navigation("WellOperations");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ namespace AsbCloudDb.Model
|
|||||||
{
|
{
|
||||||
public virtual DbSet<Cluster> Clusters { get; set; }
|
public virtual DbSet<Cluster> Clusters { get; set; }
|
||||||
public virtual DbSet<Company> Companies { get; set; }
|
public virtual DbSet<Company> Companies { get; set; }
|
||||||
|
public virtual DbSet<WellComposite> WellComposites { get; set; }
|
||||||
public virtual DbSet<Deposit> Deposits { get; set; }
|
public virtual DbSet<Deposit> Deposits { get; set; }
|
||||||
public virtual DbSet<FileCategory> FileCategories { get; set; }
|
public virtual DbSet<FileCategory> FileCategories { get; set; }
|
||||||
public virtual DbSet<FileInfo> Files { get; set; }
|
public virtual DbSet<FileInfo> Files { get; set; }
|
||||||
@ -71,6 +72,29 @@ namespace AsbCloudDb.Model
|
|||||||
.HasConstraintName("t_cluster_t_deposit_id_fk");
|
.HasConstraintName("t_cluster_t_deposit_id_fk");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<WellComposite>(entity =>
|
||||||
|
{
|
||||||
|
entity.HasKey(
|
||||||
|
nameof(WellComposite.IdWell),
|
||||||
|
nameof(WellComposite.IdWellSrc),
|
||||||
|
nameof(WellComposite.IdWellSectionType));
|
||||||
|
|
||||||
|
entity.HasOne(d => d.Well)
|
||||||
|
.WithMany(p => p.WellComposites)
|
||||||
|
.HasForeignKey(d => d.IdWell)
|
||||||
|
.HasConstraintName("t_well_сomposite_t_well_id_fk");
|
||||||
|
|
||||||
|
entity.HasOne(d => d.WellSrc)
|
||||||
|
.WithMany(p => p.WellCompositeSrcs)
|
||||||
|
.HasForeignKey(d => d.IdWellSrc)
|
||||||
|
.HasConstraintName("t_well_сomposite_src_t_well_id_fk");
|
||||||
|
|
||||||
|
entity.HasOne(d => d.WellSectionType)
|
||||||
|
.WithMany(p => p.WellComposites)
|
||||||
|
.HasForeignKey(d => d.IdWellSrc)
|
||||||
|
.HasConstraintName("t_well_сomposite_t_well_section_type_id_fk");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<TelemetryDataSaub>(entity =>
|
modelBuilder.Entity<TelemetryDataSaub>(entity =>
|
||||||
{
|
{
|
||||||
entity.HasOne(d => d.Telemetry)
|
entity.HasOne(d => d.Telemetry)
|
||||||
|
@ -16,7 +16,6 @@ namespace AsbCloudDb.Model
|
|||||||
[Column("id_telemetry")]
|
[Column("id_telemetry")]
|
||||||
public int IdTelemetry { get; set; }
|
public int IdTelemetry { get; set; }
|
||||||
|
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
[ForeignKey(nameof(IdTelemetry))]
|
[ForeignKey(nameof(IdTelemetry))]
|
||||||
[InverseProperty(nameof(Model.Telemetry.Users))]
|
[InverseProperty(nameof(Model.Telemetry.Users))]
|
||||||
@ -37,7 +36,6 @@ namespace AsbCloudDb.Model
|
|||||||
[Column("level")]
|
[Column("level")]
|
||||||
public int? Level { get; set; }
|
public int? Level { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public string MakeDisplayName()
|
public string MakeDisplayName()
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(Surname))
|
if (!string.IsNullOrEmpty(Surname))
|
||||||
|
@ -20,7 +20,6 @@ namespace AsbCloudDb.Model
|
|||||||
[Column("id_role")]
|
[Column("id_role")]
|
||||||
public int? IdRole { get; set; }
|
public int? IdRole { get; set; }
|
||||||
|
|
||||||
|
|
||||||
[Column("login")]
|
[Column("login")]
|
||||||
[StringLength(255)]
|
[StringLength(255)]
|
||||||
public string Login { get; set; }
|
public string Login { get; set; }
|
||||||
|
@ -52,5 +52,11 @@ namespace AsbCloudDb.Model
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
[InverseProperty(nameof(WellOperation.Well))]
|
[InverseProperty(nameof(WellOperation.Well))]
|
||||||
public virtual ICollection<WellOperation> WellOperations { get; set; }
|
public virtual ICollection<WellOperation> WellOperations { get; set; }
|
||||||
|
|
||||||
|
[InverseProperty(nameof(WellComposite.Well))]
|
||||||
|
public virtual ICollection<WellComposite> WellComposites { get; set; }
|
||||||
|
|
||||||
|
[InverseProperty(nameof(WellComposite.WellSrc))]
|
||||||
|
public virtual ICollection<WellComposite> WellCompositeSrcs { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
32
AsbCloudDb/Model/WellComposite.cs
Normal file
32
AsbCloudDb/Model/WellComposite.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
namespace AsbCloudDb.Model
|
||||||
|
{
|
||||||
|
[Table("t_well_сomposite"), Comment("Композитная скважина")]
|
||||||
|
public class WellComposite : IIdWell
|
||||||
|
{
|
||||||
|
[Column("id_well"), Comment("Id скважины получателя")]
|
||||||
|
public int IdWell { get; set; }
|
||||||
|
|
||||||
|
[Column("id_well_src"), Comment("Id скважины композита")]
|
||||||
|
public int IdWellSrc { get; set; }
|
||||||
|
|
||||||
|
[Column("id_well_section_type"), Comment("Id тип секции композита")]
|
||||||
|
public int IdWellSectionType { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(IdWell))]
|
||||||
|
[InverseProperty(nameof(Model.Well.WellComposites))]
|
||||||
|
public virtual Well Well { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(IdWellSrc))]
|
||||||
|
[InverseProperty(nameof(Model.Well.WellCompositeSrcs))]
|
||||||
|
public virtual Well WellSrc { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(IdWellSectionType))]
|
||||||
|
[InverseProperty(nameof(Model.WellSectionType.WellComposites))]
|
||||||
|
public virtual WellSectionType WellSectionType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -25,5 +25,9 @@ namespace AsbCloudDb.Model
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
[InverseProperty(nameof(DrillParams.WellSectionType))]
|
[InverseProperty(nameof(DrillParams.WellSectionType))]
|
||||||
public virtual ICollection<DrillParams> DrillParamsCollection { get; set; }
|
public virtual ICollection<DrillParams> DrillParamsCollection { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
[InverseProperty(nameof(WellComposite.WellSectionType))]
|
||||||
|
public virtual ICollection<WellComposite> WellComposites { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,42 +47,6 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<MeasureDto>> GetAllLastAsync(int idWell, CancellationToken token)
|
|
||||||
{
|
|
||||||
var categories = await cacheCategories.WhereAsync(token).ConfigureAwait(false);
|
|
||||||
if (!categories.Any())
|
|
||||||
return default;
|
|
||||||
|
|
||||||
var queries = categories.Select(c => db.Measures.Include(m => m.Category)
|
|
||||||
.Where(m => m.IdWell == idWell && m.IdCategory == c.Id && !m.IsDeleted)
|
|
||||||
.OrderByDescending(m => m.Timestamp)
|
|
||||||
.Take(1)
|
|
||||||
);
|
|
||||||
|
|
||||||
var qi = queries.GetEnumerator();
|
|
||||||
qi.MoveNext();
|
|
||||||
var query = qi.Current;
|
|
||||||
while (qi.MoveNext())
|
|
||||||
query = query.Union(qi.Current);
|
|
||||||
|
|
||||||
//var query = db.Measures
|
|
||||||
// .Where(e => e.IdWell == idWell)
|
|
||||||
// .GroupBy(e => e.IdCategory)
|
|
||||||
// .Select(g => g.Where(e => e.Timestamp == g.Max(m => m.Timestamp)).First());
|
|
||||||
|
|
||||||
//var query = db.Measures
|
|
||||||
// .Where(m => m.IdWell == idWell && m.Timestamp == db.Measures
|
|
||||||
// .Where(subm => subm.IdWell == m.IdWell && subm.IdCategory == m.IdCategory).Max(subm => subm.Timestamp));
|
|
||||||
|
|
||||||
var entities = await query
|
|
||||||
.AsNoTracking()
|
|
||||||
.ToListAsync(token)
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
|
|
||||||
var dtos = entities.Adapt<MeasureDto, Measure>((d, s) => d.CategoryName = s.Category?.Name);
|
|
||||||
return dtos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<IEnumerable<MeasureDto>> GetHisoryAsync(int idWell, CancellationToken token)
|
public async Task<IEnumerable<MeasureDto>> GetHisoryAsync(int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
var query = db.Measures.Include(m => m.Category)
|
var query = db.Measures.Include(m => m.Category)
|
||||||
@ -105,6 +69,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
if (data.Data is null)
|
if (data.Data is null)
|
||||||
throw new ArgumentException("data.data is not optional", nameof(data));
|
throw new ArgumentException("data.data is not optional", nameof(data));
|
||||||
var entity = data.Adapt<Measure>();
|
var entity = data.Adapt<Measure>();
|
||||||
|
entity.IdWell = idWell;
|
||||||
db.Measures.Add(entity);
|
db.Measures.Add(entity);
|
||||||
return db.SaveChangesAsync(token);
|
return db.SaveChangesAsync(token);
|
||||||
}
|
}
|
||||||
@ -122,10 +87,10 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
.Where(m => m.Id == data.Id && !m.IsDeleted)
|
.Where(m => m.Id == data.Id && !m.IsDeleted)
|
||||||
.FirstOrDefaultAsync(token)
|
.FirstOrDefaultAsync(token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (entity is null)
|
if (entity is null)
|
||||||
throw new ArgumentException("id doesn't exist", nameof(data));
|
throw new ArgumentException("id doesn't exist", nameof(data));
|
||||||
|
|
||||||
|
entity.IdWell = idWell;
|
||||||
entity.Timestamp = data.Timestamp;
|
entity.Timestamp = data.Timestamp;
|
||||||
entity.Data = data.Data;
|
entity.Data = data.Data;
|
||||||
|
|
||||||
|
@ -52,18 +52,6 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
=> await cacheRelationCompaniesWells.ContainsAsync(r => r.IdWell == idWell &&
|
=> await cacheRelationCompaniesWells.ContainsAsync(r => r.IdWell == idWell &&
|
||||||
r.IdCompany == idCompany, token).ConfigureAwait(false);
|
r.IdCompany == idCompany, token).ConfigureAwait(false);
|
||||||
|
|
||||||
public async Task<IEnumerable<WellOperationDto>> GetOperationsAsync(int idWell, CancellationToken token)
|
|
||||||
{
|
|
||||||
var entities = await db.WellOperations.Where(o => o.IdWell == idWell)
|
|
||||||
.AsNoTracking()
|
|
||||||
.ToListAsync(token)
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
|
|
||||||
var dtos = entities.Adapt<WellOperationDto>();
|
|
||||||
|
|
||||||
return dtos;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static WellDto From(Well well)
|
private static WellDto From(Well well)
|
||||||
{
|
{
|
||||||
var wellDto = new WellDto
|
var wellDto = new WellDto
|
||||||
|
@ -32,17 +32,6 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[Route("lastAll")]
|
|
||||||
public async Task<IActionResult> GetAllLastAsync([FromRoute] int idWell, CancellationToken token = default)
|
|
||||||
{
|
|
||||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
|
||||||
return Forbid();
|
|
||||||
|
|
||||||
var result = await measureService.GetAllLastAsync(idWell, token).ConfigureAwait(false);
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("last/{idCategory}")]
|
[Route("last/{idCategory}")]
|
||||||
public async Task<IActionResult> GetLastAsync([FromRoute] int idWell, [FromRoute] int idCategory, CancellationToken token = default)
|
public async Task<IActionResult> GetLastAsync([FromRoute] int idWell, [FromRoute] int idCategory, CancellationToken token = default)
|
||||||
|
@ -18,7 +18,6 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
public class TelemetryController : ControllerBase
|
public class TelemetryController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IDataService DataService;
|
|
||||||
private readonly ITelemetryService telemetryService;
|
private readonly ITelemetryService telemetryService;
|
||||||
private readonly IMessageService messageService;
|
private readonly IMessageService messageService;
|
||||||
private readonly IEventService eventService;
|
private readonly IEventService eventService;
|
||||||
@ -28,14 +27,12 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
|
|
||||||
public TelemetryController(
|
public TelemetryController(
|
||||||
ITelemetryService telemetryService,
|
ITelemetryService telemetryService,
|
||||||
IDataService DataService,
|
|
||||||
IMessageService messageService,
|
IMessageService messageService,
|
||||||
IEventService eventService,
|
IEventService eventService,
|
||||||
ITelemetryUserService telemetryUserService,
|
ITelemetryUserService telemetryUserService,
|
||||||
IHubContext<TelemetryHub> telemetryHubContext,
|
IHubContext<TelemetryHub> telemetryHubContext,
|
||||||
ITelemetryTracker telemetryTracker)
|
ITelemetryTracker telemetryTracker)
|
||||||
{
|
{
|
||||||
this.DataService = DataService;
|
|
||||||
this.telemetryService = telemetryService;
|
this.telemetryService = telemetryService;
|
||||||
this.messageService = messageService;
|
this.messageService = messageService;
|
||||||
this.eventService = eventService;
|
this.eventService = eventService;
|
||||||
@ -59,31 +56,6 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: remove when panels update will be done.
|
|
||||||
/// <summary>
|
|
||||||
/// Принимает данные от разных систем по скважине
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uid">Уникальный идентификатор отправителя</param>
|
|
||||||
/// <param name="dtos">Данные</param>
|
|
||||||
/// <param name="token">Токен для отмены задачи</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost]
|
|
||||||
[Obsolete]
|
|
||||||
[Route("{uid}/data")]
|
|
||||||
public async Task<IActionResult> PostDataAsync(string uid, [FromBody] IEnumerable<TelemetryDataSaubDto> dtos,
|
|
||||||
CancellationToken token = default)
|
|
||||||
{
|
|
||||||
var idWell = telemetryService.GetidWellByTelemetryUid(uid);
|
|
||||||
await DataService.UpdateDataAsync(uid, dtos, token).ConfigureAwait(false);
|
|
||||||
|
|
||||||
if (idWell != null && dtos.Any())
|
|
||||||
await Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}")
|
|
||||||
.SendAsync("ReceiveDataSaub", dtos), token).ConfigureAwait(false);
|
|
||||||
|
|
||||||
telemetryTracker.SaveRequestDate(uid);
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Принимает список новых сообщений от телеметрии
|
/// Принимает список новых сообщений от телеметрии
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using AsbCloudDb.Model;
|
using AsbCloudApp.Data;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
|
|
||||||
namespace AsbCloudWebApi
|
namespace AsbCloudWebApi
|
||||||
@ -7,7 +7,7 @@ namespace AsbCloudWebApi
|
|||||||
{
|
{
|
||||||
public static int? GetCompanyId(this ClaimsPrincipal user)
|
public static int? GetCompanyId(this ClaimsPrincipal user)
|
||||||
{
|
{
|
||||||
var claimIdCompany = user.FindFirst(nameof(User.IdCompany));
|
var claimIdCompany = user.FindFirst(nameof(UserDto.IdCompany));
|
||||||
if (claimIdCompany is null)
|
if (claimIdCompany is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ namespace AsbCloudWebApi
|
|||||||
|
|
||||||
public static int? GetUserId(this ClaimsPrincipal user)
|
public static int? GetUserId(this ClaimsPrincipal user)
|
||||||
{
|
{
|
||||||
var userId = user.FindFirst(nameof(User.Id));
|
var userId = user.FindFirst(nameof(UserDto.Id));
|
||||||
if (userId is null)
|
if (userId is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user