Ver Fonte

Merge branch 'dev/v4.8.28_rjj' of qmx/jy into release/v4.8.28

renjiaojiao há 2 anos atrás
pai
commit
300cd01509

+ 13 - 0
src/jfw/modules/bigmember/src/service/analysis/decision.go

@@ -2,6 +2,7 @@
 package analysis
 
 import (
+	elastic "app.yhyue.com/moapp/jybase/es"
 	"encoding/json"
 	"fmt"
 	"jy/src/jfw/modules/bigmember/src/config"
@@ -406,6 +407,18 @@ func (this *Analysis) DecReviewExperts() {
 				getRes.BuyerContent = BuyerContentStruct(getRes.BuyerContent)
 				decQuery := DecReviewExpertsQuery(getRes.Area, getRes.BuyerContent, getRes.Buyer, buyer_buyerClass, getRes.LimitTime, getRes.SearchItem, getRes.ProjectScope)
 				aggsArr := getDecInfo(decQuery, buyer_buyerClass, getRes, 0)
+				//log.Println("专家top10", aggsArr["reviewExperts"])
+				var expertlist []map[string]interface{}
+				if reviewExperts, ok := aggsArr["reviewExperts"].([]map[string]interface{}); ok {
+					for _, v := range reviewExperts {
+						expertName := qutil.ObjToString(v["key"])
+						decQuery := ExpertsCooperationProjectCount(expertName, getRes.Area, getRes.BuyerContent, getRes.Buyer, getRes.LimitTime, getRes.SearchItem, getRes.ProjectScope)
+						_, count, _ := elastic.GetAggs("projectset", "projectset", decQuery)
+						v["count"] = count
+						expertlist = append(expertlist, v)
+					}
+					aggsArr["reviewExperts"] = expertlist
+				}
 
 				regMap.Data = map[string]interface{}{
 					"PAnalysis": aggsArr,

+ 105 - 0
src/jfw/modules/bigmember/src/service/analysis/esquery.go

@@ -525,6 +525,111 @@ func DecReviewExpertsQuery(area map[string]interface{}, business_scope []ViewKey
 	return qstr
 }
 
+// 专家top10合作项目数查询
+func ExpertsCooperationProjectCount(expertName string, area map[string]interface{}, business_scope []ViewKeyWord, buyer, limitTime string, searchItem, projectScope int) string {
+	var query = `{"track_total_hits": true,"query":{"bool":{"must":[{"bool":{"should":[%s],"must":[%s]}},{"bool":{"should":[%s],"minimum_should_match":%d}},{"term":{"review_experts":"%s"}}]}},"_source":[%s]}`
+
+	//基础查询
+	bools := []string{}
+	musts := []string{}
+	shoulds := []string{}
+
+	if searchItem == 1 { //采购单位同类型检索
+		//项目采购单位 模糊匹配
+		buyerSql := fmt.Sprintf(`{"query_string": {"default_field": "buyer","query": "*%s*"}}`, buyer)
+		musts = append(musts, buyerSql)
+	}
+
+	if searchItem == 2 { //地区同类型检索
+		//省份
+		areaCity := []string{}
+		//citys := []string{}
+		if len(area) > 0 {
+			areaquery := `{"terms":{"area":[`
+			var i = 0
+			for k, v := range area {
+				if len(qutil.ObjArrToStringArr(v.([]interface{}))) == 0 {
+					if i > 0 {
+						areaquery += `,`
+					}
+					areaquery += `"` + strings.ReplaceAll(strings.ReplaceAll(k, "省", ""), "市", "") + `"`
+					i += 1
+				}
+			}
+			areaquery += `]}}`
+			if i > 0 {
+				areaCity = append(areaCity, areaquery)
+			}
+		}
+
+		if len(areaCity) > 0 {
+			musts = append(musts, strings.Join(areaCity, ","))
+		}
+	}
+
+	//检索日期
+	if limitTime != "" {
+		var (
+			gteTime time.Time
+			gte     int64
+		)
+		sTime := time.Now()
+		switch limitTime {
+		case "oneYear":
+			gteTime = sTime.AddDate(-1, 0, 0)
+		case "threeYear":
+			gteTime = sTime.AddDate(-3, 0, 0)
+		default: // 默认近五年
+			gteTime = sTime.AddDate(-5, 0, 0)
+		}
+		gte = time.Date(gteTime.Year(), 1, 1, 0, 0, 0, 0, time.Local).Unix()
+		musts = append(musts, fmt.Sprintf(`{"range":{"jgtime":{"gte":%d,"lt":%d}}}`, gte, sTime.Unix()))
+	}
+	//中标项目
+	if entity.PSearch_DecMust != "" {
+		musts = append(musts, fmt.Sprintf(query_bool_must, entity.PSearch_DecMust))
+	}
+	boolsNum := 0
+	//should
+	if len(business_scope) > 0 && projectScope != 1 {
+		boolsNum = 1
+		findfields := `"projectname.pname","purchasing"`
+		multi_match := fmt.Sprintf(multi_match_public, "%s", findfields)
+		for _, kv := range business_scope {
+			shoulds := []string{}
+			must_not := []string{}
+			//关键词
+			for _, v := range kv.Keyword {
+				shoulds = append(shoulds, fmt.Sprintf(multi_match, "\""+v+"\""))
+			}
+			//附加词
+			if len(kv.Appended) > 0 {
+				for _, vv := range kv.Appended {
+					shoulds = append(shoulds, fmt.Sprintf(multi_match, "\""+vv+"\""))
+				}
+			}
+			if len(kv.Exclude) > 0 {
+				//排除词
+				for _, vv := range kv.Exclude {
+					must_not = append(must_not, fmt.Sprintf(multi_match, "\""+vv+"\""))
+				}
+			}
+			//添加
+			if len(shoulds) > 0 {
+				notStr := ""
+				if len(must_not) > 0 {
+					notStr = fmt.Sprintf(`,"must_not":[%s]`, strings.Join(must_not, ","))
+				}
+				bools = append(bools, fmt.Sprintf(query_bool_must_and, strings.Join(shoulds, ","), notStr))
+			}
+		}
+	}
+
+	qstr := fmt.Sprintf(query, strings.Join(shoulds, ","), strings.Join(musts, ","), strings.Join(bools, ","), boolsNum, expertName, entity.PSearch_DecField)
+	log.Println("str:", qstr)
+	return qstr
+}
+
 // 投标决策分析查询语句--free
 func DecQueryFree(area map[string]interface{}, business_scope []ViewKeyWord, limitTime, buyer string, searchItem int) string {