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
e3bcc1db
authored
Mar 17, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修改匹配请求量
parent
a7126d63
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
34 deletions
internal/logic/match.go
internal/logic/match.go
View file @
e3bcc1db
...
...
@@ -30,7 +30,7 @@ func MatchGoods(message model.BomMessage) (err error) {
if
configs
.
ApiSetting
.
Mode
==
"debug"
{
perGoDealNumber
=
200
}
else
{
perGoDealNumber
=
4
0
perGoDealNumber
=
10
0
}
//开启协程处理搜索
var
wg
sync
.
WaitGroup
...
...
@@ -80,41 +80,51 @@ func SearchGoods(bomId int, bomItems []model.BomItem, deliveryType, sort int, wg
bomItems
=
common
.
TrimBomItemSpace
(
bomItems
)
//获取转换后的标准参数,或者是识别出参数列是否有型号
bomItems
=
GetStandardAttrs
(
bomItems
)
//第一次先去精确匹配
goodsMapList
,
err
:=
getUpdateGoodsData
(
bomId
,
bomItems
,
deliveryType
,
sort
,
client
,
true
)
if
err
!=
nil
{
return
}
//要删除已经精确匹配过的bomItem,得到需要去模糊匹配的商品
var
fuzzyBomItems
[]
model
.
BomItem
for
_
,
bomItem
:=
range
bomItems
{
//不在精确匹配结果里面的,同时商品名称不能为空的
if
!
checkInGoodsMap
(
bomItem
,
goodsMapList
)
&&
bomItem
.
GoodsName
!=
""
{
fuzzyBomItems
=
append
(
fuzzyBomItems
,
bomItem
)
//线上es性能垃圾,批量请求条数或者并发数过高,就会拒绝请求,只能用循环,控制每次批量请求的条数,所以要循环再处理
perNumber
:=
5
var
needDealBomItems
[]
model
.
BomItem
for
i
:=
0
;
i
<
len
(
bomItems
);
i
=
i
+
perNumber
{
if
i
+
perNumber
>
len
(
bomItems
)
{
needDealBomItems
=
bomItems
[
i
:
]
}
else
{
needDealBomItems
=
bomItems
[
i
:
i
+
perNumber
]
}
}
//第二次去模糊匹配
fuzzyGoodsMapList
,
err
:=
getUpdateGoodsData
(
bomId
,
fuzzyBomItems
,
deliveryType
,
sort
,
client
,
false
)
if
err
!=
nil
{
return
}
//再删除模糊匹配到的数据,就得到完全没有匹配的数据了
var
notMatchBomItems
[]
model
.
BomItem
var
needMatchGoodsMapList
=
append
(
goodsMapList
,
fuzzyGoodsMapList
...
)
for
_
,
bomItem
:=
range
bomItems
{
if
!
checkInGoodsMap
(
bomItem
,
needMatchGoodsMapList
)
{
notMatchBomItems
=
append
(
notMatchBomItems
,
bomItem
)
//第一次先去精确匹配
goodsMapList
,
err
:=
getUpdateGoodsData
(
bomId
,
needDealBomItems
,
deliveryType
,
sort
,
client
,
true
)
if
err
!=
nil
{
return
err
}
//要删除已经精确匹配过的bomItem,得到需要去模糊匹配的商品
var
fuzzyBomItems
[]
model
.
BomItem
for
_
,
bomItem
:=
range
needDealBomItems
{
//不在精确匹配结果里面的,同时商品名称不能为空的
if
!
checkInGoodsMap
(
bomItem
,
goodsMapList
)
&&
bomItem
.
GoodsName
!=
""
{
fuzzyBomItems
=
append
(
fuzzyBomItems
,
bomItem
)
}
}
//第二次去模糊匹配
fuzzyGoodsMapList
,
err
:=
getUpdateGoodsData
(
bomId
,
fuzzyBomItems
,
deliveryType
,
sort
,
client
,
false
)
if
err
!=
nil
{
return
err
}
//再删除模糊匹配到的数据,就得到完全没有匹配的数据了
var
notMatchBomItems
[]
model
.
BomItem
var
needMatchGoodsMapList
=
append
(
goodsMapList
,
fuzzyGoodsMapList
...
)
for
_
,
bomItem
:=
range
needDealBomItems
{
if
!
checkInGoodsMap
(
bomItem
,
needMatchGoodsMapList
)
{
notMatchBomItems
=
append
(
notMatchBomItems
,
bomItem
)
}
}
//先去处理没有匹配到的数据
err
=
UpdateNoMatchBomItem
(
notMatchBomItems
,
true
)
if
err
!=
nil
{
return
err
}
//然后去处理匹配到的数据
err
=
UpdateGoodsData
(
needMatchGoodsMapList
)
if
err
!=
nil
{
return
err
}
}
//先去处理没有匹配到的数据
err
=
UpdateNoMatchBomItem
(
notMatchBomItems
,
true
)
if
err
!=
nil
{
return
}
//然后去处理匹配到的数据
err
=
UpdateGoodsData
(
needMatchGoodsMapList
)
if
err
!=
nil
{
return
}
return
}
...
...
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