diff --git a/adaptors/安心云es主题特征to河北公路设施监测.go b/adaptors/安心云es主题特征to河北公路设施监测.go index 38a4e44..bef6f68 100644 --- a/adaptors/安心云es主题特征to河北公路设施监测.go +++ b/adaptors/安心云es主题特征to河北公路设施监测.go @@ -18,9 +18,9 @@ type Adaptor_AXYES_HBGL struct { } func (the Adaptor_AXYES_HBGL) Transform(rawMsg string) []NeedPush { - esAggTop := models.EsAggTop{} + esAggDateHistogram := models.EsThemeAggDateHistogram{} var needPush []NeedPush - err := json.Unmarshal([]byte(rawMsg), &esAggTop) + err := json.Unmarshal([]byte(rawMsg), &esAggDateHistogram) if err != nil { return nil } diff --git a/consumers/consumerHBJCAS.go b/consumers/consumerHBJCAS.go index 82d4bd8..f06fb65 100644 --- a/consumers/consumerHBJCAS.go +++ b/consumers/consumerHBJCAS.go @@ -142,7 +142,7 @@ func (the *consumerHBJCAS) getESQueryStr(structureId, factorId, start, end strin } }, "aggs": { - "groupBySensorId": { + "groupSensor": { "terms": { "field": "sensor" }, diff --git a/models/esThemeAggDateHistogram.go b/models/esThemeAggDateHistogram.go new file mode 100644 index 0000000..6c1d7e7 --- /dev/null +++ b/models/esThemeAggDateHistogram.go @@ -0,0 +1,58 @@ +package models + +import "time" + +type EsThemeAggDateHistogram struct { + Took int `json:"took"` + TimedOut bool `json:"timed_out"` + Shards struct { + Total int `json:"total"` + Successful int `json:"successful"` + Skipped int `json:"skipped"` + Failed int `json:"failed"` + } `json:"_shards"` + Hits struct { + Total int `json:"total"` + MaxScore float64 `json:"max_score"` + Hits []interface{} `json:"hits"` + } `json:"hits"` + Aggregations GPBySensorIdAggByDateHistogram `json:"aggregations"` +} +type GPBySensorIdAggByDateHistogram struct { + GroupSensor struct { + DocCountErrorUpperBound int `json:"doc_count_error_upper_bound"` + SumOtherDocCount int `json:"sum_other_doc_count"` + Buckets []Buckets `json:"buckets"` + } `json:"groupSensor"` +} + +type Buckets struct { + Key int `json:"key"` + DocCount int `json:"doc_count"` + GroupDate struct { + Buckets []BucketsXY `json:"buckets"` + } `json:"groupDate"` +} + +type BucketsXY struct { + KeyAsString time.Time `json:"key_as_string"` + Key int64 `json:"key"` + DocCount int `json:"doc_count"` + X ExtendedStats `json:"x"` + Y ExtendedStats `json:"y"` +} + +type ExtendedStats struct { + Count int `json:"count"` + Min float64 `json:"min"` + Max float64 `json:"max"` + Avg float64 `json:"avg"` + Sum float64 `json:"sum"` + SumOfSquares float64 `json:"sum_of_squares"` + Variance float64 `json:"variance"` + StdDeviation float64 `json:"std_deviation"` + StdDeviationBounds struct { + Upper float64 `json:"upper"` + Lower float64 `json:"lower"` + } `json:"std_deviation_bounds"` +}