package com.dne.ems.model;

import java.time.LocalDateTime;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.Data;

/**
 * 空气质量指数(AQI)数据实体
 *
 * <p>表示网格工作人员提交的空气质量数据，映射到'aqi_data'表，
 * 存储特定网格位置收集的详细污染物信息。
 *
 * <p>主要字段：
 * <ul>
 *   <li>aqiValue - 空气质量指数值</li>
 *   <li>pm25/pm10 - 颗粒物浓度</li>
 *   <li>so2/no2/co/o3 - 气体污染物浓度</li>
 * </ul>
 *
 * @author DNE开发团队
 * @version 1.0
 * @since 2025-06-16
 */
@Entity
@Table(name = "aqi_data")
@Data
public class AqiData {

    /**
     * 主键ID，AQI数据记录的唯一标识
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 关联的反馈ID
     *
     * <p>可为null，表示工作人员主动提交的数据而非响应反馈任务
     */
    private Long feedbackId;

    /**
     * The grid cell (location) where this data was recorded.
     * This field is mandatory.
     */
    @ManyToOne
    @JoinColumn(name = "grid_id", nullable = false)
    private Grid grid;

    /**
     * The ID of the grid worker who reported this data.
     * This field is mandatory.
     */
    @Column(nullable = false)
    private Long reporterId;

    /**
     * The overall Air Quality Index (AQI) value.
     */
    private Integer aqiValue;

    /**
     * The concentration of PM2.5 (fine particulate matter) in µg/m³.
     */
    private Double pm25;

    /**
     * The concentration of PM10 (inhalable particulate matter) in µg/m³.
     */
    private Double pm10;

    /**
     * The concentration of SO2 (Sulfur Dioxide) in µg/m³.
     */
    private Double so2;

    /**
     * The concentration of NO2 (Nitrogen Dioxide) in µg/m³.
     */
    private Double no2;

    /**
     * The concentration of CO (Carbon Monoxide) in mg/m³.
     */
    private Double co;

    /**
     * The concentration of O3 (Ozone) in µg/m³.
     */
    private Double o3;

    /**
     * The name of the primary pollutant contributing to the AQI value.
     */
    private String primaryPollutant;

    /**
     * The timestamp when this data was recorded.
     * Defaults to the current time upon creation.
     */
    @Column(nullable = false)
    private LocalDateTime recordTime = LocalDateTime.now();
} 