Commit 4e9a3c1a by mushishixian

单个属性和封装的匹配问题

parent 4a81bcc7
Showing with 13 additions and 14 deletions
...@@ -14,16 +14,17 @@ type RecvPro struct { ...@@ -14,16 +14,17 @@ type RecvPro struct {
} }
func init() { func init() {
//queueExchange := rabbitmq.QueueExchange{ queueExchange := rabbitmq.QueueExchange{
// "bom_match", "bom_match",
// "bom_match", "bom_match",
// "bom", "bom",
// "direct", "direct",
// "amqp://huntadmin:jy2y2900@192.168.1.237:5672/", "amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
//} }
//
//str := `{"bom_id":666,"delivery_type":1,"sort":1}` //str := `{"bom_id":666,"delivery_type":1,"sort":1}`
//rabbitmq.Send(queueExchange, str) str := `{"bom_id":684,"delivery_type":1,"sort":1}`
rabbitmq.Send(queueExchange, str)
} }
func (t *RecvPro) Consumer(dataByte []byte) (err error) { func (t *RecvPro) Consumer(dataByte []byte) (err error) {
......
...@@ -59,10 +59,6 @@ func MatchGoodsNameByAttrs(bomItems []model.BomItem) (result []model.BomItem, er ...@@ -59,10 +59,6 @@ func MatchGoodsNameByAttrs(bomItems []model.BomItem) (result []model.BomItem, er
if responses.Hits != nil { if responses.Hits != nil {
for _, hit := range responses.Hits.Hits { for _, hit := range responses.Hits.Hits {
res, _ := hit.Source.MarshalJSON() res, _ := hit.Source.MarshalJSON()
//if bomItems[key].Attrs=="330Ω,1/4W,±5%,1206" {
// fmt.Println(string(res))
// fmt.Println(gjson.Get(string(res), "goods_name").String())
//}
if bomItems[key].GoodsName == "" || (bomItems[key].Attrs == "" && bomItems[key].GoodsName != "") { if bomItems[key].GoodsName == "" || (bomItems[key].Attrs == "" && bomItems[key].GoodsName != "") {
bomItems[key].GoodsName = gjson.Get(string(res), "goods_name").String() bomItems[key].GoodsName = gjson.Get(string(res), "goods_name").String()
} }
...@@ -96,6 +92,7 @@ func searchAttr(bomItem model.BomItem, search *es.MultiSearchService) (result *e ...@@ -96,6 +92,7 @@ func searchAttr(bomItem model.BomItem, search *es.MultiSearchService) (result *e
} }
} }
} else { } else {
attrs[0] = changeKeyword(attrs[0])
attrs = extractAttrsByStr(attrs[0]) attrs = extractAttrsByStr(attrs[0])
} }
var attrsSlice []string var attrsSlice []string
...@@ -120,7 +117,6 @@ func searchAttr(bomItem model.BomItem, search *es.MultiSearchService) (result *e ...@@ -120,7 +117,6 @@ func searchAttr(bomItem model.BomItem, search *es.MultiSearchService) (result *e
} }
} }
} }
//fmt.Println(attrsSlice)
query := getQuery(attrsSlice) query := getQuery(attrsSlice)
//如果ZyBrandId不为空,则代表匹配到了映射id //如果ZyBrandId不为空,则代表匹配到了映射id
if bomItem.ZyBrandId != "" && len(attrsSlice) > 0 { if bomItem.ZyBrandId != "" && len(attrsSlice) > 0 {
...@@ -296,6 +292,8 @@ func getQuery(attrs []string) (query *es.BoolQuery) { ...@@ -296,6 +292,8 @@ func getQuery(attrs []string) (query *es.BoolQuery) {
shouldMatchNumber = 3 shouldMatchNumber = 3
} else if len(attrs) >= 2 { } else if len(attrs) >= 2 {
shouldMatchNumber = 2 shouldMatchNumber = 2
} else if len(attrs) == 1 && strings.Contains(attr, "封装") {
shouldMatchNumber = 2
} else { } else {
shouldMatchNumber = 1 shouldMatchNumber = 1
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment