Commit 4575eb39 by mushishixian

修复温漂系数

parent 21c875c0
...@@ -6,7 +6,7 @@ import ( ...@@ -6,7 +6,7 @@ import (
"bom_server/internal/model" "bom_server/internal/model"
"bom_server/internal/pkg/gredis" "bom_server/internal/pkg/gredis"
"fmt" "fmt"
"github.com/gomodule/redigo/redis" "github.com/garyburd/redigo/redis"
"github.com/imroc/req" "github.com/imroc/req"
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
"regexp" "regexp"
...@@ -70,6 +70,17 @@ func GetStandardAttrs(bomItems []model.BomItem) []model.BomItem { ...@@ -70,6 +70,17 @@ func GetStandardAttrs(bomItems []model.BomItem) []model.BomItem {
attrsSlice = append(attrsSlice, attrs...) attrsSlice = append(attrsSlice, attrs...)
} }
} }
for key, attr := range attrsSlice {
//再去找没有单位的对应属性名称(基本上是温漂系数)
if !strings.Contains(attr, "€") {
attr = strings.ToUpper(attr)
attrName, _ := redis.String(gredis.HGet("sku_map2", attr))
if attrName!="" {
attrsSlice[key] = attrName + "€" + attr
}
}
}
//转换成新约定的形式 //转换成新约定的形式
attrsSlice = transformNew(attrsSlice) attrsSlice = transformNew(attrsSlice)
item.AttrList = attrsSlice item.AttrList = attrsSlice
...@@ -99,7 +110,7 @@ func GetStandardEsAttr(attr string) (result []string) { ...@@ -99,7 +110,7 @@ func GetStandardEsAttr(attr string) (result []string) {
if baseUnit == "" { if baseUnit == "" {
return []string{attr} return []string{attr}
} }
//获取重要属性名称 //获取重要属性名称,其中阻值和内阻的单位都是欧姆,导致要特殊处理
spUnit := "阻值(欧姆)|直流电阻(内阻)" spUnit := "阻值(欧姆)|直流电阻(内阻)"
var spUnits []string var spUnits []string
if value, exist := mapping.UnitAttrMapping[baseUnit]; exist { if value, exist := mapping.UnitAttrMapping[baseUnit]; exist {
...@@ -115,11 +126,6 @@ func GetStandardEsAttr(attr string) (result []string) { ...@@ -115,11 +126,6 @@ func GetStandardEsAttr(attr string) (result []string) {
} }
} }
//再去找没有单位的对应属性
attrName, _ = redis.String(gredis.HGet("sku_map2", attr))
if attrName != "" {
result = append(result, attrName+"€"+attr)
}
return result return result
} }
......
...@@ -118,6 +118,9 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue ...@@ -118,6 +118,9 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue
if len(bomItem.AttrList) > 0 { if len(bomItem.AttrList) > 0 {
//var params []interface{} //var params []interface{}
for _, attr := range bomItem.AttrList { for _, attr := range bomItem.AttrList {
if !strings.Contains(attr, "€") {
continue
}
//需要注意的点 : 因为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))
......
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