Commit 27107092 by mushishixian

Merge branch 'ysx-bom服务'

parents 14c3bbef f67f513b
......@@ -14,18 +14,16 @@ type RecvPro struct {
}
func init() {
if configs.ApiSetting.Mode == "debug" {
queueExchange := rabbitmq.QueueExchange{
"bom_match",
"bom_match",
"bom",
"direct",
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
}
str := `{"bom_id":408,"delivery_type":1,"sort":2}`
rabbitmq.Send(queueExchange, str)
}
//queueExchange := rabbitmq.QueueExchange{
// "bom_match",
// "bom_match",
// "bom",
// "direct",
// "amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
//}
//
//str := `{"bom_id":432,"delivery_type":1,"sort":1}`
//rabbitmq.Send(queueExchange, str)
}
func (t *RecvPro) Consumer(dataByte []byte) (err error) {
......
......@@ -232,7 +232,13 @@ func getQuery(attrs []string) (query *es.BoolQuery) {
nestedQuery = es.NewNestedQuery("attrs", subQuery)
query.Should(nestedQuery)
}
query.MinimumNumberShouldMatch(2)
var shouldMatchNumber int
if len(attrs)>=2 {
shouldMatchNumber = 2
}else{
shouldMatchNumber = 1
}
query.MinimumNumberShouldMatch(shouldMatchNumber)
}
return query
......
......@@ -31,7 +31,12 @@ func MatchGoods(message model.BomMessage) (err error) {
return errors.New("没有商品的bom单")
}
bomItems := bom.BomItems
perGoDealNumber := 40
var perGoDealNumber int
if configs.ApiSetting.Mode == "debug" {
perGoDealNumber = 200
} else {
perGoDealNumber = 40
}
//开启协程处理搜索
var wg sync.WaitGroup
//判断是否有余数
......@@ -98,8 +103,9 @@ func SearchGoods(bomId int, bomItems []model.BomItem, deliveryType, sort int, wg
}
//再删除模糊匹配到的数据,就得到完全没有匹配的数据了
var notMatchBomItems []model.BomItem
var needMatchGoodsMapList = append(goodsMapList, fuzzyGoodsMapList...)
for _, bomItem := range bomItems {
if !checkInGoodsMap(bomItem, append(goodsMapList, fuzzyGoodsMapList...)) {
if !checkInGoodsMap(bomItem, needMatchGoodsMapList) {
notMatchBomItems = append(notMatchBomItems, bomItem)
}
}
......@@ -109,7 +115,7 @@ func SearchGoods(bomId int, bomItems []model.BomItem, deliveryType, sort int, wg
return
}
//然后去处理匹配到的数据
err = UpdateGoodsData(append(goodsMapList, fuzzyGoodsMapList...))
err = UpdateGoodsData(needMatchGoodsMapList)
if err != nil {
return
}
......@@ -157,7 +163,7 @@ func UpdateSingleBomMatching(bomSn string, bomItemId int, goodsId string) (bomIt
//判断是否在里面
func checkInGoodsMap(bom model.BomItem, goodsMapList []GoodsMap) bool {
for _, goodsMap := range goodsMapList {
if bom.GoodsName == goodsMap.GoodsName {
if bom.BomItemID == goodsMap.BomItemId {
return true
}
}
......
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