|
@@ -11,16 +11,23 @@ import (
|
|
|
|
|
|
var Analysis = []string{"<10万", "10万-50万", "50万-100万", "100万-500万", "500万-1000万", "1000万-1亿", "≥1亿"}
|
|
var Analysis = []string{"<10万", "10万-50万", "50万-100万", "100万-500万", "500万-1000万", "1000万-1亿", "≥1亿"}
|
|
|
|
|
|
-func (mae *MarketAnalysisEntity) PotentialCustomizeAnalysis() map[string]interface{} {
|
|
|
|
|
|
+func PotentialCustomizeAnalysis(userid, keyWords string) (map[string]interface{}, error) {
|
|
|
|
+ mae := new(MarketAnalysisEntity)
|
|
|
|
+ if key := KeyWordFormat(userid, keyWords); key != "" {
|
|
|
|
+ if err := json.Unmarshal([]byte(key), &mae.FormatParam.KeysItems); err != nil {
|
|
|
|
+ log.Println("关键词格式化失败")
|
|
|
|
+ return nil, err
|
|
|
|
+ }
|
|
|
|
+ }
|
|
var aggs []string
|
|
var aggs []string
|
|
aggs = append(aggs, aggs_buyerclass, buyer_procurement_scale, winner_procurement_scale)
|
|
aggs = append(aggs, aggs_buyerclass, buyer_procurement_scale, winner_procurement_scale)
|
|
mae.Types = 1
|
|
mae.Types = 1
|
|
mae.FormatParam.STime = time.Now().AddDate(-1, 0, 0).Unix()
|
|
mae.FormatParam.STime = time.Now().AddDate(-1, 0, 0).Unix()
|
|
finalSql := fmt.Sprintf(mae.GetCommonQuerySqlWithAggs(), strings.Join(aggs, ","), mae.Size, "")
|
|
finalSql := fmt.Sprintf(mae.GetCommonQuerySqlWithAggs(), strings.Join(aggs, ","), mae.Size, "")
|
|
- log.Println("定制化分析报告sql查询:", finalSql)
|
|
|
|
|
|
+ log.Println("定制化分析报告es查询:", finalSql)
|
|
res, _, _ := util.GetAggs("projectset", "projectset", finalSql)
|
|
res, _, _ := util.GetAggs("projectset", "projectset", finalSql)
|
|
if res == nil || len(res) == 0 {
|
|
if res == nil || len(res) == 0 {
|
|
- return nil
|
|
|
|
|
|
+ return nil, nil
|
|
}
|
|
}
|
|
thisRow := Aggregation{}
|
|
thisRow := Aggregation{}
|
|
for name, object := range res {
|
|
for name, object := range res {
|
|
@@ -50,7 +57,7 @@ func (mae *MarketAnalysisEntity) PotentialCustomizeAnalysis() map[string]interfa
|
|
CustomerDistribute(thisRow, rMap) //客户分布
|
|
CustomerDistribute(thisRow, rMap) //客户分布
|
|
BuyerAnalysis(thisRow, rMap) //采购单位分布
|
|
BuyerAnalysis(thisRow, rMap) //采购单位分布
|
|
WinningAnalysis(thisRow, rMap) //中标单位分布
|
|
WinningAnalysis(thisRow, rMap) //中标单位分布
|
|
- return rMap
|
|
|
|
|
|
+ return rMap, nil
|
|
}
|
|
}
|
|
|
|
|
|
// CustomerDistribute 客户分布
|
|
// CustomerDistribute 客户分布
|