device_consumption.go 1.2 KB

12345678910111213141516171819202122232425262728
  1. package dao
  2. import "server/global"
  3. type DeviceConsumption struct {
  4. global.GVA_MODEL
  5. GatewayID uint `json:"gatewayID" gorm:"comment:所属网关ID"`
  6. UUID string `json:"UUID" gorm:"index;comment:灯具唯一UUID"`
  7. AreaNo string `json:"areaNo" gorm:"comment:区号"`
  8. Number string `json:"number" gorm:"comment:灯号"`
  9. DeviceName string `json:"DeviceName" gorm:"comment:网关device_name"`
  10. AcquisitionTs int64 `json:"acquisitionTs" gorm:"index;comment:采集时间戳"`
  11. TimeDur int64 `json:"timeDur" gorm:"comment:通电总时长 秒"`
  12. SensorDur int64 `json:"sensorDur" gorm:"comment:感应时长 秒"`
  13. EnergyDur int64 `json:"energyDur" gorm:"comment:等效能耗时长 秒"`
  14. Power float64 `json:"power" gorm:"comment:灯具额定功率 W"`
  15. // 预计算本次能耗,方便聚合
  16. ActualKwh float64 `json:"actualKwh" gorm:"comment:本次实际能耗 度"`
  17. TheoryKwh float64 `json:"theoryKwh" gorm:"comment:本次理论能耗 度"`
  18. }
  19. func (DeviceConsumption) TableName() string {
  20. return "device_consumption"
  21. }
  22. func (dc DeviceConsumption) CreateDeviceConsumption() error {
  23. return global.GVA_DB.Create(&dc).Error
  24. }