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设备避障上报数据")
@Measurement(name = "q20_obs")
public class Q20ObsReport {

    @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 = "避障距离，单位m")
    @Column
    private Float cp_distance;

    @Schema(description = "避障开关：1开启/0关闭")
    @Column
    private Integer cp_enable;

    @Schema(description = "下方障碍物距离，单位m，-1表示无障碍物")
    @Column
    private Float ver_down;

    @Schema(description = "上方障碍物距离，单位m，-1表示无障碍物")
    @Column
    private Float ver_up;

    @Schema(description = "水平正前方障碍物距离，单位m，-1表示无障碍物")
    @Column
    private Float around_0;

    @Schema(description = "水平右前方障碍物距离，单位m，-1表示无障碍物")
    @Column
    private Float around_1;

    @Schema(description = "水平正右方障碍物距离，单位m，-1表示无障碍物")
    @Column
    private Float around_2;

    @Schema(description = "水平右后方障碍物距离，单位m，-1表示无障碍物")
    @Column
    private Float around_3;

    @Schema(description = "水平正后方障碍物距离，单位m，-1表示无障碍物")
    @Column
    private Float around_4;

    @Schema(description = "水平左后方障碍物距离，单位m，-1表示无障碍物")
    @Column
    private Float around_5;

    @Schema(description = "水平正左方障碍物距离，单位m，-1表示无障碍物")
    @Column
    private Float around_6;

    @Schema(description = "水平左前方障碍物距离，单位m，-1表示无障碍物")
    @Column
    private Float around_7;

    private String timeStr;

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