Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
bom_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4575eb39
authored
Mar 15, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修复温漂系数
parent
21c875c0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
internal/logic/attr.go
internal/logic/search.go
internal/logic/attr.go
View file @
4575eb39
...
@@ -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/g
omodule
/redigo/redis"
"github.com/g
aryburd
/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
}
}
...
...
internal/logic/search.go
View file @
4575eb39
...
@@ -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
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment