Эх сурвалжийг харах

fix:定制化分析报告修改

duxin 2 жил өмнө
parent
commit
fec56f1b97

+ 51 - 1
common/commonSearch.go

@@ -16,7 +16,7 @@ func (mae *MarketAnalysisEntity) GetCommonQuerySqlWithAggs() string {
 func (mae *MarketAnalysisEntity) GetCommonQuerySql() string {
 	var musts, bools []string
 	//时间
-	musts = append(musts, fmt.Sprintf(`{"range":{"firsttime":{"gte":%d,"lte":%d}}}`, time.Now().AddDate(-1, 0, 0), time.Now().Unix()))
+	musts = append(musts, fmt.Sprintf(`{"range":{"firsttime":{"gte":%d,"lte":%d}}}`, time.Now().AddDate(-1, 0, 0).Unix(), time.Now().Unix()))
 	//地区
 	/*if len(mae.FormatParam.Area) > 0 || len(mae.FormatParam.City) > 0 {
 		var areaCity []string
@@ -56,6 +56,56 @@ func getAllKeywordArr(res []keyWordGroup) (rData []viewKeyWord) {
 	return
 }
 
+type T struct {
+	Aggregations struct {
+		WinnerAmountDistribution struct {
+			DocCountErrorUpperBound int `json:"doc_count_error_upper_bound"`
+			SumOtherDocCount        int `json:"sum_other_doc_count"`
+			Buckets                 []struct {
+				Key      string `json:"key"`
+				DocCount int    `json:"doc_count"`
+				Amount   struct {
+					Value float64 `json:"value"`
+				} `json:"amount"`
+			} `json:"buckets"`
+		} `json:"winner_amount_distribution"`
+		ProjectCount struct {
+			DocCount int `json:"doc_count"`
+		} `json:"project_count"`
+		ProjectAmount struct {
+			Value float64 `json:"value"`
+		} `json:"project_amount"`
+		ProjectCountNot0 struct {
+			DocCount int `json:"doc_count"`
+		} `json:"project_count_not0"`
+		BuyerclassScale struct {
+			DocCountErrorUpperBound int `json:"doc_count_error_upper_bound"`
+			SumOtherDocCount        int `json:"sum_other_doc_count"`
+			Buckets                 []struct {
+				Key              string `json:"key"`
+				DocCount         int    `json:"doc_count"`
+				BuyerclassAmount struct {
+					Value float64 `json:"value"`
+				} `json:"buyerclass_amount"`
+				BuyerclassTotal struct {
+					DocCount int `json:"doc_count"`
+				} `json:"buyerclass_total"`
+			} `json:"buckets"`
+		} `json:"buyerclass_scale"`
+		BuyerAmountDistribution struct {
+			DocCountErrorUpperBound int `json:"doc_count_error_upper_bound"`
+			SumOtherDocCount        int `json:"sum_other_doc_count"`
+			Buckets                 []struct {
+				Key      string `json:"key"`
+				DocCount int    `json:"doc_count"`
+				Amount   struct {
+					Value float64 `json:"value"`
+				} `json:"amount"`
+			} `json:"buckets"`
+		} `json:"buyer_amount_distribution"`
+	} `json:"aggregations"`
+}
+
 // getGroupKeywordArr 模糊拆分为多个精准匹配
 func getGroupKeywordArr(res []viewKeyWord) (rData []viewKeyWord) {
 	for _, kw := range res {

+ 2 - 0
common/customizedAnalysis.go

@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"fmt"
 	"leadGeneration/util"
+	"log"
 	"strings"
 )
 
@@ -13,6 +14,7 @@ func (mae *MarketAnalysisEntity) PotentialCustomizeAnalysis() map[string]interfa
 	var aggs []string
 	aggs = append(aggs, aggs_buyerclass, buyer_procurement_scale, winner_procurement_scale)
 	finalSql := fmt.Sprintf(mae.GetCommonQuerySqlWithAggs(), strings.Join(aggs, ","))
+	log.Println("定制化分析报告sql查询:", finalSql)
 	res, _ := util.GetAggs("projectset", "projectset", finalSql)
 	if res == nil || len(res) == 0 {
 		return nil

+ 32 - 25
common/marketAnalysisEntity.go

@@ -8,48 +8,55 @@ const (
 	//中标单位分布
 	winner_procurement_scale = `"winner_amount_distribution": {"terms": {"field": "entidlist","size": 0},"aggs": {"amount": {"sum": {"field": "sortprice"}}}}`
 
+	localMultiMatch     = `{"multi_match": {"query": %s,"type": "phrase", "fields": ["purchasing","pname"]}}`
+	query_bool_must_and = `{"bool": {"must": [%s]%s}}`
 	PSearch_DecMust     = `"bidstatus": ["中标","成交","合同","单一"]`
 	query_bool_must     = `{"terms": {%s}}`
-	query_bool_must_and = `{"bool": {"must": [%s]%s}}`
-	localMultiMatch     = `{"multi_match": {"query": %s,"type": "phrase", "fields": ["purchasing","pname"]}}`
 )
 
 type Aggregation struct {
-	ProjectAmount struct {
-		Value float64 `json:"value"`
-	} `json:"project_amount"`
-	BuyerAmountDistribution struct {
-		Buckets []struct {
+	WinnerAmountDistribution struct {
+		DocCountErrorUpperBound int `json:"doc_count_error_upper_bound"`
+		SumOtherDocCount        int `json:"sum_other_doc_count"`
+		Buckets                 []struct {
 			Key      string `json:"key"`
 			DocCount int    `json:"doc_count"`
 			Amount   struct {
 				Value float64 `json:"value"`
 			} `json:"amount"`
 		} `json:"buckets"`
-	} `json:"buyer_amount_distribution"`
-
-	WinnerAmountDistribution struct {
-		Buckets []struct {
+	} `json:"winner_amount_distribution"`
+	ProjectCount struct {
+		DocCount int `json:"doc_count"`
+	} `json:"project_count"`
+	ProjectAmount struct {
+		Value float64 `json:"value"`
+	} `json:"project_amount"`
+	ProjectCountNot0 struct {
+		DocCount int `json:"doc_count"`
+	} `json:"project_count_not0"`
+	BuyerclassScale struct {
+		DocCountErrorUpperBound int `json:"doc_count_error_upper_bound"`
+		SumOtherDocCount        int `json:"sum_other_doc_count"`
+		Buckets                 []struct {
+			Area           string `json:"key"`
+			AreaTotal      int    `json:"doc_count"`
+			BuyclassAmount struct {
+				Value int `json:"doc_count"`
+			} `json:"buyerclass_total"`
+		} `json:"buckets"`
+	} `json:"buyerclass_scale"`
+	BuyerAmountDistribution struct {
+		DocCountErrorUpperBound int `json:"doc_count_error_upper_bound"`
+		SumOtherDocCount        int `json:"sum_other_doc_count"`
+		Buckets                 []struct {
 			Key      string `json:"key"`
 			DocCount int    `json:"doc_count"`
 			Amount   struct {
 				Value float64 `json:"value"`
 			} `json:"amount"`
 		} `json:"buckets"`
-	} `json:"winner_amount_distribution"`
-
-	BuyerclassScale struct {
-		Buckets []struct {
-			Area       string `json:"key"`
-			AreaTotal  int64  `json:"doc_count"`
-			AreaAmount struct {
-				Value float64 `json:"value"`
-			} `json:"area_amount"`
-			BuyclassAmount struct {
-				Value float64 `json:"value"`
-			} `json:"buyerclass_amount"`
-		}
-	} `json:"buyerclass_scale"`
+	} `json:"buyer_amount_distribution"`
 }
 
 type MarketAnalysisEntity struct {

+ 1 - 0
main.go

@@ -3,6 +3,7 @@ package main
 import (
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
 	"leadGeneration/config"
+	_ "leadGeneration/public"
 	"net/http"
 )