package com.yuchen.saas.parking.api.vo;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.*;
import com.thinkunion.park.service.common.enums.parking.EnergyTypeEnum;
import com.thinkunion.park.service.common.enums.parking.VehicleTypeEnum;
import com.yuchen.saas.parking.api.util.DateUtils;
import com.yuchen.saas.parking.api.util.StringUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.nest.springwrap.core.tool.utils.Func;
import org.nest.springwrap.core.tool.utils.StringPool;

import java.util.Date;

/**
 * @Description 月卡导出Excel
 */
@Data
@HeadStyle(horizontalAlignment = HorizontalAlignment.CENTER)
@HeadRowHeight(25)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
@ColumnWidth(12)
@ContentRowHeight(15)
@HeadFontStyle(fontHeightInPoints =9)
@ExcelIgnoreUnannotated
public class MonthlyCardDataExcelVo {

    @ExcelProperty("序号")
    @ApiModelProperty("序号")
    private Integer order;

    @ExcelProperty("车牌号")
    @ApiModelProperty("车牌")
    private String plateNo;

    @ApiModelProperty("能源类型（0：其他类型、1：汽油车、2：新能源）")
    private Integer energyType;

    @ExcelProperty("能源类型")
    @ApiModelProperty("能源类型（0：其他类型、1：汽油车、2：新能源）")
    private String energyTypeName;

    @ApiModelProperty("车辆类型（0：其他车、1：小型车、2：大型车、3：摩托车）")
    private Integer vehicleType;

    @ExcelProperty("车牌类型")
    @ApiModelProperty("车辆类型（0：其他车、1：小型车、2：大型车、3：摩托车）")
    private String vehicleTypeName;

    @ExcelProperty("月卡类型")
    @ApiModelProperty("月卡类型")
    private String ruleName;

    @ExcelProperty("使用有效期")
    @ApiModelProperty("使用有效期")
    private String validityPeriod;

    @ApiModelProperty(name = "beginTime", value = "包租 开始时间")
    private Date beginTime;

    @ApiModelProperty(name = "endTime", value = "包租 结束时间")
    private Date endTime;

    @ExcelProperty("停车场")
    @ApiModelProperty("停车场")
    private String parkingName;

//    @ExcelProperty("车位号")
    @ApiModelProperty(name = "spaceNo", value = "车位号")
    private String spaceNo;

    @ExcelProperty("单位")
    @ApiModelProperty("单位")
    private String companyName;

    @ApiModelProperty("车主名称")
    private String personName;

    @ApiModelProperty("绑定手机号")
    private String personPhone;

    @ApiModelProperty("备注")
    private String remark;

    public String getEnergyTypeName(){
        return EnergyTypeEnum.getDescByCode(energyType);
    }

    public String getVehicleTypeName(){
        return VehicleTypeEnum.getDescByCode(energyType);
    }

    public String getValidityPeriod(){
        if(Func.isEmpty(beginTime)&&Func.isEmpty(endTime)){
            return StringPool.EMPTY;
        }
        return String.format("%s~%s",Func.isEmpty(beginTime)?StringPool.EMPTY: DateUtils.dateToString(beginTime),
                Func.isEmpty(endTime)?StringPool.EMPTY: DateUtils.dateToString(endTime));
    }

}
