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.TreatmentStatus;
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;

/**
 * 治疗记录对象 sw_treatment
 * 
 * @author ruoyi
 * @date 2025-07-15
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Treatment extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    private Long id;

    /** 诊疗记录id */
    private Long diagId;

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


    private Long sheepId;
//    用于批量新增
    private List<String> sheepIds;

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

    /** 羊只类别 */
    @Excel(name = "羊只类别")
    private String sheepType;

    /** 月龄 */
    @Excel(name = "月龄")
    private Long monthAge;

    /** 性别 */
    @Excel(name = "性别")
    private String genderName;
    private String gender;

    /** 胎次 */
    @Excel(name = "胎次")
    private Long parity;

    /** 繁殖状态 */
    @Excel(name = "繁殖状态")
    private String breed;

    /** 泌乳天数 */
    @Excel(name = "泌乳天数")
    private Long lactDay;

    /** 怀孕天数 */
    @Excel(name = "怀孕天数")
    private Long gestDay;

    /** 治疗日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "治疗日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date datetime;

    /** 疾病类型 */
    @Excel(name = "疾病类型")
    private String diseaseName;

    private Long diseaseId;


    /** 父疾病 */
    @Excel(name = "父疾病")
    private String diseasePName;

    private Long diseasePid;

    /** 兽医 */
    @Excel(name = "兽医")
    private String veterinary;
    /** 治疗状态 */
    @Excel(name = "治疗状态")
    private String statusName;
    private String status;


    /** 药品使用记录id */

    private Integer usageId;

    private Long userId;
    private Long deptId;

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




//    药品使用
    private List<SwMedicineUsageDetails> usageDetails;

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


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

    /** 性别转换 */
    public void setGender(String gender) {
        this.gender = gender;                       // 保留原始字符串
        this.genderName = null;                     // 先清空
        if (gender != null && !gender.trim().isEmpty()) {
            try {
                this.genderName = Gender.getDescByCode(Integer.valueOf(gender.trim()));
            } catch (NumberFormatException ex) {
                // 可选：记录日志、或抛业务异常
                this.genderName = "未知";
            }
        }
    }
    /** 状态转换 */
    public void setStatus(String status) {
        this.status = status;
        this.statusName = null;
        if (status != null && !status.trim().isEmpty()) {
            try {
                this.statusName = TreatmentStatus.getDescByCode(Integer.valueOf(status.trim()));
            } catch (NumberFormatException ex) {
                // 可选：记录日志、或抛业务异常
                this.statusName = "未知";
            }
        }
    }

}
