Commit fa6e2fd3 by mushishixian

优化

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