Commit 6d55a733 by mushishixian

完善

parent 8fed8855
The file could not be displayed because it is too large.
...@@ -22,7 +22,7 @@ func init() { ...@@ -22,7 +22,7 @@ func init() {
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/", "amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
} }
str := `{"bom_id":175,"delivery_type":1,"sort":1}` str := `{"bom_id":195,"delivery_type":1,"sort":1}`
rabbitmq.Send(queueExchange, str) rabbitmq.Send(queueExchange, str)
} }
......
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"bom_server/internal/model" "bom_server/internal/model"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt"
es "gopkg.in/olivere/elastic.v5" es "gopkg.in/olivere/elastic.v5"
"strconv" "strconv"
) )
...@@ -45,6 +46,12 @@ func UpdateNoMatchBomItem(bomItems []model.BomItem) (err error) { ...@@ -45,6 +46,12 @@ func UpdateNoMatchBomItem(bomItems []model.BomItem) (err error) {
if err != nil { if err != nil {
return return
} }
matchingDelStatus := 2
err = model.Db.Table("lie_bom_item_matching_"+tableEnd).Where("bom_item_id IN (?)", updateIdList).
Updates(map[string]interface{}{"status": matchingDelStatus}).Error
if err != nil {
return
}
return nil return nil
} }
...@@ -81,12 +88,17 @@ func UpdateBomItem(bomId, bomItemId int) (err error) { ...@@ -81,12 +88,17 @@ func UpdateBomItem(bomId, bomItemId int) (err error) {
if err != nil { if err != nil {
return return
} }
err = UpdateGoodsData(goodsMapList) fmt.Println(goodsMapList)
if len(goodsMapList) == 0 { if len(goodsMapList) == 0 {
err = UpdateNoMatchBomItem(bomItems) err = UpdateNoMatchBomItem(bomItems)
if err != nil { if err != nil {
return return
} }
} else {
err = UpdateGoodsData(goodsMapList)
if err != nil {
return
}
} }
return return
} }
...@@ -33,7 +33,10 @@ func BatchSaveMatchings(bomId int, matchingList []model.BomItemMatching) (err er ...@@ -33,7 +33,10 @@ func BatchSaveMatchings(bomId int, matchingList []model.BomItemMatching) (err er
tableEnd := string(bomIdStr[len(bomIdStr)-1]) tableEnd := string(bomIdStr[len(bomIdStr)-1])
tableName := "lie_bom_item_matching_" + tableEnd tableName := "lie_bom_item_matching_" + tableEnd
var isBuyBomItemIdList, noBuyBomItemIdList []int var isBuyBomItemIdList, noBuyBomItemIdList []int
for _, matching := range matchingList { for k, matching := range matchingList {
if k == 1 || k == 2 || k == 3 {
time.Sleep(2 * time.Second)
}
//先去数据库查询是否存在该记录,有的话修改,没有就新增 //先去数据库查询是否存在该记录,有的话修改,没有就新增
var match model.BomItemMatching var match model.BomItemMatching
model.Db.Table(tableName).Where("bom_item_id = ?", matching.BomItemID).First(&match) model.Db.Table(tableName).Where("bom_item_id = ?", matching.BomItemID).First(&match)
......
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "github.com/prometheus/common/log"
es "gopkg.in/olivere/elastic.v5" es "gopkg.in/olivere/elastic.v5"
"math" "math"
"regexp" "regexp"
...@@ -53,9 +53,9 @@ func MatchGoods(message model.BomMessage) (err error) { ...@@ -53,9 +53,9 @@ func MatchGoods(message model.BomMessage) (err error) {
} }
go func() { go func() {
if err := SearchGoods(bomId, bomData, message.DeliveryType, message.Sort, &wg); err != nil { if err := SearchGoods(bomId, bomData, message.DeliveryType, message.Sort, &wg); err != nil {
fmt.Println(err) log.Error(err)
} }
}() }()
} }
wg.Wait() wg.Wait()
//全部处理完以后要去修改主表的同步状态 //全部处理完以后要去修改主表的同步状态
......
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