Commit 4575eb39 by mushishixian

修复温漂系数

parent 21c875c0
......@@ -6,7 +6,7 @@ import (
"bom_server/internal/model"
"bom_server/internal/pkg/gredis"
"fmt"
"github.com/gomodule/redigo/redis"
"github.com/garyburd/redigo/redis"
"github.com/imroc/req"
"github.com/tidwall/gjson"
"regexp"
......@@ -70,6 +70,17 @@ func GetStandardAttrs(bomItems []model.BomItem) []model.BomItem {
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)
item.AttrList = attrsSlice
......@@ -99,7 +110,7 @@ func GetStandardEsAttr(attr string) (result []string) {
if baseUnit == "" {
return []string{attr}
}
//获取重要属性名称
//获取重要属性名称,其中阻值和内阻的单位都是欧姆,导致要特殊处理
spUnit := "阻值(欧姆)|直流电阻(内阻)"
var spUnits []string
if value, exist := mapping.UnitAttrMapping[baseUnit]; exist {
......@@ -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
}
......
......@@ -118,6 +118,9 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue
if len(bomItem.AttrList) > 0 {
//var params []interface{}
for _, attr := range bomItem.AttrList {
if !strings.Contains(attr, "€") {
continue
}
//需要注意的点 : 因为0.158Ω可以对应 电阻 或者 直流电阻 ,所以当识别出来是电阻 或者 直流电阻 的时候,就不能用must,要用should
if strings.Contains(attr, "ZLNZ€") || strings.Contains(attr, "OM€") {
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