Commit 1a1d7b62 by mushishixian

fix

parent f8931d40
...@@ -14,16 +14,16 @@ type RecvPro struct { ...@@ -14,16 +14,16 @@ 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":491,"delivery_type":1,"sort":1}` //str := `{"bom_id":523,"delivery_type":1,"sort":1}`
rabbitmq.Send(queueExchange, str) //rabbitmq.Send(queueExchange, str)
} }
func (t *RecvPro) Consumer(dataByte []byte) (err error) { func (t *RecvPro) Consumer(dataByte []byte) (err error) {
......
...@@ -105,7 +105,6 @@ func searchAttr(attrOrigin, brandName, encap string, search *es.MultiSearchServi ...@@ -105,7 +105,6 @@ func searchAttr(attrOrigin, brandName, encap string, search *es.MultiSearchServi
source.Sort("brand_sort", true) source.Sort("brand_sort", true)
source = source.From(0).Size(1) source = source.From(0).Size(1)
searchRequest := es.NewSearchRequest().Source(source) searchRequest := es.NewSearchRequest().Source(source)
//fmt.Println(searchRequest.Body())
return search.Add(searchRequest) return search.Add(searchRequest)
} }
...@@ -147,18 +146,20 @@ func changeKeyword(attr string) (result string) { ...@@ -147,18 +146,20 @@ func changeKeyword(attr string) (result string) {
//将属性值转成ES的标准值(例如 : 阻值(欧姆)€3000) //将属性值转成ES的标准值(例如 : 阻值(欧姆)€3000)
func TransformESParam(attr string) (result string) { func TransformESParam(attr string) (result string) {
attr = changeKeyword(attr) attr = changeKeyword(attr)
unitMapping := mapping.UnitValueMapping //needCheckUnits := getNeedCheckUnit()
//获取该属性对应的单位 //获取该属性对应的单位
for unit, _ := range unitMapping { //for _, unit := range needCheckUnits {
index := strings.Index(attr, unit) // //todo : bug
if index > 0 { // index := strings.Index(attr, unit)
attr = string([]rune(attr)[:index+len(unit)-1]) // if index > 0 {
} // attr = string([]rune(attr)[:index+len(unit)-1])
//得到截取后的参数,去得到需要用于es查询的参数 // }
attrValue := getAttrValueByAttr(attr) // //得到截取后的参数,去得到需要用于es查询的参数
return attrValue //attrValue := getAttrValueByAttr(attr)
} // return attrValue
return //}
attrValue := getAttrValueByAttr(attr)
return attrValue
} }
//根据参数单位或者参数值获取对应的重要属性,组成最后查询的字符串 //根据参数单位或者参数值获取对应的重要属性,组成最后查询的字符串
...@@ -257,3 +258,11 @@ func getQuery(attrs []string) (query *es.BoolQuery) { ...@@ -257,3 +258,11 @@ func getQuery(attrs []string) (query *es.BoolQuery) {
return query return query
} }
func getNeedCheckUnit() (unitSlice []string) {
unitMapping := mapping.UnitValueMapping
for unit, _ := range unitMapping {
unitSlice = append(unitSlice, unit)
}
return
}
...@@ -51,6 +51,9 @@ func UpdateGoodsData(goodsMapList []GoodsMap) (err error) { ...@@ -51,6 +51,9 @@ func UpdateGoodsData(goodsMapList []GoodsMap) (err error) {
if err != nil { if err != nil {
return err return err
} }
if bomMatching.GoodsName == "" {
continue
}
bomMatchingList = append(bomMatchingList, bomMatching) bomMatchingList = append(bomMatchingList, bomMatching)
} }
} }
......
...@@ -33,7 +33,7 @@ func MatchGoods(message model.BomMessage) (err error) { ...@@ -33,7 +33,7 @@ func MatchGoods(message model.BomMessage) (err error) {
bomItems := bom.BomItems bomItems := bom.BomItems
var perGoDealNumber int var perGoDealNumber int
if configs.ApiSetting.Mode == "debug" { if configs.ApiSetting.Mode == "debug" {
perGoDealNumber = 40 perGoDealNumber = 200
} else { } else {
perGoDealNumber = 40 perGoDealNumber = 40
} }
...@@ -83,7 +83,6 @@ func SearchGoods(bomId int, bomItems []model.BomItem, deliveryType, sort int, wg ...@@ -83,7 +83,6 @@ func SearchGoods(bomId int, bomItems []model.BomItem, deliveryType, sort int, wg
defer client.Stop() defer client.Stop()
//匹配之前,去遍历bom_item,把没有型号名称但是有参数的bom_item进行型号补充 //匹配之前,去遍历bom_item,把没有型号名称但是有参数的bom_item进行型号补充
bomItems, err = MatchGoodsNameByAttrs(bomItems) bomItems, err = MatchGoodsNameByAttrs(bomItems)
//第一次先去精确匹配 //第一次先去精确匹配
goodsMapList, err := getUpdateGoodsData(bomId, bomItems, deliveryType, sort, client, true) goodsMapList, err := getUpdateGoodsData(bomId, bomItems, deliveryType, sort, client, true)
if err != nil { if err != nil {
......
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