Commit 6d55a733 by mushishixian

完善

parent 8fed8855
The file could not be displayed because it is too large.
......@@ -22,7 +22,7 @@ func init() {
"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)
}
......
......@@ -5,6 +5,7 @@ import (
"bom_server/internal/model"
"encoding/json"
"errors"
"fmt"
es "gopkg.in/olivere/elastic.v5"
"strconv"
)
......@@ -45,6 +46,12 @@ func UpdateNoMatchBomItem(bomItems []model.BomItem) (err error) {
if err != nil {
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
}
......@@ -81,12 +88,17 @@ func UpdateBomItem(bomId, bomItemId int) (err error) {
if err != nil {
return
}
err = UpdateGoodsData(goodsMapList)
fmt.Println(goodsMapList)
if len(goodsMapList) == 0 {
err = UpdateNoMatchBomItem(bomItems)
if err != nil {
return
}
} else {
err = UpdateGoodsData(goodsMapList)
if err != nil {
return
}
}
return
}
......@@ -33,7 +33,10 @@ func BatchSaveMatchings(bomId int, matchingList []model.BomItemMatching) (err er
tableEnd := string(bomIdStr[len(bomIdStr)-1])
tableName := "lie_bom_item_matching_" + tableEnd
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
model.Db.Table(tableName).Where("bom_item_id = ?", matching.BomItemID).First(&match)
......
......@@ -7,7 +7,7 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"github.com/prometheus/common/log"
es "gopkg.in/olivere/elastic.v5"
"math"
"regexp"
......@@ -53,9 +53,9 @@ func MatchGoods(message model.BomMessage) (err error) {
}
go func() {
if err := SearchGoods(bomId, bomData, message.DeliveryType, message.Sort, &wg); err != nil {
fmt.Println(err)
log.Error(err)
}
}()
}()
}
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