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
3ea7aee3
authored
Jun 18, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
参数匹配型号
parent
3e477f1e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
16 deletions
cmd/queue/bom.go
internal/logic/attr.go
internal/logic/match.go
cmd/queue/bom.go
View file @
3ea7aee3
...
...
@@ -22,7 +22,7 @@ func init() {
// "amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
//}
//
//str := `{"bom_id":5
23
,"delivery_type":1,"sort":1}`
//str := `{"bom_id":5
30
,"delivery_type":1,"sort":1}`
//rabbitmq.Send(queueExchange, str)
}
...
...
internal/logic/attr.go
View file @
3ea7aee3
...
...
@@ -58,7 +58,6 @@ func MatchGoodsNameByAttrs(bomItems []model.BomItem) (result []model.BomItem, er
res
,
_
:=
hit
.
Source
.
MarshalJSON
()
//还要去判断至少符合特定数量参数匹配的结果,比如最小匹配参数为2,那就是要有两个参数匹配到才正确
bomItems
[
key
]
.
GoodsName
=
gjson
.
Get
(
string
(
res
),
"goods_name"
)
.
String
()
//fmt.Println(string(res))
}
}
}
...
...
internal/logic/match.go
View file @
3ea7aee3
...
...
@@ -228,16 +228,13 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
if
!
rawSearch
{
bom
.
GoodsName
=
common
.
SubKeyWordStr
(
bom
.
GoodsName
)
}
if
bom
.
GoodsName
==
""
{
continue
}
//经过了最前面的参数匹配
//如果型号还是为空,则用参数去匹配,因为有可能参数里面填了型号
//
if bom.GoodsName == "" && bom.Attrs == "" {
//
continue
//
} else if bom.GoodsName == "" && bom.Attrs != "" {
//
bom.GoodsName = bom.Attrs
//
}
if
bom
.
GoodsName
==
""
&&
bom
.
Attrs
==
""
{
continue
}
else
if
bom
.
GoodsName
==
""
&&
bom
.
Attrs
!=
""
{
bom
.
GoodsName
=
bom
.
Attrs
}
//构建一个goods_name对应的bomItems列表
searchRequest
:=
getSearchParams
(
index
,
bom
.
GoodsName
,
bom
.
BrandName
,
sort
,
bom
.
Number
,
rawSearch
)
searchFlag
=
true
...
...
@@ -294,11 +291,6 @@ func getSearchParams(index, goodsName, brandName string, sort, number int, flag
}
//要去判断sort,sort=2是按照价格排序
if
sort
==
2
{
//if index != "liexin_ziying" {
// source.Sort("single_price_sort", false)
//}
//source.Sort("single_price_sort", false)
//source.Sort("stock", false)
source
.
Sort
(
"single_price"
,
true
)
//sort=3是按照库存排序
}
else
if
sort
==
3
{
...
...
@@ -308,7 +300,6 @@ func getSearchParams(index, goodsName, brandName string, sort, number int, flag
source
.
Sort
(
"_score"
,
false
)
source
=
source
.
From
(
0
)
.
Size
(
1
)
searchRequest
=
es
.
NewSearchRequest
()
.
Source
(
source
)
//fmt.Println(searchRequest.Body())
return
searchRequest
}
...
...
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