package com.ningdatech.carapi.car.position.model.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.time.LocalDateTime;
import java.util.Objects;

/**
 * @author liuxinxin
 * @date 2022/10/8 上午11:13
 */

@ApiModel(description = "车辆轨迹数据")
@Data
public class ResTrajectoryDataVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("记录id")
    private String recordId;

    @ApiModelProperty("车牌")
    private String carPlate;

    @ApiModelProperty("经度")
    private BigDecimal carLongitude;

    @ApiModelProperty("纬度")
    private BigDecimal carLatitude;

    @ApiModelProperty("海拔高度")
    private BigDecimal carAltitude;

    @ApiModelProperty("行驶速度")
    private BigDecimal carVelocity;

    @ApiModelProperty("行驶方向")
    private BigDecimal carDirection;

    @ApiModelProperty("在线状态")
    private String onlineStatus;

    @ApiModelProperty("运营商名称")
    private String operatorName;

    @ApiModelProperty("运营商id")
    private String operatorId;

    @ApiModelProperty("时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private String updateTime;

    @ApiModelProperty("是否超速")
    private Boolean isOverSpeed = Boolean.FALSE;

    public BigDecimal getCarLongitude(){
        if(Objects.nonNull(this.carLongitude)){
            this.carLongitude = this.carLongitude.setScale(BigDecimal.ROUND_HALF_EVEN, RoundingMode.HALF_UP);
            return this.carLongitude;
        }
        return this.carLongitude;
    }

    public BigDecimal getCarAltitude(){
        if(Objects.nonNull(this.carAltitude)){
            this.carAltitude = this.carAltitude.setScale(BigDecimal.ROUND_HALF_EVEN, RoundingMode.HALF_UP);
            return this.carAltitude;
        }
        return this.carAltitude;
    }

    public BigDecimal getCarVelocity(){
        if(Objects.nonNull(this.carVelocity)){
            this.carVelocity = this.carVelocity.setScale(BigDecimal.ROUND_HALF_EVEN, RoundingMode.HALF_UP);
            return this.carVelocity;
        }
        return this.carVelocity;
    }

    public BigDecimal getCarDirection(){
        if(Objects.nonNull(this.carDirection)){
            this.carDirection = this.carDirection.setScale(BigDecimal.ROUND_HALF_EVEN, RoundingMode.HALF_UP);
            return this.carDirection;
        }
        return this.carDirection;
    }
}
