|
@@ -12,16 +12,23 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-func (mae *MarketAnalysisEntity) AdvancedProject() map[string]interface{} {
|
|
|
- finalSql := fmt.Sprintf(mae.GetCommonQuerySqlWithAggs(), projectsNumber, mae.Size, projectsSort)
|
|
|
- log.Println("定制化分析报告sql查询:", finalSql)
|
|
|
+func AdvancedProject(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
|
|
|
+ }
|
|
|
+ }
|
|
|
mae.Types = 2
|
|
|
mae.FormatParam.SubType = []string{"拟建", "采购意向"}
|
|
|
mae.Size = 2
|
|
|
mae.FormatParam.STime = time.Now().AddDate(0, -3, 0).Unix()
|
|
|
+ finalSql := fmt.Sprintf(mae.GetCommonQuerySqlWithAggs(), projectsNumber, mae.Size, projectsSort)
|
|
|
+ log.Println("超前项目es查询:", finalSql)
|
|
|
res, _, data := util.GetAggs("bidding", "bidding", finalSql)
|
|
|
if res == nil || len(res) == 0 || data == nil || len(data) == 0 {
|
|
|
- return nil
|
|
|
+ return nil, nil
|
|
|
}
|
|
|
var thisRow SuperProjects
|
|
|
for name, object := range res {
|
|
@@ -43,7 +50,7 @@ func (mae *MarketAnalysisEntity) AdvancedProject() map[string]interface{} {
|
|
|
redisData[v.Key] = v.DocCount
|
|
|
}
|
|
|
if len(redisData) == 0 {
|
|
|
- return nil
|
|
|
+ return nil, nil
|
|
|
}
|
|
|
resData := make([]map[string]interface{}, len(data))
|
|
|
for i, v := range data {
|
|
@@ -52,7 +59,10 @@ func (mae *MarketAnalysisEntity) AdvancedProject() map[string]interface{} {
|
|
|
}
|
|
|
}
|
|
|
log.Println("AdvancedProject redis data :", resData)
|
|
|
- return nil
|
|
|
+ return map[string]interface{}{
|
|
|
+ "projectTop2": resData,
|
|
|
+ "projectCount": resData,
|
|
|
+ }, nil
|
|
|
}
|
|
|
|
|
|
func KeyWordFormat(userid, keyWords string) string {
|