Ver Fonte

feat:采购单位搜索 地区和城市异常处理

wangshan há 3 anos atrás
pai
commit
82e38a1f81
2 ficheiros alterados com 10 adições e 5 exclusões
  1. 9 3
      jyBXBuyer/rpc/model/buyerListBYEs.go
  2. 1 2
      jyBXCore/rpc/util/search.go

+ 9 - 3
jyBXBuyer/rpc/model/buyerListBYEs.go

@@ -32,15 +32,21 @@ func BuyerListQuery(in *bxbuyer.BuyerListReq) (qstr string) {
 	query_aggs := `"aggs": {"group_field": {"terms": {"field": %s,"size": %d%s},"aggs": {"count": {"sum": {"field": "bidamount"}}}}}`
 	query_sort := `,"order": {"count": "desc"}`
 	query_bool_must := `{"terms":{"%s":[%s]}}`
+	query_bool_should := `{"bool":{"should":[%s],"minimum_should_match": 1}}`
+
 	bools := []string{}
 	musts := []string{}
+	musts_should := []string{}
 	//省份
 	if len(in.Province) > 0 {
-		musts = append(musts, fmt.Sprintf(`{"terms":{"area":["%s"]}}`, strings.Join(in.Province, "\",\"")))
+		musts_should = append(musts_should, fmt.Sprintf(`{"terms":{"area":["%s"]}}`, strings.Join(in.Province, "\",\"")))
 	}
 	//城市
 	if len(in.City) > 0 {
-		musts = append(musts, fmt.Sprintf(`{"terms":{"city":["%s"]}}`, strings.Join(in.City, "\",\"")))
+		musts_should = append(musts_should, fmt.Sprintf(`{"terms":{"city":["%s"]}}`, strings.Join(in.City, "\",\"")))
+	}
+	if len(musts_should) > 0 {
+		musts = append(musts, fmt.Sprintf(query_bool_should, strings.Join(musts_should, ",")))
 	}
 	//采购单位名称
 	if len(in.BuyerName) > 0 {
@@ -196,7 +202,7 @@ func GetBuyerList(qstr string, in *bxbuyer.BuyerListReq, isCache bool) (resp *bx
 					if icr {
 						isRws = IsReceived(buyerNames, entUserId)
 					}
-					log.Println("---:", isRws)
+					//log.Println("---:", isRws)
 					for _, fv := range fiftyArr {
 						fv.Province = infoMap[fv.Buyer].Province
 						fv.City = infoMap[fv.Buyer].City

+ 1 - 2
jyBXCore/rpc/util/search.go

@@ -11,7 +11,6 @@ import (
 	"io/ioutil"
 	IC "jyBXCore/rpc/init"
 	"jyBXCore/rpc/type/bxcore"
-	"log"
 	"math/big"
 	"net/http"
 	"net/url"
@@ -101,7 +100,7 @@ func HttpEs(ques, analyzer, esAddress string) (res string) {
 	URL.RawQuery = Q.Encode()
 	resp, err := http.Get(URL.String())
 	if err != nil {
-		log.Println("es连接失败 err1:", err)
+		logx.Info("es连接失败 err1:", err)
 		resp, err = getesResp(ques, analyzer, addrs)
 		if err != nil {
 			return