You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1011 B

package common_models
import (
"fmt"
"time"
)
type AggData struct {
Date time.Time
SensorId int
StructId int
FactorId int
AggTypeId int // 聚集类型 : 10分钟/30分钟/3小时/6小时/12小时/时/日/周/月聚集
AggMethodId int // 聚集方法 : 平均值/最大值/最小值
Agg map[string]float64 // 聚集数据
Changed map[string]float64 // 变化量
}
func (a *AggData) _t() time.Time {
return a.Date
}
func (a *AggData) _q() string {
return fmt.Sprintf("agg:%d", a.SensorId)
}
func (a *AggData) _r() string {
return fmt.Sprintf("[Structure:%d] [Station:%d]", a.StructId, a.SensorId)
}
var typeDict = map[int]string{
2001: "d",
2002: "w",
2003: "m",
2004: "y",
2005: "h",
2006: "10m",
2007: "30m",
2008: "3h",
2009: "6h",
2010: "12h",
3001: "avg",
3002: "max",
3003: "min",
3004: "mid",
3005: "sum",
}
func GetAggTypeName(t int) string {
if val, ok := typeDict[t]; ok {
return val
}
return ""
}