package com.ningdatech.carapi.safe.model.vo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ningdatech.carapi.common.base.BaseEntity;
import com.ningdatech.carapi.common.constant.MissCertEnum;
import com.ningdatech.carapi.common.constant.ViolationTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * <p>
 * 
 * </p>
 *
 * @author PoffyZhang
 * @since 2022-10-12
 */
@Data
@ApiModel(value = "NdVehicleViolation", description = "安全管理-违章管理")
@NoArgsConstructor
@ToString(callSuper = true)
@Accessors(chain = true)
@AllArgsConstructor
public class NdVehicleViolationVO extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * ID
     */
    @ApiModelProperty("id")
    private Long id;

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

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

    /**
     * 企业
     */
    @ApiModelProperty("企业")
    private Long companyId;

    /**
     * 企业名
     */
    @ApiModelProperty("企业名")
    private String companyName;

    /**
     * 驾驶员
     */
    @ApiModelProperty("驾驶员")
    private String driverName;

    /**
     * 驾驶员ID
     */
    @ApiModelProperty("驾驶员ID")
    private String driverId;

    /**
     * 身份证号
     */
    @ApiModelProperty("身份证号")
    private String idCard;

    /**
     * 违章时间
     */
    @ApiModelProperty("违章时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDateTime violationDate;

    /**
     * 违章类型
     */
    @ApiModelProperty("违章类型")
    private Integer violationType;

    /**
     * 违章类型
     */
    @ApiModelProperty("违章类型")
    private String violationTypeName;

    /**
     * 缺少证件类型
     */
    @ApiModelProperty("缺少证件类型")
    private Integer missingCertificateType;

    /**
     * 缺少证件类型
     */
    @ApiModelProperty("缺少证件类型名")
    private String missingCertificateTypeName;

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

    /**
     * 闯红灯地址
     */
    @ApiModelProperty("闯红灯地址")
    private String addressRedLight;

    /**
     * 违规路段名
     */
    @ApiModelProperty("违规路段名")
    private String waySection;

    /**
     * 违章次数
     */
    @ApiModelProperty("违章次数")
    private Integer violationTimes;

    /**
     * 违章时间段
     */
    @ApiModelProperty("违章时间段")
    private String violationPeriod;

    public String getViolationTypeName(){
        if(Objects.nonNull(this.violationType)){
            this.violationTypeName = ViolationTypeEnum.getDescByCode(this.violationType);
            return this.violationTypeName;
        }
        return StringUtils.EMPTY;
    }
    public String getMissingCertificateTypeName(){
        if(Objects.nonNull(this.missingCertificateType)){
            this.missingCertificateTypeName = MissCertEnum.getDescByCode(this.missingCertificateType);
            return this.missingCertificateTypeName;
        }
        return StringUtils.EMPTY;
    }
}
