package com.limap.core.screen.vo;


import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

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

@Data
@ApiModel(value = "EquipmentHistory", description = "历史数据")
public class EquipmentHistory {

    @ApiModelProperty("日期")
    private String day;
    @ApiModelProperty("时间")
    private String time;

    @ApiModelProperty("溶氧")
    private Double dissolvedOxygen;

    @ApiModelProperty("水温")
    private Double temperature;

    @ApiModelProperty("饱和度")
    private Double saturability;

    private Double pH;

    @ApiModelProperty("盐度")
    private Double salinity;

    // Setter 方法：保留两位小数
    public void setDissolvedOxygen(Double dissolvedOxygen) {
        this.dissolvedOxygen = roundToTwoDecimals(dissolvedOxygen);
    }

    public void setTemperature(Double temperature) {
        this.temperature = roundToTwoDecimals(temperature);
    }

    public void setSaturability(Double saturability) {
        this.saturability = roundToTwoDecimals(saturability);
    }

    public void setPH(Double pH) {
        this.pH = roundToTwoDecimals(pH);
    }

    public void setSalinity(Double salinity) {
        this.salinity = roundToTwoDecimals(salinity);
    }

    // 工具方法：保留两位小数
    private Double roundToTwoDecimals(Double value) {
        if (value == null) {
            return null;
        }
        return BigDecimal.valueOf(value)
                .setScale(2, RoundingMode.HALF_UP)
                .doubleValue();
    }
}
