猪群管理聚合服务 增加调栏管理

This commit is contained in:
2025-10-05 17:30:39 +08:00
parent 6d080d250d
commit 01327eb8d2
10 changed files with 350 additions and 33 deletions

View File

@@ -0,0 +1,19 @@
package models
import (
"time"
"gorm.io/gorm"
)
// PigTransferLog 记录了每一次猪只数量在猪栏间的变动事件。
// 它作为事件溯源的基础,用于推算任意时间点猪栏的猪只数量。
type PigTransferLog struct {
gorm.Model
TransferTime time.Time `json:"transfer_time"` // 迁移发生时间
PigBatchID uint `json:"pig_batch_id"` // 关联的猪群ID
PenID uint `json:"pen_id"` // 发生变动的猪栏ID
Quantity int `json:"quantity"` // 变动数量(正数表示增加,负数表示减少)
Type string `json:"type"` // 变动类型 (e.g., "群内调栏", "跨群调栏", "销售", "死亡", "新购入")
CorrelationID string `json:"correlation_id"` // 用于关联一次完整操作(如一次调栏会产生两条日志)
}