package com.pj.project.tb_car;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.pj.project4sp.global.BusinessException;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;

import lombok.Data;
import lombok.Getter;
import lombok.experimental.Accessors;

/**
 * Model: tb_car --
 *
 * @author qzy
 */
@Data
@Accessors(chain = true)
@TableName(TbCar.TABLE_NAME)
@EqualsAndHashCode(callSuper = false)
public class TbCar extends Model<TbCar> implements Serializable {

    // ---------- 模块常量 ----------
    /**
     * 序列化版本id
     */
    private static final long serialVersionUID = 1L;
    /**
     * 此模块对应的表名
     */
    public static final String TABLE_NAME = "tb_car";
    public static final String ADD = "tb-car-add";
    public static final String EDIT = "tb-car-edit";
    public static final String DEL = "tb-car-del";
    public static final String IMPORT = "tb-car-import";
    /**
     * 此模块对应的权限码
     */
    public static final String PERMISSION_CODE = "tb-car";


    // ---------- 表中字段 ----------
    /**
     * 主键
     */
    private String id;

    /**
     * 名称
     */
    private String cardNo;
    private String customerId;
    private String customerName;
    /**
     * 0临时车、1行政车、2业务车
     */
    private Integer carType;
    /**
     * 规格
     */
    private Double cardSize;
    private Double weight;
    private String phone;
    private String people;


    private String countryName;
    private String remark;

    /**
     * 最后一次运输商品
     */
    private String lastGoodsName;

    /**
     * 最后一次运输商品编号
     */
    private String lastGoodsCode;

    /**
     * 最后一次载重
     */
    private Double lastNetWeight;

    /**
     * 最后一次入境时间
     */
    private Date lastInTime;

    /**
     * 最后一次出境时间
     */
    private Date lastOutTime;

    /**
     * 当前状态(1=境外,2=境内)
     */
    private int status;


    @Getter
    @AllArgsConstructor
    public static enum CarTypeEnum {
        /**
         * 0临时车、1行政车、2业务车
         */
        TEMPORARY_CAR("临时车",0),
        ADMINISTRATIVE_CAR("行政车",1),
        BUSINESS_CAR("业务车",2)
        ;
        private String name;
        private Integer type;

        public static Integer getType(String des){
          return   Arrays.stream(CarTypeEnum.values()).filter(obj-> StrUtil.equals(obj.getName(),des))
                    .findAny().orElseThrow(()->new BusinessException("系统找不到"+des)).getType();
        }
    }


}
