package gc.mda.kcg.domain.stats;

import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.type.SqlTypes;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Map;

@Entity
@Table(name = "prediction_stats_monthly", schema = "kcg")
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
public class PredictionStatsMonthly {

    @Id
    @Column(name = "stat_month")
    private LocalDate statMonth;

    @Column(name = "total_detections")
    private Integer totalDetections;

    @Column(name = "total_enforcements")
    private Integer totalEnforcements;

    @JdbcTypeCode(SqlTypes.JSON)
    @Column(name = "by_category", columnDefinition = "jsonb")
    private Map<String, Object> byCategory;

    @JdbcTypeCode(SqlTypes.JSON)
    @Column(name = "by_zone", columnDefinition = "jsonb")
    private Map<String, Object> byZone;

    @JdbcTypeCode(SqlTypes.JSON)
    @Column(name = "by_risk_level", columnDefinition = "jsonb")
    private Map<String, Object> byRiskLevel;

    @JdbcTypeCode(SqlTypes.JSON)
    @Column(name = "by_gear_type", columnDefinition = "jsonb")
    private Map<String, Object> byGearType;

    @JdbcTypeCode(SqlTypes.JSON)
    @Column(name = "by_violation_type", columnDefinition = "jsonb")
    private Map<String, Object> byViolationType;

    @Column(name = "event_count")
    private Integer eventCount;

    @Column(name = "critical_event_count")
    private Integer criticalEventCount;

    @Column(name = "false_positive_count")
    private Integer falsePositiveCount;

    @Column(name = "ai_accuracy_pct", precision = 12, scale = 2)
    private BigDecimal aiAccuracyPct;

    @Column(name = "updated_at")
    private OffsetDateTime updatedAt;
}
