forked from ddrilling/AsbCloudServer
Обновление модели и репозитория
1. Разделено сохранение блоков 2. Обновлена сущность суточного отчёта 3. Обновлена миграция 4. Обнолён репозиторий. Исправлены ошибки. Добавлен метод получения суточного отчёта по Id скважины и дате формирования. Переопределён метод Convert. Удалён метод AnyAsync, проверка за которую отвечал этот метод больше не требуется
This commit is contained in:
parent
87c8c84660
commit
940d56dc8f
@ -26,17 +26,8 @@ public interface IDailyReportRepository : ICrudRepository<DailyReportDto>
|
|||||||
/// Получить суточный отчёт
|
/// Получить суточный отчёт
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell"></param>
|
/// <param name="idWell"></param>
|
||||||
/// <param name="dateStart"></param>
|
/// <param name="date"></param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<DailyReportDto?> GetOrDefaultAsync(int idWell, DateTime dateStart, CancellationToken cancellationToken);
|
Task<DailyReportDto?> GetOrDefaultAsync(int idWell, DateTime date, CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Проверка существование суточного отчёта
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="idWell"></param>
|
|
||||||
/// <param name="dateStart"></param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<bool> AnyAsync(int idWell, DateTime dateStart, CancellationToken cancellationToken);
|
|
||||||
}
|
}
|
@ -13,7 +13,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
namespace AsbCloudDb.Migrations
|
namespace AsbCloudDb.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(AsbCloudDbContext))]
|
[DbContext(typeof(AsbCloudDbContext))]
|
||||||
[Migration("20231103095402_Update_DailyReport")]
|
[Migration("20231114051111_Update_DailyReport")]
|
||||||
partial class Update_DailyReport
|
partial class Update_DailyReport
|
||||||
{
|
{
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@ -122,7 +122,8 @@ namespace AsbCloudDb.Migrations
|
|||||||
.HasColumnName("caption");
|
.HasColumnName("caption");
|
||||||
|
|
||||||
b.Property<bool>("IsContact")
|
b.Property<bool>("IsContact")
|
||||||
.HasColumnType("boolean");
|
.HasColumnType("boolean")
|
||||||
|
.HasColumnName("is_contact");
|
||||||
|
|
||||||
b.Property<int>("Order")
|
b.Property<int>("Order")
|
||||||
.HasColumnType("integer")
|
.HasColumnType("integer")
|
||||||
@ -136,23 +137,72 @@ namespace AsbCloudDb.Migrations
|
|||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 1,
|
Id = 1,
|
||||||
Caption = "Недрапользователь",
|
Caption = "Недропользователь",
|
||||||
IsContact = false,
|
IsContact = true,
|
||||||
Order = 1
|
Order = 3
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 2,
|
Id = 2,
|
||||||
Caption = "Буровой подрядчик",
|
Caption = "Буровой подрядчик",
|
||||||
IsContact = false,
|
IsContact = true,
|
||||||
Order = 2
|
Order = 2
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 3,
|
Id = 3,
|
||||||
Caption = "Сервис автоматизации бурения",
|
Caption = "Сервис автоматизации бурения",
|
||||||
IsContact = false,
|
IsContact = true,
|
||||||
Order = 0
|
Order = 0
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 4,
|
||||||
|
Caption = "Сервис по ГТИ",
|
||||||
|
IsContact = true,
|
||||||
|
Order = 6
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 5,
|
||||||
|
Caption = "Растворный сервис",
|
||||||
|
IsContact = true,
|
||||||
|
Order = 4
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 6,
|
||||||
|
Caption = "Сервис по ННБ",
|
||||||
|
IsContact = true,
|
||||||
|
Order = 5
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 7,
|
||||||
|
Caption = "Служба супервайзинга",
|
||||||
|
IsContact = false,
|
||||||
|
Order = 1
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 9,
|
||||||
|
Caption = "Сервис по цементированию",
|
||||||
|
IsContact = true,
|
||||||
|
Order = 7
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 11,
|
||||||
|
Caption = "Дизельный сервис",
|
||||||
|
IsContact = false,
|
||||||
|
Order = 9
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 12,
|
||||||
|
Caption = "Сервис по обслуживанию верхних силовых приводов",
|
||||||
|
IsContact = true,
|
||||||
|
Order = 8
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -223,7 +273,7 @@ namespace AsbCloudDb.Migrations
|
|||||||
b.HasComment("Контакты");
|
b.HasComment("Контакты");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AsbCloudDb.Model.DailyReport", b =>
|
modelBuilder.Entity("AsbCloudDb.Model.DailyReports.DailyReport", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@ -231,34 +281,39 @@ namespace AsbCloudDb.Migrations
|
|||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<string>("Blocks")
|
b.Property<DateTime>("Date")
|
||||||
.HasColumnType("jsonb")
|
|
||||||
.HasColumnName("blocks")
|
|
||||||
.HasComment("Блоки использующиеся в отчёте");
|
|
||||||
|
|
||||||
b.Property<DateTime>("DateEnd")
|
|
||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
.HasColumnName("date_end")
|
.HasColumnName("date")
|
||||||
.HasComment("Конечная дата отчёта");
|
.HasComment("Дата формирования отчёта");
|
||||||
|
|
||||||
b.Property<DateTime?>("DateLastUpdate")
|
b.Property<DateTime?>("DateLastUpdate")
|
||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
.HasColumnName("date_last_update")
|
.HasColumnName("date_last_update")
|
||||||
.HasComment("Дата последнего обновления");
|
.HasComment("Дата последнего обновления");
|
||||||
|
|
||||||
b.Property<DateTime>("DateStart")
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasColumnName("date_start")
|
|
||||||
.HasComment("Начальная дата отчёта");
|
|
||||||
|
|
||||||
b.Property<int>("IdWell")
|
b.Property<int>("IdWell")
|
||||||
.HasColumnType("integer")
|
.HasColumnType("integer")
|
||||||
.HasColumnName("id_well")
|
.HasColumnName("id_well")
|
||||||
.HasComment("ID скважины");
|
.HasComment("ID скважины");
|
||||||
|
|
||||||
|
b.Property<string>("SignBlock")
|
||||||
|
.HasColumnType("jsonb")
|
||||||
|
.HasColumnName("sign_block")
|
||||||
|
.HasComment("Подпись");
|
||||||
|
|
||||||
|
b.Property<string>("SubsystemBlock")
|
||||||
|
.HasColumnType("jsonb")
|
||||||
|
.HasColumnName("subsystem_block")
|
||||||
|
.HasComment("Наработкой подсистем");
|
||||||
|
|
||||||
|
b.Property<string>("TimeBalanceBlock")
|
||||||
|
.HasColumnType("jsonb")
|
||||||
|
.HasColumnName("time_balance_block")
|
||||||
|
.HasComment("Баланс времени");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("IdWell", "DateStart")
|
b.HasIndex("IdWell", "Date")
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
|
|
||||||
b.ToTable("t_daily_report");
|
b.ToTable("t_daily_report");
|
||||||
@ -4598,14 +4653,14 @@ namespace AsbCloudDb.Migrations
|
|||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 65536,
|
Id = 65536,
|
||||||
Description = "Spin master",
|
Description = "Осцилляция",
|
||||||
Name = "Spin master"
|
Name = "Осцилляция"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 65537,
|
Id = 65537,
|
||||||
Description = "Torque master",
|
Description = "Демпфер",
|
||||||
Name = "Torque master"
|
Name = "Демпфер"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -7089,6 +7144,36 @@ namespace AsbCloudDb.Migrations
|
|||||||
Id = 33,
|
Id = 33,
|
||||||
Caption = "Техническая колонна 3",
|
Caption = "Техническая колонна 3",
|
||||||
Order = 2.2f
|
Order = 2.2f
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 34,
|
||||||
|
Caption = "Хвостовик 6",
|
||||||
|
Order = 6.5f
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 35,
|
||||||
|
Caption = "Хвостовик 7",
|
||||||
|
Order = 6.6f
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 36,
|
||||||
|
Caption = "Хвостовик 8",
|
||||||
|
Order = 6.7f
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 37,
|
||||||
|
Caption = "Хвостовик 9",
|
||||||
|
Order = 6.8f
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 38,
|
||||||
|
Caption = "Хвостовик 10",
|
||||||
|
Order = 6.9f
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -7864,7 +7949,7 @@ namespace AsbCloudDb.Migrations
|
|||||||
b.Navigation("Well");
|
b.Navigation("Well");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AsbCloudDb.Model.DailyReport", b =>
|
modelBuilder.Entity("AsbCloudDb.Model.DailyReports.DailyReport", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("AsbCloudDb.Model.Well", "Well")
|
b.HasOne("AsbCloudDb.Model.Well", "Well")
|
||||||
.WithMany()
|
.WithMany()
|
@ -30,20 +30,13 @@ namespace AsbCloudDb.Migrations
|
|||||||
defaultValue: 0)
|
defaultValue: 0)
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "blocks",
|
|
||||||
table: "t_daily_report",
|
|
||||||
type: "jsonb",
|
|
||||||
nullable: true,
|
|
||||||
comment: "Блоки использующиеся в отчёте");
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<DateTime>(
|
migrationBuilder.AddColumn<DateTime>(
|
||||||
name: "date_end",
|
name: "date",
|
||||||
table: "t_daily_report",
|
table: "t_daily_report",
|
||||||
type: "timestamp with time zone",
|
type: "timestamp with time zone",
|
||||||
nullable: false,
|
nullable: false,
|
||||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
comment: "Конечная дата отчёта");
|
comment: "Дата формирования отчёта");
|
||||||
|
|
||||||
migrationBuilder.AddColumn<DateTime>(
|
migrationBuilder.AddColumn<DateTime>(
|
||||||
name: "date_last_update",
|
name: "date_last_update",
|
||||||
@ -52,13 +45,26 @@ namespace AsbCloudDb.Migrations
|
|||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "Дата последнего обновления");
|
comment: "Дата последнего обновления");
|
||||||
|
|
||||||
migrationBuilder.AddColumn<DateTime>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "date_start",
|
name: "sign_block",
|
||||||
table: "t_daily_report",
|
table: "t_daily_report",
|
||||||
type: "timestamp with time zone",
|
type: "jsonb",
|
||||||
nullable: false,
|
nullable: true,
|
||||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
comment: "Подпись");
|
||||||
comment: "Начальная дата отчёта");
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "subsystem_block",
|
||||||
|
table: "t_daily_report",
|
||||||
|
type: "jsonb",
|
||||||
|
nullable: true,
|
||||||
|
comment: "Наработкой подсистем");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "time_balance_block",
|
||||||
|
table: "t_daily_report",
|
||||||
|
type: "jsonb",
|
||||||
|
nullable: true,
|
||||||
|
comment: "Баланс времени");
|
||||||
|
|
||||||
migrationBuilder.AddPrimaryKey(
|
migrationBuilder.AddPrimaryKey(
|
||||||
name: "PK_t_daily_report",
|
name: "PK_t_daily_report",
|
||||||
@ -66,9 +72,9 @@ namespace AsbCloudDb.Migrations
|
|||||||
column: "Id");
|
column: "Id");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_t_daily_report_id_well_date_start",
|
name: "IX_t_daily_report_id_well_date",
|
||||||
table: "t_daily_report",
|
table: "t_daily_report",
|
||||||
columns: new[] { "id_well", "date_start" },
|
columns: new[] { "id_well", "date" },
|
||||||
unique: true);
|
unique: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +85,7 @@ namespace AsbCloudDb.Migrations
|
|||||||
table: "t_daily_report");
|
table: "t_daily_report");
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
migrationBuilder.DropIndex(
|
||||||
name: "IX_t_daily_report_id_well_date_start",
|
name: "IX_t_daily_report_id_well_date",
|
||||||
table: "t_daily_report");
|
table: "t_daily_report");
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(
|
||||||
@ -87,11 +93,7 @@ namespace AsbCloudDb.Migrations
|
|||||||
table: "t_daily_report");
|
table: "t_daily_report");
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(
|
||||||
name: "blocks",
|
name: "date",
|
||||||
table: "t_daily_report");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "date_end",
|
|
||||||
table: "t_daily_report");
|
table: "t_daily_report");
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(
|
||||||
@ -99,7 +101,15 @@ namespace AsbCloudDb.Migrations
|
|||||||
table: "t_daily_report");
|
table: "t_daily_report");
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(
|
||||||
name: "date_start",
|
name: "sign_block",
|
||||||
|
table: "t_daily_report");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "subsystem_block",
|
||||||
|
table: "t_daily_report");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "time_balance_block",
|
||||||
table: "t_daily_report");
|
table: "t_daily_report");
|
||||||
|
|
||||||
migrationBuilder.AddColumn<DateOnly>(
|
migrationBuilder.AddColumn<DateOnly>(
|
@ -264,7 +264,7 @@ namespace AsbCloudDb.Migrations
|
|||||||
b.HasComment("Контакты");
|
b.HasComment("Контакты");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AsbCloudDb.Model.DailyReport", b =>
|
modelBuilder.Entity("AsbCloudDb.Model.DailyReports.DailyReport", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@ -272,34 +272,39 @@ namespace AsbCloudDb.Migrations
|
|||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<string>("Blocks")
|
b.Property<DateTime>("Date")
|
||||||
.HasColumnType("jsonb")
|
|
||||||
.HasColumnName("blocks")
|
|
||||||
.HasComment("Блоки использующиеся в отчёте");
|
|
||||||
|
|
||||||
b.Property<DateTime>("DateEnd")
|
|
||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
.HasColumnName("date_end")
|
.HasColumnName("date")
|
||||||
.HasComment("Конечная дата отчёта");
|
.HasComment("Дата формирования отчёта");
|
||||||
|
|
||||||
b.Property<DateTime?>("DateLastUpdate")
|
b.Property<DateTime?>("DateLastUpdate")
|
||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
.HasColumnName("date_last_update")
|
.HasColumnName("date_last_update")
|
||||||
.HasComment("Дата последнего обновления");
|
.HasComment("Дата последнего обновления");
|
||||||
|
|
||||||
b.Property<DateTime>("DateStart")
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasColumnName("date_start")
|
|
||||||
.HasComment("Начальная дата отчёта");
|
|
||||||
|
|
||||||
b.Property<int>("IdWell")
|
b.Property<int>("IdWell")
|
||||||
.HasColumnType("integer")
|
.HasColumnType("integer")
|
||||||
.HasColumnName("id_well")
|
.HasColumnName("id_well")
|
||||||
.HasComment("ID скважины");
|
.HasComment("ID скважины");
|
||||||
|
|
||||||
|
b.Property<string>("SignBlock")
|
||||||
|
.HasColumnType("jsonb")
|
||||||
|
.HasColumnName("sign_block")
|
||||||
|
.HasComment("Подпись");
|
||||||
|
|
||||||
|
b.Property<string>("SubsystemBlock")
|
||||||
|
.HasColumnType("jsonb")
|
||||||
|
.HasColumnName("subsystem_block")
|
||||||
|
.HasComment("Наработкой подсистем");
|
||||||
|
|
||||||
|
b.Property<string>("TimeBalanceBlock")
|
||||||
|
.HasColumnType("jsonb")
|
||||||
|
.HasColumnName("time_balance_block")
|
||||||
|
.HasComment("Баланс времени");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("IdWell", "DateStart")
|
b.HasIndex("IdWell", "Date")
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
|
|
||||||
b.ToTable("t_daily_report");
|
b.ToTable("t_daily_report");
|
||||||
@ -7935,7 +7940,7 @@ namespace AsbCloudDb.Migrations
|
|||||||
b.Navigation("Well");
|
b.Navigation("Well");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AsbCloudDb.Model.DailyReport", b =>
|
modelBuilder.Entity("AsbCloudDb.Model.DailyReports.DailyReport", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("AsbCloudDb.Model.Well", "Well")
|
b.HasOne("AsbCloudDb.Model.Well", "Well")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
|
@ -3,6 +3,7 @@ using AsbCloudDb.Model.Subsystems;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using AsbCloudDb.Model.DailyReports;
|
||||||
using AsbCloudDb.Model.Manuals;
|
using AsbCloudDb.Model.Manuals;
|
||||||
using AsbCloudDb.Model.ProcessMaps;
|
using AsbCloudDb.Model.ProcessMaps;
|
||||||
|
|
||||||
@ -333,10 +334,16 @@ namespace AsbCloudDb.Model
|
|||||||
|
|
||||||
modelBuilder.Entity<DailyReport>(entity =>
|
modelBuilder.Entity<DailyReport>(entity =>
|
||||||
{
|
{
|
||||||
entity.HasIndex(e => new { e.IdWell, e.DateStart })
|
entity.HasIndex(e => new { e.IdWell, e.Date })
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
|
|
||||||
entity.Property(e => e.Blocks)
|
entity.Property(e => e.SubsystemBlock)
|
||||||
|
.HasJsonConversion();
|
||||||
|
|
||||||
|
entity.Property(e => e.SignBlock)
|
||||||
|
.HasJsonConversion();
|
||||||
|
|
||||||
|
entity.Property(e => e.TimeBalanceBlock)
|
||||||
.HasJsonConversion();
|
.HasJsonConversion();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace AsbCloudDb.Model;
|
|
||||||
|
|
||||||
[Table("t_daily_report"), Comment("Ежедневные отчёты")]
|
|
||||||
public class DailyReport : IId
|
|
||||||
{
|
|
||||||
[Key]
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
[Column("id_well"), Comment("ID скважины")]
|
|
||||||
public int IdWell { get; set; }
|
|
||||||
|
|
||||||
[Column("date_last_update", TypeName = "timestamp with time zone"), Comment("Дата последнего обновления")]
|
|
||||||
public DateTime? DateLastUpdate { get; set; }
|
|
||||||
|
|
||||||
[Column("date_start", TypeName = "timestamp with time zone"), Comment("Начальная дата отчёта")]
|
|
||||||
public DateTime DateStart { get; set; }
|
|
||||||
|
|
||||||
[Column("date_end", TypeName = "timestamp with time zone"), Comment("Конечная дата отчёта")]
|
|
||||||
public DateTime DateEnd { get; set; }
|
|
||||||
|
|
||||||
[Column("blocks", TypeName = "jsonb"), Comment("Блоки использующиеся в отчёте")]
|
|
||||||
public string? Blocks { get; set; }
|
|
||||||
|
|
||||||
[ForeignKey(nameof(IdWell))]
|
|
||||||
public virtual Well Well { get; set; } = null!;
|
|
||||||
}
|
|
8
AsbCloudDb/Model/DailyReports/Blocks/Sign/SignBlock.cs
Normal file
8
AsbCloudDb/Model/DailyReports/Blocks/Sign/SignBlock.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace AsbCloudDb.Model.DailyReports.Blocks.Sign;
|
||||||
|
|
||||||
|
public class SignBlock : ItemInfo
|
||||||
|
{
|
||||||
|
public SignRecord? DrillingMaster { get; set; }
|
||||||
|
|
||||||
|
public SignRecord? Supervisor { get; set; }
|
||||||
|
}
|
10
AsbCloudDb/Model/DailyReports/Blocks/Sign/SignRecord.cs
Normal file
10
AsbCloudDb/Model/DailyReports/Blocks/Sign/SignRecord.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace AsbCloudDb.Model.DailyReports.Blocks.Sign;
|
||||||
|
|
||||||
|
public class SignRecord
|
||||||
|
{
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
|
||||||
|
public string Surname { get; set; } = null!;
|
||||||
|
|
||||||
|
public string? Patronymic { get; set; }
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Model.DailyReports.Blocks.Subsystem;
|
||||||
|
|
||||||
|
public class SubsystemBlock : ItemInfo
|
||||||
|
{
|
||||||
|
public double? WellBore { get; set; }
|
||||||
|
|
||||||
|
public double? MeasurementsPerDay { get; set; }
|
||||||
|
|
||||||
|
public double? TotalRopPlan { get; set; }
|
||||||
|
|
||||||
|
public string? Comment { get; set; }
|
||||||
|
|
||||||
|
public IEnumerable<SubsystemRecord>? Subsystems { get; set; }
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
namespace AsbCloudDb.Model.DailyReports.Blocks.Subsystem;
|
||||||
|
|
||||||
|
public class SubsystemRecord
|
||||||
|
{
|
||||||
|
public string SubsystemName { get; set; } = null!;
|
||||||
|
|
||||||
|
public int IdTimeInterval { get; set; }
|
||||||
|
|
||||||
|
public double? SumDepthInterval { get; set; }
|
||||||
|
|
||||||
|
public double? UsedTimeHours { get; set; }
|
||||||
|
|
||||||
|
public double? KUsage { get; set; }
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Model.DailyReports.Blocks.TimeBalance;
|
||||||
|
|
||||||
|
public class TimeBalanceBlock : ItemInfo
|
||||||
|
{
|
||||||
|
public int IdSection { get; set; }
|
||||||
|
|
||||||
|
public string? SectionName { get; set; }
|
||||||
|
|
||||||
|
public double? WellDepthPlan { get; set; }
|
||||||
|
|
||||||
|
public double WellDepthFact { get; set; }
|
||||||
|
|
||||||
|
public double? WellOperationSlipsTimeCount { get; set; }
|
||||||
|
|
||||||
|
public IEnumerable<TimeBalanceRecord>? WellOperations { get; set; }
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
namespace AsbCloudDb.Model.DailyReports.Blocks.TimeBalance;
|
||||||
|
|
||||||
|
public class TimeBalanceRecord
|
||||||
|
{
|
||||||
|
public int IdWellOperation { get; set; }
|
||||||
|
|
||||||
|
public double? DurationHoursPlan { get; set; }
|
||||||
|
|
||||||
|
public double? DurationHoursFact { get; set; }
|
||||||
|
|
||||||
|
public double? DrillingDeviationPerSection { get; set; }
|
||||||
|
|
||||||
|
public double? DrillingDeviationPerDay { get; set; }
|
||||||
|
|
||||||
|
public string? ReasonDeviation { get; set; }
|
||||||
|
}
|
37
AsbCloudDb/Model/DailyReports/DailyReport.cs
Normal file
37
AsbCloudDb/Model/DailyReports/DailyReport.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using AsbCloudDb.Model.DailyReports.Blocks.Sign;
|
||||||
|
using AsbCloudDb.Model.DailyReports.Blocks.Subsystem;
|
||||||
|
using AsbCloudDb.Model.DailyReports.Blocks.TimeBalance;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Model.DailyReports;
|
||||||
|
|
||||||
|
[Table("t_daily_report"), Comment("Ежедневные отчёты")]
|
||||||
|
public class DailyReport : IId
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Column("id_well"), Comment("ID скважины")]
|
||||||
|
public int IdWell { get; set; }
|
||||||
|
|
||||||
|
[Column("date_last_update", TypeName = "timestamp with time zone"), Comment("Дата последнего обновления")]
|
||||||
|
public DateTime? DateLastUpdate { get; set; }
|
||||||
|
|
||||||
|
[Column("date", TypeName = "timestamp with time zone"), Comment("Дата формирования отчёта")]
|
||||||
|
public DateTime Date { get; set; }
|
||||||
|
|
||||||
|
[Column("sign_block", TypeName = "jsonb"), Comment("Подпись")]
|
||||||
|
public SignBlock? SignBlock { get; set; }
|
||||||
|
|
||||||
|
[Column("time_balance_block", TypeName = "jsonb"), Comment("Баланс времени")]
|
||||||
|
public TimeBalanceBlock? TimeBalanceBlock { get; set; }
|
||||||
|
|
||||||
|
[Column("subsystem_block", TypeName = "jsonb"), Comment("Наработкой подсистем")]
|
||||||
|
public SubsystemBlock? SubsystemBlock { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(IdWell))]
|
||||||
|
public virtual Well Well { get; set; } = null!;
|
||||||
|
}
|
@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using AsbCloudDb.Model.DailyReports;
|
||||||
using AsbCloudDb.Model.Manuals;
|
using AsbCloudDb.Model.Manuals;
|
||||||
using AsbCloudDb.Model.ProcessMaps;
|
using AsbCloudDb.Model.ProcessMaps;
|
||||||
|
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.Json;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Data.DailyReport;
|
using AsbCloudApp.Data.DailyReport;
|
||||||
using AsbCloudApp.Data.DailyReport.Blocks.Sign;
|
|
||||||
using AsbCloudApp.Data.DailyReport.Blocks.Subsystems;
|
|
||||||
using AsbCloudApp.Data.DailyReport.Blocks.TimeBalance;
|
using AsbCloudApp.Data.DailyReport.Blocks.TimeBalance;
|
||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
using AsbCloudApp.Requests;
|
using AsbCloudApp.Requests;
|
||||||
using AsbCloudDb;
|
using AsbCloudDb;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
|
using AsbCloudDb.Model.DailyReports;
|
||||||
|
using Mapster;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Repository;
|
namespace AsbCloudInfrastructure.Repository;
|
||||||
@ -19,15 +19,6 @@ namespace AsbCloudInfrastructure.Repository;
|
|||||||
public class DailyReportRepository : CrudRepositoryBase<DailyReportDto, DailyReport>,
|
public class DailyReportRepository : CrudRepositoryBase<DailyReportDto, DailyReport>,
|
||||||
IDailyReportRepository
|
IDailyReportRepository
|
||||||
{
|
{
|
||||||
private class Blocks
|
|
||||||
{
|
|
||||||
public SubsystemBlockDto? Subsystem { get; set; }
|
|
||||||
|
|
||||||
public TimeBalanceBlockDto? TimeBalance { get; set; }
|
|
||||||
|
|
||||||
public SignBlockDto? Sign { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public DailyReportRepository(IAsbCloudDbContext dbContext)
|
public DailyReportRepository(IAsbCloudDbContext dbContext)
|
||||||
: base(dbContext)
|
: base(dbContext)
|
||||||
{
|
{
|
||||||
@ -41,10 +32,10 @@ public class DailyReportRepository : CrudRepositoryBase<DailyReportDto, DailyRep
|
|||||||
var query = GetQuery().Where(d => d.IdWell == idWell);
|
var query = GetQuery().Where(d => d.IdWell == idWell);
|
||||||
|
|
||||||
if (request.GeDate.HasValue)
|
if (request.GeDate.HasValue)
|
||||||
query = query.Where(d => d.DateStart >= request.GeDate.Value.ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc));
|
query = query.Where(d => d.Date >= request.GeDate.Value.ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc));
|
||||||
|
|
||||||
if (request.LeDate.HasValue)
|
if (request.LeDate.HasValue)
|
||||||
query = query.Where(d => d.DateStart <= request.LeDate.Value.ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc));
|
query = query.Where(d => d.Date <= request.LeDate.Value.ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc));
|
||||||
|
|
||||||
if (request.SortFields?.Any() == true)
|
if (request.SortFields?.Any() == true)
|
||||||
{
|
{
|
||||||
@ -62,45 +53,44 @@ public class DailyReportRepository : CrudRepositoryBase<DailyReportDto, DailyRep
|
|||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<DailyReportDto?> GetOrDefaultAsync(int idWell, DateTime dateStart, CancellationToken cancellationToken)
|
public async Task<DailyReportDto?> GetOrDefaultAsync(int idWell, DateTime date, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var entity = await GetQuery()
|
var entity = await GetQuery()
|
||||||
.Include(d => d.Well)
|
.Include(d => d.Well)
|
||||||
|
.AsNoTracking()
|
||||||
.SingleOrDefaultAsync(d => d.IdWell == idWell &&
|
.SingleOrDefaultAsync(d => d.IdWell == idWell &&
|
||||||
d.DateStart == dateStart, cancellationToken);
|
d.Date == date, cancellationToken);
|
||||||
|
|
||||||
return entity is null ? null : Convert(entity);
|
return entity is null ? null : Convert(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<bool> AnyAsync(int idWell, DateTime dateStart, CancellationToken cancellationToken) =>
|
|
||||||
GetQuery().AnyAsync(d => d.IdWell == idWell && d.DateStart == dateStart, cancellationToken);
|
|
||||||
|
|
||||||
protected override DailyReport Convert(DailyReportDto src)
|
|
||||||
{
|
|
||||||
var entity = base.Convert(src);
|
|
||||||
|
|
||||||
entity.Blocks = JsonSerializer.Serialize(new Blocks
|
|
||||||
{
|
|
||||||
Subsystem = src.SubsystemBlock,
|
|
||||||
TimeBalance = src.TimeBalanceBlock,
|
|
||||||
Sign = src.SignBlock,
|
|
||||||
});
|
|
||||||
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override DailyReportDto Convert(DailyReport src)
|
protected override DailyReportDto Convert(DailyReport src)
|
||||||
{
|
{
|
||||||
var dto = base.Convert(src);
|
var dto = base.Convert(src);
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(src.Blocks))
|
if (dto.TimeBalanceBlock is null)
|
||||||
return dto;
|
return dto;
|
||||||
|
|
||||||
var blocks = JsonSerializer.Deserialize<Blocks>(src.Blocks);
|
dto.TimeBalanceBlock.WellDepth = new PlanFactDto<double?>()
|
||||||
|
{
|
||||||
|
Plan = src.TimeBalanceBlock?.WellDepthPlan
|
||||||
|
};
|
||||||
|
|
||||||
dto.SubsystemBlock = blocks?.Subsystem;
|
if (src.TimeBalanceBlock?.WellOperations?.Any() == true)
|
||||||
dto.TimeBalanceBlock = blocks?.TimeBalance;
|
{
|
||||||
dto.SignBlock = blocks?.Sign;
|
dto.TimeBalanceBlock.WellOperations = src.TimeBalanceBlock.WellOperations.Select(w =>
|
||||||
|
{
|
||||||
|
var wellOperation = w.Adapt<TimeBalanceRecordDto>();
|
||||||
|
|
||||||
|
wellOperation.DurationHours = new PlanFactDto<double?>()
|
||||||
|
{
|
||||||
|
Plan = w.DurationHoursPlan,
|
||||||
|
Fact = w.DurationHoursFact
|
||||||
|
};
|
||||||
|
|
||||||
|
return wellOperation;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user