Commit 8709c3b6 by mushishixian

fix

parent ae492025
......@@ -33,12 +33,15 @@ func MatchGoodsNameByAttrs(bomItems []model.BomItem) (result []model.BomItem, er
if item.GoodsName != "" && item.Attrs == "" {
search = searchAttr(item, search)
searchFlag = true
}
//如果没有型号,但是有参数(参数有可能是型号),那就去匹配参数
if item.GoodsName == "" && item.Attrs != "" {
}else{
search = searchAttr(item, search)
searchFlag = true
}
////如果没有型号,但是有参数(参数有可能是型号),那就去匹配参数
//if item.GoodsName == "" && item.Attrs != "" {
// search = searchAttr(item, search)
// searchFlag = true
//}
}
if !searchFlag {
return bomItems, nil
......@@ -56,6 +59,10 @@ func MatchGoodsNameByAttrs(bomItems []model.BomItem) (result []model.BomItem, er
if responses.Hits != nil {
for _, hit := range responses.Hits.Hits {
res, _ := hit.Source.MarshalJSON()
//if bomItems[key].Attrs=="330Ω,1/4W,±5%,1206" {
// fmt.Println(string(res))
// fmt.Println(gjson.Get(string(res), "goods_name").String())
//}
if bomItems[key].GoodsName == "" || (bomItems[key].Attrs == "" && bomItems[key].GoodsName != "") {
bomItems[key].GoodsName = gjson.Get(string(res), "goods_name").String()
}
......@@ -170,7 +177,7 @@ func splitAttrs(attrs string) (result []string) {
//提取参数
func extractAttr(attr string) []string {
regexpUnit := strings.Join(getNeedCheckUnit(), "|")
r, _ := regexp.Compile("(\\d+[\\/\\d. ]*|\\d)(" + regexpUnit + ")" + "")
r, _ := regexp.Compile("$(\\d+[\\/\\d. ]*|\\d)(" + regexpUnit + ")" + "")
res := r.FindAllString(attr, 100)
return res
}
......
......@@ -7,20 +7,16 @@ var KeywordRegular = map[string]string{
"NPO|NP0|nPO|npO|npo|nP0|np0": "C0G",
"华科|华新科技|华新科": "华新",
`(欧姆|欧|O|o|R|r)`: "Ω",
`(Uf|uf|μf|uF|UF)`: "μF",
`(Uh|uh|μh|uH|UH)`: "μH",
`K`: "nF",
`v`: "V",
`(欧姆|欧|O|o|R|r)$`: "Ω",
`(Uf|uf|μf|uF|UF)$`: "μF",
`(Nf|NF)$`: "nF",
`(Uh|uh|μh|uH|UH)$`: "μH",
`K$`: "nF",
`v$`: "V",
}
var PureNumberRegular = `(\d+(\.\d+)?)`
var GetAttrUnitRegular = `[\d.]|±|\+_|\+-|/|\(.*\)|\+/-|`
//`^[\d\.]+(欧姆|欧|O|o|R|r)$`: "Ω",
//`^[\d\.]+(Uf|uf|μf|uF|UF)$`: "μF",
//`^[\d\.]+(Uh|uh|μh|uH|UH)$`: "μH",
//`^[\d\.]+K$`: "KΩ",
//属性单位对应属性
var UnitAttrMapping = map[string]string{
"r": "阻值(欧姆)|直流电阻(内阻)",
......
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