package com.ningdatech.carapi.car.position.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.Objects;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * <p>
 * 
 * </p>
 *
 * @author PoffyZhang
 * @since 2022-11-17
 */
@TableName("nd_data_access_gps_2022_11")
@Data
@ApiModel(value = "VehiclePositionInfo对象", description = "")
public class VehiclePositionInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    private String carPlate;

    private Boolean plateColor;

    private BigDecimal carLongitude;

    private BigDecimal carLatitude;

    private BigDecimal carAltitude;

    private BigDecimal carVelocity;

    private BigDecimal carDirection;

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

    private String operatorName;

    private String operatorId;

    @ApiModelProperty("报警标识")
    private Integer alarmFlag;

    @ApiModelProperty("状态，根据需求去取对应的位数参考jtt808/8.21下的状态定义")
    private Integer status;

    @ApiModelProperty("仪表盘里程数")
    private Integer dashboardMileage;

    @ApiModelProperty("仪表盘速度")
    private Integer dashboardSpeed;

    @ApiModelProperty("recordId")
    @TableId(value = "record_id", type = IdType.AUTO)
    private Long recordId;

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

    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;
    }
}
