Procházet zdrojové kódy

数据导出采购单位、中标单位模糊匹配

renjiaojiao před 1 rokem
rodič
revize
5c364be156
1 změnil soubory, kde provedl 20 přidání a 2 odebrání
  1. 20 2
      common/src/qfw/util/dataexport/dataexport.go

+ 20 - 2
common/src/qfw/util/dataexport/dataexport.go

@@ -117,6 +117,8 @@ func getDataExportSql(scd *SieveCondition) string {
 	query_bool_should_and := `{"bool":{"should":[%s],"minimum_should_match": 1 %s}}`
 	query_price := `{"bool":{"must":[{"range":{"bidamount":{%s}}}]}},{"bool":{"must":[{"range":{"budget":{%s}}}],"must_not":[{"range":{"bidamount":{"gte":-1}}}]}}`
 	query_bool_must := `{"terms":{"%s":[%s]}}`
+	query_bool_should_wildcard := `{"bool":{"should":[%s]}}`
+	query_wildcard := `{"wildcard":{"%s":"*%s*"}}`
 	query_bool_must_and := `{"bool":{"must":[%s]%s}}`
 	query_exists := `{"constant_score":{"filter":{"exists":{"field":"%s"}}}}`
 	query_bool_must_term := `{"bool": {"must": [{ "term": {"isValidFile": %t }}]}}`
@@ -225,13 +227,29 @@ func getDataExportSql(scd *SieveCondition) string {
 		musts = append(musts, fmt.Sprintf(query_bool_must, "s_subscopeclass", `"`+strings.Join(scd.Industry, `","`)+`"`))
 	}
 	if len(scd.Buyer) > 0 {
-		musts = append(musts, fmt.Sprintf(query_bool_must, "buyer", `"`+strings.Join(scd.Buyer, `","`)+`"`))
+		str := ""
+		for i, v := range scd.Buyer {
+			if i < len(scd.Buyer)-1 {
+				str += fmt.Sprintf(query_wildcard, "buyer", v) + ","
+			} else {
+				str += fmt.Sprintf(query_wildcard, "buyer", v)
+			}
+		}
+		musts = append(musts, fmt.Sprintf(query_bool_should_wildcard, str))
 	}
 	if len(scd.Buyerclass) > 0 {
 		musts = append(musts, fmt.Sprintf(query_bool_must, "buyerclass", `"`+strings.Join(scd.Buyerclass, `","`)+`"`))
 	}
 	if len(scd.Winner) > 0 {
-		musts = append(musts, fmt.Sprintf(query_bool_must, "s_winner", `"`+strings.Join(scd.Winner, `","`)+`"`))
+		str := ""
+		for i, v := range scd.Winner {
+			if i < len(scd.Winner)-1 {
+				str += fmt.Sprintf(query_wildcard, "s_winner", v) + ","
+			} else {
+				str += fmt.Sprintf(query_wildcard, "s_winner", v)
+			}
+		}
+		musts = append(musts, fmt.Sprintf(query_bool_should_wildcard, str))
 	}
 	_minPrice := ""
 	_maxPrice := ""