ソースを参照

Merge branch 'feature/v4.9.43' of https://jygit.jydev.jianyu360.cn/qmx/jy into feature/v4.9.43

wangshan 11 ヶ月 前
コミット
44db086c10

+ 27 - 19
src/jfw/modules/bigmember/src/entity/marketAnalysis/customized_analysis.go

@@ -11,13 +11,13 @@ import (
 )
 
 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":{}}},"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":34},"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":40},"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":{}}}}}}}`
-	aggs_buyerclass            = `"buyerclass_scale":{"terms":{"field":"buyerclass","size":2000,"exclude":["其它",""]},"aggs":{"buyerclass_amount":{"sum":{"field":"sortprice"}},"buyerclass_total":{"filter":{"match_all":{}}}}}`
-	aggs_buyerclass_other      = `"buyerclass_scale_other":{"terms":{"field":"buyerclass","include":["其它",""]},"aggs":{"buyerclass_amount":{"sum":{"field":"sortprice"}},"buyerclass_total":{"filter":{"match_all":{}}}}}`
+	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":{}}},"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":34},"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":40},"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":{}}}}}}}`
+	aggs_buyerclass      = `"buyerclass_scale":{"terms":{"field":"buyerclass","size":2000,"exclude":["其它",""]},"aggs":{"buyerclass_amount":{"sum":{"field":"sortprice"}},"buyerclass_total":{"filter":{"match_all":{}}}}}`
+	//aggs_buyerclass_other      = `"buyerclass_scale_other":{"terms":{"field":"buyerclass","include":["其它",""]},"aggs":{"buyerclass_amount":{"sum":{"field":"sortprice"}},"buyerclass_total":{"filter":{"match_all":{}}}}}`
 	aggs_buyerclass_counttop3  = `"buyerclass_count_top3":{"terms":{"field":"buyerclass","exclude":["其它",""],"order":[{"buyerclass_count":"desc"}],"size":70},"aggs":{"buyerclass_count":{"filter":{"match_all":{}}},"bidcount_top":{"terms":{"field":"entidlist","exclude": ["-"],"order":[{"buyer_winner_count":"desc"}],"size":3},"aggs":{"buyer_winner_count":{"filter":{"match_all":{}}}}}}}`
 	aggs_buyerclass_amounttop3 = `"buyerclass_amount_top3":{"terms":{"field":"buyerclass","exclude":["其它",""],"order":[{"buyerclass_amount":"desc"}],"size":70},"aggs":{"buyerclass_amount":{"sum":{"field":"sortprice"}},"winner_top":{"terms":{"field":"entidlist","exclude": ["-"],"order":[{"buyer_winner_amount":"desc"}],"size":3},"aggs":{"buyer_winner_amount":{"sum":{"field":"sortprice"}}}}}}`
 	sortprice_str              = `{"key":"<10万","from":0.0000000000001,"to":100000},{"key":"10万-50万","from":100000,"to":500000},{"key":"50万-100万","from":500000,"to":1000000},{"key":"100万-500万","from":1000000,"to":5000000},{"key":"500万-1000万","from":5000000,"to":10000000},{"key":"1000万-1亿","from":10000000,"to":100000000},{"key":"≥1亿","from":100000000}`
@@ -27,6 +27,9 @@ const (
 )
 
 type AreaCTop struct {
+	ProjectCount struct {
+		DocCount int `json:"doc_count"`
+	} `json:"project_count"`
 	Total     int64 `json:"doc_count"`
 	CountNot0 struct {
 		Count int64 `json:"doc_count"`
@@ -221,7 +224,8 @@ func (mae *MarketAnalysisEntity) AllData() (rMap map[string]interface{}, err err
 		aggs = append(aggs, aggs_area_amounttop3, aggs_area_counttop3)
 	}
 	if len(buyclass) != 1 {
-		aggs = append(aggs, aggs_buyerclass, aggs_buyerclass_other, aggs_buyerclass_amounttop3, aggs_buyerclass_counttop3)
+		//aggs = append(aggs, aggs_buyerclass, aggs_buyerclass_other, aggs_buyerclass_amounttop3, aggs_buyerclass_counttop3)
+		aggs = append(aggs, aggs_buyerclass, aggs_buyerclass_amounttop3, aggs_buyerclass_counttop3)
 	}
 	finalSql := fmt.Sprintf(mae.GetCommonQuerySqlWithAggs(), strings.Join(aggs, ","))
 	log.Println("allData sql:", finalSql)
@@ -240,13 +244,13 @@ func (mae *MarketAnalysisEntity) AllData() (rMap map[string]interface{}, err err
 				continue
 			}
 		} else if name == "project_count" {
-			if json.Unmarshal(bArr, &thisRow) != nil {
-				continue
-			}
-		} else if name == "buyerclass_scale_other" {
-			if json.Unmarshal(bArr, &thisRow.BuyerclassScaleOther) != nil {
+			if json.Unmarshal(bArr, &thisRow.ProjectCount) != nil {
 				continue
 			}
+			//} else if name == "buyerclass_scale_other" {
+			//	if json.Unmarshal(bArr, &thisRow.BuyerclassScaleOther) != nil {
+			//		continue
+			//	}
 		} else if name == "project_count_not0" {
 			if json.Unmarshal(bArr, &thisRow.CountNot0) != nil {
 				continue
@@ -449,17 +453,21 @@ func CustomerDistribute(thisRow AreaCTop) (data []map[string]interface{}, otherD
 		rM["buyclass"] = v.Area
 		rM["total"] = v.AreaTotal
 		rM["amount"] = v.BuyclassAmount.Value
-		data = append(data, rM)
-	}
-	for _, v := range thisRow.BuyerclassScaleOther.Buckets {
 		total += v.AreaTotal
 		amount += v.BuyclassAmount.Value
+		data = append(data, rM)
 	}
-	if total != 0 || amount != 0 {
+	//for _, v := range thisRow.BuyerclassScaleOther.Buckets {
+	//	total += v.AreaTotal
+	//	amount += v.BuyclassAmount.Value
+	//}
+	pCount := util.Int64All(thisRow.ProjectCount) - total
+	pAmount := util.Float64All(thisRow.Amount) - amount
+	if pCount != 0 || pAmount != 0 {
 		otherData = make(map[string]interface{})
 		otherData["buyclass"] = "其它"
-		otherData["total"] = total
-		otherData["amount"] = amount
+		otherData["total"] = pCount
+		otherData["amount"] = pAmount
 	}
 	return
 }