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

+ 16 - 1
src/jfw/modules/bigmember/src/entity/marketAnalysis/commonSearch.go

@@ -2,6 +2,8 @@ package marketAnalysis
 
 import (
 	qutil "app.yhyue.com/moapp/jybase/common"
+	elastic "app.yhyue.com/moapp/jybase/es"
+	mgo "app.yhyue.com/moapp/jybase/mongodb"
 	"fmt"
 	"strings"
 )
@@ -46,7 +48,20 @@ func (mae *MarketAnalysisEntity) GetCommonQuerySql() string {
 	}
 	//中标企业
 	if mae.FormatParam.Winner != "" {
-		musts = append(musts, fmt.Sprintf(`{"term":{"s_winner":"%s"}}`, mae.FormatParam.Winner))
+		var winnerId string
+		if mgo.IsObjectIdHex(mae.FormatParam.Winner) {
+			winnerId = mae.FormatParam.Winner
+		} else {
+			rData := elastic.Get("qyxy", "qyxy", fmt.Sprintf(`{"query": {"bool": {"must": [{"term": {"company_name": "%s"}}]}},"_source":["_id"]"size": 1}`, mae.FormatParam.Winner))
+			if rData != nil && len(*rData) > 0 {
+				winnerId = qutil.InterfaceToStr((*rData)[0]["_id"])
+			}
+		}
+		if winnerId != "" {
+			musts = append(musts, fmt.Sprintf(`{"term":{"entidlist":"%s"}}`, winnerId))
+		} else {
+			musts = append(musts, fmt.Sprintf(`{"term":{"s_winner":"%s"}}`, mae.FormatParam.Winner))
+		}
 	}
 	//采购单位
 	if mae.FormatParam.Buyer != "" {