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.PrescriptionType;
import com.zhyc.module.biosafety.enums.TreatmentStatus;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;

/**
 * 药品使用记录对象 sw_medicine_usage
 * 
 * @author ruoyi
 * @date 2025-07-12
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SwMedicineUsage extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** id */
    private Integer id;

    /** 使用名称 */
    @Excel(name = "使用名称",width = 20, needMerge = true)
    private String name;

    /** 羊舍名称 */
    @Excel(name = "羊舍名称" ,width = 20, needMerge = true)
    private String sheepfoldName;
    private Integer sheepfoldId;
    /** 耳号 */
    @Excel(name = "耳号",width = 20, needMerge = true)
    private String sheepNo;
    private String[] sheepNos;
    /** 全部羊耳号列表（用于多耳号查询） */
    private List<String> allEarNumbers;


    private Integer sheepId;
    /** 使用时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "使用日期", width = 30, dateFormat = "yyyy-MM-dd", needMerge = true)
    private Date datetime;

    /** 使用类型 */
    @Excel(name = "使用类型",width = 20, needMerge = true)
    private String useTypeName;
    private String useType;


    private Long userId;
    private Long deptId;

    /** 药品使用记录详情信息 */
    @Excel
    private List<SwMedicineUsageDetails> swMedicineUsageDetailsList;


    /** 状态转换 */
    public void setUseType(String useType) {
        this.useType = useType;
        this.useTypeName = null;
        if (useType != null && !useType.trim().isEmpty()) {
            try {
                this.useTypeName = PrescriptionType.getDescByCode(Integer.valueOf(useType.trim()));
            } catch (NumberFormatException ex) {
                // 可选：记录日志、或抛业务异常
                this.useTypeName = "未知";
            }
        }
    }
}
