xuzhiheng 1 vuosi sitten
vanhempi
commit
509fd47a4a
2 muutettua tiedostoa jossa 285 lisäystä ja 5 poistoa
  1. 39 5
      customerdata/src/task.go
  2. 246 0
      sqlutil/src/sqlmodel/rules_es.go

+ 39 - 5
customerdata/src/task.go

@@ -57,6 +57,7 @@ func GetCustomerData() {
 		extends := qu.ObjToString(c["s_extends"]) //扩展信息
 		extends := qu.ObjToString(c["s_extends"]) //扩展信息
 		pushModel := qu.IntAll(c["i_pushmodel"])  //推送模式
 		pushModel := qu.IntAll(c["i_pushmodel"])  //推送模式
 		dataSave := qu.ObjToString(c["s_dataSave"])
 		dataSave := qu.ObjToString(c["s_dataSave"])
+		exact := qu.IntAll(c["i_exact"])
 		log.Println("当前客户 ", customer)
 		log.Println("当前客户 ", customer)
 		cus := &Customer{}
 		cus := &Customer{}
 		cus.SaveDataMap = map[string]map[string]interface{}{}
 		cus.SaveDataMap = map[string]map[string]interface{}{}
@@ -68,6 +69,8 @@ func GetCustomerData() {
 		cus.PushModel = pushModel
 		cus.PushModel = pushModel
 		cus.AppId = appId
 		cus.AppId = appId
 		cus.DataSave = dataSave
 		cus.DataSave = dataSave
+		cus.Exact = exact
+
 		for _, v := range strings.Split(extends, ",") {
 		for _, v := range strings.Split(extends, ",") {
 			if v == "hospitalgrade" {
 			if v == "hospitalgrade" {
 				cus.IsSearchHosp = true
 				cus.IsSearchHosp = true
@@ -1097,22 +1100,53 @@ func exactMatchs(rule, title, detail string, match []map[string]string, nameArr
 		log.Println("表达式错误 ", err)
 		log.Println("表达式错误 ", err)
 		return false
 		return false
 	}
 	}
-
+	titleMap := map[string]bool{}
+	contentMap := map[string]bool{}
 	for _, keys := range match {
 	for _, keys := range match {
 		types := keys["s_keymatch"] // 1,2,3
 		types := keys["s_keymatch"] // 1,2,3
 		key := keys["s_matchkey"]   //软件,工程
 		key := keys["s_matchkey"]   //软件,工程
 		group := keys["s_group"]
 		group := keys["s_group"]
 		if strings.Contains(types, "1") {
 		if strings.Contains(types, "1") {
 			for _, v := range strings.Split(key, ",") {
 			for _, v := range strings.Split(key, ",") {
-				if strings.Contains(strings.ToUpper(title), strings.ToUpper(v)) {
-					realdata["title_"+group] = realdata["title_"+group] + 1
+				if strings.Contains(v, "&&") {
+					isOk := true
+					for _, vv := range strings.Split(v, "&&") {
+						if !strings.Contains(strings.ToUpper(title), strings.ToUpper(vv)) {
+							isOk = false
+						}
+					}
+					if isOk {
+						realdata["title_"+group] = realdata["title_"+group] + 1
+					}
+				} else {
+					if strings.Contains(strings.ToUpper(title), strings.ToUpper(v)) {
+						if !titleMap[v] {
+							realdata["title_"+group] = realdata["title_"+group] + 1
+							titleMap[v] = true
+						}
+					}
 				}
 				}
 			}
 			}
 		}
 		}
 		if strings.Contains(types, "2") {
 		if strings.Contains(types, "2") {
 			for _, v := range strings.Split(key, ",") {
 			for _, v := range strings.Split(key, ",") {
-				if strings.Contains(strings.ToUpper(detail), strings.ToUpper(v)) {
-					realdata["content_"+group] = realdata["content_"+group] + 1
+				if strings.Contains(v, "&&") {
+					isOk := true
+					for _, vv := range strings.Split(v, "&&") {
+						if !strings.Contains(strings.ToUpper(detail), strings.ToUpper(vv)) {
+							isOk = false
+						}
+					}
+					if isOk {
+						realdata["content_"+group] = realdata["content_"+group] + 1
+					}
+				} else {
+					if strings.Contains(strings.ToUpper(detail), strings.ToUpper(v)) {
+						if !contentMap[v] {
+							realdata["content_"+group] = realdata["content_"+group] + 1
+							contentMap[v] = true
+						}
+					}
 				}
 				}
 			}
 			}
 		}
 		}

+ 246 - 0
sqlutil/src/sqlmodel/rules_es.go

@@ -0,0 +1,246 @@
+package sqlmodel
+
+type QueryObjecct struct {
+	// Filtered struct {
+	// Filter *Filter `json:"filter,omitempty"`
+	// Query  *Query      `json:"query,omitempty"`
+	Bool *BoolObject `json:"bool,omitempty"`
+	// } `json:"filtered,omitempty"`
+}
+
+type Query struct {
+	Bool *BoolObject `json:"bool,omitempty"`
+}
+
+type Filter struct {
+	Bool *BoolObject `json:"bool,omitempty"`
+}
+
+// 省市县
+type AreaCityDistrictMust struct {
+	*AreaCityDistrict `json:"terms,omitempty"`
+}
+
+// 省市县
+type AreaCityDistrict struct {
+	Area     []string `json:"area,omitempty"`
+	City     []string `json:"city,omitempty"`
+	District []string `json:"district,omitempty"`
+}
+
+// 网站名称
+type SiteMust struct {
+	*Site `json:"terms,omitempty"`
+}
+
+type Site struct {
+	Site []string `json:"site,omitempty"`
+}
+
+type DistrictObject struct {
+	Term struct {
+		City     string `json:"city,omitempty"`
+		District string `json:"district,omitempty"`
+	} `json:"term,omitempty"`
+}
+
+// 一级分类、二级分类
+type ToptypeSubtypeMust struct {
+	*ToptypeSubtype `json:"terms,omitempty"`
+}
+
+// 一级分类、二级分类
+type ToptypeSubtype struct {
+	Toptype []string `json:"toptype,omitempty"`
+	Subtype []string `json:"subtype,omitempty"`
+}
+
+//一级公告类型
+//type ScopeclassMust1 struct {
+//	*Scopeclass `json:"prefix,omitempty"`
+//}
+
+// 公告类型
+type ScopeclassMust struct {
+	*Scopeclass `json:"terms,omitempty"`
+}
+type Scopeclass struct {
+	Globaltopscopeclass []string `json:"s_topscopeclass,omitempty"`
+	Globalsubscopeclass []string `json:"s_subscopeclass,omitempty"`
+}
+
+type BudgetMust struct {
+	BudgetObj *BudgetObj `json:"range,omitempty"`
+}
+type BudgetObj struct {
+	Budget *BudgetOrBidamount `json:"budget,omitempty"`
+}
+type BidamountMust struct {
+	BidamountObj *BidamountObj `json:"range,omitempty"`
+}
+type BidamountObj struct {
+	Bidamount *BudgetOrBidamount `json:"bidamount,omitempty"`
+}
+type BudgetOrBidamount struct {
+	Gte float64 `json:"gte,omitempty"`
+	Lt  float64 `json:"lt,omitempty"`
+}
+
+// 时间范围
+type PublishtimeMust struct {
+	PublishtimeObject *PublishtimeObject `json:"range,omitempty"`
+}
+
+// 时间范围
+type PublishtimeObject struct {
+	//查询时间
+	Publishtime  *Publishtime  `json:"publishtime,omitempty"`
+	Publishtime1 *Publishtime1 `json:"publishtime1,omitempty"`
+	Publishtime2 *Publishtime2 `json:"publishtime2,omitempty"`
+}
+
+// 查询时间
+type Publishtime struct {
+	Gte int `json:"gte"`
+	Lt  int `json:"lt"`
+}
+type Publishtime1 struct {
+	Gte int `json:"gte"`
+}
+type Publishtime2 struct {
+	Lt int `json:"lt"`
+}
+
+type ExpurasingtimeMust struct {
+	ExpurasingtimeObject *ExpurasingtimeObject `json:"range,omitempty"`
+}
+
+// 时间范围
+type ExpurasingtimeObject struct {
+	//查询时间
+	Expurasingtime  *Expurasingtime  `json:"procurementlist.expurasingtime,omitempty"`
+	Expurasingtime1 *Expurasingtime1 `json:"procurementlist.expurasingtime1,omitempty"`
+	Expurasingtime2 *Expurasingtime2 `json:"procurementlist.expurasingtime2,omitempty"`
+}
+
+// 查询时间
+type Expurasingtime struct {
+	Gte int `json:"gte"`
+	Lt  int `json:"lt"`
+}
+type Expurasingtime1 struct {
+	Gte int `json:"gte"`
+}
+type Expurasingtime2 struct {
+	Lt int `json:"lt"`
+}
+
+// 字段是或否存在
+type ExistfieldsObjectMust struct {
+	ExistfieldsObject *ExistfieldsObject `json:"constant_score,omitempty"`
+}
+
+// 字段存在 存在放MustNot,字符串为空忽略
+type ExistfieldsObject struct {
+	Filter struct {
+		Exists struct {
+			Field string `json:"field,omitempty"`
+		} `json:"exists,omitempty"`
+	} `json:"filter,omitempty"`
+}
+
+type ShouldObj struct {
+	MatchPhrase *MatchPhrase `json:"match_phrase,omitempty"`
+	MultiMatch  *MultiMatch  `json:"multi_match,omitempty"`
+}
+
+// 匹配方式
+type MatchPhrase struct {
+	Title       string `json:"title,omitempty"`
+	Detail      string `json:"detail,omitempty"`
+	Purchasing  string `json:"purchasing,omitempty"`
+	Attachments string `json:"attachments,omitempty"`
+	Projectname string `json:"projectname,omitempty"`
+}
+
+type MultiMatch struct {
+	Query  string   `json:"query,omitempty"`
+	Type   string   `json:"type,omitempty"`
+	Fields []string `json:"fields,omitempty"`
+}
+
+// 匹配方式 采购单位、中标单位 正则匹配
+type Regular struct {
+	Regexp1 *MultiMatch `json:"regexp1,omitempty"`
+	Regexp2 *MultiMatch `json:"regexp2,omitempty"`
+}
+type Regular_Buyer struct {
+	//Buyer string `json:"buyer.mbuyer,omitempty"`
+	Query  string   `json:"query,omitempty"`
+	Type   string   `json:"type,omitempty"`
+	Fields []string `json:"fields,omitempty"`
+}
+type Regular_winner struct {
+	//Winner string `json:"s_winner.mwinner,omitempty"`
+	Query  string   `json:"query,omitempty"`
+	Type   string   `json:"type,omitempty"`
+	Fields []string `json:"fields,omitempty"`
+}
+
+/********************************************/
+type BuyerMatch struct {
+	*Buyer `json:"terms,omitempty"`
+}
+type Buyer struct {
+	Buyer []string `json:"buyer,omitempty"`
+}
+
+type WinnerMatch struct {
+	*Winner `json:"terms,omitempty"`
+}
+type Winner struct {
+	Winner []string `json:"s_winner,omitempty"`
+}
+
+/********************************************/
+
+// 排除词 must_not
+type NotkeyObject struct {
+	MatchPhrase *MatchPhrase `json:"match_phrase,omitempty"`
+	MultiMatch  *MultiMatch  `json:"multi_match,omitempty"`
+}
+
+// 采购单位行业 should
+type BuyerclassObject struct {
+	Terms struct {
+		Buyerclass []string `json:"buyerclass,omitempty"`
+	} `json:"terms,omitempty"`
+}
+
+type TopscopeclassObject struct {
+	Terms struct {
+		Topscopeclass []string `json:"s_topscopeclass,omitempty"`
+	} `json:"terms,omitempty"`
+}
+
+// 公告行业二级 should
+type SubscopeclassObject struct {
+	Terms struct {
+		Subscopeclass []string `json:"s_subscopeclass,omitempty"`
+	} `json:"terms,omitempty"`
+}
+
+// xf should
+type NewEsObject struct {
+	Bool struct {
+		Must    []interface{} `json:"must,omitempty"`
+		MustNot []interface{} `json:"must_not,omitempty"`
+		Should  []interface{} `json:"should,omitempty"`
+	} `json:"bool,omitempty"`
+}
+
+type BoolObject struct {
+	Must    []interface{} `json:"must,omitempty"`
+	MustNot []interface{} `json:"must_not,omitempty"`
+	Should  []interface{} `json:"should,omitempty"`
+}