package com.ningdatech.carapi.car.position.model.vo;

import com.ningdatech.carapi.common.constant.VehicleTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Objects;
import java.util.Optional;

/**
 * @author liuxinxin
 * @date 2022/10/8 下午2:30
 */

@ApiModel(description = "实时监控车辆gis列表")
@Data
public class ResRealTimeMonitorVehicleGisListVO {

    @ApiModelProperty("车辆颜色")
    private String plateColor;

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

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

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

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

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

    @ApiModelProperty("公司名id")
    private Long companyId;

    @ApiModelProperty("公司名")
    private String companyName;

    @ApiModelProperty("车辆类型")
    private Integer vehicleType;

    @ApiModelProperty("车辆类型名")
    private String vehicleTypeName;

    @ApiModelProperty("时间")
    private String updateTime;

    @ApiModelProperty("自编号")
    private String selfNo;

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

    private Integer limitSpeed;

    private Integer status;
    private Integer moving;

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

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

    public String getVehicleTypeName(){
        if(Objects.nonNull(this.vehicleType)){
            Optional.ofNullable(VehicleTypeEnum.getDescByCode(vehicleType)).ifPresent(v ->
                    this.vehicleTypeName = v);
            return this.vehicleTypeName;
        }
        return StringUtils.EMPTY;
    }
}
