Commit fa6e2fd3 by mushishixian

优化

parent 3c0b0a6b
The file could not be displayed because it is too large.
......@@ -14,16 +14,16 @@ type RecvPro struct {
}
func init() {
//queueExchange := rabbitmq.QueueExchange{
// "bom_match",
// "bom_match",
// "bom",
// "direct",
// "amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
//}
//
//str := `{"bom_id":141,"delivery_type":1,"sort_type":1}`
//rabbitmq.Send(queueExchange, str)
queueExchange := rabbitmq.QueueExchange{
"bom_match",
"bom_match",
"bom",
"direct",
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
}
str := `{"bom_id":98,"delivery_type":1,"sort":1}`
rabbitmq.Send(queueExchange, str)
}
func (t *RecvPro) Consumer(dataByte []byte) (err error) {
......
......@@ -12,7 +12,8 @@ url = "amqp://huntadmin:jy2y2900@192.168.1.237:5672/"
[api]
base = http://192.168.2.232:40001
goods = http://192.168.2.232:60004
upload = http://api.liexin.net
upload = http://api.liexin.com/oss/upload
api_port = 60010
[oss]
upload_key = fh6y5t4rr351d2c3bryi
......@@ -22,4 +23,4 @@ push_url = http://192.168.1.237:1988/v1/push
[es]
url = http://192.168.2.232:9200
goods_index_name = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,zhuanmai,peigenesis,powell,rs,buerklin,liexin_ziying
\ No newline at end of file
goods_index_name = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin
\ No newline at end of file
......@@ -2,16 +2,11 @@ package logic
import (
"bom_server/internal/model"
"fmt"
)
//根据bom_id查出bom表信息
func GetBomInfo(bomId int) (bom model.Bom) {
err := model.Db.Where("bom_id = ?", bomId).First(&bom).Error
if err != nil {
fmt.Println(err)
}
fmt.Println(err)
model.Db.Where("bom_id = ?", bomId).First(&bom)
return bom
}
......
......@@ -4,7 +4,7 @@ import (
"bom_server/configs"
"bom_server/internal/model"
"encoding/json"
"fmt"
"errors"
es "gopkg.in/olivere/elastic.v5"
"strconv"
)
......@@ -58,6 +58,9 @@ func UpdateBomItem(bomId, bomItemId int) (err error) {
//先去查主表的信息
bom := GetBomInfo(bomId)
bomItem := GetBomItem(bomId, bomItemId)
if bom.BomID == 0 || bomItem.BomID == 0 {
return errors.New("该bom单不存在商品")
}
var bomItems []model.BomItem
bomItems = append(bomItems, bomItem)
//获取排序条件
......@@ -68,15 +71,11 @@ func UpdateBomItem(bomId, bomItemId int) (err error) {
return err
}
}
if len(bomItems) == 0 {
return
}
client, err := es.NewClient(es.SetURL(configs.ESSetting.Url))
if err != nil {
panic(err)
return err
}
defer client.Stop()
fmt.Println(bomItems[0].BomID)
//直接模糊匹配
goodsMapList, err := getUpdateGoodsData(bomId, bomItems, where.DeliveryType, where.Sort, client, false)
if err != nil {
......
......@@ -23,7 +23,6 @@ func UploadToOss(path, fileType string) (ossPath string, err error) {
}
url := configs.ApiSetting.Upload
uploadKey := configs.OssSetting.UploadKey
fmt.Println(uploadKey)
now := time.Now().Unix()
nowStr := strconv.Itoa(int(now))
params := req.Param{
......
......@@ -3,7 +3,6 @@ package http
import (
"bom_server/internal/common"
"bom_server/internal/logic"
"fmt"
"github.com/gin-gonic/gin"
"strconv"
)
......@@ -12,7 +11,6 @@ import (
func UpdateBomItem(c *gin.Context) {
bomItemIdStr := c.PostForm("bom_item_id")
bomIdStr := c.PostForm("bom_id")
fmt.Println(bomIdStr,bomItemIdStr)
bomItemId, _ := strconv.Atoi(bomItemIdStr)
bomId, _ := strconv.Atoi(bomIdStr)
err := logic.UpdateBomItem(bomId, bomItemId)
......
......@@ -9,8 +9,6 @@ import (
func InitRouter() *gin.Engine {
router := gin.Default()
router.Use(gin.Logger())
router.Use(gin.Recovery())
router.POST("/bom/export", Export)
router.POST("/bom_matching/refresh", RefreshBomMatchingGoods)
router.POST("/bom_matching/update", UpdateBomMatching)
......
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