Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
go_sku_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
710bbabc
authored
Jul 01, 2025
by
hcy
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
sku管道
parent
bf50e227
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
14 deletions
controller/sku_controller.go
controller/sku_controller.go
View file @
710bbabc
...
...
@@ -54,7 +54,7 @@ func CommonController(ctx *gin.Context) map[string]interface{} {
}
var
wg
sync
.
WaitGroup
ch
:=
make
(
chan
sync
.
Map
)
//管道
ch
:=
make
(
chan
sync
.
Map
,
50
)
//管道
zyGoodsId
:=
make
([]
string
,
0
,
goodsSliceCount
)
lyGoodsId
:=
make
([]
string
,
0
,
goodsSliceCount
)
...
...
@@ -73,13 +73,13 @@ func CommonController(ctx *gin.Context) map[string]interface{} {
common
.
PrintDebugHtml
(
ctx
,
zyGoodsId
)
wg
.
Add
(
1
)
//协程计数一
// 必须创建一个新的slice副本,否则数据会被覆盖
idsToProcess
:=
make
([]
string
,
len
(
zyGoodsId
))
copy
(
idsToProcess
,
zyGoodsId
)
go
func
()
{
go
func
(
ctx_in
*
gin
.
Context
,
goodsIds_in
[]
string
,
chs_in
chan
sync
.
Map
)
{
defer
wg
.
Done
()
zyService
.
ZyGoodsDetail
(
ctx
,
idsToProcess
,
ch
)
}()
zyService
.
ZyGoodsDetail
(
ctx_in
,
goodsIds_in
,
chs_in
)
}(
ctx
,
idsToProcess
,
ch
)
zyGoodsId
=
zyGoodsId
[
:
0
]
}
}
else
{
//联营
...
...
@@ -88,12 +88,14 @@ func CommonController(ctx *gin.Context) map[string]interface{} {
common
.
PrintDebugHtml
(
ctx
,
"ly增加协程1002:"
)
common
.
PrintDebugHtml
(
ctx
,
lyGoodsId
)
wg
.
Add
(
1
)
idsToProcess
:=
make
([]
string
,
len
(
lyGoodsId
))
copy
(
idsToProcess
,
lyGoodsId
)
go
func
()
{
go
func
(
ctx_in
*
gin
.
Context
,
goodsIds_in
[]
string
,
chs_in
chan
sync
.
Map
)
{
defer
wg
.
Done
()
lyService
.
LyGoodsDetail
(
ctx
,
idsToProcess
,
ch
)
}()
lyService
.
LyGoodsDetail
(
ctx_in
,
goodsIds_in
,
chs_in
)
}(
ctx
,
idsToProcess
,
ch
)
lyGoodsId
=
lyGoodsId
[
:
0
]
}
}
...
...
@@ -103,24 +105,26 @@ func CommonController(ctx *gin.Context) map[string]interface{} {
common
.
PrintDebugHtml
(
ctx
,
"zy增加协程1003:"
)
common
.
PrintDebugHtml
(
ctx
,
zyGoodsId
)
wg
.
Add
(
1
)
//协程计数一
idsToProcess
:=
make
([]
string
,
len
(
zyGoodsId
))
copy
(
idsToProcess
,
zyGoodsId
)
go
func
()
{
go
func
(
ctx_in
*
gin
.
Context
,
goodsIds_in
[]
string
,
chs_in
chan
sync
.
Map
)
{
defer
wg
.
Done
()
zyService
.
ZyGoodsDetail
(
ctx
,
idsToProcess
,
ch
)
}()
zyService
.
ZyGoodsDetail
(
ctx
_in
,
goodsIds_in
,
chs_in
)
}(
ctx
,
zyGoodsId
,
ch
)
}
if
len
(
lyGoodsId
)
>
0
{
common
.
PrintDebugHtml
(
ctx
,
"ly增加协程1004:"
)
common
.
PrintDebugHtml
(
ctx
,
lyGoodsId
)
wg
.
Add
(
1
)
idsToProcess
:=
make
([]
string
,
len
(
lyGoodsId
))
copy
(
idsToProcess
,
lyGoodsId
)
go
func
()
{
go
func
(
ctx_in
*
gin
.
Context
,
goodsIds_in
[]
string
,
chs_in
chan
sync
.
Map
)
{
defer
wg
.
Done
()
lyService
.
LyGoodsDetail
(
ctx
,
idsToProcess
,
ch
)
}()
lyService
.
LyGoodsDetail
(
ctx
_in
,
goodsIds_in
,
chs_in
)
}(
ctx
,
idsToProcess
,
ch
)
}
// 开启一个协程,等待所有任务完成,然后关闭channel
...
...
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