float64全部改float32
This commit is contained in:
@@ -54,8 +54,8 @@ const (
|
||||
// 它提供了必要的元数据,以便应用程序能够正确解释从设备读取的原始数据。
|
||||
type ValueDescriptor struct {
|
||||
Type SensorType `json:"type"`
|
||||
Multiplier float64 `json:"multiplier"` // 乘数,用于原始数据转换
|
||||
Offset float64 `json:"offset"` // 偏移量,用于原始数据转换
|
||||
Multiplier float32 `json:"multiplier"` // 乘数,用于原始数据转换
|
||||
Offset float32 `json:"offset"` // 偏移量,用于原始数据转换
|
||||
}
|
||||
|
||||
// --- 指令结构体 (Command Structs) ---
|
||||
|
||||
@@ -16,7 +16,7 @@ type RawMaterial struct {
|
||||
gorm.Model
|
||||
Name string `gorm:"size:100;unique;not null;comment:原料名称"`
|
||||
Description string `gorm:"size:255;comment:描述"`
|
||||
Quantity float64 `gorm:"not null;comment:库存总量, 单位: g"`
|
||||
Quantity float32 `gorm:"not null;comment:库存总量, 单位: g"`
|
||||
}
|
||||
|
||||
func (RawMaterial) TableName() string {
|
||||
@@ -29,9 +29,9 @@ type RawMaterialPurchase struct {
|
||||
RawMaterialID uint `gorm:"not null;index;comment:关联的原料ID"`
|
||||
RawMaterial RawMaterial `gorm:"foreignKey:RawMaterialID"`
|
||||
Supplier string `gorm:"size:100;comment:供应商"`
|
||||
Amount float64 `gorm:"not null;comment:采购数量, 单位: g"`
|
||||
UnitPrice float64 `gorm:"comment:单价"`
|
||||
TotalPrice float64 `gorm:"comment:总价"`
|
||||
Amount float32 `gorm:"not null;comment:采购数量, 单位: g"`
|
||||
UnitPrice float32 `gorm:"comment:单价"`
|
||||
TotalPrice float32 `gorm:"comment:总价"`
|
||||
PurchaseDate time.Time `gorm:"primaryKey;comment:采购日期"`
|
||||
CreatedAt time.Time
|
||||
}
|
||||
@@ -56,7 +56,7 @@ const (
|
||||
type RawMaterialStockLog struct {
|
||||
gorm.Model
|
||||
RawMaterialID uint `gorm:"not null;index;comment:关联的原料ID"`
|
||||
ChangeAmount float64 `gorm:"not null;comment:变动数量, 正数为入库, 负数为出库"`
|
||||
ChangeAmount float32 `gorm:"not null;comment:变动数量, 正数为入库, 负数为出库"`
|
||||
SourceType StockLogSourceType `gorm:"size:50;not null;index;comment:库存变动来源类型"`
|
||||
SourceID uint `gorm:"not null;index;comment:来源记录的ID (如 RawMaterialPurchase.ID 或 FeedUsageRecord.ID)"`
|
||||
HappenedAt time.Time `gorm:"primaryKey;comment:业务发生时间"`
|
||||
@@ -86,7 +86,7 @@ type FeedFormulaComponent struct {
|
||||
FeedFormulaID uint `gorm:"not null;index;comment:外键到 FeedFormula"`
|
||||
RawMaterialID uint `gorm:"not null;index;comment:外键到 RawMaterial"`
|
||||
RawMaterial RawMaterial `gorm:"foreignKey:RawMaterialID"`
|
||||
Percentage float64 `gorm:"not null;comment:该原料在配方中的百分比 (0-1.0)"`
|
||||
Percentage float32 `gorm:"not null;comment:该原料在配方中的百分比 (0-1.0)"`
|
||||
}
|
||||
|
||||
func (FeedFormulaComponent) TableName() string {
|
||||
@@ -102,7 +102,7 @@ type FeedUsageRecord struct {
|
||||
Pen Pen `gorm:"foreignKey:PenID"`
|
||||
FeedFormulaID uint `gorm:"not null;index;comment:使用的饲料配方ID"`
|
||||
FeedFormula FeedFormula `gorm:"foreignKey:FeedFormulaID"`
|
||||
Amount float64 `gorm:"not null;comment:使用数量, 单位: g"`
|
||||
Amount float32 `gorm:"not null;comment:使用数量, 单位: g"`
|
||||
RecordedAt time.Time `gorm:"primaryKey;comment:记录时间"`
|
||||
OperatorID uint `gorm:"not null;comment:操作员"`
|
||||
Remarks string `gorm:"comment:备注, 如 '例行喂料, 弱猪补料' 等"`
|
||||
|
||||
@@ -48,9 +48,9 @@ type PowderInstructions struct {
|
||||
// 出栏前停药期
|
||||
WithdrawalPeriod time.Duration `json:"withdrawal_period"`
|
||||
// 拌料使用计量, 每千克体重用多少克药, 单位: g/kg
|
||||
BodyWeightDosageUsed float64 `json:"body_weight_dosage_used"`
|
||||
BodyWeightDosageUsed float32 `json:"body_weight_dosage_used"`
|
||||
// 拌料使用剂量, 每升水加多少克药或每千克饲料干重加多少克药, 单位: g/kg(L)
|
||||
MixDosageUsed float64 `json:"mix_dosage_used"`
|
||||
MixDosageUsed float32 `json:"mix_dosage_used"`
|
||||
// 拌料使用方式, 兑水/拌料
|
||||
MixType MixType `json:"mix_type"`
|
||||
}
|
||||
@@ -61,8 +61,8 @@ type Medication struct {
|
||||
Name string `gorm:"size:100;not null;comment:药品名称" json:"name"`
|
||||
Type MedicationType `gorm:"size:20;not null;comment:兽药类型 (粉剂, 针剂, 疫苗)" json:"type"`
|
||||
Category MedicationCategory `gorm:"size:30;not null;comment:兽药种类 (四环素类, 磺胺类等)" json:"category"`
|
||||
DosagePerUnit float64 `gorm:"size:50;comment:一份药物的计量 (针剂计量单位为毫升, 粉剂为克)" json:"dosage_per_unit"`
|
||||
ActiveIngredientConcentration float64 `gorm:"size:50;comment:有效成分含量百分比" json:"active_ingredient_concentration"`
|
||||
DosagePerUnit float32 `gorm:"size:50;comment:一份药物的计量 (针剂计量单位为毫升, 粉剂为克)" json:"dosage_per_unit"`
|
||||
ActiveIngredientConcentration float32 `gorm:"size:50;comment:有效成分含量百分比" json:"active_ingredient_concentration"`
|
||||
Manufacturer string `gorm:"size:100;comment:生产厂家" json:"manufacturer"`
|
||||
Instructions datatypes.JSON `gorm:"type:jsonb;comment:使用说明" json:"instructions"`
|
||||
}
|
||||
@@ -86,7 +86,7 @@ type MedicationLog struct {
|
||||
PigBatchID uint `gorm:"not null;index;comment:关联的猪批次ID"`
|
||||
MedicationID uint `gorm:"not null;index;comment:关联的药品ID"`
|
||||
Medication Medication `gorm:"foreignKey:MedicationID"` // 预加载药品信息
|
||||
DosageUsed float64 `gorm:"not null;comment:使用的总剂量 (单位由药品决定,如g或ml)"`
|
||||
DosageUsed float32 `gorm:"not null;comment:使用的总剂量 (单位由药品决定,如g或ml)"`
|
||||
TargetCount int `gorm:"not null;comment:用药对象数量"`
|
||||
Reason MedicationReasonType `gorm:"size:20;not null;comment:用药原因"`
|
||||
Description string `gorm:"size:255;comment:具体描述,如'治疗呼吸道病'"`
|
||||
|
||||
@@ -95,7 +95,7 @@ func (WeighingBatch) TableName() string {
|
||||
// WeighingRecord 记录了单次称重信息
|
||||
type WeighingRecord struct {
|
||||
gorm.Model
|
||||
Weight float64 `gorm:"not null;comment:单只猪重量 (kg)"`
|
||||
Weight float32 `gorm:"not null;comment:单只猪重量 (kg)"`
|
||||
WeighingBatchID uint `gorm:"not null;index;comment:关联的批次称重ID"`
|
||||
PenID uint `gorm:"not null;index;comment:所在猪圈ID"`
|
||||
OperatorID uint `gorm:"not null;comment:操作员ID"`
|
||||
|
||||
@@ -13,8 +13,8 @@ type PigPurchase struct {
|
||||
PurchaseDate time.Time `gorm:"primaryKey;comment:采购日期"`
|
||||
Supplier string `gorm:"comment:供应商"`
|
||||
Quantity int `gorm:"not null;comment:采购数量"`
|
||||
UnitPrice float64 `gorm:"not null;comment:单价"`
|
||||
TotalPrice float64 `gorm:"not null;comment:总价"`
|
||||
UnitPrice float32 `gorm:"not null;comment:单价"`
|
||||
TotalPrice float32 `gorm:"not null;comment:总价"`
|
||||
Remarks string `gorm:"size:255;comment:备注"`
|
||||
OperatorID uint `gorm:"comment:操作员ID"`
|
||||
}
|
||||
@@ -30,8 +30,8 @@ type PigSale struct {
|
||||
SaleDate time.Time `gorm:"primaryKey;comment:销售日期"`
|
||||
Buyer string `gorm:"comment:购买方"`
|
||||
Quantity int `gorm:"not null;comment:销售数量"`
|
||||
UnitPrice float64 `gorm:"not null;comment:单价"`
|
||||
TotalPrice float64 `gorm:"not null;comment:总价"`
|
||||
UnitPrice float32 `gorm:"not null;comment:单价"`
|
||||
TotalPrice float32 `gorm:"not null;comment:总价"`
|
||||
Remarks string `gorm:"size:255;comment:备注"`
|
||||
OperatorID uint `gorm:"comment:操作员ID"`
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ const (
|
||||
// SignalMetrics 存储信号强度数据
|
||||
type SignalMetrics struct {
|
||||
RssiDbm int `json:"rssi_dbm"` // 绝对信号强度(dBm),受距离、障碍物影响
|
||||
SnrDb float64 `json:"snr_db"` // 信号与噪声的相对比率(dB),由 RSSI 减去噪声地板(Noise Floor)
|
||||
SnrDb float32 `json:"snr_db"` // 信号与噪声的相对比率(dB),由 RSSI 减去噪声地板(Noise Floor)
|
||||
SensitivityDbm int `json:"sensitivity_dbm"` // 网关的最低检测阈值(dBm)
|
||||
MarginDb int `json:"margin_db"` // SNR 相对于接收器灵敏度的余量, Margin = SNR - Sensitivity
|
||||
}
|
||||
@@ -36,17 +36,17 @@ type BatteryLevel struct {
|
||||
|
||||
// TemperatureData 存储温度数据
|
||||
type TemperatureData struct {
|
||||
TemperatureCelsius float64 `json:"temperature_celsius"` // 温度值 (摄氏度)
|
||||
TemperatureCelsius float32 `json:"temperature_celsius"` // 温度值 (摄氏度)
|
||||
}
|
||||
|
||||
// HumidityData 存储湿度数据
|
||||
type HumidityData struct {
|
||||
HumidityPercent float64 `json:"humidity_percent"` // 湿度值 (%)
|
||||
HumidityPercent float32 `json:"humidity_percent"` // 湿度值 (%)
|
||||
}
|
||||
|
||||
// WeightData 存储重量数据
|
||||
type WeightData struct {
|
||||
WeightKilograms float64 `json:"weight_kilograms"` // 重量值 (公斤)
|
||||
WeightKilograms float32 `json:"weight_kilograms"` // 重量值 (公斤)
|
||||
}
|
||||
|
||||
// SensorData 存储所有类型的传感器数据,对应数据库中的 'sensor_data' 表。
|
||||
|
||||
Reference in New Issue
Block a user