package com.zhyc.module.biosafety.domain;

import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zhyc.module.biosafety.enums.QuarantineResult;
import com.zhyc.module.biosafety.enums.QuarantineStatus;
import com.zhyc.module.enums.Gender;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
import org.apache.ibatis.type.Alias;

/**
 * 检疫记录对象 sw_quarantine_report
 * 
 * @author ruoyi
 * @date 2025-07-14
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Alias("QuarantineReport")
public class QuarantineReport extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** id */
    private Long id;


//  羊只耳号
    private String[] ids;

    /** 羊只 */
    private Long sheepId;

    @Excel(name = "羊只耳号")
    private String sheepNo;
    private String[] sheepNos;
    /** 全部羊耳号列表（用于多耳号查询） */
    private List<String> allEarNumbers;

    @Excel(name = "品种")
    private String variety;
    /** 检疫日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "检疫日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date datetime;

    @Excel(name = "羊只类别")
    private String sheepType;
    @Excel(name = "羊只性别")
    private String genderName;
    private String gender;
    @Excel(name = "月龄")
    private Long monthAge;
    @Excel(name = "胎次")
    private Long parity;
    @Excel(name = "繁育状态")
    private String breed;




    /** 检疫项目 */

    private Long quarItem;

    /** 检疫项目 */
    @Excel(name = "检疫项目")
    private String itemName;


    /** 样品类型 */
    private Long sampleType;

    /** 样品 */
    @Excel(name = "样品类型")
    private String sample;


    /** 采样员 */
    @Excel(name = "采样员")
    private String sampler;

    /** 检疫员 */
    @Excel(name = "检疫员")
    private String quarOfficer;

    /** 检疫结果 */
    @Excel(name = "检疫结果")
    private String resultName;
    private String result;

    /** 状态 */
    @Excel(name = "状态")
    private String statusName;
    private Integer status;

    /** 备注*/
    @Excel(name = "备注")
    private String comment;

    private Long userId;
    private Long deptId;

    /**
     * 是否在群查询条件（0-在群，1-离群），非数据库字段
     */
    private Integer isDelete;

    public void setGender(String gender) {
        this.gender = gender;
        if (gender != null && !gender.trim().isEmpty()) {
            try {
                Integer genderCode = Integer.valueOf(gender.trim());
                this.genderName = Gender.getDescByCode(genderCode);
            } catch (NumberFormatException e) {
                // 如果转换失败，设置为空或默认值
                this.genderName = null;
            }
        } else {
            this.genderName = null;
        }
    }
//    检疫结果转换
    public void setResult(String result) {
        this.result = result;
        if (result != null && !result.trim().isEmpty()) {
            try {
                Integer resultCode = Integer.valueOf(result.trim());
                this.resultName = QuarantineResult.getDescByCode(resultCode);
            } catch (NumberFormatException e) {
                // 如果转换失败，设置为空或默认值
                this.resultName = null;
            }
        } else {
            this.genderName = null;
        }
    }
//    检疫状态
    public void setStatus(Integer status) {
        this.status = status;
        if (status != null) {
            try {
                this.statusName = QuarantineStatus.getDescByCode(status);
            } catch (NumberFormatException e) {
                // 如果转换失败，设置为空或默认值
                this.statusName = null;
            }
        } else {
            this.statusName = null;
        }
    }

    //  排序查询
    private String orderByColumn;
    private String isAsc;
}
