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>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="dateStart"></param>
|
||||
/// <param name="date"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<DailyReportDto?> GetOrDefaultAsync(int idWell, DateTime dateStart, 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);
|
||||
Task<DailyReportDto?> GetOrDefaultAsync(int idWell, DateTime date, CancellationToken cancellationToken);
|
||||
}
|
@ -13,7 +13,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
[DbContext(typeof(AsbCloudDbContext))]
|
||||
[Migration("20231103095402_Update_DailyReport")]
|
||||
[Migration("20231114051111_Update_DailyReport")]
|
||||
partial class Update_DailyReport
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@ -122,7 +122,8 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("caption");
|
||||
|
||||
b.Property<bool>("IsContact")
|
||||
.HasColumnType("boolean");
|
||||
.HasColumnType("boolean")
|
||||
.HasColumnName("is_contact");
|
||||
|
||||
b.Property<int>("Order")
|
||||
.HasColumnType("integer")
|
||||
@ -136,23 +137,72 @@ namespace AsbCloudDb.Migrations
|
||||
new
|
||||
{
|
||||
Id = 1,
|
||||
Caption = "Недрапользователь",
|
||||
IsContact = false,
|
||||
Order = 1
|
||||
Caption = "Недропользователь",
|
||||
IsContact = true,
|
||||
Order = 3
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 2,
|
||||
Caption = "Буровой подрядчик",
|
||||
IsContact = false,
|
||||
IsContact = true,
|
||||
Order = 2
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 3,
|
||||
Caption = "Сервис автоматизации бурения",
|
||||
IsContact = false,
|
||||
IsContact = true,
|
||||
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("Контакты");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DailyReport", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DailyReports.DailyReport", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -231,34 +281,39 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Blocks")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("blocks")
|
||||
.HasComment("Блоки использующиеся в отчёте");
|
||||
|
||||
b.Property<DateTime>("DateEnd")
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date_end")
|
||||
.HasComment("Конечная дата отчёта");
|
||||
.HasColumnName("date")
|
||||
.HasComment("Дата формирования отчёта");
|
||||
|
||||
b.Property<DateTime?>("DateLastUpdate")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date_last_update")
|
||||
.HasComment("Дата последнего обновления");
|
||||
|
||||
b.Property<DateTime>("DateStart")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date_start")
|
||||
.HasComment("Начальная дата отчёта");
|
||||
|
||||
b.Property<int>("IdWell")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_well")
|
||||
.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.HasIndex("IdWell", "DateStart")
|
||||
b.HasIndex("IdWell", "Date")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("t_daily_report");
|
||||
@ -4598,14 +4653,14 @@ namespace AsbCloudDb.Migrations
|
||||
new
|
||||
{
|
||||
Id = 65536,
|
||||
Description = "Spin master",
|
||||
Name = "Spin master"
|
||||
Description = "Осцилляция",
|
||||
Name = "Осцилляция"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 65537,
|
||||
Description = "Torque master",
|
||||
Name = "Torque master"
|
||||
Description = "Демпфер",
|
||||
Name = "Демпфер"
|
||||
});
|
||||
});
|
||||
|
||||
@ -7089,6 +7144,36 @@ namespace AsbCloudDb.Migrations
|
||||
Id = 33,
|
||||
Caption = "Техническая колонна 3",
|
||||
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");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DailyReport", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DailyReports.DailyReport", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.Well", "Well")
|
||||
.WithMany()
|
@ -30,20 +30,13 @@ namespace AsbCloudDb.Migrations
|
||||
defaultValue: 0)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "blocks",
|
||||
table: "t_daily_report",
|
||||
type: "jsonb",
|
||||
nullable: true,
|
||||
comment: "Блоки использующиеся в отчёте");
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "date_end",
|
||||
name: "date",
|
||||
table: "t_daily_report",
|
||||
type: "timestamp with time zone",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||
comment: "Конечная дата отчёта");
|
||||
comment: "Дата формирования отчёта");
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "date_last_update",
|
||||
@ -52,13 +45,26 @@ namespace AsbCloudDb.Migrations
|
||||
nullable: true,
|
||||
comment: "Дата последнего обновления");
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "date_start",
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "sign_block",
|
||||
table: "t_daily_report",
|
||||
type: "timestamp with time zone",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||
comment: "Начальная дата отчёта");
|
||||
type: "jsonb",
|
||||
nullable: true,
|
||||
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(
|
||||
name: "PK_t_daily_report",
|
||||
@ -66,9 +72,9 @@ namespace AsbCloudDb.Migrations
|
||||
column: "Id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_daily_report_id_well_date_start",
|
||||
name: "IX_t_daily_report_id_well_date",
|
||||
table: "t_daily_report",
|
||||
columns: new[] { "id_well", "date_start" },
|
||||
columns: new[] { "id_well", "date" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
@ -79,19 +85,15 @@ namespace AsbCloudDb.Migrations
|
||||
table: "t_daily_report");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_t_daily_report_id_well_date_start",
|
||||
name: "IX_t_daily_report_id_well_date",
|
||||
table: "t_daily_report");
|
||||
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Id",
|
||||
table: "t_daily_report");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "blocks",
|
||||
table: "t_daily_report");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "date_end",
|
||||
name: "date",
|
||||
table: "t_daily_report");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
@ -99,7 +101,15 @@ namespace AsbCloudDb.Migrations
|
||||
table: "t_daily_report");
|
||||
|
||||
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");
|
||||
|
||||
migrationBuilder.AddColumn<DateOnly>(
|
@ -264,7 +264,7 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasComment("Контакты");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DailyReport", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DailyReports.DailyReport", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -272,34 +272,39 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Blocks")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("blocks")
|
||||
.HasComment("Блоки использующиеся в отчёте");
|
||||
|
||||
b.Property<DateTime>("DateEnd")
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date_end")
|
||||
.HasComment("Конечная дата отчёта");
|
||||
.HasColumnName("date")
|
||||
.HasComment("Дата формирования отчёта");
|
||||
|
||||
b.Property<DateTime?>("DateLastUpdate")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date_last_update")
|
||||
.HasComment("Дата последнего обновления");
|
||||
|
||||
b.Property<DateTime>("DateStart")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date_start")
|
||||
.HasComment("Начальная дата отчёта");
|
||||
|
||||
b.Property<int>("IdWell")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_well")
|
||||
.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.HasIndex("IdWell", "DateStart")
|
||||
b.HasIndex("IdWell", "Date")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("t_daily_report");
|
||||
@ -7935,7 +7940,7 @@ namespace AsbCloudDb.Migrations
|
||||
b.Navigation("Well");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DailyReport", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DailyReports.DailyReport", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.Well", "Well")
|
||||
.WithMany()
|
||||
|
@ -3,6 +3,7 @@ using AsbCloudDb.Model.Subsystems;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AsbCloudDb.Model.DailyReports;
|
||||
using AsbCloudDb.Model.Manuals;
|
||||
using AsbCloudDb.Model.ProcessMaps;
|
||||
|
||||
@ -333,10 +334,16 @@ namespace AsbCloudDb.Model
|
||||
|
||||
modelBuilder.Entity<DailyReport>(entity =>
|
||||
{
|
||||
entity.HasIndex(e => new { e.IdWell, e.DateStart })
|
||||
entity.HasIndex(e => new { e.IdWell, e.Date })
|
||||
.IsUnique();
|
||||
|
||||
entity.Property(e => e.Blocks)
|
||||
entity.Property(e => e.SubsystemBlock)
|
||||
.HasJsonConversion();
|
||||
|
||||
entity.Property(e => e.SignBlock)
|
||||
.HasJsonConversion();
|
||||
|
||||
entity.Property(e => e.TimeBalanceBlock)
|
||||
.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.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AsbCloudDb.Model.DailyReports;
|
||||
using AsbCloudDb.Model.Manuals;
|
||||
using AsbCloudDb.Model.ProcessMaps;
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Data.DailyReport;
|
||||
using AsbCloudApp.Data.DailyReport.Blocks.Sign;
|
||||
using AsbCloudApp.Data.DailyReport.Blocks.Subsystems;
|
||||
using AsbCloudApp.Data.DailyReport.Blocks.TimeBalance;
|
||||
using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Requests;
|
||||
using AsbCloudDb;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbCloudDb.Model.DailyReports;
|
||||
using Mapster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace AsbCloudInfrastructure.Repository;
|
||||
@ -19,15 +19,6 @@ namespace AsbCloudInfrastructure.Repository;
|
||||
public class DailyReportRepository : CrudRepositoryBase<DailyReportDto, DailyReport>,
|
||||
IDailyReportRepository
|
||||
{
|
||||
private class Blocks
|
||||
{
|
||||
public SubsystemBlockDto? Subsystem { get; set; }
|
||||
|
||||
public TimeBalanceBlockDto? TimeBalance { get; set; }
|
||||
|
||||
public SignBlockDto? Sign { get; set; }
|
||||
}
|
||||
|
||||
public DailyReportRepository(IAsbCloudDbContext dbContext)
|
||||
: base(dbContext)
|
||||
{
|
||||
@ -41,10 +32,10 @@ public class DailyReportRepository : CrudRepositoryBase<DailyReportDto, DailyRep
|
||||
var query = GetQuery().Where(d => d.IdWell == idWell);
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
@ -62,45 +53,44 @@ public class DailyReportRepository : CrudRepositoryBase<DailyReportDto, DailyRep
|
||||
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()
|
||||
.Include(d => d.Well)
|
||||
.AsNoTracking()
|
||||
.SingleOrDefaultAsync(d => d.IdWell == idWell &&
|
||||
d.DateStart == dateStart, cancellationToken);
|
||||
d.Date == date, cancellationToken);
|
||||
|
||||
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)
|
||||
{
|
||||
var dto = base.Convert(src);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(src.Blocks))
|
||||
if (dto.TimeBalanceBlock is null)
|
||||
return dto;
|
||||
|
||||
dto.TimeBalanceBlock.WellDepth = new PlanFactDto<double?>()
|
||||
{
|
||||
Plan = src.TimeBalanceBlock?.WellDepthPlan
|
||||
};
|
||||
|
||||
var blocks = JsonSerializer.Deserialize<Blocks>(src.Blocks);
|
||||
if (src.TimeBalanceBlock?.WellOperations?.Any() == true)
|
||||
{
|
||||
dto.TimeBalanceBlock.WellOperations = src.TimeBalanceBlock.WellOperations.Select(w =>
|
||||
{
|
||||
var wellOperation = w.Adapt<TimeBalanceRecordDto>();
|
||||
|
||||
wellOperation.DurationHours = new PlanFactDto<double?>()
|
||||
{
|
||||
Plan = w.DurationHoursPlan,
|
||||
Fact = w.DurationHoursFact
|
||||
};
|
||||
|
||||
dto.SubsystemBlock = blocks?.Subsystem;
|
||||
dto.TimeBalanceBlock = blocks?.TimeBalance;
|
||||
dto.SignBlock = blocks?.Sign;
|
||||
return wellOperation;
|
||||
});
|
||||
}
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user