package com.sw.common.accessory.server.dto;

import com.alibaba.excel.annotation.ExcelProperty;
import com.sw.common.core.annotation.Trans;
import com.sw.common.core.easyexcel.EasyBaseConverter;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.ListValue;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import static com.sw.common.accessory.config.Constant.*;

/**
 * @author zhaowenjie
 */
@Data
public class AccessoryImportDto {
    @ExcelProperty(value = "设备编号", index = 0)
    @ApiModelProperty(value = "设备编号", required = true)
//    @NotBlank(message = "设备编号，不能为空")
    String equipmentCode;
    @ExcelProperty(value = "物料名称", index = 1)
    @ApiModelProperty(value = "物料名称", required = true)
    String materialName;
    @ExcelProperty(value = "物料料号", index = 2)
    @ApiModelProperty(value = "物料料号", required = true)
    @NotBlank(message = "物料料号，不能为空")
    String materialCode;
    @ExcelProperty(value = "批次号", index = 3)
    @ApiModelProperty(value = "批次号", required = true)
    String batchCode;
    @ExcelProperty(value = "唯一码", index = 4)
    @ApiModelProperty(value = "唯一码", required = true)
    @NotBlank(message = "唯一码，不能为空")
    String uniqueCode;

    @Trans(ENUM_DICT_ACCY_STATUS)
    @ExcelProperty(value = "物料状态", index = 5, converter = EasyBaseConverter.class)
    @ApiModelProperty(value = "物料状态", required = true)
    @NotNull(message = "物料状态，不能为空")
    @ListValue(enumDictName = ENUM_DICT_ACCY_STATUS)
    Integer accessoryStatus;

    @Trans(ENUM_DICT_ACCY_USE_STATUS)
    @ExcelProperty(value = "使用状态", index = 6, converter = EasyBaseConverter.class)
    @ApiModelProperty(value = "使用状态", required = true)
    @NotNull(message = "使用状态，不能为空")
    @ListValue(values = {0, 1, 3}, enumDictName = ENUM_DICT_ACCY_USE_STATUS, message = "使用状态只能为 待上机，上机中，已退库")
    Integer status;

    @ExcelProperty(value = "已使用寿命", index = 7)
    @ApiModelProperty(value = "已使用寿命", required = true)
    @NotNull(message = "使用状态，不能为空")
    @Min(value = 0, message = "已使用寿命，不能小于0")
    Integer usefulLife;
    /**
     * 寿命类型（0：炉次） ,默认 0
     */
    @Trans(ENUM_DICT_ACCY_LIFE_TYPE)
    @ExcelProperty(value = "寿命类型", index = 8, converter = EasyBaseConverter.class)
    @NotNull(message = "寿命类型，不能为空")
    @ListValue(enumDictName = ENUM_DICT_ACCY_LIFE_TYPE)
    Integer lifeType;
    @ExcelProperty(value = "备注", index = 9)
    @ApiModelProperty(value = "备注", required = true)
    String remarks;

    public String getEquipmentCode() {
        return equipmentCode == null ? "" : equipmentCode;
    }
}
