| | |
| | | // DevicePlc 设备的PLC配置 |
| | | DevicePlc struct { |
| | | gorm.Model |
| | | DeviceID string `gorm:"unique;column:device_id;type:varchar(255);not null;default ''" json:"deviceID"` //设备编号 |
| | | Brand string `gorm:"type:varchar(191)" json:"brand"` |
| | | Method constvar.PlcMethod `gorm:"type:varchar(191)" json:"method"` |
| | | Address string `gorm:"type:varchar(191)" json:"address"` //plc ip地址, method = modbusTCP用 |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *DevicePlcSearch) SetDeviceId(deviceId string) *DevicePlcSearch { |
| | | slf.DeviceID = deviceId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *DevicePlcSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Table(slf.TableName()) |
| | | |
| | |
| | | db = db.Where("id = ?", slf.ID) |
| | | } |
| | | |
| | | if slf.DeviceID != "" { |
| | | db = db.Where("device_id = ?", slf.DeviceID) |
| | | } |
| | | |
| | | if slf.Order != "" { |
| | | db = db.Order(slf.Order) |
| | | } |