|
@@ -1,17 +1,17 @@
|
|
|
package marketAnalysis
|
|
|
|
|
|
import (
|
|
|
- "encoding/json"
|
|
|
- "fmt"
|
|
|
util "app.yhyue.com/moapp/jybase/common"
|
|
|
elastic "app.yhyue.com/moapp/jybase/es"
|
|
|
- "strings"
|
|
|
+ "encoding/json"
|
|
|
+ "fmt"
|
|
|
util2 "jy/src/jfw/modules/bigmember/src/util"
|
|
|
+ "strings"
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
query_aggs_sortprice = `"sortprice_ranges": {"range":{"field":"sortprice","ranges":[%s]},"aggs":{"sum_sortprice":{"sum":{"field":"sortprice"}}}}`
|
|
|
- aggs_area = `"area_distribution": {"terms": {"field": "area","size": 40},"aggs": {"area_amount": {"sum": {"field": "sortprice"}},"area_total": {"filter": {"match_all":{}}}}}`
|
|
|
+ aggs_area = `"area_distribution": {"terms": {"field": "area","size": 40},"aggs": {"area_amount": {"sum": {"field": "sortprice"}},"area_total": {"filter": {"match_all":{}}},"city_group": {"terms": {"field": "city","size": 40},"aggs": {"city_amount": {"sum": {"field": "sortprice"}}}}}}`
|
|
|
query_top10 = `,"sort": [{"sortprice": "desc"}],"from": 0,"size": 10`
|
|
|
aggs_area_amounttop3 = `"area_amount_top3":{"terms":{"field":"area","exclude":["全国"],"order":[{"area_amount":"desc"}],"size":3},"aggs":{"area_amount":{"sum":{"field":"sortprice"}},"winner_top":{"terms":{"field":"entidlist","exclude": ["-"],"order":[{"area_winner_amount":"desc"}],"size":3},"aggs":{"area_winner_amount":{"sum":{"field":"sortprice"}}}}}}`
|
|
|
aggs_area_counttop3 = `"area_count_top3":{"terms":{"field":"area","exclude":["全国"],"order":[{"area_count":"desc"}],"size":3},"aggs":{"area_count":{"filter":{"match_all":{}}},"winner_top":{"terms":{"field":"entidlist","exclude": ["-"],"order":[{"area_winner_count":"desc"}],"size":3},"aggs":{"area_winner_count":{"filter":{"match_all":{}}}}}}}`
|
|
@@ -52,6 +52,15 @@ type AreaCTop struct {
|
|
|
BuyclassAmount struct {
|
|
|
Value float64 `json:"value"`
|
|
|
} `json:"buyerclass_amount"`
|
|
|
+ CityGroup struct {
|
|
|
+ Buckets []struct {
|
|
|
+ City string `json:"key"`
|
|
|
+ CityTotal int64 `json:"doc_count"`
|
|
|
+ CityAmount struct {
|
|
|
+ Value float64 `json:"value"`
|
|
|
+ } `json:"city_amount"`
|
|
|
+ }
|
|
|
+ } `json:"city_group"`
|
|
|
}
|
|
|
} `json:"area_distribution"`
|
|
|
BuyerclassScale struct {
|
|
@@ -406,6 +415,17 @@ func AreaDistribute(thisRow AreaCTop) (data []map[string]interface{}) {
|
|
|
rM["area"] = v.Area
|
|
|
rM["total"] = v.AreaTotal
|
|
|
rM["amount"] = v.AreaAmount.Value
|
|
|
+ var rmc []map[string]interface{}
|
|
|
+ if len(v.CityGroup.Buckets) > 0 {
|
|
|
+ for _, c := range v.CityGroup.Buckets {
|
|
|
+ rmc = append(rmc, map[string]interface{}{
|
|
|
+ "city": c.City,
|
|
|
+ "total": c.CityTotal,
|
|
|
+ "amount": c.CityAmount.Value,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ rM["areaDetails"] = rmc
|
|
|
+ }
|
|
|
data = append(data, rM)
|
|
|
}
|
|
|
return
|