Commit d06eb99e by mushishixian

修复完成:

parent f4087c27
...@@ -28,7 +28,6 @@ func init() { ...@@ -28,7 +28,6 @@ func init() {
} }
func (t *RecvPro) Consumer(dataByte []byte) (err error) { func (t *RecvPro) Consumer(dataByte []byte) (err error) {
fmt.Println("开始")
var message model.BomMessage var message model.BomMessage
if err = json.Unmarshal(dataByte, &message); err != nil { if err = json.Unmarshal(dataByte, &message); err != nil {
log.Error(err) log.Error(err)
......
...@@ -26,6 +26,7 @@ func GetStandardAttrs(bomItems []model.BomItem) []model.BomItem { ...@@ -26,6 +26,7 @@ func GetStandardAttrs(bomItems []model.BomItem) []model.BomItem {
} }
params := req.BodyJSON(attrParams) params := req.BodyJSON(attrParams)
resp, err := req.Post(configs.ApiSetting.Attrs, params) resp, err := req.Post(configs.ApiSetting.Attrs, params)
//fmt.Println(resp)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
...@@ -60,7 +61,6 @@ func GetStandardAttrs(bomItems []model.BomItem) []model.BomItem { ...@@ -60,7 +61,6 @@ func GetStandardAttrs(bomItems []model.BomItem) []model.BomItem {
var attrsSlice []string var attrsSlice []string
for _, attr := range item.AttrList { for _, attr := range item.AttrList {
attrs := GetStandardEsAttr(attr) attrs := GetStandardEsAttr(attr)
fmt.Println(attrs)
if attr != "" { if attr != "" {
attrsSlice = append(attrsSlice, attrs...) attrsSlice = append(attrsSlice, attrs...)
} }
......
...@@ -71,6 +71,7 @@ func UpdateBomItem(bomId, bomItemId int) (err error) { ...@@ -71,6 +71,7 @@ func UpdateBomItem(bomId, bomItemId int) (err error) {
//先去查主表的信息 //先去查主表的信息
bom := GetBomInfo(bomId) bom := GetBomInfo(bomId)
bomItem := GetBomItem(bomId, bomItemId) bomItem := GetBomItem(bomId, bomItemId)
bomItem.Amount = bom.Amount
if bom.BomID == 0 || bomItem.BomID == 0 { if bom.BomID == 0 || bomItem.BomID == 0 {
return errors.New("该bom单不存在商品") return errors.New("该bom单不存在商品")
} }
......
...@@ -20,5 +20,8 @@ func TransformEncap(encap string) (attrValue string) { ...@@ -20,5 +20,8 @@ func TransformEncap(encap string) (attrValue string) {
pureNumber = encapCheck pureNumber = encapCheck
} }
} }
if len(pureNumber) < 4 {
return ""
}
return pureNumber return pureNumber
} }
...@@ -152,6 +152,7 @@ func UpdateSingleBomMatching(bomSn string, bomItemId int, goodsId string) (bomIt ...@@ -152,6 +152,7 @@ func UpdateSingleBomMatching(bomSn string, bomItemId int, goodsId string) (bomIt
} }
//还要返回对应的信息 //还要返回对应的信息
bomItemInfo = GetBomItem(bom.BomID, bomItemId) bomItemInfo = GetBomItem(bom.BomID, bomItemId)
bomItemInfo.Amount = bom.Amount
bomMatching := GetBomMatching(bom.BomID, bomItemId) bomMatching := GetBomMatching(bom.BomID, bomItemId)
bomItemInfo.Matching = bomMatching bomItemInfo.Matching = bomMatching
return return
......
...@@ -6,7 +6,6 @@ import ( ...@@ -6,7 +6,6 @@ import (
"bom_server/internal/model" "bom_server/internal/model"
"context" "context"
"encoding/json" "encoding/json"
"fmt"
es "gopkg.in/olivere/elastic.v5" es "gopkg.in/olivere/elastic.v5"
"regexp" "regexp"
"strings" "strings"
...@@ -80,10 +79,10 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor ...@@ -80,10 +79,10 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
//构建请求参数 //构建请求参数
func getSearchParams(index string, bomItem model.BomItem, sort int, flag bool) (searchRequest *es.SearchRequest) { func getSearchParams(index string, bomItem model.BomItem, sort int, flag bool) (searchRequest *es.SearchRequest) {
fmt.Println("商品名称 : ", bomItem.GoodsName) //fmt.Println("商品名称 : ", bomItem.GoodsName)
fmt.Println("参数列表 : ", bomItem.AttrList) //fmt.Println("参数列表 : ", bomItem.AttrList)
bomItem.Encap = TransformEncap(bomItem.Encap) bomItem.Encap = TransformEncap(bomItem.Encap)
fmt.Println("封装 : ", bomItem.Encap) //fmt.Println("封装 : ", bomItem.Encap)
query := getTermQuery(bomItem, sort, flag) query := getTermQuery(bomItem, sort, flag)
source := es.NewSearchSource().Query(query) source := es.NewSearchSource().Query(query)
if sort == 1 { if sort == 1 {
...@@ -101,7 +100,7 @@ func getSearchParams(index string, bomItem model.BomItem, sort int, flag bool) ( ...@@ -101,7 +100,7 @@ func getSearchParams(index string, bomItem model.BomItem, sort int, flag bool) (
} }
source = source.From(0).Size(1) source = source.From(0).Size(1)
searchRequest = es.NewSearchRequest().Source(source) searchRequest = es.NewSearchRequest().Source(source)
fmt.Println(searchRequest.Body()) //fmt.Println(searchRequest.Body())
return searchRequest return searchRequest
} }
...@@ -119,9 +118,9 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue ...@@ -119,9 +118,9 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue
//var params []interface{} //var params []interface{}
for _, attr := range bomItem.AttrList { for _, attr := range bomItem.AttrList {
//需要注意的点 : 因为0.158Ω可以对应 电阻 或者 直流电阻 ,所以当识别出来是电阻 或者 直流电阻 的时候,就不能用must,要用should //需要注意的点 : 因为0.158Ω可以对应 电阻 或者 直流电阻 ,所以当识别出来是电阻 或者 直流电阻 的时候,就不能用must,要用should
if strings.Contains(attr,"ZLNZ€") || strings.Contains(attr,"OM€") { if strings.Contains(attr, "ZLNZ€") || strings.Contains(attr, "OM€") {
query.Should(es.NewTermQuery("attr_bom", attr)) query.Should(es.NewTermQuery("attr_bom", attr))
}else{ } else {
query.Must(es.NewTermQuery("attr_bom", attr)) query.Must(es.NewTermQuery("attr_bom", attr))
} }
} }
...@@ -141,6 +140,7 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue ...@@ -141,6 +140,7 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue
query = query.Must(es.NewTermQuery("encap", bomItem.Encap)) query = query.Must(es.NewTermQuery("encap", bomItem.Encap))
} }
//搜索库存 //搜索库存
//fmt.Println("总数量:", bomItem.Number, bomItem.Amount)
query = query.Should(es.NewConstantScoreQuery(es.NewRangeQuery("stock").Gte(bomItem.Number * bomItem.Amount))) query = query.Should(es.NewConstantScoreQuery(es.NewRangeQuery("stock").Gte(bomItem.Number * bomItem.Amount)))
} else { } else {
query = query.Must(es.NewTermQuery("auto_goods_name", bomItem.GoodsName)) query = query.Must(es.NewTermQuery("auto_goods_name", bomItem.GoodsName))
......
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