package dao

import (
	"server/global"
)

type PowerStatistics struct {
	global.GVA_MODEL
	TunnelSn         string  `json:"tunnelSn" gorm:"comment:隧道sn"`
	TotalActivePower float64 `json:"totalActivePower" gorm:"comment:总有功功率"`
	UploadTime       string  `json:"uploadTime" gorm:"comment:时间"`
}

func (PowerStatistics) TableName() string {
	return "power_statistics"
}

func (p PowerStatistics) CreatePowerStatistics() error {
	return global.GVA_DB.Create(&p).Error
}

func QueryPowerStatisticsBySn(tunnelSn string) (powerStatistics []PowerStatistics, err error) {
	err = global.GVA_DB.Where("tunnel_sn = ?", tunnelSn).Find(&powerStatistics).Error
	return powerStatistics, err
}
