Commit a794ff74 by mushishixian

封装优化

parent fcadb0ae
Showing with 31 additions and 4 deletions
......@@ -108,10 +108,11 @@ func searchAttr(bomItem model.BomItem, search *es.MultiSearchService) (result *e
//单独针对封装进行转换
if bomItem.Encap != "" {
//先提取出纯数字
numberR, _ := regexp.Compile(mapping.PureNumberRegular)
pureNumber := numberR.FindString(bomItem.Encap)
//再去找对应属性
attrValue := "封装" + "€" + pureNumber
//numberR, _ := regexp.Compile(mapping.PureNumberRegular)
//pureNumber := numberR.FindString(bomItem.Encap)
////再去找对应属性
//attrValue := "封装" + "€" + pureNumber
attrValue := TransformEncap(bomItem.Encap)
if !php2go.InArray(attrValue, attrsSlice) {
subQuery := es.NewTermQuery("attrs.attr_value", attrValue)
nestedQuery := es.NewNestedQuery("attrs", subQuery)
......
package logic
import (
"bom_server/internal/mapping"
"bom_server/internal/pkg/gredis"
"github.com/gomodule/redigo/redis"
"regexp"
)
//转换封装
func TransformEncap(encap string) (attrValue string) {
numberR, _ := regexp.Compile(mapping.PureNumberRegular)
pureNumber := numberR.FindString(encap)
//判断是多少位数字,如果是3位,则代表可能需要往前面补零
if len(pureNumber) == 3 {
encapCheck := "0" + pureNumber
//补全完以后,去sku_map2尝试获取值,如果存在的话,就代表是正确的封装
attrName, _ := redis.String(gredis.HGet("sku_map2", encapCheck))
if attrName != "" {
pureNumber = encapCheck
}
}
//再去找对应属性
attrValue = "封装" + "€" + pureNumber
return attrValue
}
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