using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;

namespace AsbCloudDb.Model
{
    [Table("t_process_map"), Comment("Операции по скважине – РТК")]
    public class ProcessMap : IId, IWellRelated
    {
        [Key]
        [Column("id")]
        public int Id { get; set; }

        [Column("well_id"), Comment("Id скважины")]
        public int IdWell { get; set; }

        [Column("id_user"), Comment("Id пользователя")]
        public int IdUser { get; set; }

        [Column("id_wellsection_type"), Comment("Тип секции")]
        public int IdWellSectionType { get; set; }

        [Column("last_update", TypeName = "timestamp with time zone"), Comment("Дата последнего изменения")]
        public DateTimeOffset LastUpdate { get; set; }

        [Column("depth_start"), Comment("Стартовая глубина")]
        public double DepthStart { get; set; }

        [Column("depth_end"), Comment("Глубина окончания интервала")]
        public double DepthEnd { get; set; }

        [Column("axial_load_plan"), Comment("Нагрузка, план")]
        public double AxialLoadPlan { get; set; }

        [Column("axial_load_fact"), Comment("Нагрузка, факт")]
        public double? AxialLoadFact { get; set; }

        [Column("pressure_plan"), Comment("Перепад давления, план")]
        public double PressurePlan { get; set; }

        [Column("pressure_fact"), Comment("Перепад давления, факт")]
        public double? PressureFact { get; set; }

        [Column("top_drive_torque_plan"), Comment("Момент на ВСП, план")]
        public double TopDriveTorquePlan { get; set; }

        [Column("top_drive_torque_fact"), Comment("Момент на ВСП, факт")]
        public double? TopDriveTorqueFact { get; set; }

        [Column("top_drive_speed_plan"), Comment("Обороты на ВСП, план")]
        public double TopDriveSpeedPlan { get; set; }

        [Column("top_drive_speed_fact"), Comment("Обороты на ВСП, факт")]
        public double? TopDriveSpeedFact { get; set; }

        [Column("flow_plan"), Comment("Расход, план")]
        public double FlowPlan { get; set; }

        [Column("flow_fact"), Comment("Расход, факт")]
        public double? FlowFact { get; set; }

        [Column("rop_plan"), Comment("Плановая механическая скорость, м/ч")]
        public double RopPlan { get; set; }

        [JsonIgnore]
        [ForeignKey(nameof(IdWell))]
        public virtual Well Well { get; set; } = null!;

        [JsonIgnore]
        [ForeignKey(nameof(IdWellSectionType))]
        public virtual WellSectionType WellSectionType { get; set; } = null!;
    }
}