package com.ruoyi.web.v1.model;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalTime;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.*;

/**
 * 入场批次对象 entrance_batch
 * 
 * @author coede
 * @date 2025-03-19
 */
public class EntranceBatch extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** ID */
    private Long id;

    /** 供应商ID */
    @Excel(name = "供应商ID")
    private Long supplierId;

    /** 进场时间 */
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "进场时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime entranceTime;

    /** 产地：三选一：1-本市、2-市外、3-省外，默认本市 */
    @Excel(name = "产地：三选一：1-本市、2-市外、3-省外，默认本市")
    private String originPlace;


    /** 动物品种 */
    @Excel(name = "动物品种")
    private String variety;
    private String animalType;

    /** 运输车辆 */
    @Excel(name = "运输车辆")
    private String transportVehicle;

    /** 重量 */
    @Excel(name = "重量")
    private BigDecimal weight;

    /** 待宰圈 */
    @Excel(name = "待宰圈")
    private String pigpens;

    /** 检疫证号码 */
    @Excel(name = "检疫证号码")
    private String animalCertNo;

    /** 检疫证图片或文件 */
    @Excel(name = "检疫证图片或文件")
    private String animalCertPics;

    /** 货主 */
    @Excel(name = "货主")
    private String cargoOwner;

    /** 主体识别号 */
    @Excel(name = "主体识别号")
    private String companyNo;

    /** 货主联系方式 */
    @Excel(name = "货主联系方式")
    private String cargoOwnerPhone;

    /** 动物种类 */
    @Excel(name = "动物种类")
    private String animalCategory;

    /** 数量 */
    @Excel(name = "数量")
    private Integer amount;

    /** 单位 */
    @Excel(name = "单位")
    private String units;

    /** 用途 */
    @Excel(name = "用途")
    private String useto;

    /** 启运地点 */
    @Excel(name = "启运地点")
    private String fromPlace;

    /** 到达地点 */
    @Excel(name = "到达地点")
    private String toPlace;

    /** 承运人 */
    @Excel(name = "承运人")
    private String carrier;

    /** 承运人联系方式 */
    @Excel(name = "承运人联系方式")
    private String carrierPhone;

    /** 牲畜耳标号 */
    @Excel(name = "牲畜耳标号")
    private String animalEartags;

    /** 备注 */
    @Excel(name = "备注")
    private String remark;
    private String yunzaifangshi;
    private String yunzaipaihao;
    private String xiaoduqingkuang;

    public String getYunzaifangshi() {
        return yunzaifangshi;
    }

    public void setYunzaifangshi(String yunzaifangshi) {
        this.yunzaifangshi = yunzaifangshi;
    }

    public String getYunzaipaihao() {
        return yunzaipaihao;
    }

    public void setYunzaipaihao(String yunzaipaihao) {
        this.yunzaipaihao = yunzaipaihao;
    }

    public String getXiaoduqingkuang() {
        return xiaoduqingkuang;
    }

    public void setXiaoduqingkuang(String xiaoduqingkuang) {
        this.xiaoduqingkuang = xiaoduqingkuang;
    }

    /** 删除标志 */
    private String delFlag;

    private HarmlessTreatment harmlessTreatment;

    private Supplier supplier;

    public String getAnimalType() {
        return animalType;
    }

    public void setAnimalType(String animalType) {
        this.animalType = animalType;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }

    public void setSupplierId(Long supplierId) 
    {
        this.supplierId = supplierId;
    }

    @NotNull(message = "供应商不能为空")
    public Long getSupplierId() 
    {
        return supplierId;
    }

    public void setEntranceTime(LocalDateTime entranceTime)
    {
        this.entranceTime = entranceTime;
    }

    public void entranceTimeAdapter() {
        if(entranceTime != null) {
            LocalDateTime realTime = entranceTime;
            if((realTime.getHour() == 0) && (realTime.getMinute() == 0) && (realTime.getSecond() == 0)) {
                LocalTime nowTime = LocalTime.now();
                realTime = realTime.withHour(nowTime.getHour())
                        .withMinute(nowTime.getMinute())
                        .minusSeconds(nowTime.getSecond())
                        .withNano(nowTime.getNano());
                entranceTime = realTime;
            }
        }else {
            this.entranceTime = LocalDateTime.now();
        }
    }

    @NotNull(message = "进场时间不能为空")
    public LocalDateTime getEntranceTime()
    {
        return entranceTime;
    }

    public void setOriginPlace(String originPlace)
    {
        this.originPlace = originPlace;
    }

    @NotBlank(message = "产地不能为空")
    public String getOriginPlace()
    {
        return originPlace;
    }

    public void setVariety(String variety) 
    {
        this.variety = variety;
    }

    @NotBlank(message = "品种不能为空")
    public String getVariety() 
    {
        return variety;
    }

    public void setTransportVehicle(String transportVehicle) 
    {
        this.transportVehicle = transportVehicle;
    }

    @Size(min = 0, max = 10, message = "运输车牌号输入超出最大长度限制（10位）")
    public String getTransportVehicle() 
    {
        return transportVehicle;
    }

    public void setWeight(BigDecimal weight) 
    {
        this.weight = weight;
    }

    @DecimalMin(value = "0.01", inclusive = true, message = "重量输入超出设定范围限制（0.01~99999.99）")
    @DecimalMax(value = "99999.99", inclusive = true, message = "重量输入超出设定范围限制（0.01~99999.99）")
    @Digits(integer = 5, fraction = 2, message = "重量输入的整数部分不能超过5位，小数部分不能超过2位")
    public BigDecimal getWeight() 
    {
        return weight;
    }

    public void setPigpens(String pigpens) 
    {
        this.pigpens = pigpens;
    }

    public String getPigpens() 
    {
        return pigpens;
    }

    public void setAnimalCertNo(String animalCertNo)
    {
        this.animalCertNo = animalCertNo;
    }

    @NotBlank(message = "检疫证号不能为空")
    @Pattern(regexp = "^\\d+$", message = "检疫证号格式输入错误（数字）")
    public String getAnimalCertNo()
    {
        return animalCertNo;
    }

    public void setAnimalCertPics(String animalCertPics) 
    {
        this.animalCertPics = animalCertPics;
    }

    public String getAnimalCertPics() 
    {
        return animalCertPics;
    }

    public void setCargoOwner(String cargoOwner) 
    {
        this.cargoOwner = cargoOwner;
    }

    @NotBlank(message = "货主不能为空")
    @Size(min = 1, max = 30, message = "货主输入超出最大长度限制（30位）")
    public String getCargoOwner() 
    {
        return cargoOwner;
    }

    public void setCompanyNo(String companyNo) 
    {
        this.companyNo = companyNo;
    }

    @NotBlank(message = "主体识别号不能为空")
    @Size(min = 1, max = 18, message = "主体识别号输入超出最大长度限制（18位）")
    public String getCompanyNo() 
    {
        return companyNo;
    }

    public void setCargoOwnerPhone(String cargoOwnerPhone) 
    {
        this.cargoOwnerPhone = cargoOwnerPhone;
    }

    @NotBlank(message = "联系方式不能为空")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "联系方式格式输入错误")
    public String getCargoOwnerPhone() 
    {
        return cargoOwnerPhone;
    }

    public void setAnimalCategory(String animalCategory) 
    {
        this.animalCategory = animalCategory;
    }

    @NotBlank(message = "动物种类不能为空")
    @Size(min = 1, max = 10, message = "动物种类输入超出最大长度限制（10位）")
    public String getAnimalCategory() 
    {
        return animalCategory;
    }

    public void setAmount(Integer amount) 
    {
        this.amount = amount;
    }

    @NotNull(message = "数量不能为空")
    @Min(value = 1, message = "数量输入超出设定范围限制（1~999）")
    @Max(value = 999, message = "数量输入超出设定范围限制（1~999）")
    public Integer getAmount() 
    {
        return amount;
    }

    public void setUnits(String units) 
    {
        this.units = units;
    }

    @NotBlank(message = "单位不能为空")
    public String getUnits() 
    {
        return units;
    }

    public void setUseto(String useto)
    {
        this.useto = useto;
    }

    @NotBlank(message = "用途不能为空")
    @Size(min = 1, max = 10, message = "用途输入超出最大长度限制（10位）")
    public String getUseto()
    {
        return useto;
    }

    public void setFromPlace(String fromPlace) 
    {
        this.fromPlace = fromPlace;
    }

    @NotBlank(message = "启运地点不能为空")
    @Size(min = 1, max = 50, message = "启运地点输入超出最大长度限制（50位）")
    public String getFromPlace() 
    {
        return fromPlace;
    }

    public void setToPlace(String toPlace) 
    {
        this.toPlace = toPlace;
    }

    @NotBlank(message = "到达地点不能为空")
    @Size(min = 1, max = 50, message = "到达地点输入超出最大长度限制（50位）")
    public String getToPlace() 
    {
        return toPlace;
    }

    public void setCarrier(String carrier) 
    {
        this.carrier = carrier;
    }

    @NotBlank(message = "承运人不能为空")
    @Size(min = 1, max = 30, message = "承运人输入超出最大长度限制（30位）")
    public String getCarrier() 
    {
        return carrier;
    }

    public void setCarrierPhone(String carrierPhone) 
    {
        this.carrierPhone = carrierPhone;
    }

    @NotBlank(message = "联系方式不能为空")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "联系方式格式输入错误")
    public String getCarrierPhone() 
    {
        return carrierPhone;
    }

    public void setAnimalEartags(String animalEartags) 
    {
        this.animalEartags = animalEartags;
    }

    @NotBlank(message = "耳标号不能为空")
    @Size(min = 15, max = 5000, message = "耳标号格式输入错误")
    public String getAnimalEartags() 
    {
        return animalEartags;
    }

    @Override
    public void setRemark(String remark)
    {
        this.remark = remark;
    }

    @Override
    @Size(min = 0, max = 50, message = "备注输入超出最大长度限制（50位）")
    public String getRemark()
    {
        return remark;
    }

    public void setDelFlag(String delFlag) 
    {
        this.delFlag = delFlag;
    }

    public String getDelFlag() 
    {
        return delFlag;
    }

    public void setHarmlessTreatment(HarmlessTreatment harmlessTreatment)
    {
        this.harmlessTreatment = harmlessTreatment;
    }

    public HarmlessTreatment getHarmlessTreatment()
    {
        return harmlessTreatment;
    }

    public void setSupplier(Supplier supplier)
    {
        this.supplier = supplier;
    }
    public Supplier getSupplier()
    {
        return supplier;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("supplierId", getSupplierId())
            .append("entranceTime", getEntranceTime())
            .append("variety", getVariety())
            .append("transportVehicle", getTransportVehicle())
            .append("weight", getWeight())
            .append("pigpens", getPigpens())
            .append("animalCertNo", getAnimalCertNo())
            .append("animalCertPics", getAnimalCertPics())
            .append("cargoOwner", getCargoOwner())
            .append("companyNo", getCompanyNo())
            .append("cargoOwnerPhone", getCargoOwnerPhone())
            .append("animalCategory", getAnimalCategory())
            .append("amount", getAmount())
            .append("units", getUnits())
            .append("useto", getUseto())
            .append("fromPlace", getFromPlace())
            .append("toPlace", getToPlace())
            .append("carrier", getCarrier())
            .append("carrierPhone", getCarrierPhone())
            .append("animalEartags", getAnimalEartags())
            .append("remark", getRemark())
            .append("createTime", getCreateTime())
            .append("createBy", getCreateBy())
            .append("updateTime", getUpdateTime())
            .append("updateBy", getUpdateBy())
            .append("delFlag", getDelFlag())
                .append("harmlessTreatment", getHarmlessTreatment())
                .append("supplier", getSupplier())
            .toString();
    }
}
