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设备RTK定位数据 InfluxDB记录
 *
 * @author 938693313@qq.com
 * @since 1.0.0 2026/5/12
 */
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Data
@Schema(name = "Q20设备RTK上报数据")
@Measurement(name = "q20_rtk")
public class Q20RtkReport {

    @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 = "定位类型：0未定位/1单点定位/2差分定位/4固定解")
    @Column
    private Integer fix_type;

    @Schema(description = "纬度，WGS84")
    @Column
    private Double latitude;

    @Schema(description = "经度，WGS84")
    @Column
    private Double longitude;

    @Schema(description = "海拔高度，单位m")
    @Column
    private Float altitude;

    @Schema(description = "椭球高，单位m")
    @Column
    private Float ellipsoid_height;

    @Schema(description = "可见卫星数")
    @Column
    private Integer satellite_visible;

    @Schema(description = "水平位置精度因子，单位m")
    @Column
    private Float eph;

    @Schema(description = "垂直位置精度因子，单位m")
    @Column
    private Float epv;

    @Schema(description = "速度，单位m/s")
    @Column
    private Float velocity;

    @Schema(description = "偏航角，单位°")
    @Column
    private Float yaw;

    @Schema(description = "航迹角，单位°")
    @Column
    private Float cog;

    @Schema(description = "水平精度，单位m")
    @Column
    private Float horizontal_acc;

    @Schema(description = "垂直精度，单位m")
    @Column
    private Float vertical_acc;

    @Schema(description = "速度精度，单位m/s")
    @Column
    private Float velocity_acc;

    private String timeStr;

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