package com.muyu.domain;

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.muyu.domain.req.CarInformationAddReq;
import com.muyu.domain.req.CarInformationUpdReq;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.function.Supplier;

/**
 * 企业车辆管理实体类
 * @Author：yang
 * @Package：com.muyu.domain
 * @Project：cloud-server-8
 * @name：CarInformation
 * @Date：2024/9/22 22:18
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@Tag(name = "企业车辆管理实体类")
@TableName(value = "car_information",autoResultMap = true)
public class CarInformation {

    /**
     * 车辆ID
     */
    @TableId(value = "car_information_id",type = IdType.AUTO)
    private Long carInformationId;
    /**
     * 车辆唯一VIN
     */
//    @TableName(value = "car_information_VIN")
            @TableField(value = "car_information_VIN")
    private String carInformationVIN;
    /**
     * 车牌号
     */
    private String carInformationLicensePlate;
    /**
     * 车辆颜色
     */
    private String carInformationColor;
    /**
     * 车辆驾驶员
     */
    private String carInformationDriver;
    /**
     * 车辆电子围栏外键ID
     */
    @Schema(title = "车辆电子围栏外键ID", type = "Integer")
    private Integer carInformationFence;
    /**
     * 车检到期日期
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd")
    private Date carInformationExamineEnddata;
    /**
     * 车辆类型外键ID
     */
//    @Schema(title = "车辆类型外键ID", type = "Long")
    private Long carInformationType;
    /**
     * 车辆品牌
     */
    private String carInformationBrand;
    /**
     * 是否重点车辆 (0否默认 1是 )
     */
    private Integer carInformationFocus;

    /**
     * 车辆电机厂商
     */
    private String carInformationMotorManufacturer;

    /**
     * 车辆电机型号
     */
    private String carInformationMotorModel;

    /**
     * 车辆电池厂商
     */
    private String carInformationBatteryManufacturer;

    /**
     * 车辆电池型号
     */
    private String carInformationBatteryModel;

    /**
     * 启用状态(1.在线 2.离线 3.已断开 4.待连接 5.维修中)
     */
    private Integer carInformationState;

    /**
     * 车辆策略id
     */
    private Integer carStrategyId;



    public static CarInformation carInformationBuilder(CarInformation carInformation) {
        return CarInformation.builder()
                .carInformationId(carInformation.getCarInformationId())
                .carInformationLicensePlate(carInformation.getCarInformationLicensePlate())
                .build();
    }

    public static CarInformation carInformationUpdBuilder(CarInformationUpdReq carInformation, Supplier<Long> idSupplier) {
        return CarInformation.builder()
                .carInformationId(idSupplier.get())
                .carInformationBrand(carInformation.getCarInformationBrand())
                .carInformationColor(carInformation.getCarInformationColor())
                .carInformationDriver(carInformation.getCarInformationDriver())
                .carInformationMotorManufacturer(carInformation.getCarInformationMotorManufacturer())
                .carInformationMotorModel(carInformation.getCarInformationMotorModel())
                .carInformationBatteryManufacturer(carInformation.getCarInformationBatteryManufacturer())
                .carInformationBatteryModel(carInformation.getCarInformationBatteryModel())
                .carInformationFence(carInformation.getCarInformationFence())
                .carInformationType(carInformation.getCarInformationType())
                .carInformationFocus(carInformation.getCarInformationFocus())
                .carInformationMotorModel(carInformation.getCarInformationMotorModel())
                .build();
    }

    public static CarInformation carInformationAddBuilder(CarInformationAddReq carInformation) {
        return CarInformation.builder()
                .carInformationVIN(carInformation.getCarInformationVIN())
                .carInformationLicensePlate(carInformation.getCarInformationLicensePlate())
                .carInformationBrand(carInformation.getCarInformationBrand())
                .carInformationColor(carInformation.getCarInformationColor())
                .carInformationDriver(carInformation.getCarInformationDriver())
                .carInformationMotorManufacturer(carInformation.getCarInformationMotorManufacturer())
                .carInformationMotorModel(carInformation.getCarInformationMotorModel())
                .carInformationBatteryManufacturer(carInformation.getCarInformationBatteryManufacturer())
                .carInformationBatteryModel(carInformation.getCarInformationBatteryModel())
                .carInformationFence(carInformation.getCarInformationFence())
                .carInformationType(carInformation.getCarInformationType())
                .carInformationMotorModel(carInformation.getCarInformationMotorModel())
                .build();
    }

    public static CarInformation carInformationListBuilder(CarInformation carInformation) {
        return CarInformation.builder()
                .carInformationId(carInformation.getCarInformationId())
                .carInformationVIN(carInformation.getCarInformationVIN())
                .carInformationLicensePlate(carInformation.getCarInformationLicensePlate())
                .carInformationBrand(carInformation.getCarInformationBrand())
                .carInformationColor(carInformation.getCarInformationColor())
                .carInformationDriver(carInformation.getCarInformationDriver())
                .carInformationMotorManufacturer(carInformation.getCarInformationMotorManufacturer())
                .carInformationMotorModel(carInformation.getCarInformationMotorModel())
                .carInformationBatteryManufacturer(carInformation.getCarInformationBatteryManufacturer())
                .carInformationBatteryModel(carInformation.getCarInformationBatteryModel())
                .carInformationFence(carInformation.getCarInformationFence())
                .carInformationType(carInformation.getCarInformationType())
                .carInformationMotorModel(carInformation.getCarInformationMotorModel())
                .carStrategyId(carInformation.getCarStrategyId())
                .build();
    }
}
