Ver código fonte

fix:优化winner名称查询

duxin 3 anos atrás
pai
commit
e53cc13c85

+ 27 - 5
src/jfw/modules/bigmember/src/entity/marketAnalysis/customizad_distribution.go

@@ -32,7 +32,7 @@ const (
 
 
 	//中标单位
 	//中标单位
 	//winner_procurement_scale = `"winner_count":{"filter": {"range": {"sortprice": {"gt": 0}}},"aggs": {"cardinality_winner_count": {"cardinality": {"field": "s_winner"}}}},"winner_time_distribution": {"range": { "field": "sortprice","ranges": [%s]},"aggs":{"s_winner_count": {"cardinality": {"field": "s_winner"}}}},"winner_amount_distribution": {"terms": {"field": "s_winner","size": 0},"aggs": {"amount": {"sum": {"field": "sortprice"}}}}`
 	//winner_procurement_scale = `"winner_count":{"filter": {"range": {"sortprice": {"gt": 0}}},"aggs": {"cardinality_winner_count": {"cardinality": {"field": "s_winner"}}}},"winner_time_distribution": {"range": { "field": "sortprice","ranges": [%s]},"aggs":{"s_winner_count": {"cardinality": {"field": "s_winner"}}}},"winner_amount_distribution": {"terms": {"field": "s_winner","size": 0},"aggs": {"amount": {"sum": {"field": "sortprice"}}}}`
-	winner_procurement_scale = `"winner_amount_distribution": {"terms": {"field": "s_winner","size": 0},"aggs": {"amount": {"sum": {"field": "sortprice"}}}}`
+	winner_procurement_scale = `"winner_amount_distribution": {"terms": {"field": "entidlist","size": 0},"aggs": {"amount": {"sum": {"field": "sortprice"}}}}`
 
 
 	//中标单位top3(价格)
 	//中标单位top3(价格)
 	winner_sortprice = `"winner_amount_top3": {"terms": {"field": "entidlist","exclude":["-"],"order": [{"s_winner_amount": "desc"}],"size": 3},"aggs": {"s_winner_amount": {"sum": {"field": "sortprice"}},"buyer_top": {"terms": {"field": "buyer","order": [{"buyer_winner_amount": "desc"}],"size": 3},"aggs": {"buyer_winner_amount": {"sum": {"field": "sortprice"}}}}}}`
 	winner_sortprice = `"winner_amount_top3": {"terms": {"field": "entidlist","exclude":["-"],"order": [{"s_winner_amount": "desc"}],"size": 3},"aggs": {"s_winner_amount": {"sum": {"field": "sortprice"}},"buyer_top": {"terms": {"field": "buyer","order": [{"buyer_winner_amount": "desc"}],"size": 3},"aggs": {"buyer_winner_amount": {"sum": {"field": "sortprice"}}}}}}`
@@ -672,6 +672,7 @@ func BuyerAnalysis(thisBuyerRow BuyerWinnerRow, rMap map[string]interface{}) {
 	for _, v := range buyerA {
 	for _, v := range buyerA {
 		count_b = count_b + v.Count
 		count_b = count_b + v.Count
 	}
 	}
+
 	for _, v := range Analysis {
 	for _, v := range Analysis {
 		var data buyer
 		var data buyer
 		data.Name = v
 		data.Name = v
@@ -696,6 +697,19 @@ func BuyerAnalysis(thisBuyerRow BuyerWinnerRow, rMap map[string]interface{}) {
 		Number int64       `json:"number"`
 		Number int64       `json:"number"`
 		//Accounted interface{} `json:"accounted"`
 		//Accounted interface{} `json:"accounted"`
 	}
 	}
+	var winnerKeys []string
+	for _, v := range thisBuyerRow.BuyerCountTop3.Buckets {
+		for _, v1 := range v.SWinnerTop.Buckets {
+			winnerKeys = append(winnerKeys, v1.Key)
+		}
+	}
+	for _, v := range thisBuyerRow.BuyerAmountTop3.Buckets {
+		for _, v1 := range v.SWinnerTop.Buckets {
+			winnerKeys = append(winnerKeys, v1.Key)
+		}
+	}
+
+	winnerName := GetEntNameByIds(winnerKeys)
 	//采购单位-项目数量TOP3
 	//采购单位-项目数量TOP3
 	countMap := []interface{}{}
 	countMap := []interface{}{}
 	for _, v := range thisBuyerRow.BuyerCountTop3.Buckets {
 	for _, v := range thisBuyerRow.BuyerCountTop3.Buckets {
@@ -709,7 +723,7 @@ func BuyerAnalysis(thisBuyerRow BuyerWinnerRow, rMap map[string]interface{}) {
 		for _, v1 := range v.SWinnerTop.Buckets {
 		for _, v1 := range v.SWinnerTop.Buckets {
 			var _dd number_project
 			var _dd number_project
 			_dd.Number = v1.BuyerWinnerAmount.Value
 			_dd.Number = v1.BuyerWinnerAmount.Value
-			_dd.Name = IdToWinner(v1.Key)
+			_dd.Name = winnerName[v1.Key]
 			_dd.Id = util.EncodeId(v1.Key)
 			_dd.Id = util.EncodeId(v1.Key)
 
 
 			/*if _d.Number != 0 {
 			/*if _d.Number != 0 {
@@ -753,7 +767,7 @@ func BuyerAnalysis(thisBuyerRow BuyerWinnerRow, rMap map[string]interface{}) {
 			}
 			}
 			var _dd amount_project
 			var _dd amount_project
 			_dd.Amount = v1.BuyerWinnerAmount.Value
 			_dd.Amount = v1.BuyerWinnerAmount.Value
-			_dd.Name = IdToWinner(v1.Key)
+			_dd.Name = winnerName[v1.Key]
 			_dd.Id = util.EncodeId(v1.Key)
 			_dd.Id = util.EncodeId(v1.Key)
 			/*	if _d.Amount != 0 {
 			/*	if _d.Amount != 0 {
 				_dd.Accounted = v1.BuyerWinnerAmount.Value / _d.Amount
 				_dd.Accounted = v1.BuyerWinnerAmount.Value / _d.Amount
@@ -810,13 +824,21 @@ func WinningAnalysis(thisWinnerRow BuyerWinnerRow, rMap map[string]interface{})
 		Number int64  `json:"number"`
 		Number int64  `json:"number"`
 		//Accounted interface{} `json:"accounted"`
 		//Accounted interface{} `json:"accounted"`
 	}
 	}
+	var winnerKeys []string
+	for _, v := range thisWinnerRow.WinnerCountTop3.SWinnerCount {
+		winnerKeys = append(winnerKeys, v.Key)
+	}
+	for _, v := range thisWinnerRow.WinnerAmountTop3.SWinnerAmount {
+		winnerKeys = append(winnerKeys, v.Key)
+	}
 
 
+	winnerName := GetEntNameByIds(winnerKeys)
 	//中标单位-项目数量TOP3
 	//中标单位-项目数量TOP3
 	countMap := []interface{}{}
 	countMap := []interface{}{}
 	for _, v := range thisWinnerRow.WinnerCountTop3.SWinnerCount {
 	for _, v := range thisWinnerRow.WinnerCountTop3.SWinnerCount {
 		var _d number_projects
 		var _d number_projects
 		_d.Number = v.BuyerCount.Value
 		_d.Number = v.BuyerCount.Value
-		_d.Name = IdToWinner(v.Key)
+		_d.Name = winnerName[v.Key]
 		_d.Id = util.EncodeId(v.Key)
 		_d.Id = util.EncodeId(v.Key)
 		/*if thisWinnerRow.ProjectCount.Value != 0 {
 		/*if thisWinnerRow.ProjectCount.Value != 0 {
 			_d.Accounted = float64(v.BuyerCount.Value) / float64(thisWinnerRow.ProjectCount.Value)
 			_d.Accounted = float64(v.BuyerCount.Value) / float64(thisWinnerRow.ProjectCount.Value)
@@ -856,7 +878,7 @@ func WinningAnalysis(thisWinnerRow BuyerWinnerRow, rMap map[string]interface{})
 		}
 		}
 		var _d amount_projects
 		var _d amount_projects
 		_d.Amount = v.SWinnerAmount.Value
 		_d.Amount = v.SWinnerAmount.Value
-		_d.Name = IdToWinner(v.Key)
+		_d.Name = winnerName[v.Key]
 		_d.Id = util.EncodeId(v.Key)
 		_d.Id = util.EncodeId(v.Key)
 		/*if thisWinnerRow.ProjectAmount.Value != 0 {
 		/*if thisWinnerRow.ProjectAmount.Value != 0 {
 			_d.Accounted = v.SWinnerAmount.Value / thisWinnerRow.ProjectAmount.Value
 			_d.Accounted = v.SWinnerAmount.Value / thisWinnerRow.ProjectAmount.Value