package com.ruoyi.web.modules.industryservice.domain;

import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.BaseEntity;

/**
 * 牦牛资产档案实体，对应表 {@code biz_yak_asset}。
 * <p>
 * 主数据由第三方入栏建档接口 {@code GET /open-api/v1/farming/entry-filings} 同步写入；
 * 详情页「个体生理」实时值由 {@link com.ruoyi.web.modules.industryservice.service.YakAssetPhysioLiveService}
 * 调用 IoT 开放接口覆盖展示，列表仍可能展示库内快照字段。
 * </p>
 *
 * <h3>唯一性与关联</h3>
 * <ul>
 *   <li>业务主键：{@code yak_no}（场内牛只编号，对应 OpenAPI {@code cattleNo}）</li>
 *   <li>第三方主键：{@code external_id}（对应 OpenAPI {@code cattleId}），同步 upsert 时优先匹配</li>
 *   <li>耳标 {@code ear_tag_number} 用于 IoT 耳标接口查询；圈舍环境查询使用 {@code farm_external_id} + {@code enclosure_external_id}</li>
 * </ul>
 *
 * @see com.ruoyi.web.modules.industryservice.support.YakEntryOpenApiMapper
 * @see com.ruoyi.web.modules.industryservice.service.YakAssetBundleSyncTxService
 */
public class BizYakAsset extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 本地主键 */
    private Long id;

    /** 第三方牛只唯一 ID（OpenYakEntryDto.cattleId），同步合并键优先 */
    private Long externalId;

    /** 场内牛只编号（OpenYakEntryDto.cattleNo），库表唯一索引 uk_yak_no */
    private String yakNo;

    /** 耳标编号（OpenYakEntryDto.earTagNumber）；详情生理数据查询必传参数 */
    private String earTagNumber;

    /** 本地养殖场 ID（biz_pasture.id），由 farmId 解析 */
    private Long pastureId;

    /** 养殖场名称冗余展示（OpenYakEntryDto.farmName） */
    private String pastureName;

    /** 第三方养殖场 ID（OpenYakEntryDto.farmId）；环境监测接口 farmId 参数 */
    private Long farmExternalId;

    /** 第三方圈舍 ID（OpenYakEntryDto.farmEnclosureId）；环境监测接口 enclosureId 参数 */
    private Long enclosureExternalId;

    /** 本地圈舍 ID（biz_farm_enclosure.id），由 enclosureExternalId 解析 */
    private Long enclosureId;

    /** 圈舍名称（OpenYakEntryDto.farmEnclosureName） */
    private String enclosureName;

    /** 批次编号展示值；由 batch_external_id 关联 biz_farming_batch.batch_no 得到 */
    private String batchNo;

    /** 第三方养殖批次 ID（OpenYakEntryDto.batchId） */
    private Long batchExternalId;

    /** 本地养殖批次 ID（biz_farming_batch.id） */
    private Long batchId;

    /** 入栏周期（OpenYakEntryDto.entryCycle） */
    private String entryCycle;

    /** 性别：公/母（由 cattleSex 规范） */
    private String gender;

    /** 牛只品种（OpenYakEntryDto.cattleVariety） */
    private String cattleVariety;

    /** 牛只图片 URL（OpenYakEntryDto.cattlePicture） */
    private String cattlePicture;

    /** 登记人（OpenYakEntryDto.registrant） */
    private String registrant;

    /** 备注（OpenYakEntryDto.remark） */
    private String remark;

    /** 出生日期；同步时有值则据此计算 age_months */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date birthDate;

    /**
     * 月龄（月）。入栏同步时由 {@link com.ruoyi.web.modules.industryservice.support.YakAssetValidation#resolveAgeMonths}
     * 根据 birthDate 与同步时间计算写入；统计看板缺失时可由 birth_date 回退计算。
     */
    private Integer ageMonths;

    /** 入栏日期时间（OpenYakEntryDto.entryTime） */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date entryDate;

    /** 入栏体重 kg（OpenYakEntryDto.weight） */
    private BigDecimal entryWeightKg;

    /** 来源：自繁/外购/引进等（OpenYakEntryDto.cattleSource） */
    private String source;

    /** 养殖方式：半舍饲/散养/圈养等 */
    private String breedingMethod;

    /**
     * 资产状态：1 正常、2 死淘、3 丢失、4 出栏。
     * 第三方状态经 {@link com.ruoyi.web.modules.industryservice.support.YakAssetStatusMapper} 映射。
     */
    private Integer assetStatus;

    /** 状态变更日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date statusChangeDate;

    /** 状态变更原因 */
    private String statusChangeReason;

    /** 圈舍位置（入栏同步时与 enclosureName 同源） */
    private String penLocation;

    /** 预计出栏日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date expectedOutDate;

    /** 补饲方案文字 */
    private String supplementPlan;

    /**
     * 实时体温 ℃。列表读库内快照；详情由耳标接口转化后温度（temperature）实时覆盖。
     */
    private BigDecimal realtimeTemp;

    /**
     * 实时运动量（步）。列表读库内快照；详情由耳标接口 steps 实时覆盖。
     */
    private Integer realtimeSteps;

    /**
     * 环境温度 ℃。详情由环境监测接口 temperature 实时覆盖（取圈舍最新一条）。
     */
    private BigDecimal envTemp;

    /** 位置描述（OpenYakEntryDto.farmLocation 等） */
    private String location;

    /**
     * 生理数据采集/上报时间。详情取耳标 reportTime 最大的一条；与环境温度采集时间独立。
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date physioCollectTime;

    /** 父亲编号，系谱跳转用 */
    private String fatherYakNo;

    /** 母亲编号，系谱跳转用 */
    private String motherYakNo;

    /** 最近一次入栏建档同步成功时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastSyncTime;

    /** 删除标志：0 正常 2 删除 */
    private String delFlag;

    /** 列表查询专用：牦牛编号 keyword 模糊匹配，非表字段 */
    private String keyword;

    public Long getId()
    {
        return id;
    }

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

    public Long getExternalId()
    {
        return externalId;
    }

    public void setExternalId(Long externalId)
    {
        this.externalId = externalId;
    }

    public String getYakNo()
    {
        return yakNo;
    }

    public void setYakNo(String yakNo)
    {
        this.yakNo = yakNo;
    }

    public String getEarTagNumber()
    {
        return earTagNumber;
    }

    public void setEarTagNumber(String earTagNumber)
    {
        this.earTagNumber = earTagNumber;
    }

    public Long getPastureId()
    {
        return pastureId;
    }

    public void setPastureId(Long pastureId)
    {
        this.pastureId = pastureId;
    }

    public String getPastureName()
    {
        return pastureName;
    }

    public void setPastureName(String pastureName)
    {
        this.pastureName = pastureName;
    }

    public Long getFarmExternalId()
    {
        return farmExternalId;
    }

    public void setFarmExternalId(Long farmExternalId)
    {
        this.farmExternalId = farmExternalId;
    }

    public Long getEnclosureExternalId()
    {
        return enclosureExternalId;
    }

    public void setEnclosureExternalId(Long enclosureExternalId)
    {
        this.enclosureExternalId = enclosureExternalId;
    }

    public Long getEnclosureId()
    {
        return enclosureId;
    }

    public void setEnclosureId(Long enclosureId)
    {
        this.enclosureId = enclosureId;
    }

    public String getEnclosureName()
    {
        return enclosureName;
    }

    public void setEnclosureName(String enclosureName)
    {
        this.enclosureName = enclosureName;
    }

    public String getBatchNo()
    {
        return batchNo;
    }

    public void setBatchNo(String batchNo)
    {
        this.batchNo = batchNo;
    }

    public Long getBatchExternalId()
    {
        return batchExternalId;
    }

    public void setBatchExternalId(Long batchExternalId)
    {
        this.batchExternalId = batchExternalId;
    }

    public Long getBatchId()
    {
        return batchId;
    }

    public void setBatchId(Long batchId)
    {
        this.batchId = batchId;
    }

    public String getEntryCycle()
    {
        return entryCycle;
    }

    public void setEntryCycle(String entryCycle)
    {
        this.entryCycle = entryCycle;
    }

    public String getGender()
    {
        return gender;
    }

    public void setGender(String gender)
    {
        this.gender = gender;
    }

    public String getCattleVariety()
    {
        return cattleVariety;
    }

    public void setCattleVariety(String cattleVariety)
    {
        this.cattleVariety = cattleVariety;
    }

    public String getCattlePicture()
    {
        return cattlePicture;
    }

    public void setCattlePicture(String cattlePicture)
    {
        this.cattlePicture = cattlePicture;
    }

    public String getRegistrant()
    {
        return registrant;
    }

    public void setRegistrant(String registrant)
    {
        this.registrant = registrant;
    }

    public String getRemark()
    {
        return remark;
    }

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

    public Date getBirthDate()
    {
        return birthDate;
    }

    public void setBirthDate(Date birthDate)
    {
        this.birthDate = birthDate;
    }

    public Integer getAgeMonths()
    {
        return ageMonths;
    }

    public void setAgeMonths(Integer ageMonths)
    {
        this.ageMonths = ageMonths;
    }

    public Date getEntryDate()
    {
        return entryDate;
    }

    public void setEntryDate(Date entryDate)
    {
        this.entryDate = entryDate;
    }

    public BigDecimal getEntryWeightKg()
    {
        return entryWeightKg;
    }

    public void setEntryWeightKg(BigDecimal entryWeightKg)
    {
        this.entryWeightKg = entryWeightKg;
    }

    public String getSource()
    {
        return source;
    }

    public void setSource(String source)
    {
        this.source = source;
    }

    public String getBreedingMethod()
    {
        return breedingMethod;
    }

    public void setBreedingMethod(String breedingMethod)
    {
        this.breedingMethod = breedingMethod;
    }

    public Integer getAssetStatus()
    {
        return assetStatus;
    }

    public void setAssetStatus(Integer assetStatus)
    {
        this.assetStatus = assetStatus;
    }

    public Date getStatusChangeDate()
    {
        return statusChangeDate;
    }

    public void setStatusChangeDate(Date statusChangeDate)
    {
        this.statusChangeDate = statusChangeDate;
    }

    public String getStatusChangeReason()
    {
        return statusChangeReason;
    }

    public void setStatusChangeReason(String statusChangeReason)
    {
        this.statusChangeReason = statusChangeReason;
    }

    public String getPenLocation()
    {
        return penLocation;
    }

    public void setPenLocation(String penLocation)
    {
        this.penLocation = penLocation;
    }

    public Date getExpectedOutDate()
    {
        return expectedOutDate;
    }

    public void setExpectedOutDate(Date expectedOutDate)
    {
        this.expectedOutDate = expectedOutDate;
    }

    public String getSupplementPlan()
    {
        return supplementPlan;
    }

    public void setSupplementPlan(String supplementPlan)
    {
        this.supplementPlan = supplementPlan;
    }

    public BigDecimal getRealtimeTemp()
    {
        return realtimeTemp;
    }

    public void setRealtimeTemp(BigDecimal realtimeTemp)
    {
        this.realtimeTemp = realtimeTemp;
    }

    public Integer getRealtimeSteps()
    {
        return realtimeSteps;
    }

    public void setRealtimeSteps(Integer realtimeSteps)
    {
        this.realtimeSteps = realtimeSteps;
    }

    public BigDecimal getEnvTemp()
    {
        return envTemp;
    }

    public void setEnvTemp(BigDecimal envTemp)
    {
        this.envTemp = envTemp;
    }

    public String getLocation()
    {
        return location;
    }

    public void setLocation(String location)
    {
        this.location = location;
    }

    public Date getPhysioCollectTime()
    {
        return physioCollectTime;
    }

    public void setPhysioCollectTime(Date physioCollectTime)
    {
        this.physioCollectTime = physioCollectTime;
    }

    public String getFatherYakNo()
    {
        return fatherYakNo;
    }

    public void setFatherYakNo(String fatherYakNo)
    {
        this.fatherYakNo = fatherYakNo;
    }

    public String getMotherYakNo()
    {
        return motherYakNo;
    }

    public void setMotherYakNo(String motherYakNo)
    {
        this.motherYakNo = motherYakNo;
    }

    public Date getLastSyncTime()
    {
        return lastSyncTime;
    }

    public void setLastSyncTime(Date lastSyncTime)
    {
        this.lastSyncTime = lastSyncTime;
    }

    public String getDelFlag()
    {
        return delFlag;
    }

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

    public String getKeyword()
    {
        return keyword;
    }

    public void setKeyword(String keyword)
    {
        this.keyword = keyword;
    }
}
