package cn.cecep.talroad.domain;


import cn.cecep.talroad.common.core.web.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.util.Date;


/**
 * 大气站点监测数据对象 t_cod_station_data_air
 */
@ApiModel(value = "大气站点监测数据")
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("t_cod_station_data_air")
public class TCodStationDataAir extends BaseEntity {
    private static final long serialVersionUID = 1L;


    @ApiModelProperty(value = "主键")
    @TableId(value = "id", type = IdType.ASSIGN_UUID)
    private String id;


    @ApiModelProperty(value = "站点id。关联t_cod_station表id")
    private String stationId;


    @ApiModelProperty(value = "监测时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date monitorTime;


    @ApiModelProperty(value = "数据类型。D:日, H:小时, M:分钟")
    private String dataType;


    @ApiModelProperty(value = "aiq")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private BigDecimal aqi;


    @ApiModelProperty(value = "pm2.5")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private BigDecimal pm25;


    @ApiModelProperty(value = "pm10")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private BigDecimal pm10;


    @ApiModelProperty(value = "so2")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private BigDecimal so2;


    @ApiModelProperty(value = "no2")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private BigDecimal no2;


    @ApiModelProperty(value = "o3")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private BigDecimal o3;


    @ApiModelProperty(value = "co")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private BigDecimal co;


    @ApiModelProperty(value = "温度")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private BigDecimal temperature;


    @ApiModelProperty(value = "湿度")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private BigDecimal humidity;


    @ApiModelProperty(value = "压力")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private BigDecimal pressure;


    @ApiModelProperty(value = "风力")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private BigDecimal windPower;

    @ApiModelProperty(value = "风向")
    private String windDirection;


    @ApiModelProperty(value = "首要污染物")
    private String pollutant;

    @ApiModelProperty(value = "空气质量级别")
    private String airQualityclass;

    public String getAirQualityclass() {
        if (airQualityclass != null) {
            switch (airQualityclass) {
                case "1": return "优";
                case "2": return "良";
                case "3": return "轻度污染";
                case "4": return "中度污染";
                case "5": return "重度污染";
                case "6": return "严重污染";
                default: return null;
            }
        }
        return null;
    }

    @ApiModelProperty(value = "tvoc")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private BigDecimal tvoc;

    @ApiModelProperty(value = "tsp")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private BigDecimal tsp;

    public static String transformation(String windDirection) {
        if (windDirection == null) {
            return null;
        }
        double value;

        try {
            value = new BigDecimal(windDirection).doubleValue();
        } catch (Exception e) {
            return null;
        }

        if (value >= 0 && value < 22.5) {
            return "北风";
        } else if (value >= 22.5 && value < 67.5) {
            return "东北风";
        } else if (value >= 67.5 && value < 112.5) {
            return "东风";
        } else if (value >= 112.5 && value < 157.5) {
            return "东南风";
        } else if (value >= 157.5 && value < 202.5) {
            return "南风";
        } else if (value >= 202.5 && value < 247.5) {
            return "西南风";
        } else if (value >= 247.5 && value < 292.5) {
            return "西风";
        } else if (value >= 292.5 && value < 337.5) {
            return "西北风";
        } else {
            return "北风";
        }
    }

}
