Compare commits

...

4 Commits
v0.0.8 ... dev

  1. 4
      IotaData.go
  2. 5
      aggData.go
  3. 4
      cacheData.go
  4. 2
      dataTrace.go
  5. 18
      esGroupTheme.go
  6. 18
      esTheme.go

4
IotaData.go

@ -70,3 +70,7 @@ func (the *IotaData) R() string {
func (the *IotaData) GetThingId() string { func (the *IotaData) GetThingId() string {
return the.ThingId return the.ThingId
} }
func (the *IotaData) GetDeviceId() string {
return the.DeviceId
}

5
aggData.go

@ -33,6 +33,11 @@ func (the *AggData) GetThingId() string {
return the.ThingId return the.ThingId
} }
// GetDeviceId 返回SensorId
func (the *AggData) GetDeviceId() string {
return fmt.Sprintf("%d", the.SensorId)
}
var typeDict = map[int]string{ var typeDict = map[int]string{
2001: "d", 2001: "d",
2002: "w", 2002: "w",

4
cacheData.go

@ -31,6 +31,7 @@ type CacheWindow struct {
windowLen int //窗体长度 windowLen int //窗体长度
WindowSize int //窗体大小 WindowSize int //窗体大小
MethodId int //滑窗方法 MethodId int //滑窗方法
CreatReason string //创建原因
LatestData any LatestData any
ring *ring.Ring ring *ring.Ring
Params FilterParams Params FilterParams
@ -74,7 +75,7 @@ func (c *CacheWindow) MarshalBinary() (data []byte, err error) {
func (c *CacheWindow) UnmarshalBinary(data []byte) error { func (c *CacheWindow) UnmarshalBinary(data []byte) error {
return json.Unmarshal(data, c) return json.Unmarshal(data, c)
} }
func NewCacheWindow(id string, size, methodId int, params FilterParams) CacheWindow { func NewCacheWindow(id string, size, methodId int, params FilterParams, creatReason string) CacheWindow {
limit := 10 limit := 10
if size > limit { if size > limit {
size = 10 size = 10
@ -85,6 +86,7 @@ func NewCacheWindow(id string, size, methodId int, params FilterParams) CacheWin
MethodId: methodId, MethodId: methodId,
ring: ring.New(size), ring: ring.New(size),
Params: params, Params: params,
CreatReason: creatReason,
Expire: expirationInfo{ Expire: expirationInfo{
UpdateTime: time.Now(), UpdateTime: time.Now(),
Duration: 60 * 2, Duration: 60 * 2,

2
dataTrace.go

@ -13,4 +13,6 @@ type IDataTrace interface {
R() string R() string
GetThingId() string GetThingId() string
GetDeviceId() string
} }

18
esGroupTheme.go

@ -1,6 +1,9 @@
package common_models package common_models
import "time" import (
"encoding/json"
"time"
)
// EsGroupTheme 分组主题数据结构体 // EsGroupTheme 分组主题数据结构体
type EsGroupTheme struct { type EsGroupTheme struct {
@ -15,6 +18,19 @@ type EsGroupTheme struct {
CreateTime time.Time `json:"create_time"` CreateTime time.Time `json:"create_time"`
} }
func (the EsGroupTheme) MarshalJSON() ([]byte, error) {
type Alias EsGroupTheme
return json.Marshal(&struct {
CollectTime string `json:"collect_time"`
CreateTime string `json:"create_time"`
*Alias
}{
CollectTime: the.CollectTime.Format("2006-01-02T15:04:05.000+08:00"),
CreateTime: the.CreateTime.Format("2006-01-02T15:04:05.000+08:00"),
Alias: (*Alias)(&the),
})
}
// 级联测点数据 // 级联测点数据
type CorrItemData struct { type CorrItemData struct {
StationId int `json:"station_id"` StationId int `json:"station_id"`

18
esTheme.go

@ -1,6 +1,9 @@
package common_models package common_models
import "time" import (
"encoding/json"
"time"
)
type EsTheme struct { type EsTheme struct {
SensorName string `json:"sensor_name"` SensorName string `json:"sensor_name"`
@ -16,6 +19,19 @@ type EsTheme struct {
CreateTime time.Time `json:"create_time"` CreateTime time.Time `json:"create_time"`
} }
func (the EsTheme) MarshalJSON() ([]byte, error) {
type Alias EsTheme
return json.Marshal(&struct {
CollectTime string `json:"collect_time"`
CreateTime string `json:"create_time"`
*Alias
}{
CollectTime: the.CollectTime.Format("2006-01-02T15:04:05.000+08:00"),
CreateTime: the.CreateTime.Format("2006-01-02T15:04:05.000+08:00"),
Alias: (*Alias)(&the),
})
}
type EsThemeResp struct { type EsThemeResp struct {
Took int `json:"took"` Took int `json:"took"`
TimedOut bool `json:"timed_out"` TimedOut bool `json:"timed_out"`

Loading…
Cancel
Save