feat: 自动化控制模块
This commit is contained in:
parent
bbd21b217b
commit
4651eec710
@ -57,7 +57,7 @@ MaxIdleTime = 3600
|
||||
MaxOpenConns = 100
|
||||
MaxIdleConns = 50
|
||||
TablePrefix = ""
|
||||
AutoMigrate = false
|
||||
AutoMigrate = true
|
||||
|
||||
[Util]
|
||||
|
||||
|
@ -15,22 +15,22 @@ const (
|
||||
|
||||
// 设备管理
|
||||
type Device struct {
|
||||
ID int64 `json:"id" gorm:"primaryKey;comment:Unique ID;"` // Unique ID
|
||||
TenantID string `json:"tenant_id" gorm:"size:32;"` // Tenant ID
|
||||
DeviceNo string `json:"device_no" gorm:"size:32;comment:设备编号;"` // 设备编号
|
||||
Name string `json:"name" gorm:"size:64;comment:设备名称;"` // 设备名称
|
||||
Type int `json:"type" gorm:"comment:设备类型(1增氧机、2投喂机、3水循环);"` // 设备类型(1增氧机、2投喂机、3水循环)
|
||||
Status bool `json:"status" gorm:"comment:设备状态(true=在线,false=离线);"` // 设备状态(true=在线,false=离线)
|
||||
Model string `json:"model" gorm:"size:64;comment:设备型号;"` // 设备型号
|
||||
WorkshopID int64 `json:"workshop_id" gorm:"index;foreignKey:ID;references:work_shop;comment:关联车间ID;"` // 关联车间ID
|
||||
WorkshopName string `json:"workshop_name" gorm:"comment:关联车间名称;"` // 关联车间名称
|
||||
CreatedAt time.Time `json:"created_at" gorm:"index;comment:Create time;"` // Create time
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"index;comment:Update time;"` // Update time
|
||||
ID int64 `json:"id" gorm:"primaryKey;comment:Unique ID;"` // Unique ID
|
||||
TenantID string `json:"tenant_id" gorm:"size:32;"` // Tenant ID
|
||||
DeviceNo string `json:"device_no" gorm:"size:32;comment:设备编号;"` // 设备编号
|
||||
Name string `json:"name" gorm:"size:64;comment:设备名称;"` // 设备名称
|
||||
Type int `json:"type" gorm:"comment:设备类型(1增氧机、2投喂机、3水循环);"` // 设备类型(1增氧机、2投喂机、3水循环)
|
||||
Status bool `json:"status" gorm:"comment:设备状态(true=在线,false=离线);"` // 设备状态(true=在线,false=离线)
|
||||
Model string `json:"model" gorm:"size:64;comment:设备型号;"` // 设备型号
|
||||
WorkshopID int64 `json:"workshop_id" gorm:"foreignKey:ID;references:work_shop;comment:关联车间ID;"` // 关联车间ID
|
||||
WorkshopName string `json:"workshop_name" gorm:"comment:关联车间名称;"` // 关联车间名称
|
||||
CreatedAt time.Time `json:"created_at" gorm:"comment:Create time;"` // Create time
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"comment:Update time;"` // Update time
|
||||
// 预加载信息
|
||||
DeviceFishPonds []*DeviceFishPond `json:"device_fish_ponds" gorm:"index;foreignKey:DeviceID;references:ID;comment:关联鱼池ID;"`
|
||||
DeviceConfigAeration *DeviceConfigAeration `json:"device_config_aeration" gorm:"index;foreignKey:DeviceID;references:ID;comment:增氧机配置;"`
|
||||
DeviceConfigFeeding *DeviceConfigFeeding `json:"device_config_feeding" gorm:"index;foreignKey:DeviceID;references:ID;comment:投喂机配置;"`
|
||||
DeviceConfigWaterCirculation *DeviceConfigWaterCirculation `json:"device_config_water_circulation" gorm:"index;foreignKey:DeviceID;references:ID;comment:水循环配置;"`
|
||||
DeviceFishPonds []*DeviceFishPond `json:"device_fish_ponds" gorm:"foreignKey:DeviceID;references:ID;comment:关联鱼池ID;"`
|
||||
DeviceConfigAeration *DeviceConfigAeration `json:"device_config_aeration" gorm:"foreignKey:DeviceID;references:ID;comment:增氧机配置;"`
|
||||
DeviceConfigFeeding *DeviceConfigFeeding `json:"device_config_feeding" gorm:"foreignKey:DeviceID;references:ID;comment:投喂机配置;"`
|
||||
DeviceConfigWaterCirculation *DeviceConfigWaterCirculation `json:"device_config_water_circulation" gorm:"foreignKey:DeviceID;references:ID;comment:水循环配置;"`
|
||||
}
|
||||
|
||||
// Defining the query parameters for the `Device` struct.
|
||||
@ -64,7 +64,7 @@ type DeviceForm struct {
|
||||
Model string `json:"model" binding:"required,max=64"` // 设备型号
|
||||
WorkshopID int64 `json:"workshop_id" binding:"required"` // 关联车间ID
|
||||
WorkshopName string `json:"workshop_name" binding:"required"` // 关联车间名称
|
||||
DeviceFishPonds []*DeviceFishPond `json:"device_fish_ponds" gorm:"index;foreignKey:DeviceID;references:ID;comment:关联鱼池ID;"`
|
||||
DeviceFishPonds []*DeviceFishPond `json:"device_fish_ponds" gorm:"foreignKey:DeviceID;references:ID;comment:关联鱼池ID;"`
|
||||
}
|
||||
|
||||
// A validation function for the `DeviceForm` struct.
|
||||
|
@ -6,7 +6,7 @@ import "time"
|
||||
type DeviceConfigAeration struct {
|
||||
ID int64 `json:"id" gorm:"primaryKey;comment:Unique ID;"`
|
||||
TenantID string `json:"tenant_id" gorm:"size:32;"` // Tenant ID
|
||||
DeviceID int64 `json:"device_id" gorm:"uniqueIndex;not null;comment:设备ID;"`
|
||||
DeviceID int64 `json:"device_id" gorm:"not null;comment:设备ID;"`
|
||||
Level int `json:"level" gorm:"not null;comment:投料量档位;"`
|
||||
Aeration float64 `json:"aeration" gorm:"type:decimal(5,2);not null;comment:溶氧(mg/l);"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime;comment:创建时间;"`
|
||||
|
@ -6,7 +6,7 @@ import "time"
|
||||
type DeviceConfigFeeding struct {
|
||||
ID int64 `json:"id" gorm:"primaryKey;comment:Unique ID;"`
|
||||
TenantID string `json:"tenant_id" gorm:"size:32;"` // Tenant ID
|
||||
DeviceID int64 `json:"device_id" gorm:"uniqueIndex;not null;comment:设备ID;"`
|
||||
DeviceID int64 `json:"device_id" gorm:"not null;comment:设备ID;"`
|
||||
FeedLevel int `json:"feed_level" gorm:"not null;comment:投料量档位;"`
|
||||
FeedTime int `json:"feed_time" gorm:"not null;comment:投料时间(秒);"`
|
||||
IntervalTime int `json:"interval_time" gorm:"not null;comment:间隔时间(秒);"`
|
||||
|
@ -6,7 +6,7 @@ import "time"
|
||||
type DeviceConfigWaterCirculation struct {
|
||||
ID int64 `json:"id" gorm:"primaryKey;comment:Unique ID;"`
|
||||
TenantID string `json:"tenant_id" gorm:"size:32;"` // Tenant ID
|
||||
DeviceID int64 `json:"device_id" gorm:"uniqueIndex;not null;comment:设备ID;"`
|
||||
DeviceID int64 `json:"device_id" gorm:"not null;comment:设备ID;"`
|
||||
WaterTemp float64 `json:"water_temp" gorm:"type:decimal(4,1);not null;comment:水温设置(℃);"`
|
||||
WaterCirculation int `json:"water_circulation" gorm:"not null;comment:水循环量(次);"`
|
||||
Aeration float64 `json:"aeration" gorm:"type:decimal(5,2);not null;comment:增氧量(mg/l);"`
|
||||
|
@ -10,18 +10,18 @@ import (
|
||||
type DeviceControlLog struct {
|
||||
ID int64 `json:"id" gorm:"primaryKey;autoIncrement;comment:Unique ID;"` // Unique ID
|
||||
TenantID string `json:"tenant_id" gorm:"size:32;"` // Tenant ID
|
||||
DeviceID int64 `json:"device_id" gorm:"size:32;index;comment:设备ID;"` // 设备ID
|
||||
DeviceID int64 `json:"device_id" gorm:"size:32;comment:设备ID;"` // 设备ID
|
||||
DeviceModel string `json:"device_model" gorm:"size:64;comment:设备型号;"` // 设备型号
|
||||
DeviceName string `json:"device_name" gorm:"size:64;comment:设备名称;"` // 设备名称
|
||||
RelatedPondIds string `json:"related_pond_ids" gorm:"type:text;comment:关联鱼池/车间ID;"` // 关联鱼池/车间ID
|
||||
RelatedPond string `json:"related_pond" gorm:"type:text;comment:关联鱼池/车间;"` // 关联鱼池/车间
|
||||
OperatorUserID int `json:"operator_user_id" gorm:"index;comment:操作人ID;"` // 操作人ID
|
||||
OperatorUserID int `json:"operator_user_id" gorm:"comment:操作人ID;"` // 操作人ID
|
||||
Operator string `json:"operator" gorm:"size:32;comment:操作人;"` // 操作人
|
||||
Command string `json:"command" gorm:"type:text;comment:下达指令;"` // 下达指令
|
||||
CommandStatus bool `json:"command_status" gorm:"comment:指令状态(true=成功,false=失败);"` // 指令状态(true=成功,false=失败)
|
||||
Type int `json:"type" gorm:"comment:设备类型(1增氧机、2投喂机、3水循环);"` // 设备类型(1增氧机、2投喂机、3水循环)
|
||||
CreatedAt time.Time `json:"created_at" gorm:"index;comment:Create time;"` // Create time
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"index;comment:Update time;"` // Update time
|
||||
CreatedAt time.Time `json:"created_at" gorm:"comment:Create time;"` // Create time
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"comment:Update time;"` // Update time
|
||||
}
|
||||
|
||||
// Defining the query parameters for the `DeviceControlLog` struct.
|
||||
|
@ -8,13 +8,13 @@ import (
|
||||
|
||||
// 设备-鱼池关联表
|
||||
type DeviceFishPond struct {
|
||||
ID int64 `json:"id" gorm:"size:20;primaryKey;comment:Unique ID;"` // Unique ID
|
||||
TenantID string `json:"tenant_id" gorm:"size:32;"` // Tenant ID
|
||||
DeviceID int64 `json:"device_id" gorm:"index;foreignKey:ID;references:device;comment:设备ID;"` // 设备ID
|
||||
FishPondID int64 `json:"fish_pond_id" gorm:"index;foreignKey:ID;references:fish_pond;comment:鱼池ID;"` // 鱼池ID
|
||||
FishPondName string `json:"fish_pond_name" gorm:"comment:鱼池名称;"` // 鱼池名称
|
||||
CreatedAt time.Time `json:"created_at" gorm:"index;comment:Create time;"` // Create time
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"index;comment:Update time;"` // Update time
|
||||
ID int64 `json:"id" gorm:"size:20;primaryKey;comment:Unique ID;"` // Unique ID
|
||||
TenantID string `json:"tenant_id" gorm:"size:32;"` // Tenant ID
|
||||
DeviceID int64 `json:"device_id" gorm:"foreignKey:ID;references:device;comment:设备ID;"` // 设备ID
|
||||
FishPondID int64 `json:"fish_pond_id" gorm:"foreignKey:ID;references:fish_pond;comment:鱼池ID;"` // 鱼池ID
|
||||
FishPondName string `json:"fish_pond_name" gorm:"comment:鱼池名称;"` // 鱼池名称
|
||||
CreatedAt time.Time `json:"created_at" gorm:"comment:Create time;"` // Create time
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"comment:Update time;"` // Update time
|
||||
}
|
||||
|
||||
// Defining the query parameters for the `DeviceFishPond` struct.
|
||||
|
Loading…
x
Reference in New Issue
Block a user