package com.multictrl.modules.business.q20.influxdb;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.influxdb.annotations.Column;
import com.influxdb.annotations.Measurement;
import com.multictrl.common.utils.DateUtils;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.Instant;

/**
 * Q20设备遥控链路数据 InfluxDB记录
 *
 * @author 938693313@qq.com
 * @since 1.0.0 2026/5/12
 */
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Data
@Schema(name = "Q20设备RC链路上报数据")
@Measurement(name = "q20_rc")
public class Q20RcReport {

    @Schema(description = "设备SN")
    @Column(tag = true)
    private String deviceSn;

    @Schema(description = "架次号")
    @Column(tag = true)
    private String order_id;

    @Schema(hidden = true)
    @Column(timestamp = true)
    @JsonProperty("_time")
    private Instant time;

    @Schema(description = "遥控优先级")
    @Column
    private Integer priority;

    @Schema(description = "遥控通道状态")
    @Column
    private String rc_channel_state;

    @Schema(description = "遥控状态")
    @Column
    private String rc_state;

    @Schema(description = "上行丢包率，单位%")
    @Column
    private Float up_loss_rate;

    @Schema(description = "下行丢包率，单位%")
    @Column
    private Float down_loss_rate;

    @Schema(description = "当前使用链路id")
    @Column
    private Integer link_inuse_id;

    @Schema(description = "当前使用链路类型：0未知/1RC遥控/2图传/3网络")
    @Column
    private Integer link_inuse_type;

    @Schema(description = "当前使用链路信号质量，单位%")
    @Column
    private Integer link_inuse_sqe;

    @Schema(description = "当前使用链路频段，单位MHz")
    @Column
    private Integer link_inuse_band;

    @Schema(description = "网络类型：0未知/1WiFi/24G/35G")
    @Column
    private Integer network_type;

    @Schema(description = "网络信号质量，单位%")
    @Column
    private Integer network_quality;

    private String timeStr;

    public void setTime(Instant time) {
        this.time = time;
        this.timeStr = DateUtils.utcToTime(time);
    }
}
