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

namespace AsbCloudDb.Model
{

    [Table("t_telemetry_analysis"), Comment("События на скважине")]
    public class TelemetryAnalysis : IId
    {
        [Key]
        [Column("id")]
        public int Id { get; set; }

        [Column("id_telemetry")]
        public int IdTelemetry { get; set; }

        [Column("id_operation")]
        public int IdOperation { get; set; }

        [JsonIgnore]
        [ForeignKey(nameof(IdTelemetry))]
        [InverseProperty(nameof(Model.Telemetry.Analysis))]
        public virtual Telemetry Telemetry { get; set; }

        [JsonIgnore]
        [ForeignKey(nameof(IdOperation))]
        [InverseProperty(nameof(Model.WellOperationCategory.Analysis))]
        public virtual WellOperationCategory Operation { get; set; }

        [Column("unix_date", TypeName = "bigint"), Comment("Unix timestamp для Linq запросов с вычислением дат")]
        public long UnixDate { get; set; }

        [Column("duration_sec"), Comment("Кол-во секунд после предыдущей операции")]
        public int DurationSec { get; set; }

        [Column("operation_start_depth"), Comment("Глубина, на которой началась операция")]
        public double? OperationStartDepth { get; set; }

        [Column("operation_end_depth"), Comment("Глубина, на которой закончилась операция")]
        public double? OperationEndDepth { get; set; }

        [Column("is_well_depth_increasing"), Comment("Глубина забоя увеличивается")]
        public bool IsWellDepthIncreasing { get; set; }

        [Column("is_well_depth_decreasing"), Comment("Глубина забоя не увеличивается")]
        public bool IsWellDepthDecreasing { get; set; }

        [Column("is_bit_position_increasing"), Comment("Долото спускается")]
        public bool IsBitPositionIncreasing { get; set; }

        [Column("is_bit_position_decreasing"), Comment("Долото поднимается")]
        public bool IsBitPositionDecreasing { get; set; }

        [Column("is_bit_posision_lt_20"), Comment("Положение долота меньше 20м")]
        public bool IsBitPositionLt20 { get; set; }

        [Column("is_block_posision_incresing"), Comment("Талевый блок спускается")]
        public bool IsBlockPositionIncreasing { get; set; }

        [Column("is_block_posision_decresing"), Comment("Талевый блок поднимается")]
        public bool IsBlockPositionDecreasing { get; set; }

        [Column("is_rotor_speed_lt_3"), Comment("Обороты ротора ниже 3")]
        public bool IsRotorSpeedLt5 { get; set; }

        [Column("is_rotor_speed_gt_3"), Comment("Обороты ротора выше 3")]
        public bool IsRotorSpeedGt5 { get; set; }

        [Column("is_pressure_lt_20"), Comment("Давление менее 20")]
        public bool IsPressureLt20 { get; set; }

        [Column("is_pressure_gt_20"), Comment("Давление более 20")]
        public bool IsPressureGt20 { get; set; }

        [Column("is_hook_weight_not_changes"), Comment("Вес на крюке не меняется")]
        public bool IsHookWeightNotChanges { get; set; }

        [Column("is_hook_weight_lt_3"), Comment("Вес на крюке менее 3т")]
        public bool IsHookWeightLt3 { get; set; }
    }
}