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
4e9a3c1a
authored
Jun 30, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
单个属性和封装的匹配问题
parent
4a81bcc7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
14 deletions
cmd/queue/bom.go
internal/logic/attr.go
cmd/queue/bom.go
View file @
4e9a3c1a
...
...
@@ -14,16 +14,17 @@ type RecvPro struct {
}
func
init
()
{
//
queueExchange := rabbitmq.QueueExchange{
//
"bom_match",
//
"bom_match",
//
"bom",
//
"direct",
//
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
//
}
//
queueExchange
:=
rabbitmq
.
QueueExchange
{
"bom_match"
,
"bom_match"
,
"bom"
,
"direct"
,
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/"
,
}
//str := `{"bom_id":666,"delivery_type":1,"sort":1}`
//rabbitmq.Send(queueExchange, str)
str
:=
`{"bom_id":684,"delivery_type":1,"sort":1}`
rabbitmq
.
Send
(
queueExchange
,
str
)
}
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
(
err
error
)
{
...
...
internal/logic/attr.go
View file @
4e9a3c1a
...
...
@@ -59,10 +59,6 @@ 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
()
}
...
...
@@ -96,6 +92,7 @@ func searchAttr(bomItem model.BomItem, search *es.MultiSearchService) (result *e
}
}
}
else
{
attrs
[
0
]
=
changeKeyword
(
attrs
[
0
])
attrs
=
extractAttrsByStr
(
attrs
[
0
])
}
var
attrsSlice
[]
string
...
...
@@ -120,7 +117,6 @@ func searchAttr(bomItem model.BomItem, search *es.MultiSearchService) (result *e
}
}
}
//fmt.Println(attrsSlice)
query
:=
getQuery
(
attrsSlice
)
//如果ZyBrandId不为空,则代表匹配到了映射id
if
bomItem
.
ZyBrandId
!=
""
&&
len
(
attrsSlice
)
>
0
{
...
...
@@ -296,6 +292,8 @@ func getQuery(attrs []string) (query *es.BoolQuery) {
shouldMatchNumber
=
3
}
else
if
len
(
attrs
)
>=
2
{
shouldMatchNumber
=
2
}
else
if
len
(
attrs
)
==
1
&&
strings
.
Contains
(
attr
,
"封装"
)
{
shouldMatchNumber
=
2
}
else
{
shouldMatchNumber
=
1
}
...
...
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