package vip.xiaonuo.coldchain.modular.app.param;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import vip.xiaonuo.coldchain.core.service.dataprocess.model.PowerEnum;
import vip.xiaonuo.coldchain.modular.monitortargetregion.entity.MonitorTargetRegion;

import java.util.Date;

/**
 * @author jackzhou
 * @version 1.0
 * @project jfcloud-coldchain
 * @description 设备数据类，包含设备的各项监控数据及电源状态
 * @date 2024/11/17 22:39:49
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class AppDeviceData extends MonitorTargetRegion {
    @Schema(description = "数据记录的时间")
    private Date timestamp;  // 数据记录的时间

    @Schema(description = "设备温度 (℃)")
    @JsonSerialize(using = FloatNullToDashSerializer.class)  // 使用自定义序列化器
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "#.00")
    private Float temperature;  // 温度

    @Schema(description = "设备湿度 (%)")
    @JsonSerialize(using = FloatNullToDashSerializer.class)  // 使用自定义序列化器
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "#.00")
    private Float humidity;  // 湿度

    @Schema(description = "二氧化碳浓度 (ppm)")
    @JsonSerialize(using = FloatCo2ToDashSerializer.class)  // 使用自定义序列化器
    private Float co2Level;  // 二氧化碳浓度

    @Schema(description = "电池电量 (%)")
    @JsonSerialize(using = FloatNullToDashSerializer.class)  // 使用自定义序列化器
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "#.00")
    private Float batteryPercentage;  // 电池电量

    @Schema(description = "电源状态，AC电源或DC电池")
    private String plugInStatus = PowerEnum.AC.getCode();  // 电源状态（默认值为AC电源）

    @Schema(description = "温度状态 (0正常1临界2异常)")
    private String temperatureStatus;

    @Schema(description = "湿度状态 (0正常1临界2异常)")
    private String humidityStatus;

    @Schema(description = "CO2状态 (0正常1临界2异常)")
    private String co2Status;

    // 默认构造函数不再需要显式定义，Lombok 会自动生成
}
