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

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.Optional;

import org.apache.commons.lang3.StringUtils;

import com.ningdatech.carapi.common.constant.AlarmLevelEnum;
import com.ningdatech.carapi.common.constant.BgTypeEnum;
import com.ningdatech.carapi.common.constant.VehicleTypeEnum;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.RequiredArgsConstructor;

/**
 * @Classname SecurityMonitorVO
 * @Description
 * @Date 2022/11/6 20:59
 * @Created by PoffyZhang
 */
@RequiredArgsConstructor
@Data
public class SecurityMonitorVO implements Serializable {

    @ApiModelProperty("告警事件id")
    private Long alarmId;

    @ApiModelProperty("区域ID")
    private Long regionId;

    @ApiModelProperty("区域名")
    private String regionName;

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

    @ApiModelProperty("公司ID")
    private Long companyId;

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

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

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

    @ApiModelProperty("事件类型")
    private Integer alarmType;

    @ApiModelProperty("事件类型名")
    private String alarmTypeName;

    @ApiModelProperty("告警时间")
    private LocalDateTime alarmTime;

    @ApiModelProperty("地址")
    private String alarmAddress;

    @ApiModelProperty("图片链接")
    private String pictureUrl;

    @ApiModelProperty("视频链接")
    private String videoUrl;

    @ApiModelProperty("级别")
    private Integer alarmLevel;

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

    @ApiModelProperty("级别名")
    private String alarmLevelName;

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

    public String getAlarmTypeName(){
        if(Objects.nonNull(this.alarmType)){
            Optional.ofNullable(BgTypeEnum.getDescByCode(alarmType)).ifPresent(a ->
                    this.alarmTypeName = a);
            return this.alarmTypeName;
        }
        return StringUtils.EMPTY;
    }

    public String getAlarmLevelName(){
        if(Objects.nonNull(this.alarmLevel)){
            Optional.ofNullable(AlarmLevelEnum.getDescByCode(alarmLevel)).ifPresent(a ->
                    this.alarmLevelName = a);
            return this.alarmLevelName;
        }
        return StringUtils.EMPTY;
    }
}
