package com.zhyc.module.biosafety.domain;

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

import com.fasterxml.jackson.annotation.JsonFormat;
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_diagnosis
 * 
 * @author ruoyi
 * @date 2025-07-15
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Diagnosis extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** $column.columnComment */
    private Long id;

    /** 治疗记录id */
    @Excel(name = "治疗记录")
    private Long treatId;
    private Integer[] treatIds;
    /** 时间日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "时间日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date datetime;

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


    private Long sheepId;



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

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

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


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

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

    private Long diseasePid;

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

    private Long diseaseId;

    /** 诊疗结果 */
    @Excel(name = "诊疗结果")
    private String resultName;
    /** 诊断结果 */
    private String result;

    /** 开始时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date begindate;

    /** 结束时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date enddate;

    /** 治疗天数 */
    @Excel(name = "治疗天数")
    private Long treatDay;

    /** 羊舍id */
    @Excel(name = "羊舍")
    private String sheepfold;

    private Long sheepfoldId;

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

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

    private Long userId;
    private Long deptId;

    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 = Gender.getDescByCode(resultCode);
            } catch (NumberFormatException e) {
                // 如果转换失败，设置为空或默认值
                this.resultName = null;
            }
        } else {
            this.resultName = null;
        }
    }

}
