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
1a1d7b62
authored
Jun 18, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix
parent
f8931d40
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
24 deletions
cmd/queue/bom.go
internal/logic/attr.go
internal/logic/goods.go
internal/logic/match.go
cmd/queue/bom.go
View file @
1a1d7b62
...
@@ -14,16 +14,16 @@ type RecvPro struct {
...
@@ -14,16 +14,16 @@ type RecvPro struct {
}
}
func
init
()
{
func
init
()
{
queueExchange
:=
rabbitmq
.
QueueExchange
{
//
queueExchange := rabbitmq.QueueExchange{
"bom_match"
,
//
"bom_match",
"bom_match"
,
//
"bom_match",
"bom"
,
//
"bom",
"direct"
,
//
"direct",
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/"
,
//
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
}
//
}
//
str
:=
`{"bom_id":491
,"delivery_type":1,"sort":1}`
//str := `{"bom_id":523
,"delivery_type":1,"sort":1}`
rabbitmq
.
Send
(
queueExchange
,
str
)
//
rabbitmq.Send(queueExchange, str)
}
}
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
(
err
error
)
{
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
(
err
error
)
{
...
...
internal/logic/attr.go
View file @
1a1d7b62
...
@@ -105,7 +105,6 @@ func searchAttr(attrOrigin, brandName, encap string, search *es.MultiSearchServi
...
@@ -105,7 +105,6 @@ func searchAttr(attrOrigin, brandName, encap string, search *es.MultiSearchServi
source
.
Sort
(
"brand_sort"
,
true
)
source
.
Sort
(
"brand_sort"
,
true
)
source
=
source
.
From
(
0
)
.
Size
(
1
)
source
=
source
.
From
(
0
)
.
Size
(
1
)
searchRequest
:=
es
.
NewSearchRequest
()
.
Source
(
source
)
searchRequest
:=
es
.
NewSearchRequest
()
.
Source
(
source
)
//fmt.Println(searchRequest.Body())
return
search
.
Add
(
searchRequest
)
return
search
.
Add
(
searchRequest
)
}
}
...
@@ -147,18 +146,20 @@ func changeKeyword(attr string) (result string) {
...
@@ -147,18 +146,20 @@ func changeKeyword(attr string) (result string) {
//将属性值转成ES的标准值(例如 : 阻值(欧姆)€3000)
//将属性值转成ES的标准值(例如 : 阻值(欧姆)€3000)
func
TransformESParam
(
attr
string
)
(
result
string
)
{
func
TransformESParam
(
attr
string
)
(
result
string
)
{
attr
=
changeKeyword
(
attr
)
attr
=
changeKeyword
(
attr
)
unitMapping
:=
mapping
.
UnitValueMapping
//needCheckUnits := getNeedCheckUnit()
//获取该属性对应的单位
//获取该属性对应的单位
for
unit
,
_
:=
range
unitMapping
{
//for _, unit := range needCheckUnits {
index
:=
strings
.
Index
(
attr
,
unit
)
// //todo : bug
if
index
>
0
{
// index := strings.Index(attr, unit)
attr
=
string
([]
rune
(
attr
)[
:
index
+
len
(
unit
)
-
1
])
// if index > 0 {
}
// attr = string([]rune(attr)[:index+len(unit)-1])
//得到截取后的参数,去得到需要用于es查询的参数
// }
attrValue
:=
getAttrValueByAttr
(
attr
)
// //得到截取后的参数,去得到需要用于es查询的参数
return
attrValue
//attrValue := getAttrValueByAttr(attr)
}
// return attrValue
return
//}
attrValue
:=
getAttrValueByAttr
(
attr
)
return
attrValue
}
}
//根据参数单位或者参数值获取对应的重要属性,组成最后查询的字符串
//根据参数单位或者参数值获取对应的重要属性,组成最后查询的字符串
...
@@ -257,3 +258,11 @@ func getQuery(attrs []string) (query *es.BoolQuery) {
...
@@ -257,3 +258,11 @@ func getQuery(attrs []string) (query *es.BoolQuery) {
return
query
return
query
}
}
func
getNeedCheckUnit
()
(
unitSlice
[]
string
)
{
unitMapping
:=
mapping
.
UnitValueMapping
for
unit
,
_
:=
range
unitMapping
{
unitSlice
=
append
(
unitSlice
,
unit
)
}
return
}
internal/logic/goods.go
View file @
1a1d7b62
...
@@ -51,6 +51,9 @@ func UpdateGoodsData(goodsMapList []GoodsMap) (err error) {
...
@@ -51,6 +51,9 @@ func UpdateGoodsData(goodsMapList []GoodsMap) (err error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
bomMatching
.
GoodsName
==
""
{
continue
}
bomMatchingList
=
append
(
bomMatchingList
,
bomMatching
)
bomMatchingList
=
append
(
bomMatchingList
,
bomMatching
)
}
}
}
}
...
...
internal/logic/match.go
View file @
1a1d7b62
...
@@ -33,7 +33,7 @@ func MatchGoods(message model.BomMessage) (err error) {
...
@@ -33,7 +33,7 @@ func MatchGoods(message model.BomMessage) (err error) {
bomItems
:=
bom
.
BomItems
bomItems
:=
bom
.
BomItems
var
perGoDealNumber
int
var
perGoDealNumber
int
if
configs
.
ApiSetting
.
Mode
==
"debug"
{
if
configs
.
ApiSetting
.
Mode
==
"debug"
{
perGoDealNumber
=
4
0
perGoDealNumber
=
20
0
}
else
{
}
else
{
perGoDealNumber
=
40
perGoDealNumber
=
40
}
}
...
@@ -83,7 +83,6 @@ func SearchGoods(bomId int, bomItems []model.BomItem, deliveryType, sort int, wg
...
@@ -83,7 +83,6 @@ func SearchGoods(bomId int, bomItems []model.BomItem, deliveryType, sort int, wg
defer
client
.
Stop
()
defer
client
.
Stop
()
//匹配之前,去遍历bom_item,把没有型号名称但是有参数的bom_item进行型号补充
//匹配之前,去遍历bom_item,把没有型号名称但是有参数的bom_item进行型号补充
bomItems
,
err
=
MatchGoodsNameByAttrs
(
bomItems
)
bomItems
,
err
=
MatchGoodsNameByAttrs
(
bomItems
)
//第一次先去精确匹配
//第一次先去精确匹配
goodsMapList
,
err
:=
getUpdateGoodsData
(
bomId
,
bomItems
,
deliveryType
,
sort
,
client
,
true
)
goodsMapList
,
err
:=
getUpdateGoodsData
(
bomId
,
bomItems
,
deliveryType
,
sort
,
client
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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