49 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package models
 | ||
| 
 | ||
| import (
 | ||
| 	"time"
 | ||
| 
 | ||
| 	"gorm.io/gorm"
 | ||
| )
 | ||
| 
 | ||
| // PigBatchSickPigTreatmentLocation 定义了病猪治疗地点
 | ||
| type PigBatchSickPigTreatmentLocation string
 | ||
| 
 | ||
| const (
 | ||
| 	TreatmentLocationOnSite  PigBatchSickPigTreatmentLocation = "原地治疗"
 | ||
| 	TreatmentLocationSickBay PigBatchSickPigTreatmentLocation = "病猪栏治疗"
 | ||
| )
 | ||
| 
 | ||
| // PigBatchSickPigReasonType 定义了病猪变化的原因类型
 | ||
| type PigBatchSickPigReasonType string
 | ||
| 
 | ||
| const (
 | ||
| 	SickPigReasonTypeIllness     PigBatchSickPigReasonType = "患病" // 猪只患病
 | ||
| 	SickPigReasonTypeRecovery    PigBatchSickPigReasonType = "康复" // 猪只康复
 | ||
| 	SickPigReasonTypeDeath       PigBatchSickPigReasonType = "死亡" // 猪只死亡
 | ||
| 	SickPigReasonTypeEliminate   PigBatchSickPigReasonType = "淘汰" // 猪只淘汰
 | ||
| 	SickPigReasonTypeTransferIn  PigBatchSickPigReasonType = "转入" // 病猪转入当前批次
 | ||
| 	SickPigReasonTypeTransferOut PigBatchSickPigReasonType = "转出" // 病猪转出当前批次 (例如转到其他批次或出售)
 | ||
| 	SickPigReasonTypeOther       PigBatchSickPigReasonType = "其他" // 其他原因
 | ||
| )
 | ||
| 
 | ||
| // PigSickLog 记录了猪批次中病猪数量的变化日志
 | ||
| type PigSickLog struct {
 | ||
| 	gorm.Model
 | ||
| 	PigBatchID        uint                             `gorm:"primaryKey;comment:关联的猪批次ID"`
 | ||
| 	PenID             uint                             `gorm:"not null;index;comment:所在猪圈ID"`
 | ||
| 	PigIDs            string                           `gorm:"size:500;comment:涉及的猪只ID列表,逗号分隔"`
 | ||
| 	ChangeCount       int                              `gorm:"not null;comment:变化数量, 正数表示新增, 负数表示移除"`
 | ||
| 	Reason            PigBatchSickPigReasonType        `gorm:"size:20;not null;comment:变化原因 (如: 患病, 康复, 死亡, 转入, 转出, 其他)"`
 | ||
| 	BeforeCount       int                              `gorm:"comment:变化前的数量"`
 | ||
| 	AfterCount        int                              `gorm:"comment:变化后的数量"`
 | ||
| 	Remarks           string                           `gorm:"size:255;comment:备注"`
 | ||
| 	TreatmentLocation PigBatchSickPigTreatmentLocation `gorm:"size:50;comment:治疗地点"`
 | ||
| 	OperatorID        uint                             `gorm:"comment:操作员ID"`
 | ||
| 	HappenedAt        time.Time                        `gorm:"primaryKey;comment:事件发生时间"`
 | ||
| }
 | ||
| 
 | ||
| func (PigSickLog) TableName() string {
 | ||
| 	return "pig_sick_logs"
 | ||
| }
 |