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
27107092
authored
Jun 12, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'ysx-bom服务'
parents
14c3bbef
f67f513b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
17 deletions
cmd/queue/bom.go
internal/logic/attr.go
internal/logic/match.go
cmd/queue/bom.go
View file @
27107092
...
...
@@ -14,18 +14,16 @@ type RecvPro struct {
}
func
init
()
{
if
configs
.
ApiSetting
.
Mode
==
"debug"
{
queueExchange
:=
rabbitmq
.
QueueExchange
{
"bom_match"
,
"bom_match"
,
"bom"
,
"direct"
,
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/"
,
}
str
:=
`{"bom_id":408,"delivery_type":1,"sort":2}`
rabbitmq
.
Send
(
queueExchange
,
str
)
}
//queueExchange := rabbitmq.QueueExchange{
// "bom_match",
// "bom_match",
// "bom",
// "direct",
// "amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
//}
//
//str := `{"bom_id":432,"delivery_type":1,"sort":1}`
//rabbitmq.Send(queueExchange, str)
}
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
(
err
error
)
{
...
...
internal/logic/attr.go
View file @
27107092
...
...
@@ -232,7 +232,13 @@ func getQuery(attrs []string) (query *es.BoolQuery) {
nestedQuery
=
es
.
NewNestedQuery
(
"attrs"
,
subQuery
)
query
.
Should
(
nestedQuery
)
}
query
.
MinimumNumberShouldMatch
(
2
)
var
shouldMatchNumber
int
if
len
(
attrs
)
>=
2
{
shouldMatchNumber
=
2
}
else
{
shouldMatchNumber
=
1
}
query
.
MinimumNumberShouldMatch
(
shouldMatchNumber
)
}
return
query
...
...
internal/logic/match.go
View file @
27107092
...
...
@@ -31,7 +31,12 @@ func MatchGoods(message model.BomMessage) (err error) {
return
errors
.
New
(
"没有商品的bom单"
)
}
bomItems
:=
bom
.
BomItems
perGoDealNumber
:=
40
var
perGoDealNumber
int
if
configs
.
ApiSetting
.
Mode
==
"debug"
{
perGoDealNumber
=
200
}
else
{
perGoDealNumber
=
40
}
//开启协程处理搜索
var
wg
sync
.
WaitGroup
//判断是否有余数
...
...
@@ -98,8 +103,9 @@ func SearchGoods(bomId int, bomItems []model.BomItem, deliveryType, sort int, wg
}
//再删除模糊匹配到的数据,就得到完全没有匹配的数据了
var
notMatchBomItems
[]
model
.
BomItem
var
needMatchGoodsMapList
=
append
(
goodsMapList
,
fuzzyGoodsMapList
...
)
for
_
,
bomItem
:=
range
bomItems
{
if
!
checkInGoodsMap
(
bomItem
,
append
(
goodsMapList
,
fuzzyGoodsMapList
...
)
)
{
if
!
checkInGoodsMap
(
bomItem
,
needMatchGoodsMapList
)
{
notMatchBomItems
=
append
(
notMatchBomItems
,
bomItem
)
}
}
...
...
@@ -109,7 +115,7 @@ func SearchGoods(bomId int, bomItems []model.BomItem, deliveryType, sort int, wg
return
}
//然后去处理匹配到的数据
err
=
UpdateGoodsData
(
append
(
goodsMapList
,
fuzzyGoodsMapList
...
)
)
err
=
UpdateGoodsData
(
needMatchGoodsMapList
)
if
err
!=
nil
{
return
}
...
...
@@ -157,7 +163,7 @@ func UpdateSingleBomMatching(bomSn string, bomItemId int, goodsId string) (bomIt
//判断是否在里面
func
checkInGoodsMap
(
bom
model
.
BomItem
,
goodsMapList
[]
GoodsMap
)
bool
{
for
_
,
goodsMap
:=
range
goodsMapList
{
if
bom
.
GoodsName
==
goodsMap
.
GoodsName
{
if
bom
.
BomItemID
==
goodsMap
.
BomItemId
{
return
true
}
}
...
...
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