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_mode"), Comment("Id режима (1- ротор, 2 слайд)")]
        public int IdMode { 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_limit_max"), Comment("Нагрузка, допустимый максимум")]
        public double AxialLoadLimitMax { get; set; }

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

        [Column("pressure_limit_max"), Comment("Перепад давления, допустимый максимум")]
        public double PressureLimitMax { get; set; }

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

        [Column("top_drive_torque_limit_max"), Comment("Момент на ВСП, допустимый максимум")]
        public double TopDriveTorqueLimitMax { get; set; }

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

        [Column("top_drive_speed_limit_max"), Comment("Обороты на ВСП, допустимый максимум")]
        public double TopDriveSpeedLimitMax { get; set; }

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

        [Column("flow_limit_max"), Comment("Расход, допустимый максимум")]
        public double FlowLimitMax { get; set; }

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

        [Column("usage_saub"), Comment("Плановый процент использования АКБ")]
        public double UsageSaub { get; set; }

        [Column("usage_spin"), Comment("Плановый процент использования spin master")]
        public double UsageSpin { get; set; }

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

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